News for hackers. Stuff that matters.
Re:Death to C by gregjor on Saturday May 02, 2015 @10:01AM (#9477054)
Well, there's Go.

Java was supposed to fix all of these problems, but it's a mess in its own way. There's no perfect language.

Almost simultaneously with C the Pascal language was introduced, completely safe and easier to learn. It enjoyed a period of popularity, and for a while it was widely taught in high schools and universities. Some big systems were built in Pascal, but every big Pascal app I've ever seen relied on external code in C (or assembly language) because Pascal is hobbled to enforce safety (see Brian Kernighan's article "Why Pascal Is Not My Favorite Programming Language, http://www.lysator.liu.se/c/bwk-on-pascal.html). Some of Pascal's faults were fixed in Modula and Oberon but those never got any traction.

To be absolutely safe the language is either crippled so it's missing important features, or it requires a runtime to sandbox everything, check pointer references, do garbage collection, etc. And that slows things down.

I don't see C going away any time soon in embedded software, which is where bugs and vulnerabilities can be most dangerous and where they are hardest to fix. It's not much of a disaster for a video game to crash, but it can be very bad if piece of hospital hardware or a flight control system has a latent bug.

There are tools that can analyze C code both statically and dynamically -- the language is not just old, it's mature.

I'm sure someone is already rewriting the Linux kernel and all of the Unix-y tools in Rust or Go or whatever. I won't hold my breath.

Re:Death to C by coldtea on Saturday May 02, 2015 @10:09AM (#9477087)
>Well, there's Go.

Not for the things C is good for. OS work, drivers, common libs like OpenSSL callable from other apps, infrastructure work, etc.

Besides Go is nothing new. There have been similar languages ever since 1970, and they are not replacing C.

Re:Death to C by __Joker on Saturday May 02, 2015 @10:19AM (#9477137)
Agree, better shout out would be Rust. Also referring the complete interview[1] which the TC article quotes, which seems to be favouring Rust.

[1]. https://www.codementor.io/rust/tutorial/steve-klabnik-rust-v...

Re:Death to C by steveklabnik on Saturday May 02, 2015 @10:25AM (#9477167)
Two things: First, I'm on the core team, so I obviously have bias. I try to remain as objective as possible at these things, but still. Second, that interview was from October. Not a lot has changed, really, but it is an eternity in Rust-time.
Re:Death to C by akulbe on Saturday May 02, 2015 @11:41AM (#9477443)
Question for you, sir. When folks like you and the rest of the team set about making a new programming language, is it ever with the new programmer in mind? Or is your primary purpose to fix a shortcoming in another language, and as such, you're not really thinking of the beginners?

The reason I ask is because I went to look at the docs for Rust, and they still seem incomplete.

As someone on the outside looking in... I'd have a hard time recommending Rust over C, because the learning path isn't complete yet. C is extremely well-documented. I want to learn Rust, because it's the new hotness, but it seems difficult to do right now.

That said, I'm very curious to hear your thoughts on this.

Also, if you have advice on how best to learn Rust, I'd love to hear what you have to say on that. My professional experience has been almost entirely with scripting languages, and nothing more low-level than that.

Re:Death to C by steveklabnik on Saturday May 02, 2015 @11:46AM (#9477456)
> is it ever with the new programmer in mind?

New programming languages are almost never designed with the new programmer in mind. I've spent a _lot_ of time teaching people to program, and they all have really serious hurdles. There are some good projects in this space, but they're a very, very tiny minority. Don't underestimate how hard "Hello world" is, which is actually something that that PDF I linked points out.

> they still seem incomplete.

Can you elaborate on this, with specifics? It'd be really helpful.

Re:Death to C by akulbe on Saturday May 02, 2015 @12:46PM (#9477648)
I created a video with ScreenFlow.

https://www.dropbox.com/s/vuax1ocki846llu/rust_example.mp4?d...

Downloading and installing Rust, no problem. Then I tried doing the "Hello, World!" example. Pretty sure I had it typed right in vim. It didn't work.

Then, I typed it in Sublime Text, it still didn't work. Then I thought, I forgot to set +x on the file, and I remember I hadn't set anything on the shebang line in the file, so I went on in the docs.

As you can see... I got to the "Learn Rust" page, and it wasn't ready yet.

Re:Death to C by steveklabnik on Saturday May 02, 2015 @12:57PM (#9477690)
Thanks for making this! It was _very_ instructive.

First of all, I submitted a patch to remove that link to the old intro this morning, so that should go away.

Second, the issue was that you compiled the program, which worked just fine, but you never ran it! on http://doc.rust-lang.org/nightly/book/hello-world.html , the example shows:

    $ rustc main.rs
    $ ./main # or main.exe on Windows
    Hello, world!
You did the rustc, but not the ./!

As for "Learn Rust", that's one of two paths through the documentation, as the first page of the book mentions. I've been focused on the "Syntax and Semantics" section, which is the other path. "Learn Rust" is coming over the next two weeks.

Re:Death to C by akulbe on Saturday May 02, 2015 @01:08PM (#9477729)
Now I see that there was an "hw" file, now. I ran it and got the desired results. Should have paid better attention.

Hopefully, the instruction was more than, "Wow, this guy is a bonehead." :D

I think some mindset changes are needed here, in that I'm used to dealing with interpreted languages, rather than compiled ones.

Re:Death to C by steveklabnik on Saturday May 02, 2015 @01:14PM (#9477751)
It's all good! Seriously, I've taught tons of people to program, and the beginning is the hardest part.

Yeah, the two-step process is different. In the next setup section, when Cargo is introduced, you end up with a 'cargo run' command that does the build and runs your code in one step.

Re:Death to C by GolDDranks on Saturday May 02, 2015 @10:17AM (#9477126)
There's already some toy OSes written in Rust: http://scialex.github.io/reenix.pdf

I think Rust IS able to replace C, precisely for the same reason why Java and Go fail to do that: they have runtimes and they are garbage-collected. That means that you can't easily write a library in Java or Go and then call into that from another language without complicated interop and overhead. You can't write low-level code without headaches. Et cetera. Rust doesn't have a runtime, so it's like safe C++, for that matter.

Re:Death to C by lloeki on Saturday May 02, 2015 @10:32AM (#9477193)
> they have runtimes

Go has as much a runtime as C or C++ [0].

[0]: http://en.wikipedia.org/wiki/Crt0

Re:Death to C by dbaupp on Saturday May 02, 2015 @11:04AM (#9477323)
I don't think that's really true? Certainly Go has a much weighter runtime than those. Neither C nor C++ implicitly insert context switches into the runtime into the generated code, nor do they have garbage collectors that scan the processes memory.
Re:Death to C by yoklov on Saturday May 02, 2015 @11:01AM (#9477307)
My understanding is you typically bootstrap the runtime for C/C++ when you write an OS. This is a significantly larger task for Go, to the point where I'd say it's probably infeasible (Is it possible to write the Go runtime in Go? Even the GC?).
Re:Death to C by agumonkey on Saturday May 02, 2015 @10:24AM (#9477164)
> There's no perfect language.

Reminds me of cultures. Differences between groups times themselves over the years and will mostly diverge from each others (not necessarily).

Each linguistic specificity will lead to different idioms, libraries and landscape; also fitting to different domains.

Some times, Lisps or algebra-based FP (in my inexperienced eyes it could lead to safier code too) makes me think there a way to reunite all this under the same roof though.

ps: I agree with your post. Maybe language matters to a certain extent only; good system design is language agnostic.

Re:Death to C by Dewie3 on Saturday May 02, 2015 @10:32AM (#9477194)
> There's no perfect language.

> I'm sure someone is already rewriting the Linux kernel and all of the Unix-y tools in Rust or Go or whatever. I won't hold my breath.

You're right, man. Nothing is perfect and we can't start with a blank slate so we might as well give up.

http://en.wikipedia.org/wiki/Nirvana_fallacy#Perfect_solutio...

Re:Death to C by gregjor on Saturday May 02, 2015 @10:56AM (#9477285)
Thanks for the link, and here's one for you: http://www.merriam-webster.com/dictionary/condescension

I neither believe nor wrote that if we can't start with a blank slate we might as well give up. Since I specialize in working with legacy code that's actually pretty much the opposite of what I do.

What I meant by "I won't hold my breath" is that C has an enormous lead in maturity, programmers, and installed software base. Displacing it because a writer at TechCrunch thinks C sucks and Rust is better is a different kind of fallacy. I'd be happy to see a safer language that didn't sacrifice expressive power, performance, and memory footprint. Many, many candidates have been floated since C made its debut, so either they have all been found wanting, or the obstacles to moving beyond C are bigger than just inventing a safer language. That was my point.

Re:Death to C by Dewie3 on Saturday May 02, 2015 @01:59PM (#9477911)
I'll agree that the sentiment "death to C" is hyperbolic and unrealistic. A very, very long term phasing out is more realistic. :)