Live data from Hacker News

50 years of C, the good, the bad and the ugly [video]

streaming.media.ccc.de

231–240 of 257 posts

Re: 50 years of C, the good, the bad and the ugly [video]

#231
post #144

Earlier quoted context omitted.

The argument is not about what can and can’t be done in C. C is Turing complete and low level. You can do anything in C. The debate is not even about if it’s good idea (I don’t think it is but that’s separate). The question is about C semantics. Given the reply I get it’s pretty obvious that some here don’t understand what language semantics are. It’s about the amount of concepts you can express in the language. Hask…

You’re whitewashing history if you think Pascal was superior to C. There was no conspiracy among compiler developers as you imply. Also you complain about semantic richness of C, but then only point to semantically rich languages you despise. A curious reader would wonder: why care about semantically rich languages then? An observant reader would wonder: so aren’t there times where semantic richness is not useful?

Pascal, at least the original specification, does have a few flaws. It was intended to run as P-code in a VM so you wouldn't expect it to be as good as running directly on the hardware.

The successor to Pascal, which fixed it's problems, was Modula-2, which is vastly superior to C. Unfortunately by the time it came out and started becoming available, it was too late for it to compete fairly with C. Ada is comparable to Modula-2, especially before Ada added OOP, but Ada was too late to compete with C as well.

It's taken 30 years but finally we are starting to see safe languages, eg. Rust, compete with C and C++. I don't know whether Rust will be the language that overtakes C and C++, but if not, I believe a successor to it will and C and C++ will become like COBOL, that no ones uses to write any new code.

Re: 50 years of C, the good, the bad and the ugly [video]

#232

Earlier quoted context omitted.

There is no elegance there. Casting to void is not a plus. That’s just C having no proper type system. Function pointers as an elementary form of closures, come on, what’s next? Closures are defined by capture. It’s nearly as fun as pretending C as coroutines because of setjmp . How can a statement like C being semantically poor even be seen as controversial? For god sake, we are talking about a language which semant…

You really don't understand, but that's okay. C is a wonderful language, and that's the end of it really. You just try to think C as a language that SHOULD HAVE all the stupid bells and whistles you find convenient. Many of us more advanced coders have found that those stupid bells and whistles are, in fact, inconvenient. Casting to void is a powerful technique and the limits are literally endless. C is semantically…

C is a garbage language. It has a lot of undefined behaviour. It isn't safe. It isn't even strongly typed. It's only marginally better than a macro assembler. C programmers consider that a virtue but programmers who want to write safe, robust code, know C is garbage.

Re: 50 years of C, the good, the bad and the ugly [video]

#233

Earlier quoted context omitted.

C is also relatively poor at providing “a way to define data structures which are really memory layouts”. Integer sizes (historically) and padding are implementation-defined, AFAIK bit fields are underspecified in that you cannot specify in what bits of a byte they end up.

So true. I wish that C had a more rich way to define struct layouts and low-level representations for integral types. I really like how Ada does it: https://en.wikibooks.org/wiki/Ada_Programming/Representation... If you need to read or write specialized hardware registers, being able to define a data structure with a custom representation is very nice and can save significant time and effort.

I wish C had never been born.

Re: 50 years of C, the good, the bad and the ugly [video]

#234
post #205

Earlier quoted context omitted.

That same document claims, "C's approach to strings works well" which, I mean I admire Dennis Ritchie but he's just wrong.

Moving goalposts, you were asking who said it, the language authors did. If they are right or not, it is another matter.

Regarding that matter, he was wrong. I wish he'd never written the garbage that is C. It's a stain on his reputation.

Re: 50 years of C, the good, the bad and the ugly [video]

#235

Earlier quoted context omitted.

> Linux kernel is written in C Not exclusively in C, not anymore: https://docs.kernel.org/rust/index.html It might take another decade for a C-free build to be possible, though.

The Linux kernel comes with many old drivers that modern programmers have little knowledge about. It is probably more realistic to write a new kernel in rust (like Redox), targeting modern machines only.

By the time it's rewritten in Rust, old drivers will be dropped due to lack of demand for them.

Re: 50 years of C, the good, the bad and the ugly [video]

#236

Earlier quoted context omitted.

In a way, it's already happening. Many big tech companies are now defaulting to other languages than C and are actively discouraging the use of C or C++ for new code. They still have a big vested interest in maintaining existing code of course. That's not going to disappear overnight obviously.

Do you have examples? Is it all going towards Rust or are there other big tech-backed contenders?

I read recently that parts of the code for Artemis are written in Ada. Ada is also used on the ISS. Makes me wonder who besides NASA might be using Ada due to its' safety.

Re: 50 years of C, the good, the bad and the ugly [video]

#237

Earlier quoted context omitted.

Ada is a much better and modern alternative for embedded, real-time and/or systems programming. Its mature, (although still evolving) and very scalable from very, very small to very, very large systems. It also supports interoperability with C and C++. It is a primary language in GCC. See https://ada-lang.io/ and https://learn.adacore.com/ Unfortunately Ada is held back by a genuine lack of awareness and some old mis…

As strange as it might sound, the success of Rust seems to have reopened some doors for Ada. People in both communities are aware of this and already collaborating on various projects to mutual benefit.

Rust and Ada are both seen as 'safe' languages that prevent many unsafe actions by programmers.

Re: 50 years of C, the good, the bad and the ugly [video]

#238

Earlier quoted context omitted.

A good bet is that a technology will be around at least as long as it has been around (I think there's also a 'named law' for it). So I fully expect C to be around in one way or another for the next 50 years, it probably won't be as important anymore, just as COBOL or Fortran are not as important as they used to be. One reason for C to disappear completely would be if computer architectures would change so much that…

https://en.wikipedia.org/wiki/Lindy_effect > The Lindy effect (also known as Lindy's Law[1]) is a theorized phenomenon by which the future life expectancy of some non-perishable things, like a technology or an idea, is proportional to their current age. Thus, the Lindy effect proposes the longer a period something has survived to exist or be used in the present, the longer its remaining life expectancy.

While C and C++ have been around longer than COBOL was when building new systems it it was halted, at least COBOL does its job well while C and C++ don't due to their lack of safety. Also, COBOL is more difficult to replace than C and C++ are. I expect C and C++ code to start being seen as dangerous and money will be spent to eradicate it due to its potential to be a security risk in this online world.

Re: 50 years of C, the good, the bad and the ugly [video]

#239
post #2

His final conclusion is that C has to go, just like COBOL, Fortran, and PL/I. I wonder how long it will take before C will be gone totally when you realize how much COBOL and Fortran are still around. Not so long ago, I came along a module for Python 'SciPy.interpolate' that happens to be programmed in Fortran.

We can replace COBOL with a Java backend to keep the enterprise feeling going, but what would C's replacement be in this case?

Rust is already replacing C and C++. Ada is too. As the importance of safety increases, more safe languages will appear that can replace C and C++.

Re: 50 years of C, the good, the bad and the ugly [video]

#240
post #51

Earlier quoted context omitted.

C++ for starters, would already be an improvment, provided string, array and vector classes with bounds checking, get used instead of raw C pointers. Alongside RAII for resource management.

For most embedded stuff those are just extra hassle and not worth it. C and its raw pointers and are really all you need most of the time. The need to have some discipline and expertise to produce solid code with confidence is not a bad thing in the embedded domain. If the code truly is critical you need to dive deep into verification techniques anyway.

Rust has already begun to replace C in the embedded space.
Post reply on HN