Hacker News new | ask | show | jobs
by rubyfan 3468 days ago
I suppose this an advance for those already using Rust but the core message on the front page doesn't speak to me as a non-Rust person.

FTA: Rocket is a web framework for Rust that makes it simple to write fast web applications without sacrificing flexibility or type safety. All with minimal code.

I'm at a total loss for why I really care about this major part of their message (type safety). If I have already switched to Rust then I care about type safety already and you don't need to sell me on Rust, you should focus on differentiating this web framework from the ones that came before it. But if I haven't switched to Rust then I am essentially unswayed by their messaging. I can't see why it's particularly important or different over other language/frameworks for web development.

Before learning Ruby I watched the Rails blog video sometime around version 0.14.3. Immediately you could the value of the framework and the ease of a language I was unfamiliar with. The win I could see was productivity and it was enough for me and a lot of other people to learn Ruby. I don't see that with this framework or really anything in the Rust world.

4 comments

What I think the author is trying to portray is that they achieved Ruby/Python level code (in terms of boilerplate and readability) while retaining the typesafety and performance that makes Rust attractive in the first place. That's a step up in every direction. This is, of course, tackling the notion that readers might associate strongly-typed web frameworks with verbosity and complexity, whereas Rocket is neither.

I think that's important to those both familiar with rust (who want a clean framework) and those who aren't (who want a safe language without sacrificing productivity).

> I'm at a total loss for why I really care about this major part of their message (type safety).

Honestly, you might not care about type safety. It depends a lot on the kinds of programs you write.

In general, a language with a good type system[1] brings several major advantages to the table:

1. If your program compiles, there's typically a 90% chance it will work correctly on the first try, even if you just changed hundreds of lines of code.

2. Big refactorings are much less stressful.

3. Emacs or Visual Studio Code (for example) can provide pop-up completions of names and methods.

4. Problems like mysterious nulls or data races can be prevented almost entirely at compile time.

One big downside is that it gets harder to do certain kinds of (runtime) metaprogramming and you need to use macros to get similar effects.

At this point, having worked professionally with Rust, I would recommend Rust to people who are really enthusiastic about the above benefits. But if you look at that list and say, "Meh, not worth it," then you might not want to adopt a younger language like Rust. Well, unless you need to get reasonably close to the metal without sacrificing safety, which is where Rust really shines. I just wrote a fast CSV sanitizer in Rust for processing gigabytes of input, and the compiler caught a subtle memory error when one CSV line spanned two buffer reads.

[1] For the sake of argument, a "good" type system in this context includes the ability to define custom collections with type parameters, it only allows NULL to appear where explicitly permitted, and it supports tagged unions with a nice "match" construct. This seems to be roughly the minimum feature set to get the full effect described above. Examples include Haskell, Elm, Rust, ML and (to a surprising extent) TypeScript.

The state of completion in the JavaScript world is fairly impressive these days, considering what it is.
Learning that there is a framework that gives you both flexibility and type safety might be a good reason to jump into Rust if you haven't already.
You can write a safe framework in Rust, or you could just have everything as Strings. Just because it's in Rust, doesn't mean you get safety from a lot of error conditions.