From Ruby to Rust
Published: 2019-04-24 17:21:33

---
title: From Ruby to Rust
published: true
description: First look from Ruby to Rust
tags: 
---


I’m more than half through a software engineering bootcamp. I can’t believe how much we’ve learned over the last 2 and half months, and how much information I’ve been able to cram in this melon. But, if you’re like me, you’re passionate about software engineering and thinking about what your next step might be in the engineering world. After learning Ruby, Ruby on Rails, Javascript, HTML, and CSS, I’m learning some of the limitations of these languages as well as their strengths. 
 
![alt text](https://d2v9y0dukr6mq2.cloudfront.net/video/thumbnail/NGTYhyRhgilq4uu1a/cartoon-animation-design-of-knowledge-creativity-and-intellectual-education-icons-flow-from-a-man-head-brain-with-infographic-text-in-4k-ultra-hd-video_s4urukez__F0014.png)
	
Ruby is an intuitive, easily readable, and easily setup language. With Ruby on Rails, typing in a generate scaffold command sets up the start of a backend server that might take a day more to type out from scratch, but does in it a few seconds. Ruby has syntactical sugar on top of syntactical sugar to make typing out code pleasurable.  Like wait…I don’t need parenthesis here or typing there, but how does ruby know…magic. Ruby is full of magical behind the scenes workings that just make programming easier and more intuitive than most other languages.  This magic is part of what made Slant.co rank ruby 5th for beginning developers. Why not first? Because the magic of Ruby comes with several drawbacks.


	
Developers that start with Ruby, and only know Ruby, may not understand things like pointers, typing, and/or data structures.  Also, since Ruby almost strictly functions as an object oriented language, Ruby only developers may not learn or understand many of the other programming paradigms.  Ruby also has limitations of scale and resource consumption making working with larger projects far less efficient, case in point Twitter [switching languages](https://blog.twitter.com/engineering/en_us/topics/infrastructure/2017/the-infrastructure-behind-twitter-scale.html). So...

![alt text](https://gx0ri2vwi9eyht1e3iyzyc17-wpengine.netdna-ssl.com/wp-content/uploads/2018/01/next.jpg)


	
All this brought me to a question. What would be a good language to learn that would help solidify deeper concepts and make me a more useful and productive developer? I want to write efficient code that uses minimum resources. I want to have the power of C++ without the years long learning curve or the complexity of syntax.  And, I wanted the enjoyability and ease of coding I get with Ruby. I’d heard about Rust from a few more experienced developers that were kind of pointing me towards it after I told them what I was looking for.  


	
Rust is closer to C than Ruby. However, It has better memory safety and management.  For example, pointers are not allowed to point to other pointers. On compile, the intermediate pointers are removed from the equation. Types are only mutable or immutable if you explicitly them to be.  There is also no automated garbage collector. Instead, it uses RAII (Resource Acquisition Is Initializtion) which provides deterministic management of resources and at compile, prevents  things like dangling pointers and other forms of undefined behavior.  Also, the syntax and code structure force developers to write optimal code. 


	
Because of its memory safety and resource efficiency, slant.co has ranked Rust as the #1 language to learn for backend developers, the #2 language for concurrency and meta programming.  Rust also earned #1 as the best all around compiled language, as well as 2017’ and 2018’s most loved programming language on Stack Overflow’s [developer survey](https://stackoverflow.com/insights/survey/2017#most-loved-dreaded-and-wanted.). 


	
Getting started with Rust is fairly easy and straight forward. You can read “[The Book](https://doc.rust-lang.org/book/)” online.  The book will walk you through all the basics from Hello World, to building a CLI, and even a server setup.  Going from any language, even magical Ruby, to Rust isn’t too difficult since a lot of the concepts are the same.  You just get to learn to how to have more control over how things work.  In ruby, you might make an object that looks something like:


![alt text](https://thepracticaldev.s3.amazonaws.com/i/p1q428svihtmawbjjow5.png)

In Rust, the same thing might look something like:

![alt text](https://thepracticaldev.s3.amazonaws.com/i/qa8nirw5q70vgx6hxrdf.png)

Rust has a large community to learn from and is well documented.  So, as you dive deeper into the language there is ever more information and people to learn from.