Rust will be the language of the future

Rust will be the language of the future. I bet on it.

What does it even take for a language to become successful?

Well, lots of things I think but at the very least it should have a unique selling point. Something that makes the language stand out and is attractive to developers.

In 2009 I was all excited about Node.js. I was writing web servers with ASP.NET at that time. Suddenly evented I/O was there to teach us how all our threading was bad for scalability. That combined with the promise of sharing code between the client and the server got all of us excited…Yay, five years passed since then.

Well nowadays it’s all about the march towards Go it seems.

So what does Go bring to the table? First of all: It’s a compiled language. For the last thirty years or so we’ve seemed to focus on interpreted languages or such that operate on a Virtual Machine. Think Java, Scala, C#, F# JavaScript, Python, Ruby and so on.

Now it’s all the fuzz about compiling to native code again. Even the .NET team just recently announced that you can now compile your C# code to native code to get the speed of C++ with the joy of C#.

So one of Go’s claims is to be fast just like C++ but without the pain of C++. It also offers a great answer to parallelism with goroutines and channels. In a few words: threads without the costs of threads[1]. Green threads.  Yeah, sounds great! As a language geek that got me hooked as well. Well not for long. Go is simple. It’s easy to learn. Great. But…On the other hand. It’s just a little *too* simple for me. No generics, barely any functional programming influence, it has nil (null). I quickly came to the conclusion that Go is not good for me.

So, what’s up with Rust?

Rust is a language by the awesome folks of Mozilla. It’s entirely developed in the open (that alone is such a huge win!) and it makes big claims that have potential to disrupt our current programing language world.

One of it’s biggest claims is that you can use Rust for projects that previously would have been written in C of C++. Like kernels, operating systems or browsers. Not even Go in it’s current form could make such claims because it’s not low level enough.

Rust on the other hand tries to achieve two things at once. Being low level and being high level at the same time! This is the most exciting part for me!  On one hand Rust is a very modern language. It has generics, traits, it is expression orientated, has pattern matching, closures and a lot of other exciting features.

On the other hand it is very low level, too. It doesn’t use garbage collection by default. It just defines a couple of new rules that the compiler enforces on you *at compile time* which eliminates the need for a garbage collection. That said, you still can apply garbage collection to certain parts of your program if you need to!

But it’s not just all about garbage collection. It also lets you take deep control about heap vs stack allocations that for instance wouldn’t be possible in Go because Go’s compiler uses escape analysis to figure out if something should go on the heap. So basically, you can have all the low level control you need, when you need it!

But does that mean that it’s restricted to low level systems programmers? I don’t think so! Speaking for myself, I’m certainly not a low level systems programmer. I wish I had C or C++ skills. Unfortunately I coded with pampers on for all my live. I used BASIC, Visual Basic, PHP, Java, C#, F#, JavaScript but I never used C or C++[2].

Whatever! I’m currently getting my feet wet with Rust. I started to work on a web application framework for Rust that aims to be simple. Nickel.rs.

Does this look too low level to you (apart from the terrible syntax highlighting)?

extern crate http;
extern crate nickel;

use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };

fn main() {
    let mut server = Nickel::new();

    fn a_handler (_req: &Request, res: &mut Response) {
        res.send("hello world");
    }

    server.get("/bar", a_handler);
    server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}

This is a simple nickel.rs application. I think it doesn’t look too scary for anyone ever written a web application in express.js. I’ll talk about it at the next Rust Bay Area meetup.

Leave alone the language for a moment. The community is great, too!

I’m probably the one with the most stupid Rust questions on StackOverflow but people invest a lot of time to put together great answers. And as I’m writing this people  on IRC help me to get the wording right.

And dear reader, if you are looking at this from a JavaScript or Ruby angle, you might be surprised to find some familiar faces. Yehuda Katz, EmberJS and Ruby on Rails core developer is currently hard at work to work on a package manager and several other libraries for Rust.

If you didn’t take a look at Rust yet I highly recommend to do so…

[1] Not trying to be accurate.  Go hacker news, kill me.
[2] Not 100%. I tried C++ with the age of 11 but failed miserably.

About these ads

6 thoughts on “Rust will be the language of the future

  1. b4283 says:

    Yeah, Rust’s great and I’m just reading the tutorial to learn it. Somehow my friend are a little concerned that the language spec isn’t stable yet, so it changes over version. Do you have any suggestions for this ?

  2. I programmed in C for a few years, C++ for many more, then Java for even more, along with C#, and learned scripting languages like perl, and smattering of Python, and JavaScript. Wrote a rather non trivial Go program to learn Go – which I rather liked at the time but, well, it wasn’t low level enough to really be a successor to C or C++. Spent some time with Scala, but am more interested in actor concurrency so have just moved on to Java 8 with lambdas and the Akka actor library – and RxJava for reactive programming model (asynchronous streams processing).
    Finally got around to looking at Rust. Hmm, I think I’ve finally found what I’ve been searching for – a true systems programming capable language, that has modern ideas incorporated, not excessively complicated (i.e., not Scala), and yet able to range up to write large scale, complex software systems where maybe Java and the like are currently used. Or turn right around and do stuff for a Raspberry Pi or other embedded programming project where want a very minimal runtime foot print.
    Rust is really looking promising – need to get some time to do some kind of small project

    • cburgdorf says:

      Nope, I didn’t. I heard about it but I don’t know too much about it. What the biggest selling point? I mean, Rust has memory safety without GC. What’s the most exciting thing about D?

  3. All opinionated comments here, of course, but will chime in on this one: I read up on D some and like the articles published by D’s author on Dr. Dobbs on writing new languages, but it strikes me as fixing warts of C++ and not so much as new things on the table like the safe memory usage and safe concurrency management as per Rust. It offers destructor like memory reclamation or managed memory, immutable memory, message passing, etc. I don’t get the sense though that it has static analysis comparable to Rust that would always insure safe memory usage.

    I liked Go but it went strictly with garbage collected memory – doesn’t look as suitable for writing kernels and embedded programming as Rust could be. Plus it has loop holes in regard to memory objects that represent areas where bugs could happen – Rust safe memory concepts, in contrast to Go, look like they’ve closed those possibilities.

    The compile time analysis of memory usage per owner/borrower, etc., and that memory management is manual – can dial in what is deemed suitable – look to be the hallmark of Rust.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s