Live data from Hacker News

John Carmack: writing Rust code feels wholesome

twitter.com

71–80 of 85 posts

Re: John Carmack: writing Rust code feels wholesome

#71

Does anyone know, is https://github.com/rust-lang/rfcs/blob/master/text/0066-bett... ever going to be resolved? I really do not like the idea of having to create a new variable for something so simple as this.

Seems to be unanimously agreed to be a good idea, but is a bit tricky to actually implement[1]. Hopefully some day.

[1] https://github.com/rust-lang/rust/issues/15023

Re: John Carmack: writing Rust code feels wholesome

#72
post #4

Many comments in twitter mentions rust still not being ready for server code ( which i start to feel strange since concurrency is the only major issue on the server side, and supposed to be rust strength). Anyone can confirm ?

It's pretty nice for server code, but still has one major shortcoming which is that's it's kind of tricky to write high-performance IO-heavy code (it's easy if you want to have a thread blocked on every IO request, but that's bad for performance if you have many concurrent requests).

This will improve a lot once async/await stabilizes. It already works great in nightly if all of the libraries you want to use support it.

Re: John Carmack: writing Rust code feels wholesome

#73
post #69
post #4

Many comments in twitter mentions rust still not being ready for server code ( which i start to feel strange since concurrency is the only major issue on the server side, and supposed to be rust strength). Anyone can confirm ?

https://www.ageofascent.com/2019/02/04/asp-net-core-saturati... That actix you see appearing in most lists and mostly nearly top is written in Rust btw. Fun fact- frameworks managed by microsoft dominate the space ;)

IIRC actix was gettin some flack for using very unsafe code to hit those benchmarks. Still cool.

Re: John Carmack: writing Rust code feels wholesome

#74
post #39
post #4

Many comments in twitter mentions rust still not being ready for server code ( which i start to feel strange since concurrency is the only major issue on the server side, and supposed to be rust strength). Anyone can confirm ?

This is because of the removal of the fat runtime and green threads about 5 years ago. Since there was no blessed way to do high concurrency in the language any more, some code started using normal threads, some code (tokio) started using normal callbacks. Callbacks in rust are tricky because of the type system. Around a year ago, async/await became possible due to the development of the Pin idea. async with the awai…

Porting from futures to async shouldn’t be too hard based on my experience doing it in JS.

Re: John Carmack: writing Rust code feels wholesome

#75
post #73
post #69

Earlier quoted context omitted.

https://www.ageofascent.com/2019/02/04/asp-net-core-saturati... That actix you see appearing in most lists and mostly nearly top is written in Rust btw. Fun fact- frameworks managed by microsoft dominate the space ;)

IIRC actix was gettin some flack for using very unsafe code to hit those benchmarks. Still cool.

There is absolutely no shame in using unsafe!

Re: John Carmack: writing Rust code feels wholesome

#77
post #74
post #39

Earlier quoted context omitted.

This is because of the removal of the fat runtime and green threads about 5 years ago. Since there was no blessed way to do high concurrency in the language any more, some code started using normal threads, some code (tokio) started using normal callbacks. Callbacks in rust are tricky because of the type system. Around a year ago, async/await became possible due to the development of the Pin idea. async with the awai…

Porting from futures to async shouldn’t be too hard based on my experience doing it in JS.

Sure, but js doesn’t have rust’s type system. It will probably be straightforward once everything is settled down, but right now Future 0.1 (tokio) and Future 0.3 (async/await) aren’t comptatible and you’ll find examples that use one or the other, or plain threads, or plain callbacks. It’s possible to get up and running quickly with the examples from various libraries, but when you try to mix them, if they use different styles, it becomes very challenging. Once async/await is finalized and everything moves to it this won’t be a problem, but that’s probably going to take at least a year or possibly years.

Re: John Carmack: writing Rust code feels wholesome

#78
post #75
post #73

Earlier quoted context omitted.

IIRC actix was gettin some flack for using very unsafe code to hit those benchmarks. Still cool.

There is absolutely no shame in using unsafe!

The issue was that the author uses unsafe code unsafely and often for questionable performance or ergonomics gains that didn't actually need unsafe anyway. Fortunately, he cleaned up pretty much all of it, as I understand it, with the help of some involved community members when people freaked out about it all.

Re: John Carmack: writing Rust code feels wholesome

#79
post #77
post #74

Earlier quoted context omitted.

Porting from futures to async shouldn’t be too hard based on my experience doing it in JS.

Sure, but js doesn’t have rust’s type system. It will probably be straightforward once everything is settled down, but right now Future 0.1 (tokio) and Future 0.3 (async/await) aren’t comptatible and you’ll find examples that use one or the other, or plain threads, or plain callbacks. It’s possible to get up and running quickly with the examples from various libraries, but when you try to mix them, if they use differ…

I did a test and converted one of my libraries to async/await and it was not that hard. There are easy converters between the future versions for the transition period.

https://github.com/pimeys/a2/pull/30/files

Re: John Carmack: writing Rust code feels wholesome

#80
post #40

Earlier quoted context omitted.

I've been programming in C and C++ since sometime around 1992 (and Pascal before that). For the last 3 years, I've been writing Rust professionally. Here's my Rust advice for C and C++ programmers: - Rust is a higher-level language than C. A C/C++ programmer could think of Rust as "C++ without most of the footguns and magic." - Certain types of C/C++ code will translate very easily to Rust. For example, if your code…

I'll probably hold off on learning Rust deeply until they have async/await as keywords. Most of the programming I do involves async, and I currently do my day programming in Dart, which is an absolute joy to do async programming in. They had Future-based APIs from day one, so the whole ecosystem was built around futures starting out. They've had async/await as keywords for over 5 years now. It's so ergonomic it's pai…

Interesting, what kind of job requires you to program in Dart?
Post reply on HN