Hacker News new | ask | show | jobs
by ActorNightly 809 days ago
The best way to think of Rust as essentially the new Java, which sort of "won" over C++ due to its more strict syntax with mandatory OOP and code patterns. Rust enhances this by running most of the checks in the compiler so you get native code, with very few runtime additions for type safety.

But just like Java, its almost useless to code in it for personal or smaller projects.

For almost all of my projects where I needed performant code, the way I would do this is write it in C, and then just call the code from Python or Node. Its much easier to just focus on low level performant C code that can be written in usually one file, and then just write all the interface to it through higher level languages, especially for web frameworks.

4 comments

> But just like Java, its almost useless to code in it for personal or smaller projects.

That's entirely the opposite from my experience. Rust is a pleasure to code in for personal projects once you're familiar with the language, especially compared to C/C++. Managing dependencies is more straightforward, and there are a lot of crates out there to make writing your project easier.

You and I must have different ideas of "pleasure to code." The appeal of Computer Science for me is learning how things work at a deeper level, tracking every bit and byte, and pushing performance to its limits. The pleasure is in writing the interesting libraries, not gluing them together. Any technology that restricts me has zero appeal.
It honestly depends on what you work on for your argument.

In general, think about the general use case for all types of development. For example, I have a bunch of finance code. I host it on a Jupyter Lab server in notebooks, so I can run/edit it from anywhere.

If I want something that is fast (which in this case is rare to see outside of using pytorch), I can write a C extension quite easily - the amount of effort that it takes me to set up boilerplate code is the same amount of effort as it takes thinking about Rust memory semantics. The code will be quite isolated from the rest of the system (unless you purposefully try to break Python), and you don't really have to even do dynamic memory if you are trying to do processing. I did this at work with fast json parsing and data extraction, and it was super easy to do.

Then there is the whole ML aspect, which is first and foremost python before anything else. Especially in the whole data sets, with the fact that you can easily generate training data in Python, whereas other languages require a lot of custom code.

Interesting, haven’t heard this viewpoint before of Rust being a drop in replacement for Java. From my limited experience with Rust it felt like the learning curve was way steeper than when I was learning Java for my previous job. Good point on C though, one of my old CS instructors would always call C his swiss army knife since its so small he had practically the entire syntax in his head.
Rust is not a drop in replacement right now in the sense that it does require more learning curve, but for example if colleges switched to teaching everything in Rust, then you would see its use on the same level as Java.
OP never said rust was a drop in replacement for java
I think the notion of that comment is Rust is the new "new C++".
This reads like having no more than passing familiarity, and no real experience with rust.

It (just like so many other languages) is fantastic for personal projects. Especially because you can target cross platform easily and get native performance.

Proclaiming any non-estoteric language is "almost useless to code in for personal or smaller projects" speaks volumes.

> But just like Java, its almost useless to code in it for personal or smaller projects.

I seem to be writing an OS with it just fine.