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

I was not keen on spending time reading rust syntax specs the moment you said rust is actually c++.


When did I say rust is actually C++? I said its memory allocation model is the same: normally done in containers or smart pointers, but malloc and free are still available under the hood if you really need them.

Many other things about rust are extremely different from C++.


Ok, now I see the semi-colon.

So rust has heavy memory allocation implicit in the syntax (not meant only for the stack). I remember now I did not want that (like those horrible c++ new/delete).

Thx to have refreshed my memory about rust syntax.


There is no syntax that allocates in Rust. This was one of Linus' big reasons for accepting it into Linux.

Functions can call malloc or equivalent, and while constructors don't exist, destructors do, so you can call free in them.


the syntax implicit expensive free is the same issue than the syntax implicit expensive allocation. I clearly recall when I read early rust specs that I did not want that (and more).

Additionally, I wonder if they fixed the other C issues, namely removing integer promotion, implicit casts (but different explicit casts for compile-time and runtime), enum, _generic, typeof, 1 loop keyword is enough, no switch, goto is not harmful, have only sized primitive types, change extern/static... Hopefully, rust does not have object-orientation.

And you can bet, you will find a bunch of sickos not writting simple and core rust for linux... but rust with tons of extensions only in 1 or 2 compilers like the "C" from linux which is actually the C from gcc and nothing else (clang and icc playing catchup).

I should re-read the language syntax specs though. But I guess, I would drop that reading if I encounter a definitive nono again.


> I clearly recall when I read early rust specs

Rust changed drastically before 1.0, so depending on when you read this, it may be 100% irrelevant.

> namely removing integer promotion,

Rust does not do integer promotion.

> implicit casts

Rust does not do implicit casts (often called "coercion")

> enum

Rust's enums can do what C's enums do, but are more powerful by default, you can add arbitrary data to them, not just a synonym for some integers.

> _generic

Rust has a full generic system. Very different than _generic.

> 1 loop keyword is enough

Rust has loop for infinite loops, while, and an iterator-based for loop. There's no do/while.

> no switch

Rust has 'match', which is like a switch but extra powerful, especially when combined with features like enums.

> goto is not harmful

Rust does not have goto. It would be harmful for the kinds of static analysis Rust does. Rust does have named break though, which can do many (but not all) of the things you'd do with goto.

Additionally due to RAII and the way errors work on Rust, you don't need goto for error handling like you would in C.

> have only sized primitive types,

Not 100% sure what you mean by this.

> change extern/static

I don't know what this means.

> Hopefully, rust does not have object-orientation.

It depends on what you mean by OOP, but in general, the answer is "no". There's no classes, no inheritance. You can do dynamic dispatch, but it's fairly rare.

> But I guess, I would drop that reading if I encounter a definitive nono again.

Given what you said about destructors, that hasn't changed, so sounds like you'd stop.


It's very unlikely you would ever have to use something like C++'s new/delete in Rust unless you are doing something like re-implementing the Vec class.


In c++, it is not only with new/delete, heavy allocations do happen implicitely everywhere. Now, I recall I did not want that.

thx anyway.




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

Search: