this post was submitted on 17 Jan 2024
-2 points (47.7% liked)

Programming

16864 readers
41 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 1 year ago
MODERATORS
-2
Rust vs C (programming.dev)
submitted 8 months ago* (last edited 8 months ago) by [email protected] to c/[email protected]
 

Without any ::prelude and some void* arguments. Maybe you have thoughts about it.

The URL is just a sample of "why" but not "because".

I have my own preference but will keep it inside my mind to not burn a tornado that will erase me from the matrix of the world.

P.S.: I think C is faster, more powerful, and more elegant. I like it more than Rust.

all 23 comments
sorted by: hot top controversial new old
[–] [email protected] 28 points 8 months ago (2 children)

Rust's 1.0 release (i.e. the date on which the language received any sort of stability guarantee) was in 2015, and this article was written in 2019. Measuring the pace of feature development of a four-year-old language by its release notes, and comparing against a 50-year-old language by counting bullet points in Wikipedia articles, is absolutely ridiculous.

Yes, younger languages adopt features more quickly, and Rust was stabilized in a "minimal viable product" state, with many planned features not yet ready for stabilization. So of course the pace of new features in Rust is high compared to older languages. But Wikipedia articles are in no way comparable to release notes as a measure of feature adoption.

I think C is faster, more powerful, and more elegant.

"More elegant" is a matter of opinion. But "faster" and "more powerful" should be measurable in some way. I'm not aware of any evidence that C is "faster" than Rust, and in fact this would be extremely surprising since they can both be optimized with LLVM, and several of the features Rust has that C doesn't, such as generics and ubiquitous strict aliasing, tend to improve performance.

"Powerful" can mean many things, but the most useful meaning I've encountered is essentially "flexibility of application" : that is, a more powerful language can be used in more niches, such as obscure embedded hardware platforms. It's really hard to compete with C in this regard, but that's largely a matter of momentum and historical lock-in: hardware vendors support C because it's currently the lowest common denominator for all hardware and software. There's nothing about Rust the language that makes it inappropriate for hardware vendors to support at a low level. Additionally, GCC is probably the toolchain with the broadest hardware support (even hardware vendors that use a bespoke compiler often do so by forking GCC), and Rust currently has two projects (mrustc and gccrs) working to provide a way to use GCC with Rust. So even the advantage C has in terms of hardware support is narrowing.

But note that there are also niches for which C is widely considered less appropriate than Rust! The most obvious example is probably use in a front-end web application. Yes, C should in theory be usable on the front-end using emscripten, but Rust has had decent support for compiling to WebAssembly almost as long as it's been stabilized.

[–] [email protected] 4 points 8 months ago

One of the bullet points for C++ is the increase of the version number in the version header file. Wow much feature.

[–] [email protected] 20 points 8 months ago (1 children)

Safety. Yes, Rust is more safe. I don’t really care.

I think this is honestly the crux of Drew's argument.

If a compiler is to prove safety of a program in a language with low level memory management, then there is a lot of inherent complexity. Drew doesn't like complexity, therefore Drew doesn't like safety.

[–] [email protected] 6 points 8 months ago

All his other arguments have some meat, though they're debatable. This one statement is the most surprising and probably the only unacceptable stance in that entire article. Rust is just starting to be more widely used - and that success can be attributed to how much people and companies are fed up with bugs caused by unsupervised manual memory management.

C didn't have that sort of machine supervision for safety - but then again, computers simply weren't powerful enough to do the safety analysis back when C was created. Retrofitting an analyzer isn't possible without changing the language completely. But today the situation is different. We have vastly more powerful computers and static safety analysis isn't a limiting factor for newer languages. Insisting that unsafe programming is acceptable is a very regressive stance. Look for a safety paradigm with less cognitive overhead to the programmer? That's worthwhile. But safety is an absolute necessity. If decades of programming has taught us anything, it's that even the most knowledgeable coders can make mistakes with disastrous consequences due to momentary lapses in judgment. There's no justification in not using the computing power at our disposal to catch such mistakes when they happen.

[–] [email protected] 17 points 8 months ago

Why are you posting a 5 year old blog post? Me thinks it's to stir the pot.

[–] [email protected] 11 points 8 months ago (1 children)

C is many things, but elegant really isn't one of them.

C has always been part of the "worse is better"/New Jersey school of thinking. The ultimate goal is simplicity. Particularly simplicity of language implementation, even if that makes programs written in that language more complex or error prone. It's historically been a very successful approach.

Rust, on the other hand, is part of "The Right Thing"/MIT approach. Simplicity is good, but it's more important to be correct and complete even if it complicates things a bit.

I don't really think of void* and ubiquitous nulls, for example, as the hallmark of elegance, but as pretty simple, kludgey solutions.

Rust, on the other hand, brings a lot of really elegant solutions from ML- family languages to a systems language. So you get algebraic data types, pattern matching, non-nullable references by default, closures, typeclasses, expression-oriented syntax, etc.

[–] [email protected] 0 points 8 months ago (1 children)

C has always been (...)

I think you tried too hard to see patterns where there are none.

It's way simpler than what you tried to make it out to be: C was one of the very first programming languages put together. It's authors rushed to get a working compiler while using it to develop an operating system. In the 70s you did not had the benefit of leveraging half a century of UX, DX, or any X at all. The only X that was a part of the equation was the developers' own personal experience.

Once C was made a reality, it stuck. Due to the importance of preserving backward compatibility, it stays mostly the same.

Rust was different. Rust was created after the world piled up science, technology, experience, and craftsmanship for half a century. Their authors had the benefit of a clean slate approach and insight onto what worked and didn't worked before. They had the advantage of having a wealth of knowledge and insight being formed already before they started.

That's it.

[–] [email protected] 4 points 8 months ago* (last edited 8 months ago) (1 children)

'Worse is better' came from a Common Lisp guy from MIT back in 1991, describing the success of C and UNIX.

It's really not just that Rust is new and C is old. Compare Rust with Go, for example. Go is a fairly modern example of a 'worse is better' language.

Back in 1970s when C was invented, Lisp had been around for over a decade. C came out the same year as smalltalk, a year before ML, and 3 years before Scheme.

Rust is a very modern language, yes. There's no way we could have had it in the 70s; many of its language features hadn't been invented yet. But it very much depends on MIT style research languages for its basis.

[–] [email protected] 1 points 8 months ago

Interesting how Richard Gabriel framed it as New Jersey (Bell Labs) vs MIT.

[–] [email protected] 11 points 8 months ago

This is an old post and a lot has changed since then. Many of the points in that article are no longer true. Drew himself started a language - hare, for which he is considering Rust style borrow checker to ensure safety. It's a bit wrong to bash anything based on a half a decade old opinion.

[–] [email protected] 7 points 8 months ago

Oh another Rust vs C discussion.

I bet the comparisons totally won't be controversial on both sides at all. That never happens.

[–] [email protected] 2 points 8 months ago

This is an opinion and conclusion I completely expected to see from Drew. He's carrying the torch for the old guard but damn if it's not an uphill battle these days.

[–] [email protected] 2 points 8 months ago

Did you try to add an image and remove the URL to the article im the process?