News for hackers. Stuff that matters.
Re:Rust vs C Pitfalls by groovy2shoes on Tuesday December 27, 2016 @07:56PM (#13267632)
C has also been relatively stable for the last 25 years or so. Rust changes every 6 weeks.

Yes, the language is supposedly not undergoing breaking changes without strict deprecation and feature-gating. However, as new features are added to the language, libraries are usually updated to leverage them, and suddenly you are also forced to keep up with that rapid release cadence to ensure your project still builds.

Meanwhile, C code from the mid-80s still compiles with modern compilers, often without any changes whatsoever, and without any feature gates.

Don't get me wrong. I like Rust and what the project is trying to do. But I see two major problems that are preventing me from using it for anything major at the moment: 1) the extremely rapid rate of change, and 2) difficulty of implementation (both of which, taken together, lead me to expect no serious alternative implementations any time soon).

Before I will be willing to adopt Rust as a C replacement in full, there needs to be a solid, stable language definition that compiler writers can target and programmers can rely on for a good chunk of time. I have a feeling we'll get there eventually once the number of new, useful features that are missing from the language starts to dwindle and it begins to stabilize naturally.

In the meantime, I'd settle for an "LTS" release or something. That could work.

Re:Rust vs C Pitfalls by tatterdemalion on Tuesday December 27, 2016 @10:47PM (#13268292)
I don't understand. Rust 1.0 code will compile on Rust 1.14, in the same way that C code from the 80s will compile on modern C compilers. That's what "backwards compatible" means!

Your dependencies don't upgrade themselves. Its true that if you upgrade your dependencies, they may depend on a more recent verison of rustc, in which case you need to upgrade rustc as a part of upgrading that dependency. But if you are using rustup this is not harder than upgrading those dependencies - probably easier in fact.

In exchange for downloading a tarball at most every six weeks, you get a language that is developing new features.

Re:Rust vs C Pitfalls by mmstick on Wednesday December 28, 2016 @01:46AM (#13268890)
The problem with your concept is that C does not offer an official standard library and compiler suite, so you're trying to compare the C spec to the Rust standard library + compiler.

The actual Rust API has changed very little since the 1.0 release. All the changes that have occurred have been mere additions to the language -- nothing breaking. Hence why the 1.0 release was termed as a 1.0 release. There won't be anything happening that causes breakage until a 2.0 release.

You'll find that C compiler and library development is also rapid like Rust. There's new versions of LLVM/Clang and GCC being released on a regular basis. There are constant updates to musl and glibc. These changes tend to break far more often than Rust, which is developed in Rust and can be guaranteed to be much safer.

That Rust is being openly developed on GitHub with a significant number of developers, with an official compiler + library + doc + comprehensive suite of resources collectively being maintained, that's a significant incentive to work with Rust. There's a solid RFC process to prevent anything silly from entering the language. No random decisions by random people -- it takes a lot of convincing to add a new feature to Rust.

Re:Rust vs C Pitfalls by groovy2shoes on Wednesday December 28, 2016 @06:10AM (#13269807)
C does have a standard library. It's described in full in the ANSI/ISO/IEC standard for the C programming language, and it's on your system, likely called libc or something along those lines.

Anyway, I don't think that's a problem with my concept at all. What I want for Rust, and what I think will eventually be feasible for Rust as the language matures, is a standard that can be shared by compiler writers and Rust programmers. A standard is worthless if it's inadequate (see ISO Pascal or ISO Basic, for example), so it's a good thing that right now Rust is iterating quickly and improving rapidly. But eventually, there's going to need to be a stationary target for compiler writers to aim for, and for Rust programmers to be confident that the code they write today won't be littered with deprecated features, anti-patterns, and worst practices tomorrow.

Frankly, I don't see wide adoption happening in the corporate world until there's an LTS compiler at the very least.

Re:Rust vs C Pitfalls by mmstick on Wednesday December 28, 2016 @02:13PM (#13272811)
> C does have a standard library. It's described in full in the ANSI/ISO/IEC standard for the C programming language, and it's on your system, likely called libc or something along those lines.

What you're describing is the spec and not the implementation. An implementation would be glibc (GNU Libc with open source proprietary extensions) and musl (MIT implementation that strictly adheres to spec). These libraries are updated often.

Meanwhile, Rust offers more than just a specification. It offers an implementation. This is libcore-rust + libstd-rust. This is what receives updates each 6 weeks. It also offers a compiler that comes with it, rustc, which is also what receives updates each 6 weeks.

Rust strictly adheres to semantic versioning, so changes to the API are not allowed without a major version bump. Code that was written for Rust 1.0 will still compile on Rust 1.15. Code written for Rust 1.15 may not compile for a Rust 1.0 compiler though because bumping the second version implies adding new features. Rust doesn't yet utilize a patch version though. There's never been any critical issues discovered in each stable release.

> Frankly, I don't see wide adoption happening in the corporate world until there's an LTS compiler at the very least.

Can't say that I understand why a LTS compiler would be required for adoption. Many in the corporate world are already using Rust, either publicly as an official friend of Rust or privately in smaller projects. There's nothing a LTS compiler would provide that would be beneficial to the corporate world. Semantic versioning and the ease of managing Rust toolchains with rustup has everything pretty well covered.

Re:Rust vs C Pitfalls by groovy2shoes on Sunday January 01, 2017 @01:31AM (#13294905)
I can only attest to my own experiences at various corporations, and those corporations want to thoroughly vet any software platform before targeting it and supporting it for customers.

As to my own concerns (rather than corporate concerns), here's where I'm coming from:

When I wind up choosing C for a particular project, I don't use it because I like it (I don't particularly like C). Typically, I use it because there are three factors I've considered: 1) This particular project needs the low-level access or performance characteristics provided by a systems language, and 2) C is such a language, 3) C is ubiquitous.[1]

The thing is, every platform for the last 25 years or so has had a reliable ANSI C compiler. If the goal of my project is to be cross-platform, then a carefully-written application in standard C is guaranteed to be able to reach the widest number of users, many of whom won't have to do or install anything to build my application, since many environments already include a C compiler without any additional installation necessary (think Unix, BSD, a shrinking number of Linux distros, ...). Using C puts my application on the path of least resistance for potential users.

Similarly, if I'm writing a library, every language with an FFI can trivially access a library written in C. Even without an FFI, most languages can interface with C code through some kind of bindings (like the Lua-C API, for example). Again, choosing C is a path to wide adoption.

Again, I don't particularly like C as a language. However, right now, it has an undeniable advantage as a platform. I do like Rust, however, and I would love to see Rust give C the boot. In order to do that, it needs to eventually (one day when the rate of additions/changes to the language has slowed and it has grown more stable/mature) offer a platform that can be relied on to "just work" on any given platform with minimal fuss and without any sudden changes. As such, both the "end-programmer" and the compiler-writer in me would like to see some version of Rust (again, eventually) that is "set in stone" and widely available, which really would solidify that notion of stability/maturity.

I'm not advocating for Rust to stop innovating. For all I care, the "standard" can be a simple snapshot of some state of the language, the way the Haskell Reports seem to be nowadays: GHC keeps on iterating and innovating the language, yet there's still a standard updated every x years that provides a static target. But for that designated snapshot, I want to see a compiler (or two, or several) and a bunch of libraries that are supported for the long haul.

It's simply a matter of "C has this, it's an important property thereof, and any replacement will need it, too".

[1]: Some other projects demand C because they constitute contributions or extensions of other projects that are already written in C; e.g., kernel code for an existing OS that is written in C.

Re:Rust vs C Pitfalls by blub on Wednesday December 28, 2016 @07:06AM (#13269995)
When Rust (or Swift or golang) gets ISO standardized we'll know that it's mature and left the "move fast and break things" phase. This won't happen, because it's still growing now, so it doesn't make sense to standardize. They might even always want to be able to move fast. I don't see golang ever being standardized.

The fact that someone says on HN "we're backwards compatible" doesn't quite offer the same level of trust as an ISO standard. Especially when there are some conflicting reports out there i.e. there are many super-awesome libraries that only work with nightly (I think it's called), because many of those maintainers are early adopters that love to try out new features.

Programming languages and libraries are building blocks, I don't want them to change under me in the middle of a project. This is why I dropped Swift, the 1.0 -> 2.0 migration was a very painful, and from what I hear recent major version changes aren't running smooth either.

Re:Rust vs C Pitfalls by tatterdemalion on Wednesday December 28, 2016 @12:35PM (#13272069)
> Especially when there are some conflicting reports out there i.e. there are many super-awesome libraries that only work with nightly (I think it's called), because many of those maintainers are early adopters that love to try out new features.

This is totally orthogonal to whether or not Rust stable is backward compatible, which it is. People put a lot of work into making sure it is, and this sort of FUD is very frustrating to read.

Re:Rust vs C Pitfalls by mmstick on Wednesday December 28, 2016 @02:18PM (#13272850)
> The fact that someone says on HN "we're backwards compatible" doesn't quite offer the same level of trust as an ISO standard.

Then you shouldn't take the word of a random person but from the Semantic Versioning guidelines. If you're not following the semantic versioning guidelines then you're doing it wrong.

http://semver.org/

> Especially when there are some conflicting reports out there i.e. there are many super-awesome libraries that only work with nightly (I think it's called), because many of those maintainers are early adopters that love to try out new features.

Totally irrelevant. Very few libraries, if any, require a nightly compiler. The libraries that do offer features that require a nightly compiler have those features as optional. Anyway, once the new Macros update releases, the need for that nightly compiler will go away. These libraries are just taking advantage of compiler plugins.

Re:Rust vs C Pitfalls by steveklabnik on Tuesday December 27, 2016 @07:59PM (#13267646)
There's at least two alternate compilers I know of in the works. We'll see when they're in a workable state, or at least, enough to compile rustc.

> In the meantime, I'd settle for an "LTS" release or something. That could work.

This is something we've discussed. I imagine it will happen. At first, I would expect six month LTSes, then longer ones as time goes on.

Re:Rust vs C Pitfalls by groovy2shoes on Wednesday December 28, 2016 @05:11AM (#13269615)
I could definitely live with such a solution, but even six months might be too quick. So, as long as the plan is to lengthen the LTS window, I think that could work.

The company that employs me just upgraded to a C++11-capable version of GCC three months ago. Even C++'s three year cadence seems like it might be too fast! Thing is, the company wants to vet our entire platform, which itself only changes yearly. They want to know they can get bug fixes, and vetting/upgrading the compiler is a lot of work regardless, so they tend to do one and stick with it for a while. OpenBSD does the same thing for security reasons. If Rust wants to replace C and/or C++, these are things that will need consideration eventually. I don't see my company allowing Rust any time soon, unfortunately.

As a compiler-writer, I'm more concerned that Rust is a quickly-moving target at the moment. I think that as Rust becomes more mature, it will naturally begin to stabilize feature-wise, in which case something akin to the Haskell model would work well, with innovation happening in the flagship compiler and "snapshots" of the language being taken as standards periodically. That's just a matter of time, though.

Re:Rust vs C Pitfalls by blub on Wednesday December 28, 2016 @07:14AM (#13270015)
Completely agree, C++'s three year cadence is probably the fastest more conservative industries are willing to go.

And why should one invest time for such a low-level component in their toolkit every 6 months?! I want to build software and solve problems, not spend my time keeping up with programming languages and library updates.

Re:Rust vs C Pitfalls by tatterdemalion on Wednesday December 28, 2016 @12:44PM (#13272126)
I have upgraded Rust every six weeks. I run `rustup update stable` and wait a minute. Its not a time investment! Rust puts so much work into guaranteeing backwards compatibility so that updating every 6 weeks is an effortless process.

You seem to come from an experience where software updates are kinda sorta mostly backwards compatible. Rust works very hard to actually be backwards compatible. There is infrastructure to check for regressions across the entire package ecosystem, which is run regularly on HEAD and on any commit we think might potentially be breaking before we even land it.

Re:Rust vs C Pitfalls by naasking on Wednesday December 28, 2016 @01:03AM (#13268756)
> Meanwhile, C code from the mid-80s still compiles with modern compilers, often without any changes whatsoever, and without any feature gates.

You say that like it's a good thing that with C, you can ignore 30 years of progress in software development. Colour me unconvinced.

Re:Rust vs C Pitfalls by grzm on Wednesday December 28, 2016 @01:11AM (#13268775)
If the software does what you want, being able to run on 30 years worth of hardware with just a recompile is a good thing. At the end of the day, it's what the software does that's important.
Re:Rust vs C Pitfalls by naasking on Wednesday December 28, 2016 @01:22AM (#13268812)
> If the software does what you want, being able to run on 30 years worth of hardware with just a recompile is a good thing

That's not a responsible metric. 30 year old software was written against 30 year old APIs vulnerable to known attack vectors, and with 30 year old notions about security. The belief that this software is suitable for modern use is absurd IMO.

And if the types of programs you're talking about are small UNIX-like utilities, well then they're small and easily updated aren't they?

Re:Rust vs C Pitfalls by groovy2shoes on Wednesday December 28, 2016 @05:23AM (#13269659)
More often than not, brand-spanking-new software is written against 30-year-old APIs.

Lots of software we use day-to-day is old. For example, a couple years ago I fixed a 20-year-old bug in netcat, which itself hadn't been updated since the mid 90s. After I fixed the bug, I didn't need to fish out an old compiler or any compatibility libraries; I just compiled it with the latest GCC and glibc, and carried on with my day.

Don't get me wrong, I like Rust a lot and I'm excited that there's finally a real contender for the systems programming throne after all these years. I'm just less enthused about the prospect of refactoring my codebase once every few months to stay current. This is something that I think will level out with time, though. C itself was almost 20 years old before it was standardized, after all. I don't think it will take Rust that long, and I look forward to the day my copy of the Rust standard arrives on my doorstep.

Re:Rust vs C Pitfalls by naasking on Wednesday December 28, 2016 @09:30AM (#13270669)
> More often than not, brand-spanking-new software is written against 30-year-old APIs.

Let's assume this is true, brand-spanking new software will be written against 30 year old APIs that have survived 30 years of attacks and audits, but will avoid the ones that have proven vulnerable.

> I'm just less enthused about the prospect of refactoring my codebase once every few months to stay current.

The perception that you need to do this is false. You might feel pressured to refactor simply because of new syntactic improvements that make code clearer (like switching try!() macro to infix ?), but that pressure is a fiction. There's no real need to do it.

Re:Rust vs C Pitfalls by dikaiosune on Wednesday December 28, 2016 @12:47PM (#13272155)
> After I fixed the bug, I didn't need to fish out an old compiler or any compatibility libraries; I just compiled it with the latest GCC and glibc, and carried on with my day.

Could you show me an example where post-1.0 you wouldn't be able to do this with Rust?

Re:Rust vs C Pitfalls by grzm on Wednesday December 28, 2016 @01:26AM (#13268834)
If the software does what you want includes all of those criteria. If you find that there are deficiencies in any of those areas, that would qualify as a reason to make changes, weighed against the cost of doing so.
Re:Rust vs C Pitfalls by naasking on Wednesday December 28, 2016 @09:27AM (#13270647)
> If the software does what you want includes all of those criteria.

Except most people don't consider those as criteria at all. The only criteria considered are "does it run and produce the output I want".

Re:Rust vs C Pitfalls by Manishearth on Wednesday December 28, 2016 @01:41AM (#13268876)
And the plan is that you'll be able to do the same with Rust; the more rapid release strategy doesn't affect that at all.

What the rapid releases do affect is the rate at which new releases of libraries stop working on older compilers, which absolutely has to do with ignoring progress.

Re:Rust vs C Pitfalls by erikpukinskis on Wednesday December 28, 2016 @11:08AM (#13271381)
This is my same problem with JavaScript. Yes it's wonderful that changes are backwards compatible. But if the entire community is updating libraries you rely on to use new language features then you have no choice but to use those features too.

Or stop using other peoples' code and just use core language features and build everything from scratch. Which is what I end up doing, and it has some benefits. But it definitely slows you down.