Why Rust Is the Future
scalac.io
scalac.io
> Rust is simply easier to approach, the learning curve is not very steep
Lol, yeah right.
> One of the biggest issues that are plaguing the developers are memory management issues.
...not an issue in any garbage collected language.
> some areas it may run even three times faster than Scala or Java
Statements like this are almost completely useless. Rust isn't automatically fast, and Java isn't automatically slow.
> it lets you write code that will most likely never go wrong as the compiler is there to check it all
Oh please...
> Rust is a popular programming language for cryptocurrencies and blockchain.
What, no AI?
Rust deserves better promotion than such a fluff piece.
> ...not an issue in any garbage collected language.
I pretty strongly disagree. It’s less of an issue in strongly typed languages but definitely null references and (arguably) type/encoding runtime errors are memory management issues much more common in garage collected languages.
What I love about Haskell (thousands of hours) and to a lesser degree rust (hundreds of hours) over most languages is that they are very expressive while at the same time the compiler catches what feels like 20x as many mistakes as I’d get from python or modern JavaScript.
Then it also runs faster, on a smaller footprint than most other stacks.
Both Haskell (and to a lesser degree) rust are much harder to learn than python/ruby/js but rust is probably on-par with c++ or java.
In fact with the emphasis on (mutable) references vs values; it seems to pretty much encourage the antithesis of functional programming.
What I really love about functional programming is the simplicity of understanding what is going on from looking at the code; functional programming does that by guaranteeing a "function" is always-and-only acting in a specific, simple way. Rust does it (not quite as strictly to my learning-eye) with forcing the tediousness of references/mutability up to the signatures.
Agreed.
It's a comparison with C++, where Rust is generally viewed as easier to learn. So OP has a valid point there.
"DARIA KARASEK Marketing Hero at Scalac. I strongly believe in creating opportunities rather than waiting for them to come. As befits Scalac team member I'm a hard worker, I always try to do the right thing and have a lot of fun! I'm an awesome friend and content writer, in that order. "
I imagine this kind of utter fluff would be entirely ignorable except when it is about Rust.
> Rust vs Python: advantages
> Rust is well-designed. Rust allows for putting statements in a lambda and everything is an expression, so it’s easier to compose particular parts of the language. Python lacks it. Rust doesn’t have classes so the object orientation is not as evolved as it is in Python. Python also comes across with the necessity of writing more tests, production outages, or runtime crashes. Rust makes it less expensive to identify and fix possible bugs.
Those advantages come at a cost, specifically in terseness and readability, which are both _strengths_ of Python. As a result, they're very different tools, and comparing them shows that the author doesn't grasp their relative strengths and how those apply to their typical use cases.
And in tasks like these, I usually don’t even miss having a garbage collector, and rarely need lifetime annotations.
Just in case: I didn't want to imply there are no use cases which overlap, only that in general the use cases for both languages are very different.
I find cargo more productive than Python’s package management, where I have to manually manage environments and requirements.txt files.
Things I like less: less “batteries included”, so I spend more time evaluating libraries and wondering if a github project hasn’t been touched since 2019 because it just works, or because the maintainer got bored. The learning curve is steep at times, and involved being blocked on pleasing the compiler.
And of course, Rust is not a one-size-fits-all language. For starters it doesn't have a garbage collector. But it is type-safe. And that alone will pay a huge dividend down the road if you choose it today.
Having to deal with JSON in Go is a massive pain comparatively. It's just way easier to do it in Node.js. I'm having to do this kind of work right now, where I'm leveraging a third-party API that has horrendous JSON responses and I'm having to convert it to a normalized JSON structure so that I can use it within my own app. I keep wishing I would have just gone with Node.js instead of Go but now I'm too far deep.
By I/O, I meant that basically anything that requires you to wait for a response is really easy in Node.js. In particular handling HTTP requests is dead simple.
My point being that I'll pick different tools for different jobs. Go is really nice when I have little control over the environment and architecture, such as with AWS Lambda. The ability to compile a binary specifically for that architecture without needing to deal with `node-gyp` in Node.js is attractive to me. But I'll weigh the pros and cons of going with each of these different tools that I'm comfortable with.
That means that you are looking at a few dimensions when determining what language to solve problems:
* can it solve the problem
* can I use it to solve the problem
* am I creating an issue by using it (for the team short term, for the company long term)
* how does using it make me a better developer
You don't need to think about this every time you write code, but when you are considering investing time learning or using a new language, it behooves you to look at the larger picture as well as the immediate situation.Rust is going to eat into Java, C#, and Golang marketshare for services soon. The tooling for writing these is fantastic, and there's a single deployable binary with no GC.
async on Rust is a pain in the ass. For your hot path, sure use Rust, otherwise no one cares about a GC language as long as it's productive and can get the job done faster.
I've got actix handlers with various async database workloads, singleton LRU reloading caches, service calls, etc. It's a breeze. I'm no more productive in Java.
Rust allows for putting statements in a lambda and everything is an expression,
so it’s easier to compose particular parts of the language. Python lacks it.
Rust doesn’t have classes so the object orientation is not as evolved as it is
in Python. Python also comes across with the necessity of writing more tests,
production outages, or runtime crashes. Rust makes it less expensive to identify
and fix possible bugs.
This person is unfamiliar with both Python and RustI think the second point about classes/object orientation is... odd. I think they might not understand traits? Which is a pretty big thing to miss out on in a comparison like this.
The point about tests is probably to do with Rust having static checks (type-checking, borrow-checking, etc.) versus Python not having these. And although you can do some static checks in Python with external tools like mypy, the type system is less expressive and easier to coerce than Rust's, so I do think you'll end up with more tests out of necessity.
This made me literally laugh out loud.
This is not to rant on Rust, but betting on it having a brighter future than any of the other languages that came and went during the past two decades is probably a risky bet. Of course we’re lucky enough to be in a line of work where you can probably work with Rust for the next 50 years if you want to, but to “hype” it as the future language is just too silly and too vague for the front page of HN in my opinion.
I mean, Ruby was future, then Go was the future, now Rust is the future (add any other hyped languages you want, and here we are programming in JavaScript, Python, C++, JAVA, COBOL, PHP, C# and other “boring” languages that are probably older than some of the people who read HN, and that just isn’t likely to change much is it?
This is pretty much what killed me on it, and I think the leadership and community really don't understand that commodity development is important to language growth.
I like Rust and it opens up some interesting domains I don't get to play with much, but it's a considerable effort to learn it when I know there are zero real opportunities to use it professionally. I keep hearing hype about how this or that big giant company is using it, but none of them are hiring for it: it seems quite a few are just shifting internal C/C++ teams to Rust. The rare public openings are either a) demand extremely senior C/C++ level dev experience, or b) vague crypto/blockchain startups that reek of fly-by-night scams.
Far from the hope of "democratizing" systems programming, it seems like the industry has instead closed ranks around it and used it as a further gatekeeping tool to keep out entry or even journeyman level experience, and certainly anyone not already bathed in the old C languages.
I thought Rust was supposed to free us from C?
I can't remember who said this, but "use boring technology" is a well used strategy. Why take the risk with a new programming language when they old ones are well understood and offer a large hiring pool?
I won't be taking the time to learn rust until the jobs are there for them. It's a chicken and egg problem I know.
Any language I choose to use today has to have sum types and protection from null pointer errors, anything else is just not acceptable.
After over a year of Rust, writing a client for a virtual world, I'm moderately happy with it. But not uncritical.
- The safety system is quite good. I haven't had to use a debugger on my own code. The one time I needed a debugger, the problem was unsafe code in a library I was using.
- Some kinds of data structures are difficult in Rust. Rust tries to be a functional language, sort of, in that it favors move semantics. If your problem really does involve complex in-memory state (I have a big 3D world to manage) there are substantial pain points. The lack of back pointers is a big problem. It's possible to work around this with reference-counted forward pointers and weak reference-counted back pointers. But the borrow checker doesn't help with that, and you can fail on double-borrow or double-lock situations at run time. When that occurs, it usually means a sizable redesign is needed. What's needed is single ownership with safe back pointers and compile time checking. This is a tough theoretical problem, because you have to prevent double mutable borrows by static analysis, but some people are thinking about it.
- When you've painted yourself into a corner in data structure design, it's often tempting to use "unsafe" to get out. I see too much of that in libraries. I don't use "unsafe" at all in my own code, and now and then I have to go and rewrite something to avoid it.
- Rust is overkill for many applications. Especially web services. For most web back-end stuff, Go is easier. Go also has all the libraries for web back-end stuff, mostly written and used by Google. So they're well-exercised and debugged. Also, goroutines, which are lightweight but preeemptable, avoid the problems of "async", where you have to be very careful about not being compute-bound for too long.
- After a lot of churn in the early years, error handling seems to have settled down to something reasonable.
- The "async everywhere" crowd needs to be restrained from making "async" mandatory in libraries. Their model is mostly applicable to web back-end systems where a large number of slow concurrent sessions have to be handled, those sessions don't interact with each other much, and there's not too much compute-bound work. Not everything is web back end.
You know what else is lightweight and preemptable? Threads. Yes, really. Unless you're on weird platforms like Windows, you can just use threads.
> making "async" mandatory in libraries
AIUI, Rust includes a simple `block_on()` feature so that you can use any async library in a sync context. The old "function color" issue is greatly mitigated in Rust.
Aside from that, I don’t believe Rust is the future. Rust is not the language for prototyping and iterating quickly. I’ve been writing Rust for 1.5 years now, and I still deal with a lot of issues wrestling with the compiler and borrow checker and dealing with lifetimes.
That article comparing Rust to Java - that Rust being simply faster - that somehow making it the future - this is laughable. Not every piece of code is trying to optimize for speed. And a decent chunk of code many people write doesn’t require advanced C++ knowledge. It’s actually faster to learn C++ IMO than Rust for these use cases.
I do enjoy writing Rust. The IDE support has gotten much better. The documentation is “good”. There are really good libraries too.. which is super critical imo.
But saying Rust is the “future” and comparing it to Python or Java is funny.
I tried writing a linked list in Rust and my first thought was “wtf”.
You might think so, but that would be overlooking one key advantage of using Rust for iterative prototyping: you don't have to worry about a hacked-together prototype being used in production! Stuff like that happens all the time, and relying on a language like Rust with its focus on safe refactoring can be a life-saver.
Also this article seems to just be pandering and rehashing common thoughts already. Like yeah its safe and no gc. We know this? I guess its weird timing how did this end up in the #1 spot.
Id like to hear more rational, neutral, non-biased thoughts about rust and its use. I know they're out there, Ive heard these kinds of opinions about rust in real life conversations, I dont think they're out their blogging, if they are idk especially critical things are being put out there. Rust users still seem to really evangelize it
However, the elephant in the room is Rust's sheer complexity.
I will give you my anecdotal experience ...
About two years ago, I was getting tired of shell scripts. Not because I didn't know how to write them properly, but because it was always invariably a messy kludge of fixes and hacks strung together in a safe(ish) manner.
Python, the cool-kid of the day was ruled out. Both for personal reasons (I think the space-sentsive nature of Python is dumb), and for practical reasons (dependencies in python is a mess).
So it was between Go and Rust. Both of which could compile into cross-platform dependency-free binaries for ease of distribution around infrastructure.
As it happens, I had a Real World (TM) project, and so what better opportunity than to hack together some spaghetti code for a proof of concept.
My first call was Rust. I wanted to like Rust, I really did. But I found it simply impenetrable as a language, hard to make progress, even in "spaghetti" mode. "The book" was well written, but it was hard to translate it into "real world". I also disliked the "everything is a dependency" and really felt a lot more should be included in "core".
I then went to Go. With Go, I found an approachable language with a more substancial "core" library. The tooling was good (even better with GoLand IDE). And I was able to hack together a not insubstancial "spaghetti" project in less than a week, which then encouraged me to start learning how to tidy it up into something more professional looking.
Yes, Go is not perfect, e.g. I particularly dislike the repetitive and verbose error handling ("if err !=nil") and can't help feeling there could be a "better way". But now I've done a number of projects with it, using all sorts of complexities such as cloud and crypto, I feel Go's benefits outweigh any minor disadvantages.
You can use pyinstaller or Nutika for python. I've used pyinstaller but I'm not sure of the cross platform part of pyinstaller. I have not tried Nutika out (hopefully soon). Pyinstaller creates a binary with the python executable in it. Nutika compiles to native binary code. Either way you have a single file to deploy and run.
However if you are planning to program as a career and building software is your trade, Rust is an excellent choice. Rust helps you build programs that are correct. Go lets people that expect languages should be able to be learned in an afternoon program.
Saying that Rust is better than Python because "Rust is well designed" is a bit of a fallacy.
Specially since these are languages that serve very different purposes and have different priorities.
> It’s now used to create web software, embedded computers, and distributed services or the command line.
What does this phrase want to tell us? "Web Software"? Do they mean Firefox? Or web development (which is not the main strength of Rust AFAIK, so it's strange to mention it first)? And it gets even stranger: create embedded computers - just with a programming language? Create [...] the command line? Whaaaaaat?
There is not a single popular game that shipped any Rust code. Actually I would extend that to "any" game.
> Rust is well-designed.
I was just reading Fluent Python 2ed[1] and pondering what a zany grab-bag of features we have in Guido's Folly.
[1] https://www.amazon.com/Fluent-Python-Concise-Effective-Progr...
> Rust vs Go: advantages
> Go lacks expressiveness. Rust has a flexible and expressive system that allows for defining new container types that can hold different types of elements, generics, traits, algebraic data types. Go gives you less control over both resources and memory.
1. It is hard to learn. A novice will pick up something like Python much faster
2. It is less productive. You “fight” the borrow checker in Rust and have long compilation times.