cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1364
Views
3
Helpful
7
Replies

Word of the Week: Rust

npetrele
Cisco Employee
Cisco Employee

There are so many programming languages to choose from. The top 10 languages in the April 2023 Tiobe Index are as follows:

  1. Python
  2. C
  3. Java
  4. C++
  5. C#
  6. Visual Basic
  7. JavaScript
  8. SQL
  9. PHP
  10. Go

Incidentally, I find the inclusion of SQL odd, since it's a relational database language, not a programming language. But the rest of the list matches what I would guess in terms of programming language popularity. 

Ranking 19 on the list, there's a language called Rust that I had never heard of, so I checked it out. I'm very impressed, and I've barely scratched the surface. It's fast because it's compiled and linked so it doesn't need a runtime and it doesn't have a garbage collector. The compiler's error handling is smart enough that you will probably never miss the need for garbage collection.

The language should be easy enough to pick up, but too complex to give you an overview here. Check out the excellent documentation for details.

Here are a couple of things that really stand out for me. First, you install Rust and keep it up to date with "rustup". Rust has its own package manager, Cargo, which behaves something like PIP

But Cargo does more than just install libraries. Cargo is a build tool. You use it to create new projects, manage the projects, compile, build and run. As a default behavior, as you add libraries, it figures out what dependencies you need and stores the versions of your library dependencies in a lock file. This is roughly like using a Python virtual environment. Every time you build the app, it will use the original versions of libraries specified in that lock file. This prevents Cargo from installing updated libraries that may introduce defects or new behavior. You're not stuck with that behavior. You can tell Cargo to ignore the lock file and update the dependencies. It's all a bit more nuanced than that, so I recommend you study the docs. 

As for the language itself, you should be able to pick it up quickly if you're already familiar with similar languages like C, C++, Java, or PHP. Beginners need only watch out for the fact that Rust treats variables as immutable by default. For example:

 

let x = 5; // x is immutable and will always have the value 5
let mut x = 5; // x is mutable and you can change the value

 

If you're like me, you may have cringed at the thought of typing "let" to set a variable, but trust me, the language is cleaner and more concise than that, overall.

Rust already has a lot of useful libraries. For example, there's a reqwest library that gives you basically the same HTTP REST features as Python requests

Anyway, I recommend that you take a look at the docs, download and install Rust and see for yourself.

Resources:

Rust: https://www.rust-lang.org/

Rust Docs: https://doc.rust-lang.org/book/title-page.html

Rust Standard Library: https://doc.rust-lang.org/std/index.html

Popular Rust Libraries: https://lib.rs/std

 

7 Replies 7

Sean Dahlberg
Cisco Employee
Cisco Employee

Your topic reminded me of something @Alex Stevenson posted last month (for anyone interested in learning more about Rust):

https://community.cisco.com/t5/developer-general-knowledge-base/extremely-cool-command-line-tools-supercharged-with-rust-part-1/ta-p/4779695

Some great info in there if Nicholas's topic got you wanting to learn more!

Wow, thanks, I missed that post. 

davidn#
Cisco Employee
Cisco Employee

I am not sure what the criteria of the Tiobe ranking is but it doesn't sound right. I would say Python and Javascript are the top 2 programming languages in term of popularity and most commonly-used

Sean Dahlberg
Cisco Employee
Cisco Employee

Yeah, I've found a few different sites that measure this differently. For example, Statistica has their top 5 as:

  1. JavaScript
  2. HTML/CSS
  3. SQL
  4. Python
  5. TypeScript

https://www.statista.com/statistics/793628/worldwide-developer-survey-most-used-languages/

And we did a somewhat similar poll on LinkedIn a week ago (had a much smaller list):

https://www.linkedin.com/posts/cisco-devnet_activity-7049174031073247232-61BE/

And Python, by far, was the top one. Of course, a small data sampling and a very specific audience.

The fact that SQL keeps showing up amuses me. Yes, SQL stands for Structured Query Language, but it's not a programming language. It reminds me of the days when I freelanced as an analyst for a data research company, and they sent out surveys with a question like this:

Which operating system do you target for your applications?

  1. iOS
  2. Windows
  3. Linux
  4. Apache

Even crazier is that a number of people who took the survey answered "Apache".  Yeah, there are web applications, but still, Apache is not an OS. 

davidn#
Cisco Employee
Cisco Employee

I made it my goal to learn enough about Rust & Leptos Web Framework during the holiday break and be able to convert my existing FARM stack app to a full-stack Rust SSR web app. Let's get Rusty!