HN Theater @HNTheaterMonth

The best talks and videos of Hacker News.

Hacker News Comments on
Considering Rust

Jon Gjengset · Youtube · 138 HN points · 1 HN comments
HN Theater has aggregated all Hacker News stories and comments that mention Jon Gjengset's video "Considering Rust".
Youtube Summary
The Rust programming language has become a serious contender in the space of "systems" programming languages, and has recently been adopted by many of the tech giants for "serious" projects. In response to this, more companies are now considering whether they too should add Rust to their tech stack. This talk hopes to help you make that decision. We go through how the language compares to many current alternatives and what the language has to offer, but also what it's primary drawbacks are and its long-term viability prospects.

You can find the slides here https://jon.thesquareplanet.com/slides/considering-rust/, or in PDF format here https://jon.thesquareplanet.com/slides/considering-rust/export.pdf.
HN Theater Rankings

Hacker News Stories and Comments

All the comments and stories posted to Hacker News that reference this video.
Anecdotal - One of favorite YouTube live-streaming personalities, Jon Gjengset[1] is a Ph.D student at MIT CSAIL. His talks are very detailed[4] and captivating[3]

[1] https://thesquareplanet.com/

Talks

[2] https://youtu.be/s19G6n0UjsM

[3] https://youtu.be/DnT-LUQgc7s

Rust Details(my favorites)

[4] https://youtu.be/rAl-9HwD858

Mar 07, 2020 · 135 points, 45 comments · submitted by Jonhoo
carapace
> Jon Gjengset

> The Rust programming language has become a serious contender in the space of "systems" programming languages, and has recently been adopted by many of the tech giants for "serious" projects. In response to this, more companies are now considering whether they too should add Rust to their tech stack. This talk hopes to help you make that decision. We go through how the language compares to many current alternatives and what the language has to offer, but also what it's primary drawbacks are and its long-term viability prospects.

https://jon.thesquareplanet.com/slides/considering-rust/expo...

lemmox
Jon has been working on a reasonably large Rust project called Noria[1], "a new streaming data-flow system designed to act as a fast storage backend for read-heavy web applications".

I found his Rust live coding sessions on YouTube[2] to be an enjoyable introduction to Rust.

[1] https://github.com/mit-pdos/noria

[2] https://www.youtube.com/channel/UC_iD0xppBwwsrM9DegC5cQQ

olalonde
I've been getting into Rust lately and really enjoying it so far. Coming from JavaScript, It can feel a bit verbose at times and I'm still trying to get an intuitive grasp of ownership but it feels like a really small cost compared to say C/C++. A nice bonus is that it has very good support for WebAssembly/Node.js which makes it easy to start using Rust for some JavaScript modules without having to re-write the whole codebase. And finally, the community is still very noob-friendly.
Waterluvian
I felt the same, coming from JavaScript and Python. Then I realised "verbosity" is actually "the language demanding you be crystal clear about what you're asking and that every code path is covered."

I just can't go back. Typescript gives me most of this. But Python feels just awful to me now. It's like an entire kind of cognitive load is being eliminated from my day.

throwaway894345
I’ve had some luck with Mypy, but it’s still very bolted-on. Even getting the type checker to find dependencies installed on your system is nontrivial. But this sort of tedium is just par for the course with Python.
deathanatos
> It can feel a bit verbose at times

Certainly can, especially compared to JavaScript. The way I've come to view this (and across more languages than just Rust) is that it's a trade-off between providing more information to the compiler which it can use to catch errors, and verbosity. You can't provide the information without some input, though things like type inference can help cut down on this. IMO, it's worth it: my Rust code, once it compiles, I feel has less bugs than my equivalent Python; I'd rather fight with the compiler than with runtime exceptions.

As I've learned Rust, I also find that sometimes you can elide some parts of things. E.g., in collect() calls, you can say Vec<_>, eliding the item in the Vec, because the iterator you're collecting it from already knows it, and it can be inferred from that.

Of course, sometimes, I think it's nice to provide the type anyways, as I find the compiler is better at inferring than I am. I've definitely spent a fair amount of time in Python looking at a variable and wondering what type IS this?

melling
I'm 20 minutes in and he's spending a lot of time talking about how Rust gets correctness right.

Are there any anecdotal stories about how Rust programs have fewer errors?

Facebook, for example, rewrote Messenger with ReasonML:

https://reasonml.github.io/blog/2017/09/08/messenger-50-reas...

And it had a lot fewer bugs:

"Messenger used to receive bugs reports on a daily basis; since the introduction of Reason, there have been a total of 10 bugs (that's during the whole year, not per week)! *"

papaf
Are there any anecdotal stories about how Rust programs have fewer errors?

My hobby projects are in Rust and Go. Its personal taste, but I prefer programming in Go. I actively dislike programming in Rust.

In Go, I usually I start a debugger once a week because I need to understand the cause of a bug or panic. I have no idea how to debug Rust, because in 2 years of Rust, I haven't had that type of low level bug.

ravloony
anecdote incoming!

In my previous gig, we had a premium website hosting platform, and our incoming clients would usually want their old inbound links to keep working. Over time, this meant a few hundred thousand autogenerated rewrite rules in Nginx. This was causing Nginx to use about 10G of memory, so restarting it, which we had to do every time we added a redirect, was an issue.

I replaced this with a small reverse proxy written in rust that loaded all of the redirects from postgresql into a cuckoo filter. Adding a redirect was an INSERT, followed by a NOTIFY to let the proxy know to add the redirect to the filter.

Putting it all together took about 2 weeks of swearing at the compiler, but it never had an issue in production, and used about 1M of memory, while adding less than 1ms of latency, or about 4ms in case of a filter hit. Cuckoo filters can have false positives, so if a redirect was found, we still had to check in the db table before returning 301.

As far as I know it's still working fine, and I use rust whenever I can.

mleonard
Interesting! Any chance you can share a few tips to get started doing the same? (eg any crates to use or other tips). I'm currently looking for a rust learning project and building what you described really hits the mark!
ohazi
> Are there any anecdotal stories about how Rust programs have fewer errors?

My anecdote is that programming in Rust intuitively "feels" like programming in languages like OCaml or Haskell, which have a reputation for "you'll often spend a lot of time fighting the compiler, but when your program finally does compile, it's much more likely to work correctly on the first run than other languages (e.g. C, C++)."

zamalek
I take about 1-2 hours to hash out some major changes to C# code. It breaks for asinine reasons (of my own fault) 7 or 8 times after I try it out. I just wrapped up my learning Rust project. Day 1 was spent with about 7 hours of coding, some unit tests, first run it worked with no stupid errors. All refactorings except one (I messed up mutability, logic error) went without a hitch after running it.

It's wholesome development, if there were such a thing. I feel good and proud of the code I write in it.

[1]: https://github.com/jcdickinson/racemus

gameswithgo
firefox has tracked some stats on this that are very promising. rust and reason also share a lot of the key correctness features
CapriciousCptl
Rust certainly makes some bugs impossible. But I don't think comparing #bugs of rewrites to the original is ever fair.
zozbot234
ReasonML is basically Ocaml with a JS-like syntax on top, so no surprise there. The main advantage of Rust over ReasonML/Ocaml is likely to be increased performance and ease of coding multi-threaded or parallel code, as opposed to correctness per se.
_bxg1
I've seen anecdotes from a few projects that were rewritten (Quake was one, I think?) and some ancient bugs were found only after the translation
3PS
Last year, npm rewrote a CPU-bound service in Node.js, Go, and Rust. They noted that the Rust version took the longest to write, but had basically no issues at runtime.

https://www.rust-lang.org/static/pdfs/Rust-npm-Whitepaper.pd...

Excerpt:

> npm’s first Rust program hasn't caused any alerts in its year and a half in production. "My biggest compliment to Rust is that it's boring," offered Dickinson, "and this is an amazing compliment." The process of deploying the new Rust service was straight-forward, and soon they were able to forget about the Rust service because it caused so few operational issues. At npm, the usual experience of deploying a JavaScript service to production was that the service would need extensive monitoring for errors and excessive resource usage necessitating debugging and restarts.

loopz
Rust is interesting, so I decided to include it in a 3 language prototyping project. I wanted to experience how it is to code for these languages, compared to the outcome. The project was dead simple, read 2 files concurrently and match lines by id's. Data was a bit unstructured, some lines would go unmatched, some would be duplicates, and report on that while deallocating memory for processing large filesizes.

Ruby: Quick fun building the classes and methods. A bit trial and error on dynamic errors. Processing was 40x slower than golang implementation though, so felt a bit discouraging after the fact. But was fun language to prototype OO in! Nice for quick'n dirty projects.

Golang: I didn't find need for OO or interfaces, so simplified for processing code mostly. The language helped in this regard, as it is quite imperative-driven. Golang was the fastest language to develop in, and showed Ruby version to be a bit over-engineered.

Rust: Never coded in Rust before, I searched SO for most relevant code examples and patched it up from several examples. I didn't go into the deeper end of things or optimize anything, but instead spent 90% of the time writing naive processing code while battling the compiler. If I'd been proficient, perhaps no battle, but this required the longest dev time and processing was noticably slower than Go, though not by a factor.

From this short anecdotal experience: Ruby for quick'n dirty fun or OO modelling. Golang for prototyping and initial versions. Rust for where you know you need safe parallellism and special optimizations. Right tool for the job!

aldanor
For me, Rust also fits "fun language to quickly prototype type system in", but I've been hacking in Rust since its 0.* days; if I were to try to do it in Ruby/Go which I've barely ever touched, it would sure take me way much longer.

If I were to compare Rust to Python/C++ which I'm proficient in, Python would be the fastest because there's zero setup time, tons of quality packages and notebook environment; C++ would take a lot longer due to having to set up builds, and due to lacking stdlib and ecosystem.

_bxg1
Even as a fan of Rust I've become exhausted by these posts. Surely everyone on here must at this point know what Rust is and roughly why people use it?
pmarin
I guess people need to kill their time somehow while their rust code finish to compile.
nickez
I think Rust fans here at HN appreciate some ammunition when convincing other people that Rust is great!
Cyph0n
Forget about Rust, and just think of it as a talk about why you should be considering language X. Do you still feel exhausted?

I think it would be interesting to see a breakdown of the blog posts and talks posted to HN by language.

_bxg1
I would if a post/talk about why you should be considering language X showed up on the front page once a week.
melling
I don't think Rust has reached wide acceptance yet.

Sure there are companies that use it, but I bet you'd have a hard time convincing your manager that Rust is widely accepted in industry.

Anyway, I certainly appreciate all of the posts.

_bxg1
Not widely accepted in industry, but widely accepted (or at least known) among HN readers
nazka
Which is a very small percentage of people in tech. In my network Rust is still very new to unknown in some tech companies. I will say Go is more the language that emerged.
_bxg1
Yes but we're not talking about the prevalence of these in general, just on HN
alexandercrohde
Can somebody please explain why Rust has so much buzz right now compared to scala?

Scala is a strongly typed, very-well vetted, functional programming language in the JVM. It pretty much has everything going for it. It's even adopted by twitter.

dpc_pw
I am big on Rust, and I enjoyed using Scala at work in the past. Scala has a more elaborated type system, and everything is heap-allocated so some stuff is easier. On the other hand... JVM is often a PITA, and debugging blowing up memory issues was common. Compilation was slow (even slower than Rust), code was sometimes slow, and emphasis on OOP has made a lot of code I had to work with overly complicated and very much a typical OOP spaghetti garbage. Null pointers are still a problem (though much less than Java). Compiler is not as helpful as rustc one, though IntelliJ integration was more mature. Lack of macros encouraged code generation which was a PITA. Collections were messed up. Tooling wasn't half as nice.

The list of complains grew big, but again: all in all, I think Scala was quite fine to work with.

xwowsersx
> It pretty much has everything going for it.

Hard to respond to that as it is so general.

> It's even adopted by twitter.

And larger companies than Twitter use Rust (though to be fair not as extensively as Twitter uses Scala).

They're really not comparable. Rust is a lower-level language with no garbage collection (yet with guarantees about memory safety due to ownership rules). Scala runs on the JVM and has significantly more in the way of OOP (depending on how you use it obviously).

That said, I've found that my extensive Scala experience does come in handy when learning Rust as some features of the type system, pattern matching, threading failures through with ?, etc. These are things you won't have any familiarity with from Java, but do from Scala.

aganame
I felt slight nausea and unexplainable deep irritation at reading this.

Scala is a disgusting mess compared to Rust in just about every way I can think of. Please for the love of everything good, consider at least Kotlin.

steveklabnik
Twitter also uses Rust. Not nearly as much as Scala, of course, but there's the Pants build system (Python + Rust), stuff like https://github.com/twitter/rezolus
wffurr
JVM, garbage collected, doesn't have zero overhead abstractions.

Might as well ask why Scala didn't take over from C++.

alexandercrohde
I don't know why you'd be dismissive of that comparison. Scala is more like Rust than any other language he discusses.
tomlu
Because performance is a P0 concern to a lot of people. Rust (and C++) has performance as a primary goal, Scala does not.
alexandercrohde
Did you even watch the video? The guy is comparing rust to things like Python which is a pretty silly comparison, relative to scala.
carlmr
Everybody knows python, few people know Scala. Isn't that enough of a reason?
wffurr
I mean sure, Scala is a great language and has a lot more in common with Rust than most languages, but it's fundamentally designed for a different role than Rust. Rust is designed as a "systems language", whereas Scala's dependence on the JVM is a non-starter for such a role.

You could say instead that Rust is a Scala-inspired systems language. Not just Scala, obviously, but by functional programming concepts like algebraic data types and type inference. Rust isn't even really a functional language itself; it's still an imperative language.

fortran77
I don't use Rust. But I never considered Scala because of the JVM.
j88439h84
> JVM, garbage collected, doesn't have zero overhead abstractions.

Is it fair to say that the significance of those points are these?

no JVM: easier deployment

not garbage collected: less latency

zero-overhead abstraction: smaller in memory

wffurr
Yes, and more to the point said qualities make Rust suitable for use in kernel-type systems and embedded progamming, whereas any JVM or other GC and VM based language generally isn't.
zamalek
I've just "incompleted" my first Rust project: a Minecraft server. I gave up due to the protocol, not Rust. I finally learned the damn thing after spouting its hypothetical advantages all over the internet. My overall conclusion was correct, but the reasoning incorrect. The borrow checker is an amazing pair programmer, but that's not the primary reason I'm having genuine fun.

Rust is a systems language that is a pleasure to build. This "how to build on Mac/Windows/OSX" is a non-issue and should be a non-issue. Solving how to build something is an utter waste of time and is complete bullshit.

Please, for the sanity of the rest of us, stop using C build systems. They are just unbelievably terrible; people have tried and tried, but you can only do so much with a fundamentally flawed bad idea.

adev_
> Please, for the sanity of the rest of us, stop using C build systems. They are just unbelievably terrible

That's not an argument. You do not even try to explain why it is terrible.

C build systems are terrible because they handle 30 years of legacy, 10 different compilers and 100 of platforms that all have their specific non-sense to handle at different compilation stages.

You can also add on that the non-standard build system specific way to handle things like debug/release builds or dynamic/static linking because every system created its own for fun... ( --release/CMAKE_BUILD_TYPE=Release/make release/-Q release=1/etc/etc, .lib files/so/a/dylib/rpath/dt_runpath, lto/not-lto, -Wl,-Bdynamic/-BStatic, etc, etc, etc )

And you get the mess you are in.

The real question on that is: Will Rust be any better in 20 years ?

My hope is that the community will be smart enough to not fragment. But history told us that every OSS project big enough fragment soon or later.

PureParadigm
Couldn't agree more. I often have to install programs from sounce, and dynamic linking, header files/include paths, etc. make the C build system extremely unreliable. It's often more of a trial and error process ("which library is it going to be missing next") than a methodical one. I've spent countless hours hunting down why libfoo.so isn't loading correctly, or why some random function is undefined at the compile stage.
HN Theater is an independent project and is not operated by Y Combinator or any of the video hosting platforms linked to on this site.
~ yaj@
;laksdfhjdhksalkfj more things
yahnd.com ~ Privacy Policy ~
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.