News for hackers. Stuff that matters.
Re:The C23 edition of Modern C is now available for free by israrkhan on Tuesday October 15, 2024 @11:18PM (#41855279)
Most important aspect of C is its portability. From small microcontrollers to almost any computing platform. I doubt that any new version of C will see that much adoption.

If I want to live on cutting edge I would rather use C++2x or Rust rather than C.

Am I missing something? What benefit this supposedly modern C offers?

Re:The C23 edition of Modern C is now available for free by vitaminka on Tuesday October 15, 2024 @11:31PM (#41855343)
these features will eventually trickle down into the mainstream, kind of like C11 is doing at the moment

also, unless you're targeting embedded or a very wide set of architectures, there's no reason why you couldn't start using C23 today

Re:The C23 edition of Modern C is now available for free by bboygravity on Wednesday October 16, 2024 @01:21AM (#41855853)
Or in other words, for embedded and existing code: most use c99, some use c11 and nobody uses c23 until at least 10 years from now.
Re:The C23 edition of Modern C is now available for free by dhhfss on Wednesday October 16, 2024 @01:47AM (#41855978)
This depends on the platform. Many embedded systems are based on arm these days and have modern toolchains available.

I cannot remember the last time I saw C99 used. C codebases generally use C11 or C17, and C++ code bases use C++20

Re:The C23 edition of Modern C is now available for free by pjmlp on Wednesday October 16, 2024 @03:34AM (#41856523)
Unless you can vouch for the C++ compiler, the best C++ portable code can offer today is C++17.

Also 8 and 16 bit embedded toolchains are certainly not on C11 / C17, they can hardly afford full C89.

Re:The C23 edition of Modern C is now available for free by flohofwoe on Wednesday October 16, 2024 @07:22AM (#41857834)
SDCC is a niche C compiler for 8-bit CPUs and is more uptodate than MSVC ;P

https://sdcc.sourceforge.net/

That's the nice thing with C: it's much easier for small teams to fully support than the latest C++ standards.

Re:The C23 edition of Modern C is now available for free by pjmlp on Wednesday October 16, 2024 @10:12AM (#41859229)
Now try to use it on the embedded deployments that require certification.
Re:The C23 edition of Modern C is now available for free by bboygravity on Saturday October 19, 2024 @05:47AM (#41886801)
Most devices that are 6+ years old (as far as I can tell) use C99. If not C89. And/or C++17, if that.

That's A LOT of devices out there. A lot of which still get maintenance and even get feature updates (I'm working on one right now, C99).

So the claim that "C codebases generally use C11 or C17, and C++ code bases use C++20" intuitively sounds like totally untrue to someone working in embedded C/C++. I've been doing this for 15+ years and I've never touched anything higher than C99 or C++17.

If you're talking about gaming, sure. But that's not "C code bases generally".

Re:The C23 edition of Modern C is now available for free by vitaminka on Wednesday October 16, 2024 @01:49AM (#41855982)
most non-embedded and non-legacy codebases could use c23, that's not an insignificant set
Re:The C23 edition of Modern C is now available for free by bboygravity on Saturday October 19, 2024 @05:50AM (#41886816)
I would argue that is an insignificant set.

Unless you think that code-bases created in the past year are a significant part of code bases that have been created since the inception of humanity.

Re:The C23 edition of Modern C is now available for free by doe_eyes on Wednesday October 16, 2024 @12:25AM (#41855595)
Of course they will, just like they did in the past with C11, GNU extensions, or some of the individual features that are now rolled into C23. For example, the 0b notation for binary numbers is widely used in the MCU world.

The microcontroller toolchains are generally built on top of GCC, so they get the features for free. There are some proprietary C compilers that are chronically lagging behind, but they are not nearly as important as they used to be two decades ago.

Re:The C23 edition of Modern C is now available for free by shakna on Wednesday October 16, 2024 @01:25AM (#41855880)
The `thread_local` specifier is used on a few microcontroller platforms already, but would be absolutely illegal in C11 and before to use. However, it vastly simplifies memory management in a threaded context.

Why would I rather step into the world of C++ just to deal with that?

Re:The C23 edition of Modern C is now available for free by casenmgreen on Wednesday October 16, 2024 @05:45AM (#41857253)
IIRC, performance and cost of thread local store varies greatly between platforms.

You have to know what you're biting into, before you use that.

Re:The C23 edition of Modern C is now available for free by flohofwoe on Wednesday October 16, 2024 @03:14AM (#41856401)
One advantage of writing C code is that you don't have annoying discussions about what idiomatic code is supposed to look like, and what language subset is the right one ;)

For the cutting edge I would recommend Zig btw, much less language complexity than both modern C++ and Rust.

One good but less visible side effect of C23 is that it harmonizes more syntax with C++ (like ... = {} vs {0}) which makes it a bit less annoying for us C library maintainers to support the people how want to compile their C code with a C++ compiler.

Re:The C23 edition of Modern C is now available for free by pjmlp on Wednesday October 16, 2024 @03:32AM (#41856506)
There is enough material in C, and related compiler extensions, to have similar discussions, starting from where to place brackets.
Re:The C23 edition of Modern C is now available for free by rbanffy on Wednesday October 16, 2024 @02:28PM (#41862159)
Maybe the C24 will define the One Right Way.
Re:The C23 edition of Modern C is now available for free by Arch-TK on Wednesday October 16, 2024 @09:01AM (#41858603)
> C library maintainers to support the people how want to compile their C code with a C++ compiler.

Just tell them to go away.

Trying to write the subset of C and C++ is a fool's errand.

Re:The C23 edition of Modern C is now available for free by jstarks on Wednesday October 16, 2024 @11:11AM (#41860015)
No inline functions in library headers, then.
Re:The C23 edition of Modern C is now available for free by flohofwoe on Wednesday October 16, 2024 @12:08PM (#41860766)
Inline is mostly pointless in C anyway though.

But it might be a minor problem for STB-style header libraries.

It's not uncommon for C++ projects to include the implementation of an STB-style header into a C++ source file instead of 'isolating' them in a C source file. That's about the only reason why I still support the common C/C++ subset in my C libraries.

Re:The C23 edition of Modern C is now available for free by pragma_x on Wednesday October 16, 2024 @09:11AM (#41858691)
I'm with you on this. The feature list reads like a subset of later C++ standards that fit within C's (deliberately) rudimentary feature set.

You could, in theory, just use C++ and be done with it. But like any C++ project you'd need a pretty strict style guide or even a linter, but this time it would have to be extra restrictive lest you slide into full C++ territory. And maybe that's a major stumbling block for some people?

Re:The C23 edition of Modern C is now available for free by BenjiWiebe on Wednesday October 16, 2024 @11:14AM (#41860058)
Won't any llvm/gcc supported target get the new version of C automatically? You won't get it in the vendor-modified ancient gcc toolchain for some other arch though.
Re:The C23 edition of Modern C is now available for free by israrkhan on Thursday October 17, 2024 @08:04PM (#41875088)
There are many embedded platforms that do not gcc/llvm based compilers.

Also most companies making those platforms are not good at updating their toolchains. Expecting developers to compile their own toolchain, that is unsupported by platform vendor, is too much to ask.

Also GCC dropped support for certain architectures along the way, and even if you are willing to compile your own toolchain, it may not work for you.