
John Carmack: writing Rust code feels wholesome - jimyl
https://twitter.com/ID_AA_Carmack/status/1094419108781789184
======
purplezooey
Man reading Twitter is so awful. It feels like sitting in one of those 2 hour
meetings where everyone is allowed to give their 30 seconds and all that's
left is your throbbing headache.

------
brutus1213
I looked seriously at rust about 2 years ago. I seem to have tried the
language at the wrong time .. they were transitioning between versions and
this made learning it hard. I grew up with C so am very comfy with pointers.
Even reference counting feels natural to me. That said, the
borrowing/ownership semantics of rust (at the time I looked at it) felt
needlessly over complicated. Has this got better? Is there a K&R equivalent
that an experienced programmer can get pick up to get productive with the
language soon?

~~~
manaskarekar
>the borrowing/ownership semantics of rust (at the time I looked at it) felt
needlessly over complicated.

Taking a wild guess here, but it sounds like you maybe referring to issues
addressed by Non-Lexical Lifetimes (NLL)?

Reference: [https://github.com/rust-
lang/rfcs/blob/master/text/2094-nll....](https://github.com/rust-
lang/rfcs/blob/master/text/2094-nll.md)

NLL are a part of Rust 2018 Edition.

Three complementary books are the best resources:

\- The Official book: [https://doc.rust-lang.org/book/](https://doc.rust-
lang.org/book/)

\- The Rust By Example book : [https://doc.rust-lang.org/rust-by-
example/](https://doc.rust-lang.org/rust-by-example/)

\- Programming Rust (O'Reilly) : [https://www.amazon.com/Programming-Rust-
Fast-Systems-Develop...](https://www.amazon.com/Programming-Rust-Fast-Systems-
Development/dp/1491927283)

~~~
est31
NLL only modes aren't available on stable Rust atm. What edition 2018 has
right now is migrate mode NLL. In order to fully enjoy NLL, you'll have to use
Rust nightly and do _#![feature(nll)]_ or _-Z borrowck=mir -Z two-phase-
borrows_ , both flags being independent of the edition you're using.

Edit: removed outdated behaviour of migration mode.

~~~
burntsushi
> What edition 2018 has right now is migrate mode NLL which emits an error if
> either NLL borrowck or AST borrowck think there is an issue with your code.

If that were true, then this example would fail to compile, since it fails
with the old AST borrowck: [https://play.rust-
lang.org/?version=stable&mode=debug&editio...](https://play.rust-
lang.org/?version=stable&mode=debug&edition=2018&gist=66e745314774b90573159d2f2c2c4850)

See: [https://rust-lang-nursery.github.io/edition-
guide/rust-2018/...](https://rust-lang-nursery.github.io/edition-
guide/rust-2018/ownership-and-lifetimes/non-lexical-lifetimes.html)

~~~
est31
Oh right, seems it got a bit more tolerant. The mode's still called migration
mode though, full NLL is to be unleashed later on: [https://github.com/rust-
lang/rust/issues/57895](https://github.com/rust-lang/rust/issues/57895)

------
bsaul
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 ?

~~~
fzzzy
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 await! macro is usable now, but
the rust community has been bikeshedding over built-in await syntax and last
time I looked that discussion was still raging.

So you can write scalable servers using normal threads, normal callbacks, and
async with the await! macro, but not the final async/await syntax because the
community hasn’t even finished deciding what it is. Porting code between these
approaches is also not particularily easy. I have seen example code for rust
networking libraries that uses all of the different approaches, but mixing the
different approaches is also difficult. So that’s probably why people say it’s
not ready even though you can write code right now that will work just fine.
The “final” way of writing it isn’t ready yet, and if you write one of the
current forms, porting to the final form will be a pain.

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

~~~
fzzzy
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.

~~~
pimeys
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](https://github.com/pimeys/a2/pull/30/files)

------
Waterluvian
When I explored rust I found the exact same feeling too, but couldn't find
that word.

My only issue is how surprisingly weak Rust support is in my favourite editor.
Rust seems to feel more popular than it is. Or maybe more people write Rust in
a "no frills notepad" kind of way.

~~~
AndyMcConachie
As an Emacs nerd I did have to find and download a Rust mode. I imagine in the
future Rust will get more support in editors.

I've also just started writing Rust in the domain in which I write code, low
level networking. I think I agree with Carmack in that it feels good. I can
get hungup on syntax when learning a new language and I don't have that
problem so much in Rust. I've been writing code in many different languages
for close to 30 years and learning Rust feels mostly right. It feels like when
I learned Python or LISP and I could guess at syntax and just get it right. As
opposed to writing /bin/sh for over twenty years and still needing to
constantly look up syntax :(

It doesn't feel like some languages I've learned in the past where everytime I
investigate something I face-palm. It seems like the more I investigate it the
right choices were made. Even when I'm frustrated with it because the compiler
won't let me do something simple, I understand that maybe the bad habit I
learned in C should end. Rust forces you to deal with things upfront that may
become problems later. It's sometimes annoying when you want to just get shit
done, but it's the 'right thing' to do.

~~~
Waterluvian
It's so nice hearing this from someone with as much experience as you. I have
far less but one feeling I had lately when switching to typescript was,
"instead of turning off this warning, maybe they're right. Maybe this is a bad
habit."

It forced me to think harder about my code's structure. I think that's what I
like about Rust too. Not being able to do anything means I have to be
thoughtful.

Which also reminds me of how to be creative with games or writing or music:
artificially limit yourself and you're forced to be more thoughtful.

------
mbroncano
Also posted in the twitter thread, a game dev wish-list for Rust

[https://users.rust-lang.org/t/my-gamedever-wishlist-for-
rust...](https://users.rust-lang.org/t/my-gamedever-wishlist-for-rust/2859)

------
johnisgood
Does anyone know, is [https://github.com/rust-
lang/rfcs/blob/master/text/0066-bett...](https://github.com/rust-
lang/rfcs/blob/master/text/0066-better-temporary-lifetimes.md) 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.

~~~
TheCoelacanth
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](https://github.com/rust-
lang/rust/issues/15023)

------
klyrs
JC: hey this language is nice

Twitter: yes but have you tried my favorite language?!

------
topspin
I've been playing with Tokio and Actix for a few days. That's the same feeling
I get.

------
azhenley
I decided to learn Go instead of Rust over the last 6 months (very limited
time so couldn’t learn both well).

Rust has gotten so much on HN lately that I think it may be time for me to
make the switch.

~~~
forinti
I started with Go and am now learning Rust. I liked Go, but it felt incomplete
(currently there's a discussion on generics) and I'm tired of Java never
settling down and now trying to be cool. Also, method declarations are weird
(method over variable or pointer).

Rust seems complete. The ownership paradigm is a bit difficult at first, but
the compiler is good at pointing out exactly what the issue is.

~~~
pjmlp
Interesting remark of Java not settling down with Rust being complete, while
some Rust libraries depend on nightly and async/await is still not fully
baked.

Languages are products, either they change with times or they die.

------
rienbdj
C++ continues to lose mind-share. When will the community acknowledge that
their tooling is lacking?

~~~
geezerjay
A tool is a tool. It's immaterial if a particular tool like C++ and its
ecosystem is no longer the best available tool for some applications. Workmen
pick the tool that best suits their tasks, and if a better tool appears it
makes no sense to assume that the old tool requires more attention.

~~~
adgasf
C++ has many users that love the language but are in denial that other
languages have advanced beyond it (not in all areas, of course, but enough
areas that matter).

~~~
ahartmetz
Do you use C++? I do, and I don't love the language. What I like about C++ is
that it's a high level low level language. Anything that isn't is not a
competitor in C++'s core application areas. D and OCaml come kinda close but
they have (in practice) mandatory garbage collection. The only real
alternatives are Ada (which somehow never achieved much mindshare) and Rust.

~~~
pjmlp
I do, as native companion to Java and .NET, and I still kind of like it.

However for my own use cases, my actual alternative is the newly founded love
for low level programming support by Java and .NET designers. Mandatory GC is
nice to have around, while only specific hotspots require a more machine
friendly coding.

