Hacker News new | past | comments | ask | show | jobs | submit login
Practical Networked Applications in Rust, Part 1: Non-Networked Key-Value Store (arveknudsen.com)
266 points by ngaut on July 24, 2019 | hide | past | favorite | 41 comments

Interesting! I'd love to take a structured distributed systems MOOC or course in a modern language well suited for the domain like Rust, Go, Scala or Elixir/Erlang. Does anyone know if something like this already exists?

The company, PingCAP, that made the course in the linked article also ported MIT 6.824 to Rust as part of their talent plan. You can check it out here https://github.com/pingcap/talent-plan/tree/master/dss

This is exactly what I was after, thank you!

I also worked through the courses in this series, up through Part 4.

I thought it was a great way to get introduced to Rust, especially when concurrency comes into play. Having only ever written this sort of code in C/C++/Java, the way Rust required me to rethink my design to properly incorporate its concurrency model was really interesting to me.

For some reason sharing "references" in a formal way felt a lot different than what I was used to, and I'm not sure why. I'd say I prefer it, perhaps because it made my design feel more deliberate.

Question for Rust programmers, do you still use Rust for quick hacking and exploration/prototyping or reach for another tool?

Rust is getting more attractive everyday, I wonder if there is something about the language that highly influences lib authors to write quality stuff or if the community has a high ratio of experienced devs.

So a couple things. The community does have experienced devs. But the language is just fun and expressive to use.

IMO all the “fighting with the borrow checker” stuff is overblown. If you do get some complaint from the compiler, it is usually very easy to fix.

Moreover, rust is very expressive. The functional facilities coupled with combinators make the language very ergonomic to use.

I use the language for almost everything I can. If it’s something that would normally be a quick script, I will still reach for rust but not be very constrained.

If the project turns into something more it’s easy to refactor and decrease memory usage etc. Testing is kind of a “first class citizen” so that plus “compilation driven development” make it a pretty hackable tool.

Yep, I've moved to writing all my automation/tools in rust. Simply because I enjoy it more. The speed and correctness is a real nice bonus.

My one caveat is that I'd say rust is a language best to pick up after you're already a polyglot with a few years of experience in several other languages. It uses so many ideas and concepts from several other paradigms that I think it helps an unusually great amount to have a polyglot background coming in.

> Question for Rust programmers, do you still use Rust for quick hacking and exploration/prototyping or reach for another tool?

I have replaced all my tooling with Rust, fwiw. Rewrote several things at work with Rust (which started this train for me lol), and now all my projects are in Rust as well.

I often say that Rusts complexity is oversold (by myself, too, at times), and it can be just as productive as Go, if used like Go. That is to say, Go is often touted as being hyper productive because it takes decisions away from you, such as Generics. You can apply the same tools to Rust, and suddenly you lack a ton of features but also reduce the possible roadblocks you might be wanting to avoid.

Personally I don't even avoid any Rust features these days, I use all of them (that I understand, at least lol.. which I think is all). I more productive than in my Go days (~5 years in Go, fwiw).

Do you use an IDE for Rust?

Previously[1] I was using Kakoune with the Rust LSP, now I'm using Atom with the Atom-IDE-Rust plugin, which is mostly just the LSP backing it I believe.

LSPs are great :)

[1]: I switched to Atom for non-Rust reasons. Boy do I miss Kakoune every day haha.

Not GP, but I use VSCode or Vim with the Rust Language Server and have had a good experience, certainly better than either the Jedi or Microsoft Python language server.

I personally use VSCode with the Rust Language Server.

A lot of people seem to really enjoy the IntelliJ Rust plugin.

I use VS Code too, slightly curious about IntelliJ for Rust though since I fundamentally like that environment.

Their proprietary code analysis [0] is mostly better than the Rust Language Server for now, even if I still use VS Code personally.

[0] https://intellij-rust.github.io/

I use it all the time to whip up quick scripts. The other day I made a cli tool that allows you to use Jmespath syntax for yaml files.

Memory management aside: compilation-time guarantees of your code is probably the best thing about the language.

It depends on what I'm doing, but generally yes I'll write it in Rust unless I think it's a bad fit (e.g. if it's something that's better off as a shell script or whatever I'll just use that instead).

I wrote a data processing utility in rust once and it took me four tries. But the final result was way better than I expected. For all the complaints that the compiler makes, it does expose genuine and obscure problems in your code that other languages would happily neglect. The key is to understand the errors rather than fight it. They are often symptoms of architectural problems in your code that you would otherwise miss. I have much more confidence in the final result while using rust compared to other languages, and the pain of satisfying the compiler is definitely worth it.

Depending... if it's truly something quick I need to do, that is disposable, I use Ruby/shell script 9/10 times. This includes things like, restarting my computer, connecting to WiFi, checking the time in London, doing math, hitting an API.

Prototyping ideas is great in Rust, since it's compiler/type system are a nice pair of helping hands.

I will say, a proper first class REPL would be nice. Maybe some day.

>> Prototyping ideas is great in Rust

Agree. I tried to prototype in Python, but even with great IDE support it's hard to manage constant refactoring when you're moving fast.

Yes, though I admit my choice is influenced by wanting to learn to be better at using Rust, not by what is best for the task

I write C at work: to me Rust is fun for playing with a more functional style. The type system makes refactoring easy when I mess up. The tooling is good and the answer to 'why is thing X like Y?' is rarely 'because of legacy'.

I’m currently reading through everything. It’s pretty cool, been seeing more and more stuff like this lately.

It could serve as a great second or third project for someone learning rust and the rust-ecosystem.

Another nice(more lightweight) hands-on Rust tutorial that I came across with: https://docs.rs/csv/1.1.1/csv/tutorial/index.html

How hard is it to build a c compiler with garbage collection and compile all the the pre-existing code with safe garbage collection ?

Your question is utterly off-topic on this thread. But the short answer is that you can’t, it’s fundamentally impossible. Garbage collection still requires that memory access be principled, so that it can determine when something is no longer in use; but things like pointer manipulation in C scupper that.

This is a perfectly reasonable question, asked out of innocent curiosity; the negative reactions to it are disgraceful.

I think building such a compiler would impractical, because in C, you can turn a pointer into an integer and back again. While it's an integer, you can hide it in ways that would make it invisible to a garbage collector. For example, in a xor linked list:


You don’t even need a compiler for this. https://en.m.wikipedia.org/wiki/Boehm_garbage_collector

I know about that one but can I compile mysql, httpd and all its dependencies with it enabled? I don't care if it is 100x slow.

sure. free() just becomes a noop. But probably they'll leak a bunch because conservative gc is kinda bad, doubly so in code that isn't made for it.

(it's really a little more complicated than that in codebases, like mysql, that probably manage their own allocation and actually care about page level stuff)

I think this is asking the wrong question

Why bother with this?

another rust hype article. with all that, readers of likes of hn, certainly would have a skewed view of industry.

HN is not a historical archive, much less one of how used programming languages are. Rust is interesting to a lot of people because it's fundamentally different in a few aspects than most other languages, and that difference also happens to coincide with some people's complaints about how hard it is to program safe systems.

I'm not really sure what you're expecting. Haskell gets a vastly disproportionate amount of time here compared to it's actual usage also, and PHP gets almost no coverage at all, but we all know it's out there in force, and so are the people that program it. Should we be pushing for a lot more PHP content? What about COBOL content? That's still in use, and I can't remember the last time I saw a submission about that.

Your comment isn't useful. Anything that ever becomes something was at one point nothing. Rust gets attention because it's doing new things. Important new things.


www.paulgraham.com/pypar.html In Python Paradox, the author argues that it's a signal of quality that someone would take the time/effort to learn Python. (Python is new and wouldn't land them a job).

Now in 2019, Python is popular. But I think it's fair to say instead that Rust wouldn't be a good choice if you wanted to get a job using a language which is popular in the industry.

From my experience people learning Rust are not people who are learning a language to get a job. They are usually experienced developers with jobs who know at least couple of languages, and learn Rust to expand their toolbox.

I'm learning Rust because:

1. I want to add a low(er) level language to the ones I already know and use.

2. Though I did some C/C++ in high school, getting really into depth with C++ at the moment seems really daunting.

3. I don't need it for a job at this point so I can afford to learn a less popular language that can potentially have a future and which exposes you to new ways of thinking about code.

How common is it these days to hire for languages, anyway?

In my case with the devs I hire the only thing I care is that they want to work in a class of languages, like frontend or backend, and that they're not super picky.

I'm hiring people to solve problems for a living. I have full confidence that anyone I hire can learn any language I throw at them. My job (when hiring) is to make sure they'll want to work in the area, maybe a footnote about the language (if even known), but that's all.

Why does language matter so much to some people (as far as hiring goes).

It would be if you wanted to get a job with people who value developer ergonomics, though.

Notably, PingCAP is a company, in industry, deploying Rust at scale, and basing this information off of said deployment.

This is a peculiar comment. Why would you think readers are seeking a balanced 'view of the industry' here? HN is much less bland than that. The guidelines have a view on what's relevant content here: If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity (https://news.ycombinator.com/newsguidelines.html).

Do you have some particular animus against Rust, or do you think it's some sort of general rule that developers should learn only the 'top 5' 'industry' languages?

I've started learning Rust, for a few reasons:

- I read a couple of chapters of Steve Klabnik and Carol Nichols' excellent "The Rust Programming Language" a while back and enjoyed it so much just as a book that I promised myself I'd read the whole thing when I had time. Now I do, so I am.

- Rust instantiates some concepts that I'm familiar with but only at a vague hand-wavy level. Learning it is educational (for me).

- Rust is used in some open-source projects I'd like to contribute to if I can.

- I have a couple of personal project ideas in disparate areas (wasm, embedded) that Rust seems well suited for

It's quite likely I'll never use Rust in a job. So what?

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact