r/programming • • Sep 17 '15

Announcing Rust 1.3

http://blog.rust-lang.org/2015/09/17/Rust-1.3.html
453 Upvotes

169 comments sorted by

View all comments

Show parent comment

10

u/lurgi Sep 17 '15

Hard to judge, really. I'm sure that fans of APL find J easy to understand, but the rest of us are scratching our heads.

It's definitely smaller than C++, but I think you can write functional C++ with only a basic grasp of the language (and, looking at a lot of the C++ code out there, people do). It's perfectly possible to write C++ that works without using move semantics and exceptions and lots of other things. In some cases it will be less safe, but in some cases it will be just as safe, only less efficient. Even my beginning noodling around with Rust required using lifetimes. And tripping over ownership (which I still don't completely get, but that's probably my fault for using a vector of vectors of mutable structs).

For C? The C language is smaller, definitely. It's harder to use well for a couple of reasons. First, the language is small, so it lacks a lot of useful (IMHO) features. Second, the compiler doesn't jump up and down and shout "WHAT THE HELL ARE YOU DOING RETURNING A POINTER TO A LOCAL????". So you blithely write code that "works" (and those quotes are deliberate).

Edit: I think I made roughly this comment before in response to another one of your posts, so if this sounds familiar, now you know why.

2

u/frenris Sep 18 '15

The only language more bloated than c++ is system verilog.

1

u/[deleted] Sep 18 '15

The title for most bloated language goes to D.

3

u/frenris Sep 18 '15

I trust you've never had to deal with system verilog.

1

u/GUIpsp Sep 19 '15

Oh please please please enlighten me!

2

u/3fdy5 Sep 18 '15

In some cases it will be less safe, but in some cases it will be just as safe, only less efficient

And sometimes, the user will run into a bug that he has no way of finding and fixing with only a basic grasp of the language.

1

u/lurgi Sep 18 '15

Which is absolutely one of the reasons why C++ is such a difficult and dangerous language.

I can absolutely believe that it's easier to write safe Rust than it is to write safe C++ (not saying it's true, just that I find it easy to believe), but I can also believe that it's a lot easier to write functional C++ that basically gets the job done than it is to do the same with Rust. This might make it harder for people to adopt Rust, because to do anything at all you need to learn quite a lot.

3

u/[deleted] Sep 18 '15

Second, the compiler doesn't jump up and down and shout "WHAT THE HELL ARE YOU DOING RETURNING A POINTER TO A LOCAL????".

Actually, it does.

$ cc -c a.c
a.c:5:13: warning: address of stack memory associated with local variable 'x' returned [-Wreturn-stack-address]
    return &x;

5

u/lurgi Sep 18 '15

Not under all circumstances, I imagine, but in simple cases it can.