News for hackers. Stuff that matters.
Re:C will never stop you from making mistakes by noelwelsh on Monday August 10, 2020 @09:22AM (#24108934)
And this is how backwards compatibility comes to kill innovation. It's a reasonable stance to keep supporting your long established users but it comes at the cost of ceding the future to the competition (cough Rust cough)
Re:C will never stop you from making mistakes by mytailorisrich on Monday August 10, 2020 @09:31AM (#24109001)
IMHO that's how it should be for a programming language.

If a programming language evolves to the point that previous programs written in that language no longer compile then it's no longer the same language.

So let's keep C as C and, as you point out, new ideas and concepts that would break things can be implemented in new languages.

C does evolve but it's also taken the pragmatic approach not to break the huge existing code base it has. In many cases these programs have been running for decades, they work.

Re:C will never stop you from making mistakes by Tehnix on Monday August 10, 2020 @10:01AM (#24109311)
>If a programming language evolves to the point that previous programs written in that language no longer compile then it's no longer the same language.

I don't really buy that you cannot ever introduce breaking changes. That's a recipe for disaster and IMHO short-sighted.

>In many cases these programs have been running for decades, they work.

And in many other cases, they have been full of security holes that take an incredible amount of work to discover.

Something like Rust's editions seems to solve this problem very well, and is indeed what they are intended for.

You can still compile old code, you just won't have full access to new features if you choose to do so. This provides a way to keep legacy systems alive while providing an upgrade path for them at the same time.

Re:C will never stop you from making mistakes by guenthert on Monday August 10, 2020 @07:33PM (#24115470)
Well, C hasn't been designed to be evolving and was also quite under-specified through most of its history; a hacker's delight, a tool to get things done, quick, but not a receipt for long-term maintainability. Given that, I'd think C did rather well.
Re:C will never stop you from making mistakes by 0xffff2 on Monday August 10, 2020 @10:45AM (#24109790)
>>If a programming language evolves to the point that previous programs written in that language no longer compile then it's no longer the same language.

>I don't really buy that you cannot ever introduce breaking changes. That's a recipe for disaster and IMHO short-sighted.

It's also empirically true in my experience. See Python2/Python3, Perl/Raku, C++98/C++11/C++20. In the latter case, I'm not even sure there are any significant breaking changes, but the feature sets are so different that I find that I pretty much always have to specify which version of C++ I'm talking about.

Re:C will never stop you from making mistakes by noelwelsh on Monday August 10, 2020 @10:27AM (#24109596)
Scala has a tool called scalafix (https://scalacenter.github.io/scalafix/) which allows people to write migration scripts (and other things) that work based on analysis of existing code. This has been used for library upgrades, and will play a big part in the Scala 2 -> Scala 3 migration coming at the end of the year. So it's not impossible to evolve a language and keep code bases current with minimal work for the end user.

For such a tool to be effective it must be possible to statically analyse code to a reasonable degree, and C is certainly not a language that enables easy static analysis.

Re:C will never stop you from making mistakes by Gibbon1 on Monday August 10, 2020 @08:01PM (#24115706)
On the other hand it's absolutely pathetic that C still doesn't have actual arrays. To head off comments, no syntactic sugar on top of pointers doesn't count at all. So don't even try to make that argument.
Re:C will never stop you from making mistakes by Oote3eep on Monday August 10, 2020 @09:53AM (#24109219)
Well, precisely : if people want modern/innovating/fast evolving languages, they can use Rust, Go, Elixir, etc.

I actually started using C for my side projects since two years precisely because I want very long term backward compatibility (that is, being able to leave a program for years without maintaining it, then make a small edit in it and build it with minimum pain). C is perfect for that, and I agree with the sentiment that backward compatibility is its most important feature.

Re:C will never stop you from making mistakes by coder543 on Monday August 10, 2020 @10:17AM (#24109502)
> I actually started using C for my side projects since two years precisely because I want very long term backward compatibility (that is, being able to leave a program for years without maintaining it, then make a small edit in it and build it with minimum pain).

Rust actually takes a very strong stance on maintaining backwards compatibility, and Go's stance is arguably even stronger in most cases. You're implying incorrectly that these languages are just breaking things left and right for no reason other than "innovation!", which isn't true.

The overwhelming majority of Rust and Go code from years ago will compile without problems today. Any code from post-1.0 that doesn't compile today was (inadvertently) relying on buggy, incorrect behaviors that have since been fixed... and even then, not all incorrect behaviors get fixed because compatibility is considered so important.

C is fine for certain applications, but no one should choose it for side projects based on some notion of backwards compatibility, in my opinion. If some company is building a business application that needs "backwards compatibility" in the sense that it can run on all sorts of arcane microarchitectures and operating systems, then sure... C is still a really painful* choice, but it might be the right choice then, or if there's an existing C code base, then it probably doesn't make business sense to rewrite it any time soon.

* yes, having no protection from footguns, no real standard library, no built-in concept of asynchronous code, and very little of anything useful is definitely painful. If C is the only valid choice for a project, then it's the only valid choice, and that's what you have to do. The number of projects where you simply can't use something other than C is diminishing by the day.

Re:C will never stop you from making mistakes by jki275 on Monday August 10, 2020 @11:43AM (#24110476)
Rust and Go haven't been around long enough to make those statements about them.
Re:C will never stop you from making mistakes by virtue3 on Monday August 10, 2020 @11:59AM (#24110662)
That and, while "backwards compatability" has been quoted as important things in these languages. I can attest to rust having issues with what is "idiomatic" rust:

https://timidger.github.io/posts/i-cant-keep-up-with-idiomat...

there are other similar complaints around the net.

While the C and C++ code I wrote over 2 decades ago is now finally "out of date" as of 5 years ago. It took a while. Not 2-3 years.

Which is absolutely attributed to the language being new, not a design fault.

C is already "settled"

Re:C will never stop you from making mistakes by jki275 on Monday August 10, 2020 @02:08PM (#24112210)
I'm learning Rust now, I don't have anything particularly against it other than the obvious, big static binaries and such, and maybe those will be fixed eventually.

I've been able to compile and run C and C++ code from 20 years ago a truly amazing number of times. It's really surprising at how easy it is to work with well written code even if it's decades old.

Will Rust and Go age that way? Maybe. Too soon to tell.

Re:C will never stop you from making mistakes by rational_indian on Monday August 10, 2020 @08:23PM (#24115871)
>I've been able to compile and run C and C++ code from 20 years ago a truly amazing number of times. It's really surprising at how easy it is to work with well written code even if it's decades old.

Not if you have used any third party libraries. Dependency management is a nightmare in these languages.

Re:C will never stop you from making mistakes by jki275 on Tuesday August 11, 2020 @09:44AM (#24120158)
Not if the project is written well. Yes, dependency hell is a thing, but there are ways to deal with it and make good code. Autotools will straight up tell you version x.x.x of library y is required, and as long as that's available, the problem is solved. Dependency hell is a thing in other languages too -- try to compile a really old Java project sometime.

I spend most of my time working deep in the internals of some things that are 10+ years old running even older versions of some highly (and often badly) modified linux kernels. The well written C/C++ projects definitely stand out.

Re:C will never stop you from making mistakes by pjmlp on Thursday August 13, 2020 @05:55AM (#24141626)
Conan and vcpkg have pretty much settled that problem.
Re:C will never stop you from making mistakes by im3w1l on Monday August 10, 2020 @01:04PM (#24111468)
It seems idiomatic C++ is recently changing much faster than before, as C++ feels the need to keep pace with competing languages. But you don't have to keep up with what's idiomatic.
Re:C will never stop you from making mistakes by guenthert on Monday August 10, 2020 @07:28PM (#24115429)
It can cause friction though, if new programmers work on old code or new and seasoned programmers work on the same project.

Of those who do like Common Lisp, many like it because the standard hasn't changed in nearly thirty years (while simultaneously offering features added to the C++ standard just very recently, e.g. a filesystem path abstraction).

Re:C will never stop you from making mistakes by sacado2 on Tuesday August 11, 2020 @05:52AM (#24118750)
I think it's the first time I see someone call Go a modern/innovating/fast evloving language. What attracted me to this language in the first place is the fact backward compatibility is seen as a dogma in the community. It's one of its strongest selling points IMO. I have production code written in 2014 that still compiles and works perfectly without any warning from any (popular) linter.
Re:C will never stop you from making mistakes by apta on Monday August 10, 2020 @11:28AM (#24110330)
golang is not modern nor fast evolving.
Re:C will never stop you from making mistakes by CodeArtisan on Monday August 10, 2020 @02:01PM (#24112114)
I pray daily that more of my fellow programmers may find the means of freeing themselves from the curse of compatibility. -- Edsger Dijkstra - 1972, Turing award lecture
Re:C will never stop you from making mistakes by quickthrower2 on Tuesday August 11, 2020 @06:02PM (#24126549)
The “trade off” not “curse” imho.

But what’s the point he is making. Is there a link to that lecture?

Re:C will never stop you from making mistakes by flingo on Monday August 10, 2020 @08:19PM (#24115836)
> And this is how backwards compatibility comes to kill innovation.

With all of the novel and esoteric programming languages that exist, I wonder why hasn't there been a "I can't believe it's not c/c++" language that breaks these things, but isn't taken seriously enough to diverge completely from the ISO language standards. (for bonus points, with standardized gcc extensions, and something like embedded asm but for compiled languages (like iso standard c))

Re:C will never stop you from making mistakes by ksec on Monday August 10, 2020 @11:38AM (#24110433)
>(cough Rust cough)

Or Zig? What other potential C replacement are there?

Re:C will never stop you from making mistakes by mhh__ on Monday August 10, 2020 @11:48AM (#24110549)
D's betterC mode is very good. It's slightly above C in abstraction (i.e you still have generics) but you get all the metaprogramming too (no more macros!)
Re:C will never stop you from making mistakes by virtue3 on Monday August 10, 2020 @12:00PM (#24110675)
Nothing like a good ole:

#define MULTIPLY(a,b) a*b

To ruin your month.

Re:C will never stop you from making mistakes by blovescoffee on Monday August 10, 2020 @12:11PM (#24110791)
Is the problem the use of a macro, which isn't as robust as a template, or is there a problem with the macro? All I can figure is there could be an accidental dereference instead of multiply.
Re:C will never stop you from making mistakes by virtue3 on Monday August 10, 2020 @12:21PM (#24110916)
The problem is macro expansion is not (potentially) what you think it is:

MULTIPLY(2+3,4+5) that expands in

2+34+5 (and not into: (2+3)(4+5)).

To have the latter, you should define:

#define MULTIPLY(a,b) ((a)*(b))

https://stackoverflow.com/questions/14041453/why-are-preproc....

Re:C will never stop you from making mistakes by favorited on Monday August 10, 2020 @03:02PM (#24112795)
But it's so nice and composable! /s

    #define DEREFERENCE(b) MULTIPLY(=, b)

    int thing DEREFERENCE(ptr);
Re:C will never stop you from making mistakes by virtue3 on Monday August 10, 2020 @07:46PM (#24115582)
You sir, are a true monster. I salute you.
Re:C will never stop you from making mistakes by schemy on Monday August 10, 2020 @09:25AM (#24108958)
Rust is the future and always will be.