SlideShare a Scribd company logo
1 of 48
Ruby is Awesome and Rust
is Awesome and Building a
Game in Both is
AWESOME
by Liz Baillie
@_lbaillie on Twitter
@lbaillie on GitHub
sorry
What’s Rust?
Why Rust?
What’s Ruby?
Why Ruby?
❤️❤️❤️❤️❤️
❤️❤️❤️❤️❤️
❤️❤️❤️❤️❤️
❤️❤️❤️❤️❤️
Ruby: my first (programming) love
❤️
Ruby = 😍
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.
Time to build a game in Rust!
wait but why
wait but why
(you gotta have goals)
- lower-level language
- more “close to the metal”
- doesn’t abstract as much away
Yehuda Katz
Yehuda Katz
(Rust core team)
Skylight + Rust = ❤️
a newer language
open source
how do programming
languages work?
idk but I’d like to find out
I love Ruby, but…
…but Rust!
Let’s build a game!
for real this time
One game to rule
them all
(sorry, I had to)
😎
build confidence!
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
what’s the
difference, then?
Ruby
Rust
this might seem like a
weird simile, but…
Ruby is great.
Rust is great.
In different ways.
https://github.com/tilde
io/learning-rust
YES! I am seeking contributions 😘
Thank you!
@_lbaillie

More Related Content

Viewers also liked

Türkiye'de Dijital Medyaya Bakış
Türkiye'de Dijital Medyaya BakışTürkiye'de Dijital Medyaya Bakış
Türkiye'de Dijital Medyaya BakışDigital Partners
 
Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 pramode_ce
 
Servo: The parallel web engine
Servo: The parallel web engineServo: The parallel web engine
Servo: The parallel web engineBruno Abinader
 
Rust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneRust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneC4Media
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the networkJeremy Lainé
 
What the &~#@<!? (Memory Management in Rust)
What the &~#@<!? (Memory Management in Rust)What the &~#@<!? (Memory Management in Rust)
What the &~#@<!? (Memory Management in Rust)David Evans
 
다른 회사는 어떻게 QA, 테스팅을 하고 있을까? (google, facebook, atlass...
다른 회사는 어떻게 QA, 테스팅을 하고 있을까? (google, facebook, atlass...다른 회사는 어떻게 QA, 테스팅을 하고 있을까? (google, facebook, atlass...
다른 회사는 어떻게 QA, 테스팅을 하고 있을까? (google, facebook, atlass...Joseph Yonggoo Yeo
 
Embedded Rust on IoT devices
Embedded Rust on IoT devicesEmbedded Rust on IoT devices
Embedded Rust on IoT devicesLars Gregori
 
Embedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesEmbedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesLars Gregori
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtDavid Evans
 
Mozilla + Rust at PCU Manila 02 DEC 2016
Mozilla + Rust at PCU Manila 02 DEC 2016Mozilla + Rust at PCU Manila 02 DEC 2016
Mozilla + Rust at PCU Manila 02 DEC 2016Robert 'Bob' Reyes
 
Component basedgameenginedesign
Component basedgameenginedesign Component basedgameenginedesign
Component basedgameenginedesign DADA246
 
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.Oliver Kriska
 
Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!Kel Cecil
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011Patrick Walton
 
Introduction to Rust Programming Language
Introduction to Rust Programming LanguageIntroduction to Rust Programming Language
Introduction to Rust Programming LanguageRobert 'Bob' Reyes
 
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...Lucidworks
 
Ruby language overview
Ruby language overviewRuby language overview
Ruby language overviewUptech
 
unba.se - ACM CSCW 2017 - IWCES15
unba.se - ACM CSCW 2017 - IWCES15unba.se - ACM CSCW 2017 - IWCES15
unba.se - ACM CSCW 2017 - IWCES15Daniel Norman
 

Viewers also liked (20)

Türkiye'de Dijital Medyaya Bakış
Türkiye'de Dijital Medyaya BakışTürkiye'de Dijital Medyaya Bakış
Türkiye'de Dijital Medyaya Bakış
 
Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017 Rust Workshop - NITC FOSSMEET 2017
Rust Workshop - NITC FOSSMEET 2017
 
Servo: The parallel web engine
Servo: The parallel web engineServo: The parallel web engine
Servo: The parallel web engine
 
Rust: Systems Programming for Everyone
Rust: Systems Programming for EveryoneRust: Systems Programming for Everyone
Rust: Systems Programming for Everyone
 
Serving QML applications over the network
Serving QML applications over the networkServing QML applications over the network
Serving QML applications over the network
 
What the &~#@<!? (Memory Management in Rust)
What the &~#@<!? (Memory Management in Rust)What the &~#@<!? (Memory Management in Rust)
What the &~#@<!? (Memory Management in Rust)
 
OOP in Rust
OOP in RustOOP in Rust
OOP in Rust
 
다른 회사는 어떻게 QA, 테스팅을 하고 있을까? (google, facebook, atlass...
다른 회사는 어떻게 QA, 테스팅을 하고 있을까? (google, facebook, atlass...다른 회사는 어떻게 QA, 테스팅을 하고 있을까? (google, facebook, atlass...
다른 회사는 어떻게 QA, 테스팅을 하고 있을까? (google, facebook, atlass...
 
Embedded Rust on IoT devices
Embedded Rust on IoT devicesEmbedded Rust on IoT devices
Embedded Rust on IoT devices
 
Embedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devicesEmbedded Rust – Rust on IoT devices
Embedded Rust – Rust on IoT devices
 
Kernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring NaughtKernel-Level Programming: Entering Ring Naught
Kernel-Level Programming: Entering Ring Naught
 
Mozilla + Rust at PCU Manila 02 DEC 2016
Mozilla + Rust at PCU Manila 02 DEC 2016Mozilla + Rust at PCU Manila 02 DEC 2016
Mozilla + Rust at PCU Manila 02 DEC 2016
 
Component basedgameenginedesign
Component basedgameenginedesign Component basedgameenginedesign
Component basedgameenginedesign
 
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
WebUp Feb 2017 - How (not) to get lost in bigger Ruby on Rails project.
 
Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!Hey! There's OCaml in my Rust!
Hey! There's OCaml in my Rust!
 
Rust All Hands Winter 2011
Rust All Hands Winter 2011Rust All Hands Winter 2011
Rust All Hands Winter 2011
 
Introduction to Rust Programming Language
Introduction to Rust Programming LanguageIntroduction to Rust Programming Language
Introduction to Rust Programming Language
 
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
Building a Large Scale SEO/SEM Application with Apache Solr: Presented by Rah...
 
Ruby language overview
Ruby language overviewRuby language overview
Ruby language overview
 
unba.se - ACM CSCW 2017 - IWCES15
unba.se - ACM CSCW 2017 - IWCES15unba.se - ACM CSCW 2017 - IWCES15
unba.se - ACM CSCW 2017 - IWCES15
 

Recently uploaded

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 

Recently uploaded (20)

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 

Ruby is Awesome and Rust is Awesome and Building a Game in Both is AWESOME

Editor's Notes

  1. Hi everyone! My name is Liz, and I’m from the United States.
  2. I’m sorry. I apologize for that, but unfortunately there’s nothing I can do about it.
  3. I’m really into your prime minister though. He seems pretty cool, so way to go on that one. I mean seriously, look at him with those pandas! It’s so great.
  4. Anyway, I live and work in Portland, OR at a company called Tilde. I work on our product, Skylight, which is a Rails profiler. So that basically means we have an app that helps Rails apps be better Rails apps.
  5. So I’m here today to talk to you about two programming languages, Ruby and Rust, and how I built basically the same text-based adventure game twice - once with Ruby, once with Rust. So, why Ruby? Why Rust? Why did I do any of this at all?
  6. So, Ruby and Rust are both pretty different but they’re both really cool.
  7. I had a few false starts over the years, trying to learn how to program, but Ruby was the first language I was able to really get into.
  8. If you don’t already know anything about it, Ruby was designed around the idea of programmer happiness.
  9. It’s very expressive and easy to learn, very similar to written English. As you can see here, writing something like “ten times do puts “Ruby is great!” “ will print “Ruby is great!” to the console, ten times. You can read it almost like a sentence, so it’s a very popular first language for people getting into programming. You don’t have to think too hard about what’s happening under the hood to get started and make things work, even if you don’t know very much about programming yet.
  10. One of the first things I made when I started learning to code was a text-based adventure game. 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.
  11. 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.
  12. You see a light in the north.
  13. you have a map
  14. what do you do? And then you type something like
  15. “look at map”
  16. then the computer responds with something else,
  17. and you type something else,
  18. 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)
  19. So anyway, it made sense that when I decided I wanted to learn Rust, that I build yet another text-based adventure game.
  20. So what is Rust and why did I want to learn it in the first place? I realize that Ashley already talked a lot about Rust but here I am to talk about it some more! I might repeat some things and if I do, sorry.
  21. Well, about a year ago, I decided I wanted to start learning a lower-level language,
  22. something more “close to the metal,” so to speak, that didn’t abstract as much away as Ruby does. I wanted to understand more about what goes on under the hood when I’m trying to talk to my computer. Fortunately, at that time, I had just started working at Tilde
  23. where I get to work with Yehuda Katz,
  24. who is on the Rust core team. Which means, if anybody’s gonna know about Rust, it’s gonna be this guy.
  25. and at least part of our product (Skylight) is written in Rust. So it made perfect sense for me learn.
  26. I also knew that it was a newer language being actively developed.
  27. I really wanted to get involved in open source
  28. and I’m really interested in how programming languages work, so it seemed like the perfect thing to get into.
  29. I mean, I love Ruby, but the whole ecosystem was pretty much all set by the time I got to it,
  30. but Rust, on the other hand! Everything with Rust was still new, so it was very exciting and changing all the time and I wanted to learn all about it.
  31. So, I decided to build basically the same game, one version with Ruby and one version with Rust
  32. so I could more easily compare and contrast the pros and cons of each language
  33. but also so I could build my confidence a bit, building one piece of the game using a language I was pretty comfortable with, and then implementing the same or similar feature in a new language that I was still learning, and on and on until I had some kind of working game.
  34. 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
  35. 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?
  36. 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.
  37. 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”. Otherwise, it seems pretty similar to the Ruby version, just a little more code, which is fine.
  38. At first glance, both implementations of a similar idea look pretty similar! However, there is a lot of code I am NOT showing you, just because there is SO much of it, and we don’t have a lot of time. So what I’d like to focus on instead is the experience of writing it. You can look at all the real code on GitHub after the talk if you want to see the whole thing (and don’t worry, I’ll give you a link)
  39. 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.
  40. 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.
  41. 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,
  42. 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.
  43. 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!
  44. 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.
  45. 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.
  46. 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.
  47. Feel free to take a look at the repo for the game, there’s instructions in the README about how to set it up. Both the Ruby and Rust games should work as of right now, though both of them don’t really have a proper “story” there’s just some weird placeholder stuff, which you might enjoy anyway. There’s a bug that allows you to pick up a jar of unicorn farts over and over and over, for example. I also have a few issues on that repo if anyone’s interested in contributing. I would love to learn more about testing in Rust, and more Rust tests just happens to be one of the things I’m looking for, so if you know anything about that, feel free to check it out.
  48. And if you want to talk about any of this, I’ll be around today and tomorrow, otherwise you can talk to me on Twitter! Thank you so much!