News for hackers. Stuff that matters.
Re:Google paid a $250K reward for a bug by jve on Monday August 11, 2025 @04:40AM (#44861987)
It is crazy that anytime someone works on application layer and wants to manipulate string, which is a very, very common thing to do when writing application, one has to consider \0 which would be an implementation detail.

How can that language still be so popular?

Re:Google paid a $250K reward for a bug by saagarjha on Monday August 11, 2025 @07:30AM (#44863017)
Programming is the consideration of implementation details. When you manipulate strings in C you consider the terminating nul byte just like when you manipulate strings in Python you consider how its stores codepoints or when you manipulate strings in Swift you think about grapheme clusters. There is no free lunch. (Though, of course, you can get reduced price lunches based on the choices you make!)
Re:Google paid a $250K reward for a bug by CrimsonCape on Tuesday August 12, 2025 @05:06PM (#44881814)
Pardon my ignorance, since I don't know C, but is it true to say that the length of string "Foo" is greater than 4 because of the null terminating byte? Or maybe there is no concept of string length? I could see this getting annoying since Foo is three chars long, you would assume it's length is 3, but we could be speaking of the actual length of bytes, in which i assume it is sizeof(char)*3+1 i.e. the sizeof(char F, char o, char o)+1nullbyte
Re:Google paid a $250K reward for a bug by probably_wrong on Thursday August 14, 2025 @05:44AM (#44898566)
The string length in C is "whatever number of bytes are there between the beginning of the string and the first \0 character". That's different from "how much memory is being used by this string" because you usually allocate a bigger buffer.

The length of the string "Foo", when properly terminated, is 3. The minimum number of bytes needed [1] to represent that string properly is 4 (3+'\0'). The actual number of bytes used by that string is whatever you asked for and received when using "malloc".

[1] Assuming ASCII and 1-byte characters.

Re:Google paid a $250K reward for a bug by saagarjha on Thursday August 14, 2025 @06:24AM (#44898781)
strlen("Foo") == 3 but you need 4 bytes to store it.
Re:Google paid a $250K reward for a bug by uecker on Monday August 11, 2025 @05:01AM (#44862128)
The language is just fine. The real question is: Why do people not use a string library that abstracts this away safely?
Re:Google paid a $250K reward for a bug by saagarjha on Monday August 11, 2025 @07:30AM (#44863021)
Why does the language not make one?
Re:Google paid a $250K reward for a bug by tonyhart7 on Monday August 11, 2025 @07:40AM (#44863100)
because at that time, C creator didn't know thing would evolve into the future. after all computer is a new thing
Re:Google paid a $250K reward for a bug by saagarjha on Monday August 11, 2025 @07:44AM (#44863125)
Ok, but the question asks why one isn't made today.
Re:Google paid a $250K reward for a bug by uecker on Monday August 11, 2025 @07:56AM (#44863200)
There are many string libraries.
Re:Google paid a $250K reward for a bug by saagarjha on Monday August 11, 2025 @07:58AM (#44863217)
As you can expect, the answer to your question is the obvious one.
Re:Google paid a $250K reward for a bug by uecker on Monday August 11, 2025 @11:56AM (#44865694)
I do not think it is obvious or trivial question. I think the problem is mostly that there is no money for enhancing the C ecosystem and educating people about possibilities. The cooperate money goes into random new things.
Re:Google paid a $250K reward for a bug by saagarjha on Thursday August 14, 2025 @06:26AM (#44898792)
I think most of the money goes to new languages that have a better strings story, yes.
Re:Google paid a $250K reward for a bug by WalterBright on Monday August 11, 2025 @01:19PM (#44866818)
Oh, people tried. Every C programmer tried it. I tried multiple times. They all failed.

Back when I was musing about what D would be like, I happened across some BASIC code. I was drawn to the use of strings, which were so simple in BASIC. I decided that D would be a failure if strings weren't as easy to use as in BASIC.

And D strings turned out to be better than I'd dared hope!

I proposed an enhancement to C to get much of that benefit, but it received zero traction in the C community. Oh well.

https://www.digitalmars.com/articles/C-biggest-mistake.html

Re:Google paid a $250K reward for a bug by eska on Monday August 11, 2025 @06:10AM (#44862579)
Lots of C applications nowadays don’t actually use any of the str functions or null termination.
Re:Google paid a $250K reward for a bug by avar on Monday August 11, 2025 @04:47AM (#44862041)
Because whatever language you think should be popular instead is running on a mountain of C code, but the reverse isn't true.
Re:Google paid a $250K reward for a bug by WalterBright on Monday August 11, 2025 @01:21PM (#44866841)
The D implementation and runtime library has zero C code in it.
Re:Google paid a $250K reward for a bug by avar on Monday August 11, 2025 @03:37PM (#44868524)
And when you run that compiler implementation, what language family was used to implement the OS and kernel it's running on, the firmware you're using etc?

That's what I meant, not that self hosted compliers don't exist.

Re:Google paid a $250K reward for a bug by AlienRobot on Monday August 11, 2025 @04:59AM (#44862109)
Okay, I want to make a desktop app that runs on Linux. Which language should I use? Java?
Re:Google paid a $250K reward for a bug by jve on Monday August 11, 2025 @05:31AM (#44862342)
That questions is kind of the point I want to make. We live in 2025 and C is still an option for new applications, i.e wrong abstraction layer for application level development.

No doubt there are valid reasons to use it, that is just the state of things they are unfortunately.

Re:Google paid a $250K reward for a bug by rkomorn on Monday August 11, 2025 @05:01AM (#44862130)
Some current trendy options would be Kotlin (with Kotlin Multiplatform) or C# (with Avalonia UI).

Edit: I guess I should've at least asked myself if the question was rhetorical.

Re:Google paid a $250K reward for a bug by uecker on Monday August 11, 2025 @05:07AM (#44862174)
Whatever you do, please do not use a language that makes it difficult to provide security updates: https://www.debian.org/releases/trixie/release-notes/issues....
Re:Google paid a $250K reward for a bug by AlienRobot on Monday August 11, 2025 @09:54AM (#44864091)
My problem with "crossplatform" GUIs that run on Linux is that they aren't made to run on Linux desktop, they are made to run on Android, iOS, Windows, macOS, and finally Linux desktop.

All I want is a menubar, a toolbar, a statusbar, and some dialog windows. I don't want fading transitions when I click a tab.

It's crazy that I'm forced to write header files just to have a menubar.

Zig 1.0 can't come soon enough.

Re:Google paid a $250K reward for a bug by rkomorn on Monday August 11, 2025 @10:00AM (#44864151)
Wouldn't Qt or GTK be good for this, then?

Or... https://quickshell.org/ ?

Re:Google paid a $250K reward for a bug by WalterBright on Monday August 11, 2025 @01:15PM (#44866761)
C was popular because, if one is familiar with assembler, it takes about an hour to become adept at programming in it.

It's also an easy language to write a compiler for. At one point I counted over 30 C compilers available for DOS.