How high level is rust?

Hi people, I'm new to rust and am curious about how high level is rust compared to another languages. I have a list of what languages to compare and I wanna know where you would classify rust among them.
The languages are: C, C++, Objective-C, D, Go, Swift, Pascal, Fortran, BASIC, Cobol, C#, Forth and Java.

When I talk about low and high level language I'm referring to how much control the language gives to the hardware and what has more abstraction levels.

1 Like

Not to be dismissive, but this is pretty well traveled ground - have you tried googling for this? :slight_smile: You’ll get lots of material on this.

Well, rust can technically go as low as assembly, but the beauty of it is the fact it can provide high level abstractions like the ones found in C# (Unfortunately I only have previous experience in C# before coming to Rust), and some from Swift, while still providing the same speed and low-latency of C++. It can also run code similar in control to C or C++ with the unsafe keyword. Its biggest selling point in my opinion is the reference checker -- something that can give the same power as a GC as in languages with a GC without the overhead or complications of a GC.

3 Likes

Rust is weird in that regard — it's both high level and low level.

Half of the time it feels very high-level, like Python or JavaScript. Type inference makes types invisible, memory is managed automatically, and you have closures, iterators and standard library for strings and containers.

But it doesn't hide low-level parts, so you get stack vs heap distinction, machine-sized integers with manual conversion, and ugly bits sticking out like #[no_mangle].

3 Likes

IMO it's the best of both worlds (high level / scripting languages vs low level / system languages), but with a knowledge cost attached that's typical for system languages e.g. you need to know about the call stack and the heap, something you generally don't need to care about when using e.g. Python or Java.

For those who are able and willing to pay that cost, I've yet to see a project where rust would be a catastrophic choice.

Drop everything with a garbage collector from that list. One can emulate a GC language from within a non-GC language, but it's impossible to emulate a non-GC language from within a GC language. Which means that GC != non-GC languages.

I find that this paper: https://people.mpi-sws.org/~dreyer/papers/rustbelt/paper.pdf gives valuable insight into the foundations of Rust, particularly the introduction and chap 2 "A tour of Rust".

@bmelo Is the only one who thought to mention languages like Fortran and Pascal. It gives a unique discussion when considering those languages vs Rust.

For instance, some say Rust's scientific computing libraries still suck: Why Rust fails hard at scientific computing - Rust Internals

This would mean that the Fortran community would pull their noses up at Rust at this point in time. Why physicists still use Fortran

1 Like

My comment was mostly to inform @bmelo that they can find plenty of existing discussion around "how high/low level is Rust", in case they wanted to start reading before anyone replied here. I wasn't trying to dissuade any discussion from happening here. And FWIW, I will note that I've not seen anything "new" mentioned here thus far from any of the numerous previous discussions around this topic, on this forum or elsewhere :slight_smile:.

2 Likes

:thinking: I've not seen Pascal vs Rust or Forth vs Rust discussions.

Is a newish question.

Control part is well travelled, abstractions somewhat.

The simplest characterization I have for Rust is that it's a natural evolution of C++, with a clear understanding of its benefits and very good solutions for many of its problems. I also find that it adds a small but well-chosen set of useful language features (such as destructuring bind and the ? operator). I am not even sure about who I should congratulate for this design and I sure hope that it doesn't devolve.

I am not aware of anything as good in the GC languages but if anybody has suggestions I'd like to hear them. I started using Go recently and even though it's a nice improvement from Python, it makes me miss Rust.

Comparison with Fortran is trickier. My understanding is that C never took off in scientific computing mainly because it lacks a good multidimensional array type with user-defined bounds. You can define such a type in C++ but I am not sure that typical compilers could do the proper loop optimizations, at least early on, or that typical programmers trusted that the compilers could do them. Also scientific programmers don't take the C++ learning curve well. (And will not take the Rust curve well either.)

1 Like

I personally view Rust mostly as a Haskell with some C-syntax that gives me more control over space-time.

An article which goes into similarities is: Haskell and Rust.
It is the sequel to Is Rust functional?.

Never say never. People already successfully emulating C/C++ in the subset of Javascript, called asm.js, in production!

To be pedantic, though, asm.js is a compiled language (like C or Rust) which also shares syntax with a language that JavaScript engines (full GC) can execute. By that description, I would compare asm.js more closely with something like cannoli; in neither case is a garbage collector actually present.