Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Sorry, I meant a "close to the hardware" language re parent.


Depending on what you mean exactly I think Rust can be considered pretty close to the hardware. I.e. there's usually an obvious straightforward translation of each line of source code to an implementation in assembly language (which may not be what's actually emitted in practice due to optimizations, but the same is true in C).

There are of course some higher-level features like trait-based generics, so it's not really as close to the machine as C, but it's a lot closer to C IMO than something like Java (or even C++).


Ada, Modula-2 (both available on GCC), D (available on its reference implementation, GCC and LLVM), Swift, Object Pascal (Free Pascal, Delphi, Oxygen), Oberon variants (Oberon, Oberon-2, Oberon-07, Active Oberon, Component Pascal), Zig, Nim, Odin,...



All systems programming languages have undefined behaviour, the golden question is how much.

Also it wasn't what the parent asked for, and I quote: "close to the hardware" language


Rust is not (much?) further from the hardware than C++


C++ is further than rust in my opinion. Vtables that support inheritance, as well as stack unwinding for exceptions, are pretty complicated and totally implicit in C++. Okay rust also technically has unwinding for panics to be fair but it’s rather unusual in practice for programmers to use panics to mean anything other than “crash the program now”.


Like trait implementations, and trait objects.


That’s fair, trait objects do cause a table to be generated, but they don’t support inheritance and subjectively I think they’re used less often than the OOP features of c++ that lead to vtable-based dynamic dispatch. (Traits are extremely common in rust, but dyn trait objects somewhat less so)


Doesn't matter how common, the feature is there, and although we aren't yet that far, might even differ across implementations.

Also trait inheritance exists, enforced via trait bounds, what Rust doesn't support is class inheritance.


> Doesn't matter how common

Yes it does, if your concern is “how often do I encounter code where I can’t predict or control what it actually does on the hardware”.


Any time there is a compiler implementation that has to provide support for translating such features into machine code.




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

Search: