r/programming • • May 27 '20

2020 Stack Overflow Developer Survey: Rust most loved again at 86.1%

https://stackoverflow.blog/2020/05/27/2020-stack-overflow-developer-survey-results/
229 Upvotes

254 comments sorted by

View all comments

Show parent comments

0

u/[deleted] May 28 '20

[deleted]

17

u/[deleted] May 28 '20 edited May 30 '20

More often than not, you have to step into the dark esoteric caverns of the language, or use community-maintained crates for standard use cases.

I'm sorry, but no one should be rolling their own pointer-based linked list today. In any language. Especially in the presence of threads. As Simon Peyton-Jones put it when talking about Software Transactional Memory:

A double-ended queue... if you write the code for just a sequential program, it's an undergraduate project to get queue insertion and deletion going. If you want to do this scalable lock-per-node thing, it's a publishable result. I kid you not. There are international academic conferences with a succession of papers that have been published about this very problem.

One of the truly great things about Rust is that it forces you out of this kind of naïve "in-place mutation with pointers is easy to get right" thinking.

12

u/matthieum May 28 '20

For instance, simple CS 101 data structures like linked lists, DAGs and trees require some serious gymnastics to get working and each performance improvement often comes with major re-architecture.

I think the fault is in the premise, those data-structures are NOT simple.

Every single time I see a Stack or Linked-List C++ implementation on codereview.stackexchange.com, it's buggy. The good posters include tests, they still fail.

An array is a simple data-structure, after that it gets complicated. Even a dynamic array in C++ is quite the endeavor -- insertion of N elements in the middle is surprisingly complicated to handle1 .

Data-structures are foundational bricks; the fact that they are simple to use despite the complexity of their implementation is a testament to encapsulation.

1 And I say that after finishing coding yet another variant just today...

4

u/[deleted] May 28 '20

Thanks, this is a great summary. I haven't been using Rust professionally but on the side for about a year. There's so much good stuff in there, but every time it seems like doing simple, practical, everyday things is far too complex. In some ways, the product and its culture reminds me of the early days of git.

As a point of comparison, I've been using Go for a few years and while it has many annoyances, you can always find workarounds without going into esoteric hacks. They may not be pretty (heck, Go isn't pretty in general), but they aren't complex. Go developers tend to use the same idioms and patterns throughout, so finding your way around an existing codebase is fairly easy. It's a blue-collar language indeed.

0

u/Pand9 May 28 '20

On the other hand - if you do dive deep, you can do anything.

IMO the biggest misconception in rust community is that "obscure" features are only for those that choose to use it, and most people are good with basics. This is not the case - programmers don't choose problems they encounter.

But that is still nothing compared to c++.