SlideShare a Scribd company logo
text-based adventure game
>
>
>
>
>
>help
> you are in a dark forest
> you are in a dark forest
>
> you see a light in the north
> you are in a dark forest
>
> you see a light in the north
>
> you have a map
> you are in a dark forest
>
> you see a light in the north
>
> you have a map
>
> what do you do?
> you are in a dark forest
>
> you see a light in the north
>
> you have a map
>
> what do you do?
>
> look at map
> you are in a dark forest
>
> you see a light in the north
>
> you have a map
>
> what do you do?
>
> look at map
>
> does not understand “look at map”
> you are in a dark forest
>
> you see a light in the north
>
> you have a map
>
> what do you do?
>
> look at map
>
> does not understand “look at map”
>
> look around
> you are in a dark forest
>
> you see a light in the north
>
> you have a map
>
> what do you do?
>
> look at map
>
> does not understand “look at map”
>
> look around
> you are in a deserted field. There is a sharp rock.
Game architecture
WARNING: I am not an expert!
# not real code, don’t judge me
playing = true
while playing
ask “What do you want to do next?”
parse user input
perform action based on user input
if user dies or game ends
playing = false
end
end
def play
puts "Welcome to #{@map.title}"
puts "What would you like to do? (Enter 'help' to see
a list of commands)"
parse_choice(gets.chomp)
while @playing
break if !@playing
puts "What now?"
choice = gets.chomp
parse_choice(choice)
end
end
Ruby
fn main() {
let player = player::Player::new(vec![], 1, 1);
let map = map::Map::new("Great Rust Adventure",
rooms);
let mut game = game::Game::new(player, map, true);
while game.playing {
game.play();
}
}
Rust
Ruby
this might seem like a weird
simile, but…
Ruby is great.
Rust is great.
In different ways.
Another Rust talk at OSCON today!
“Rust for non-Rust Developers”
5:05pm - Ballroom G
@_lbaillie

More Related Content

Recently uploaded

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
ClaraZara1
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
ssuser7dcef0
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
ChristineTorrepenida1
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
TeeVichai
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
MdTanvirMahtab2
 

Recently uploaded (20)

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)6th International Conference on Machine Learning & Applications (CMLA 2024)
6th International Conference on Machine Learning & Applications (CMLA 2024)
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
NUMERICAL SIMULATIONS OF HEAT AND MASS TRANSFER IN CONDENSING HEAT EXCHANGERS...
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
Unbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptxUnbalanced Three Phase Systems and circuits.pptx
Unbalanced Three Phase Systems and circuits.pptx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Railway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdfRailway Signalling Principles Edition 3.pdf
Railway Signalling Principles Edition 3.pdf
 
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Illustrated Adventure Survival Guide for New Rustaceans and Natives of Rubyville

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
  • 90.
  • 91.
  • 92.
  • 93.
  • 94.
  • 95.
  • 96.
  • 97.
  • 98.
  • 99.
  • 100.
  • 101.
  • 102.
  • 103.
  • 104.
  • 105.
  • 106.
  • 107.
  • 108.
  • 109.
  • 110.
  • 111.
  • 112.
  • 113.
  • 114.
  • 115.
  • 116.
  • 117.
  • 118.
  • 119.
  • 120.
  • 121.
  • 122.
  • 123.
  • 124.
  • 125.
  • 126.
  • 127.
  • 128.
  • 129.
  • 130.
  • 131.
  • 132.
  • 133.
  • 134.
  • 135.
  • 136.
  • 137.
  • 138.
  • 139.
  • 140.
  • 141.
  • 142.
  • 143.
  • 144.
  • 145.
  • 146.
  • 147.
  • 148.
  • 149.
  • 150.
  • 151.
  • 152.
  • 153.
  • 154.
  • 155.
  • 156.
  • 157.
  • 158.
  • 159.
  • 160.
  • 161.
  • 162.
  • 163.
  • 164.
  • 165.
  • 166.
  • 167.
  • 168.
  • 169.
  • 170.
  • 171.
  • 172.
  • 173.
  • 174.
  • 175.
  • 177. > you are in a dark forest
  • 178. > you are in a dark forest > > you see a light in the north
  • 179. > you are in a dark forest > > you see a light in the north > > you have a map
  • 180. > you are in a dark forest > > you see a light in the north > > you have a map > > what do you do?
  • 181. > you are in a dark forest > > you see a light in the north > > you have a map > > what do you do? > > look at map
  • 182. > you are in a dark forest > > you see a light in the north > > you have a map > > what do you do? > > look at map > > does not understand “look at map”
  • 183. > you are in a dark forest > > you see a light in the north > > you have a map > > what do you do? > > look at map > > does not understand “look at map” > > look around
  • 184. > you are in a dark forest > > you see a light in the north > > you have a map > > what do you do? > > look at map > > does not understand “look at map” > > look around > you are in a deserted field. There is a sharp rock.
  • 185. Game architecture WARNING: I am not an expert!
  • 186. # not real code, don’t judge me playing = true while playing ask “What do you want to do next?” parse user input perform action based on user input if user dies or game ends playing = false end end
  • 187. def play puts "Welcome to #{@map.title}" puts "What would you like to do? (Enter 'help' to see a list of commands)" parse_choice(gets.chomp) while @playing break if !@playing puts "What now?" choice = gets.chomp parse_choice(choice) end end Ruby
  • 188. fn main() { let player = player::Player::new(vec![], 1, 1); let map = map::Map::new("Great Rust Adventure", rooms); let mut game = game::Game::new(player, map, true); while game.playing { game.play(); } } Rust
  • 189. Ruby
  • 190.
  • 191.
  • 192.
  • 193. this might seem like a weird simile, but…
  • 194.
  • 195.
  • 196. Ruby is great. Rust is great. In different ways.
  • 197.
  • 198. Another Rust talk at OSCON today! “Rust for non-Rust Developers” 5:05pm - Ballroom G
  • 199.

Editor's Notes

  1. The full title of this talk, which does not actually fit on most CFP submission forms, is “The Illustrated Adventure Survival Guide for New rustaceans and Natives of Rubyville.” with apologies to _why the lucky stiff. I don’t know how many of you are familiar with the work of _why, but if you’re not, I would strongly recommend looking him up after this. He was a Rubyist who did a lot of really interesting work that was a big reason for me getting into programming, and this entire talk is a bit of an homage to Why’s Poignant Guide to Ruby.
  2. So, welcome! I really have to commend you, it took a lot of courage to sign up for this mission. This adventure we’re about to embark on
  3. is not for the weak or faint of heart.
  4. So if any of you are pregnant
  5. or nursing,
  6. or suffer from any kind of heart condition,
  7. or if your doctor has advised against the eating of spicy foods,
  8. I ask that you consider consulting your physician,
  9. spiritual advisor, psychic medium,
  10. or nosy next-door neighbor before accompanying me on this journey.
  11. While we wait to board the ship, some of you might want to know a little bit about me, your guide, before moving forward with this seafaring journey, and I get it. I understand.
  12. I don’t look quite like a seasoned ship’s captain, and you’re right!
  13. I’m not. I’m Liz.
  14. I used to be a cartoonist (I drew comic books),
  15. I went to art school,
  16. drew a few graphic novels.
  17. A few years ago I learned to code,
  18. went to the Flatiron School in New York and started working in web development.
  19. Nowadays I work at Tilde in Portland, OR
  20. Mainly I work on our product, Skylight, which is an application that helps developers working in Rails or other Ruby-based frameworks optimize their own apps.
  21. We also use Rust, which is a big part of why I started learning Rust in the first place.
  22. So before we get on the ship, I’ll show you a map of where we’ll be going. Right now, our ship is docked at the Port of Javascript, just off the coast of Rubyville. We’ll be sailing the seas of chunky bacon and should be landing at the Cargo Bay of Rustlandia in no time!
  23. So let’s get on board, take your seats,
  24. no standing,
  25. no eating or drinking, and most importantly
  26. no staring at the captain’s eye he’s really sensitive about it
  27. Say goodbye to your loved ones, off we go!
  28. If you all look out your windows to the west you’ll notice a beautiful sight, some foliage that’s native to Rubyville - an abstract syntax tree! It’s nodes are particularly lovely this time of year. You’re probably used to seeing these if you’re from Rubyville,
  29. they tend to sprout anytime some code gets thrown into the interpreter, just before it gets turned into byte code so the Ruby Virtual Machine can run it. As you might already know, Ruby is an interpreted language, so this is more or less what you’re used to if you’re a Rubyist
  30. but in Rustlandia we’ll have to remember to compile our code before we can run it - otherwise it won’t work! So when we get there, just remember two key phrases
  31. cargo build
  32. and cargo run. They’ll come in handy when we reach the shore and start trying to chat up the locals.
  33. If you try to just run your code directly like you did in Rubyville,
  34. they won’t know what you’re talking about.
  35. Oh, I almost forgot to mention, on the way out you’ll notice a big pile of mains - don’t forget to take one! You’ll need to put all the code that gets run for your program inside of main (unless you’re building a library, which we’re not just yet). Very important.
  36. Alright everybody off the ship, here we are! Welcome… to Rustlandia! Let’s check out the town! Remember, things move a lot faster here, so be careful!
  37. Check it out, it’s the Stack and the Heap brew pub! let’s go inside. You’re probably used to not giving much thought to memory back in Rubyville.
  38. Before I came to Rustlandia I had heard of the Stack and the Heap and I knew it had something to do with memory but never really understood it.
  39. Watch how things work at the bar. People come in and give their programs to the bartender, and she compiles and runs them.
  40. Someone wants a fancy whisky and a cheap whiskey. The good stuff is fancy so we put that in a Box and store it on the heap, because we want it to be able to stick around for a while, even though it’s high up and a bit slower to get to. Most things in Rust are stored on the stack unless you specify otherwise, which is why we had to put the fancy whisky in a Box in order to store it on the heap.
  41. So when we run this program, the good_whisky gets a spot on the heap, at the far far end of our available memory,
  42. and we put a pointer on the stack that points to that spot on the heap. Next on the stack we put the cheap_stuff, in this case it is “Old Grand-Dad,” which is a very terrible bourbon. The cheap_stuff gets served up first because it’s on top, and then we have the pointer to the fancy stuff, which the bartender has to go way way up to the top of the heap to get, which she does.
  43. All that sea travel made me hungry I think. Let’s check out one of the local eateries. I’ve heard good things about this one. It’s called Cafe de Struct.
  44. “Uh sir I can’t quite read this menu… i’m used to seeing things like
  45. this. There is a defined class, and the instance methods for that class are defined with a simple “def”, and they end with the word “end”
  46. Instead I see all these strange new things… like, Structs and Impls and… what’s this all about, huh? WAITER!!!
  47. So sorry madam, I know this isn’t something you’re used to back in Rubyville but … we here in Rustlandia, we um… have no class
  48. I can’t believe it! This is terrible! How are we going to get along without class? It’s the one thing separating us from the animals!
  49. Don’t worry, don’t worry at all - you can still get what you need!
  50. here, here is the ChunkyBacon struct. That’s where we define all the attributes we expect out of it - flavor, chunkiness, price, etc
  51. so then I can just do something like
  52. this and i’ll be all set?
  53. no no my good lady, for that you’ll need to write an Impl
  54. that’s an Implementation of ChunkyBacon. So if you want a new instance of ChunkyBacon
  55. you’ll have to write a new() method yourself - it doesn’t just happen automatically.
  56. Customer - well then! Very good. I’ll have a….
  57. i’ll have a salad
  58. and now, a word from our sponsors
  59. HEY MACK!
  60. Me?
  61. YEAH YOU THERE. YOU WANNA TRY SOME RUST?
  62. You mean the iron oxide produced as a result of a redox reaction of iron and oxygen in the presence of water or air moisture?
  63. WHAT HAVE YOU BEEN READING WIKIPEDIA? No NOT THAT RUST, FOOL!! RUST LANG MY FRIEND!
  64. Oh yeah that cool new systems programming language all the kids at school are talking about?
  65. THE VERY SAME.
  66. well, what about it?
  67. DO YA LIKE
  68. abstraction without overhead?
  69. uh I don’t know
  70. HOW ABOUT
  71. concurrency without data races?
  72. I think???
  73. WHAT ABOUT
  74. memory safety without garbage collection?
  75. That… *sounds* good? I really don’t…
  76. YOU’LL LOVE RUST
  77. Welcome to Mutability Lake! It’s a lovely day, so many of our distinguished townspeople are out sailing their toy ships. Some are fancier than others, some are mutable, some aren’t.
  78. This one here is a nice one - this one’s not mutable, so we can’t change anything about it, but I can pick it up and show it to you! Look how nice! But if we try to change anything about it
  79. HEY YOU CAN’T DO THAT! Ah the compiler is yelling at us… so we know we can’t change this boat. It’s immutable. Let’s try another one.
  80. Let’s look back at what other ships are in the lake. COOL! This one’s definitely mutable. It has a little flag that says “mut.” Let’s just make a few changes before we return it.
  81. So let’s add some wheels to this boat. PERFECT. Compiler what do you think?
  82. What’s the matter, compiler?
  83. YOU PUT WHEELS ON A BOAT IT’S NOT A BOAT ANYMORE IT’S A CAR
  84. YOU SAID YOU WOULD RETURN A BOAT YOU MUST RETURN A BOAT. As is clearly illustrated here, the Boat struct does not include anything about wheels.
  85. ok ok
  86. I’ll take the wheels off. I thought it looked pretty cool though!
  87. Let’s look for another boat in the lake. Hey THAT one looks pretty cool
  88. Yoink!
  89. HEY! THAT BOAT DOESN’T BELONG TO YOU!
  90. Oh, sorry compiler! Who owns this boat?
  91. i do
  92. Oh, so sorry. Can I borrow it? I was hoping to play with it in my bathtub.
  93. Well… will you bring it back?
  94. Of course!
  95. go right ahead!
  96. don’t forget this ampersand! so everyone knows you’re just borrowing it.
  97. So now, of course - the musical montage! (play music)
  98. hey thanks for returning my boat. compiler, does everything look good to you?
  99. NO YOU ADDED A TUGBOAT THAT’S NOT OK
  100. but compiler, these boats are all Vectors of Strings, all I did was push a tugboat onto it. A tugboat is a string!
  101. the tugboat isn’t yours and neither is the boat!
  102. Yeah that tugboat is mine
  103. well what if I just….
  104. BOOM punch the tugboat guy in the face and hit him with a remove!
  105. looks like no one owns this tugboat now
  106. you want a tugboat on your boat sir?
  107. sure
  108. Let’s do boat dot push and pass in the tugboat. now you have one!
  109. and now, a word from our sponsors.
  110. hey kid
  111. what?
  112. DID YOU GET ALL THAT INFORMATION ABOUT OWNERSHIP AND BORROWING
  113. huh?
  114. THAT’S HOW WE GET A LOT OF THE COOL STUFF I WAS TELLING YOU ABOUT BEFORE
  115. you mean like when you were yelling ‘memory safety without garbage collection ‘ at me?
  116. YES YOU GOT IT
  117. I only know Ruby though so those aren’t really problems I’ve had to deal with
  118. WELL LET ME TELL YA IF YOU WERE A C PROGRAMMER YOU’D BE REALLY EXCITED
  119. ok
  120. YOU BET IT”S OK
  121. can you just teach me something about Rust so the kids at school will finally think I’m a cool guy?
  122. SURE THING KID WE’LL TRY A LESS CONVOLUTED METAPHOR, WATCH THIS!
  123. Hello again, travelers! Have you seen our esteemed library? It’s pretty great. You can borrow just about anything, as long as you return it,
  124. they even have this great big pile of books over here that don’t belong to anyone, you can just take them if you want and then they’re yours! Every so often people will come by with donations of books they don’t need anymore, it’s great!
  125. If you want to borrow a book you just use your ampersand
  126. If you try to change a book while you’re borrowing it -
  127. the compiler will yell at you and your code won’t compile.
  128. However, if you see something you like in the “free” pile, you can just take it, and do whatever you want with it - it’s yours! You there, in the back - you had a question?
  129. yes what about if the book is a mutable reference?
  130. Great question, friend! Well, you might very well be borrowing something that’s mutable (&mut) like our collection of coloring books here (such titles as “Color me Sartre”, “Hell is Other Colors,” and “The Colors of Ambiguity”) - you can continue coloring in them while you have them and you can return them altered. Only one person can have one out at a time though.
  131. We also have some Exquisite Corpse books that are pretty cool - every time someone borrows one of those, they add a little bit to it themselves before bringing it back.
  132. I want to borrow the exquisite corpse book!
  133. me too! I want to borrow it too!
  134. No more than one mutable reference at a time. You can have it now, but you have to wait until the first person done before you can borrow it
  135. aw man
  136. No complaining! Do you want a data race? DO YOU?
  137. no…
  138. okay then
  139. So you might have noticed how clean and beautiful Rustlandia is, and yet you might have also noticed there are no garbage cans anywhere! It’s actually because of that system of borrowing and ownership that Rustlandia is able to do without garbage collection, it’s a big part of what makes everything so fast and safe here!
  140. But isn’t it annoying having the compiler yelling at you all the time?
  141. Hey now, don’t judge the compiler so harshly look you hurt his feelings!! He’s not such a bad guy, he’s just making sure everything we do is good before we can run it.
  142. The compiler is our friend who just wants the best for us! Sure his advice might be a little hard to understand at times but once you get to know him, he’s really a good guy. I promise!
  143. and now, another word from our sponsors
  144. TONIGHT ON WRST IT’S THE TRUE STORY OF HOW ONE STATICALLY TYPED PROGRAMMING LANGUAGE RISKED IT ALL TO FIGURE OUT HOW TO HANDLE IT WHEN THINGS GO WRONG.
  145. “If everything goes right, the reactor will cool down and the city will be saved. But if something goes wrong… if this whole thing goes south
  146. None
  147. well I guess I’ll just do nothing . I mean this seems like the time to return an Option right? I mean the compiler feels fine about it right?
  148. meanwhile, across town
  149. the grocery store does not have the mustard i like!
  150. RED ALERT RED ALERT EVERYONE PAY ATTENTION SHUT EVERYTHING DOWN I NEED MY DIJON!!! COMPILER AGREES DON’T YOU COMPILER
  151. Public Service Announcement: just because the code compiles doesn’t mean it’s something you should do.
  152. Results - for when something could go terribly wrong and you need to throw an error. Option - for when it’s ok to just do nothing.
  153. Hey welcome back!! Just in time for the last boat back to Rubyville. I sincerely hope you enjoyed your stay and that you visit again soon! If you want to stay a little longer there are some very nice Boxes at the Heap, otherwise the boat is ready to board!
  154. On your way back we do have some very nice reading material for you if you’re interested in learning more about Rust: I strongly recommend starting with Rust by Example, this online book will lead you by the hand step-by-step through many examples, explaining everything along the way
  155. After that I recommend looking at the official Rust reference documentation, very helpful
  156. If you’d like to try your hand at some Rust of your very own from scratch there are many excellent exercises available at exercism. There’s also an exercism table in the Expo Hall, if you’re interested in learning more about how to use exercism to learn a new programming language.
  157. If you have questions, there is the Rust Reddit and the user forums, or you can chat on one of many channels on IRC
  158. In preparation for the original version of this talk at RustConf last year, with some help from my boss Yehuda Katz, I developed a playable text-based adventure game in both Ruby and Rust. This way you can check out Ruby and Rust code that do similar things side-by-side. I’ve written a few really little ones over the years, usually when I’m trying to learn a new language or if I’m playing with a new idea. Some of you may never have played one, but it’s basically a game where everything is text. In my case, the whole game is played in your terminal, like it’s the 80s.
  159. So the way it works is, you get a prompt, usually a sentence or two followed by a question, like “You are in a dark forest.
  160. You see a light in the north
  161. You have a map
  162. What do you do? And then you type something like
  163. “look at map”
  164. then the computer responds with something else,
  165. and you type something else
  166. The computer responds to that, and so on and so forth, until your character dies or the game is over. I think nowadays games like this are also called “interactive fiction.” Let’s take a quick look at the actual game I wrote to give you a better idea of what I’m talking about. (go to terminal)
  167. So that’s the game. But how did I actually build it? Before writing a single line of code, I had to think about the architecture of the game, and there were a million different ways I could find to structure it. In the end, I wanted something extremely simple, so I went with a really basic loop
  168. that continues to ask what the player wants to do next until a particular condition is met, at which point the game ends. So in this example, which I stress is not real code, just an example of the structure I was using, we start by defining “playing” as true, and while playing is true, the game asks “What do you want to do next?” It then parses whatever the subsequent user input is and it performs an action based on that input (like, if the user says “move north” then the player’s position is changed and maybe we output something like “You have moved north”). We don’t exit the loop unless the user dies or the game ends, at which point playing is redefined as “false”. So what does this look like in Ruby or Rust?
  169. In Ruby, there’s a lot going on before we get to the “play” method, but that’s where the loop is so that’s what I’m showing you. This is a method on the “Game” class, which is initialized with a player, a map, an array of rooms, and with the value of playing as “true” so as long as playing remains true, the game will keep asking “What now?”, then parse whatever the user types, and respond to that.
  170. So, this example is ignoring a lot of other code that I wrote to support this, much like the Ruby example, but for the sake of simplicity here you can see we are creating a Player, a Map, and a Game, and you can see that while game dot playing, game play! Pretty close to what I illustrated earlier. What you can’t see, though is that unlike Ruby, I had to write my own “new” method, because Rust does not automatically give you anything like Ruby’s “initialize” and isn’t object-oriented by nature, the way Ruby is, so there are no classes per se. Otherwise, it seems pretty similar to the Ruby version, just a little more code, which is fine.
  171. So what differences did I notice in writing the game? With Ruby, I felt like I could just write whatever I wanted, make something work quickly, and then reorganize the code as I went. It’s easy to have a real “flow” like you’re just writing your ideas down in your journal and making things up as you go along. The downside of this is that it’s easy to get caught up in that flow and forget to check things out as you go, forget to test, forget to run every single part of the program that you just wrote.
  172. So I’d periodically run the program and things would just break. Without adding a whole bunch of tests after the fact, which isn’t great, I didn’t have a lot of confidence that something wouldn’t unexpectedly fall apart at runtime. All because I got caught up writing the game and forgot to check things out as I went along.
  173. Rust, on the other hand, is kind of the reverse experience. Since Rust needs to be compiled before you run it, the compiler literally won’t let you run the program until you fix all the stuff it doesn’t like. Not coincidentally, I have NOT run into any of those pesky random bugs in the Rust version of the game,
  174. probably because the compiler caught them before they would have become a problem. This can be super frustrating when you’re first learning Rust, because it can be oh so satisfying to just see SOMETHING working, and you could be working for hours just seeing errors like this over and over. It can easily become disheartening if you’re new to it. This example, by the way, I had to force an error because it had been so long since the Rust version of the game had any compiler errors. It’s just that good.
  175. So the best way I can think to compare Ruby and Rust, in terms of my personal experience with the two, is they’re like two different parenting styles. This might seem like an odd comparison, but bear with me!
  176. Ruby is like those hippie parents who let their kids do basically whatever they want and don’t put a whole lot of restrictions on them because they know the kids will figure things out on their own eventually and they’ll be ok. The downside, of course, is that the kids will hit all kinds of bumps in the road along the way because no one ever told them they should or shouldn’t do any particular thing.
  177. Rust is like those parents who are constantly telling their kids what’s best for them. They’re a little bit strict, not that bad, but just always giving unsolicited advice based on their own experiences. And yeah, maybe it turns out their advice was right, but it’s definitely a little annoying to be hearing it all the time.
  178. And just like parents, you can’t really say one way of doing things is better or worse than another, but they both have their pros and cons depending on what you’re trying to do and how you prefer to work. I’m sure someone with more experience could give you a more in-depth analysis, but this is my opinion based on my limited experience just writing a simple text game. So if you’re thinking of learning Rust, or Ruby, or both, I say go for it.
  179. You can check out the game I built at https://github.com/tildeio/learning-rust. Both versions are playable but both have kind of filler stories in them. The Ruby version’s filler game is a little more fun though, if you can only play one of them.
  180. Finally, there is another Rust talk later today called “Rust for non-Rust developers” at 5:05pm in Ballroom G which sounds really interesting. I don’t know a whole lot about it, but from the description it seems like if you want a more straightforward technical talk about why you would want to use Rust, some comparisons between Rust and Java, Python, and C, and deeper discussion about Rust’s type system as well as more information about the compiler and other fun stuff, this seems like a good talk to check out! I will probably check it out and if you’re interested in learning Rust, you should too!
  181. Thank you for having me!
  182. Once again, my name is Liz. I’m on Twitter at @_lbaillie and that’s it, the end