News for hackers. Stuff that matters.
Re:The C juggernaut illustrated (2012) by jcranmer on Saturday February 04, 2023 @06:02PM (#34659349)
> but people who _want_ to actually write, and maintain system software want to do so in C.

At the time this article was written, you would probably be correct. But for about the past 5 or so years, there's been quite a few people in this space who have entertained the use of Rust instead. This includes people who write firmware, people who write drivers, even some of the people who work on the large operating system kernels themselves--you'll find examples of people who have indicated a desire to at least explore using Rust instead of C. And there's more languages in this space that have come out after Rust (Zig perhaps the most notable of those). While this view is far from universal, it's definitely the case that there's a large number of systems programmers who are interested in no longer writing in C.

> C is on paper not a safe language, but almost all of the most trusted safety critical software is written in it, so from a Darwinistic point of view it has produced more trusted software.

My understanding of things like MISRA C is that it's almost a completely different language--to turn C into something you can use for safety-critical stuff, you need to start ripping out or at least heavily curtail basically all of C's differentiating features.

Re:The C juggernaut illustrated (2012) by Firmwarrior on Saturday February 04, 2023 @06:17PM (#34659474)
I'm going to butt in with a counterpoint, since every time someone mentions "c" on the internet a bunch of Rust people come out of the woodwork and give this impression that Rust is taking over, everything is Rust now, everyone loves Rust, etc.

I've been a mobile OS developer for a decade now. Basically nobody uses Rust in the real world of firmware/kernel engineering. There are a few public examples of doing Rust in linux and Google, but the vast majority of work is still done in c or c-flavored c++.

Maybe it'll catch on some day, but it's definitely NOT catching on in the real world of making actual products.

Re:The C juggernaut illustrated (2012) by steveklabnik on Saturday February 04, 2023 @06:49PM (#34659775)
> I've been a mobile OS developer for a decade now. Basically nobody uses Rust in the real world of firmware/kernel engineering.

You know it’s kinda funny, I read this comment and then tabbed over to twitter and then read this: https://blogs.blackberry.com/en/2023/02/this-is-the-kind-of-...

Anyway you’re not wrong that Rust is still a tiny portion of this kind of thing, but it is growing, and quickly. Only time will tell.

(I work at a company writing firmware (and virtually everything else) in Rust, but as a startup I don’t expect that to carry as much weight as big established companies, of course.)

Re:The C juggernaut illustrated (2012) by Firmwarrior on Saturday February 04, 2023 @08:10PM (#34660468)
Man oh man. I realized I'd never even seen Rust code once in my life, so I loaded up some random Rust book and skimmed through it. I know HackerNews doesn't like half-informed angry opinions, so I'll just say "I really hope Rust never takes off" and leave it at that.
Re:The C juggernaut illustrated (2012) by steveklabnik on Saturday February 04, 2023 @08:25PM (#34660578)
Not everything can be everyone's cup of tea :)
Re:The C juggernaut illustrated (2012) by dralley on Saturday February 04, 2023 @08:45PM (#34660742)
What about your brief skimming turned you off?
Re:The C juggernaut illustrated (2012) by Gigachad on Saturday February 04, 2023 @09:45PM (#34661197)
Don’t worry, that’s the same amount of research done as all the other complaints about rust.
Re:The C juggernaut illustrated (2012) by FullyFunctional on Saturday February 04, 2023 @09:48PM (#34661223)
Your loss. I tried three times to learn Rust and I had plenty of doubts, but 3rd time I struck to it and it took maybe a year before I would reach for Rust before C (I have 40 years of C muscle memory so that's saying something). Some things _are_ awkward in Rust (eg. occasionally the explicit "a[x as usize]" casts are tiring), but the payoff is awesome.
Re:The C juggernaut illustrated (2012) by FullyFunctional on Saturday February 04, 2023 @11:07PM (#34661743)
ADD: what finally worked for me was to not read the book [linearly], but instead jumping between tons of sources, lots of exercises, and generally not stressing about getting everything in all the [ample] detail. And of course doing it and doing it every day. I definitely still have lots of holes (hello async) and I'm not shy about Cloning/Copying liberally unless it really matters for performance.
Re:The C juggernaut illustrated (2012) by Ingaz on Sunday February 05, 2023 @06:41AM (#34664069)
Look on databases today.

Especially on that area of Posrgresql mutants: similar ideas came to a lot of great minds: yugabyte, neondb, cockroach DB, timescaledb, even Amazon (Aurora) an MS here.

They are trying to do different things but common: - they're all tweaking storage in very strange directions - compatibility with core postgres - importance on top (timescale is still an extension to PG) - they all trying to achive a goal of cloud-native DB

And one thing is common: Rust! (cocroachdb are still on golang but they are exception)

And if look what's going inside core postgres you will discover that almost all APIs of PG are duplicated in Rust so in future we'll see quite rusty PG

Re:The C juggernaut illustrated (2012) by anarazel on Sunday February 05, 2023 @07:49AM (#34664505)
> And if look what's going inside core postgres you will discover that almost all APIs of PG are duplicated in Rust so in future we'll see quite rusty PG

What do you mean by this?

Re:The C juggernaut illustrated (2012) by Ingaz on Monday February 06, 2023 @05:02AM (#34675460)
Even right now rust is quite adopted in PG community.

Looking on trend I expect that in near future it will be even more: - extensions - I expect rust to become first choice - core postgresql - I expect that rust to appear first in pg tools and then in postgres itself

Re:The C juggernaut illustrated (2012) by Tozen on Monday February 06, 2023 @04:26AM (#34675253)
Agree with your points. There is a big difference between hype and actual change. That some hardcore fans want their favorite language to take over, is far different from their language being anywhere near to surpassing or replacing C.

C is more than just another language, it's a quasi protocol that other languages communicate among each other with. Sorry to say, but neither Rust and Zig are likely to ever reach that level of popularity, nor are other languages going to create FFIs for them to that extent.

Another way to look at this. People run around saying Object Pascal/Pascal/Delphi is a "dead" language (despite how its still widely use), yet it stays around #15 on the TIOBE index, and has done so for years. Rust has barely reached #20 on that index and various others. Zig is nowhere to be seen on various indexes and has yet to reach 1.0, though its going on 8 years into its development. These languages have yet to catch up to and surpass Object Pascal/Pascal, much less have any shot at C, debatably in the next 10 years or ever.

Re:The C juggernaut illustrated (2012) by heywhatupboys on Tuesday February 07, 2023 @07:27AM (#34691833)
> yet it stays around #15 on the TIOBE index,

not a snowman's chance that "Object Pascal/Pascal/Delphi" is, by ANY measure, in top 15 programming languages by usage or importance in 2023...

Re:The C juggernaut illustrated (2012) by Tozen on Tuesday February 07, 2023 @08:11AM (#34692264)
Instead of just thinking about maybe only the USA or a favorite site that one might like, look at it from a wider and world perspective. You have entire school systems of various countries that use Delphi/Object Pascal. South Africa, Turkey, Jamaica, Russia, etc... To include Embarcadero is very aggressive in its outreach to schools and pushing its software and licenses, to the tune of many millions of copies (and many years). There are reasons why Embarcadero and Delphi are still very much around.

There are numerous dialects, IDEs, compilers, and interpreters of Object Pascal/Pascal all over the place (including for embedded and numerous platforms). Delphi (including Turbo Pascal nostalgia), Oxygene, Free Pascal/Lazarus/CodeTyphon, PascalABC, Pascal Script, DWScript, etc...

There are still tons of YouTube videos, books, and websites that are Delphi/Object Pascal/Pascal related. Millions upon millions of lines of code, that people still maintain, or are being produced by small businesses, independents, hobbyists, etc...

The sum total of it, plus the years that Pascal/Object Pascal has been around, means a much greater penetration and usage than many people realize, and much more than the recently trendy or fad languages people might be thinking of.

As much as people might have recently started talking about Rust or Zig on "hip" or "techie" sites, the languages are simply not that known or used to such an extent outside certain circles. Rust and Zig are not being taught like Pascal/Object Pascal was and still is in schools. They haven't been as widely written about or have as many books out about them. They aren't used as much, trusted, or relied upon. A lot more people than one might think, are on the fence, undecided, or only seldomly experimenting with them or something else. Even more, for a language to reach wide spread usage, takes more time and a lot more years than many are aware of or will admit it takes.

Re:The C juggernaut illustrated (2012) by quelsolaar on Saturday February 04, 2023 @06:21PM (#34659519)
Lots of people are _entertaining_ Rust as an option, but that's very different from C being defecto. I don't know of a single peace of software I have used written in Rust.

A lot of people have in the past had very good arguments for why their language (C++, D Java, OCaml, Objective-C) should replace C but after decades they still haven't. The C-is-dead argument predates Rust by a lot, and Rust is already 10 years old.

C may at some point be replaced, but I'm not holding my breath especially given that I think Cs success is so poorly understood, especially by people who come from other languages.

Re:The C juggernaut illustrated (2012) by jcranmer on Saturday February 04, 2023 @06:41PM (#34659695)
Sure, Rust isn't there yet; C is still undisputably the king of system languages. But it's honestly the first language to crack the chink of C's dominance in low-level programming--C no longer looks unstoppable, in a way that C++ or D never managed to achieve.
Re:The C juggernaut illustrated (2012) by di4na on Saturday February 04, 2023 @08:43PM (#34660725)
Ever used Android? VScode?

If yes, you are using software written in Rust.

Fastly? Same. Python? there is a good chance you are using cryptography, which is partially in Rust.

Firefox? Rust is in there.

And i could keep doing, at this point it is slowly creeping everywhere :)

Re:The C juggernaut illustrated (2012) by Gigachad on Saturday February 04, 2023 @09:49PM (#34661226)
Linux also contains the building blocks for loading rust modules now as I understand. And some builds like Asahi Linux contain major rust components.
Re:The C juggernaut illustrated (2012) by di4na on Sunday February 05, 2023 @07:32AM (#34664404)
Iirc AWS ship quite some rust in their hypervisor and networking stack too
Re:The C juggernaut illustrated (2012) by AnimalMuppet on Saturday February 04, 2023 @10:14PM (#34661409)
It's like Chesterton's Fence. If you don't understand why C is used, you aren't going to be able to convince people that they ought to use something else. And you for certain are not going to be able to create a language to replace it.
Re:The C juggernaut illustrated (2012) by wheelerof4te on Saturday February 04, 2023 @06:16PM (#34659467)
Still, C is far more enjoyable to write than Rust is.

Constantly fighting with your compiler is not how I would imagine a good time.

Re:The C juggernaut illustrated (2012) by jcranmer on Saturday February 04, 2023 @06:34PM (#34659623)
I care to disagree. I'd much rather fight with my compiler than play the game of "oops, I segfaulted, let me recompile with -g so I can rerun with gdb so I can figure out where I crashed." Or more minor stuff, like trying to track down which header file actually contains the implementation of, say, struct mcontext_t so I can remember how to set the value of RSP in a signal handler.

I've grown to enjoy the Rust programming far more. Having a language, and associated tooling, that's woken up to the 21st century is far more enjoyable. (Really, why is it acceptable that a major language in 2023 still defaults to providing absolutely no diagnostic information on a fault?)

Re:The C juggernaut illustrated (2012) by c-cube on Saturday February 04, 2023 @06:33PM (#34659610)
Clearly that's a matter of taste. The popularity of rust shows that some people prefer writing it to writing C or C++, otherwise they'd just write C or C++. And yeah, personally I'd rather spend time fixing compile time errors, directly in the editor as I type, than hunting segfaults with gdb later.
Re:The C juggernaut illustrated (2012) by torstenvl on Saturday February 04, 2023 @07:36PM (#34660182)
Personally — and I know this isn't a good philosophy for secure software, I'm just commenting purely on the enjoyability aspect — I much prefer the logic game of hunting memory errors over the frustration of one of my tools refusing to do what I'm telling it to do.
Re:The C juggernaut illustrated (2012) by Gigachad on Saturday February 04, 2023 @09:47PM (#34661211)
Fighting with the compiler just means you have the wrong frame of thinking. Once you learn how to express things in ways that are verifiably safe, there is no fighting because you’ll get it mostly correct the first time.
Re:The C juggernaut illustrated (2012) by eggy on Saturday February 04, 2023 @11:07PM (#34661741)
I agree, but I think you should then look at SPARK2014 [1]. Rust just has better marketing and a bigger company behind it, but SPARK2014 is simpler and has been delivering Rust's bullet list for almost 10 years.

[1] https://www.adacore.com/about-spark

Re:The C juggernaut illustrated (2012) by Gigachad on Sunday February 05, 2023 @04:00AM (#34663185)
Why on earth did they add 2014 to the name? It’s like putting an expiry date on it before it even takes off.
Re:The C juggernaut illustrated (2012) by eggy on Friday February 10, 2023 @11:10AM (#34741605)
It is more a version thing, and I always put it in the name to differentiate from Apache's Spark. That and the all-uppercase letters.
Re:The C juggernaut illustrated (2012) by tialaramex on Saturday February 04, 2023 @07:23PM (#34660086)
> My understanding of things like MISRA C is that it's almost a completely different language

MISRA's rules aren't that distinct from a C coding style you've probably used if you're an experienced C programmer. Any competent C programmer can easily read and understand code that obeys the rules - it's just C, but maybe somebody with no prior experience of MISRA might trip on some of the rules because they're unnatural. For example if you like recursive code, MISRA hates that, so don't do that (call stacks are finite). If you're used to doing shenanigans with pointers (e.g. XOR linked list), MISRA hates that too, C's pointers are just magic, don't try to fiddle with them.

I'd guess that 90+% of code I wrote with no intention for it to be MISRA would, in fact, pass MISRA rules or would pass with some minor tweaks. Some of MISRA's dozens of rules are forbidding stuff no sane C programmer writes unless it's for a contest or something, so you just won't hit those. Some require practices which were recommended in like the ANSI document, that's over 30 years ago, hopefully you are doing that already.

Re:The C juggernaut illustrated (2012) by FullyFunctional on Saturday February 04, 2023 @09:38PM (#34661131)
My annecdata: my first language after BASIC was Pascal and I worked professionally for a couple of years using Turbo Pascal, yet I preferred C. I think the reasons were (in order): verbosity and flexibility.

I always hated Wirth's obsession with bloated keywords. I like conciseness (though J might be jumping the shark).

The latter point is just a reflection of how awkward it is to the break the rules in Pascal, which was necessary for many real-world applications.

And yes, I'm also a Rust convertee (sorry haters); I can do everything I did in C in Rust and for most parts it's more readable and frankly less work. I think my biggest regret is that while I know I could write a C compiler, I don't think I could write a Rust compiler [in my lifetime].

Re:The C juggernaut illustrated (2012) by eggy on Saturday February 04, 2023 @11:04PM (#34661726)
I love J and APL, but April takes the cake for me[1]. APL in Lisp.

I also prefer SPARK2014 instead of Rust if I am not going to use C. I've started learning Rust a few times. SPARK2014 is easier to get going for me, and it has been used to produce high-integrity software and real-world applications for over a decade, and more if you include Ada from which it sprang[2].

[1] https://github.com/phantomics/april

[2] https://www.adacore.com/about-spark

Re:The C juggernaut illustrated (2012) by FullyFunctional on Saturday February 04, 2023 @11:18PM (#34661799)
April is interesting, thanks. Aside: I worked professionally in Scheme for a few years, but Haskell (and ghci) is my favorite language (thus my handle) for experimenting with non-trivial derivations and quick one-off experiments. Rust gives me some of what I love in Haskell (type classes, polymorphic types, sum types, some type inference, rich and ergonomic library, some functional style, ...) without the sad part (space leaks, unpredictable runtime, completely insane defaults from a perf POV)
Re:The C juggernaut illustrated (2012) by eggy on Friday February 10, 2023 @11:13AM (#34741637)
I find APL and J to be functional enough and terse to a point of beauty once you get it. Look at solutions on rosettacode.org between Haskell and J or APL to get a feel for what I am saying. Rust's syntax is a turn off, but that is a personal bias against my C background once I embraced Haskell, J, APL, Forth, Lisp, etc...

SPARK2014 covers me for the things Rust is striving for with a longer legacy of doing so for real world systems. It's also a simpler syntax (Ada, Pascal).