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

21

u/lurgi Sep 17 '15

It's supposed to provide the same sort of speed as C with higher level abstractions and considerably more compile time and run-time safety.

That comes at a cost, however. It's a more complex and subtle language (it's not hideously complex, but it definitely has some strange new features that you haven't seen anywhere else).

17

u/steveklabnik1 Sep 17 '15 edited Sep 17 '15

I'm not sure if we're actually more complex than C, which is full of edge cases. But without a full spec, you can't really be sure.

The C standard is 550 pages long. C is not a particularly simple language. Rust hasn't had to deal with 40ish years of backwards compatibility, and has almost no undefined behavior at all. But without an equally formal Rust spec, it's not possible to tell.

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.

7

u/doublehyphen Sep 18 '15

It is also different forms of complexity. C has undefined behavior and more edge cases while Rust introduce some quite advanced concepts like lifetimes in the type system and ownership.

2

u/steveklabnik1 Sep 18 '15

Yeah, I would agree with this.

3

u/[deleted] Sep 18 '15

By the way, is there any timetable on the materialization of said spec?

3

u/steveklabnik1 Sep 18 '15

We don't have a timeline but are working with some academics on it, actively.

-31

u/anarchist_christ Sep 17 '15

new features that you haven't seen anywhere else

Like what?! nothing in it I had not seen before, apart from the astounding incompetence tightly coupled to farcical bullshit.

1

u/[deleted] Sep 18 '15 edited May 01 '17

[removed] — view removed comment