Hacker Newsnew | past | comments | ask | show | jobs | submit | kahlonel's commentslogin

Embedded software developer here, with very minimal professional hardware design experience. I mostly write nostdlib C, and never use malloc. I write peripheral drivers from scratch even if there’s an “SDK” for it. I spend almost 40% of my time reading documentation, 30% scribbling state machines, 15% writing code and 15% testing it on hardware. LLMs don’t help me much. I use them to write scripts for me to parse my stdout and find patterns. For breakfast, I fight EEs to prove their hardware doesn’t work. I have exploded hardware setups for the products I’m developing for on my desk. JLink is the favorite thing in my aresenal. Even the slightest latency on my text editor annoys the shit out of me, which is why I don’t use IDEs.

Now we have vulnerabilities in two different flavors.

That's a great example of how to write C in 2025. Congrats and well done.


> That's a great example of how to write C in 2025. Congrats and well done.

This project is an awful example of how to write C. No checking of return values, leaking memory with realloc, over-engineered parsing (what should be 8 lines is +200).

I can understand it as a learning project, and even if it wasn't, I can sorta understand that sometimes bugs creep in ("oops, forgot to use a tmp variable for realloc in one out of 10 places") but this is not what is happening: This is not how you write C!


PuTTY was the first tool I ever used to SSH into a machine. My mind was blown when me and my friend wrote to the same file and could see each other’s sentences.


Flash


Awesome write up! Please don’t mind the hostile crowd here. They don’t like anything other than their favorite language on the front page. There’s a much bigger silent majority that still loves C and the things you can do with it.


Imagine going out, calling someone the N-word, and only getting 0.0379% of your income as a fine.


You mean the implementation is faster than the one in C. Because nothing is “faster than C”.


Why can’t something be faster than C? If a language is able to convey more information to a backend like LLVM, the backend could use that to produce more optimised code than what it could do for C.

For example, if the language is able to say, for any two pointers, the two pointers will not overlap - that would enable the backend to optimise further. In C this requires an explicit restrict keyword. In Rust, it’s the default.

By the way this isn’t theoretical. Image decoders written in Rust are faster than ones written in C, probably because the backend is able to autovectorise better. (https://www.reddit.com/r/rust/comments/1ha7uyi/memorysafe_pn...).

grep (C) is about 5-10x slower than ripgrep (Rust). That’s why ripgrep is used to execute all searches in VS Code and not grep.

Or a different tack. If you wrote a program that needed to sort data, the Rust version would probably be faster thanks to the standard library sort being the fastest, across languages (https://github.com/rust-lang/rust/pull/124032). Again, faster than C.

Happy to give more examples if you’re interested.

There’s nothing special about C that entitles it to the crown of “nothing faster”. This would have made sense in 2005, not 2025.


Narrow correction on two points:

First, I would say that "ripgrep is generally faster than GNU grep" is a true statement. But sometimes GNU grep is faster than ripgrep and in many cases, performance is comparable or only a "little" slower than ripgrep.

Secondly, VS Code using ripgrep because of its speed is only one piece of the picture. Licensing was also a major consideration. There is an issue about this where they originally considered ripgrep (and ag if I recall correctly), but I'm on mobile so I don't have the link handy.


The kind of code you can write in rust can indeed be faster than C, but someone will wax poetic about how anything is possible in C and they would be valid.

The major reason that rust can be faster than C though, is because due to the way the compiler is constructed, you can lean on threading idiomatically. The same can be true for Go, coroutines vs no coroutines in some cases is going to be faster for the use case.

You can write these things to be the same speed or even faster in C, but you won’t, because it’s hard and you will introduce more bugs per KLOC in C with concurrency vs Go or Rust.


> but someone will wax poetic about how anything is possible in C and they would be valid.

Not at all would that be valid.

C has a semantic model which was close to how early CPUs worked, but a lot has changed since. It's more like CPUs deliberately expose an API so that C programmers could feel at home, but stuff like SIMD and the like is non-existent in C besides as compiler extensions. But even just calling conventions, the stack, etc are all stuff you have no real control over in the C language, and a more optimal version of your code might want to do so. Sure, the compiler might be sufficiently smart, but then it might as well convert my Python script to that ultra-efficient machine code, right?

So no, you simply can't write everything in C, something like simd-json is just not possible. Can you put inline assembly into C? Yeah, but I can also call inline assembly from Scratch and JS, that's not C at all.

Also, Go is not even playing in the same ballpark as C/C++/Rust.


If you don't count manual SIMD intrinsics or inline assembly as C, then Rust and FORTRAN can be faster than C. This is mainly thanks to having pointer aliasing guarantees that C doesn't have. They can get autovectorization optimizations where C's semantics get in the way.


Of course many things can be faster than C, because C is very far from modern hardware. If you compile with optimisation flags, the generated machine code looks nothing like what you programmed in C.


It is quite easy for C++ and Rust to both be faster than C in things larger than toy projects. C is hardly a panacea of efficiency, and the language makes useful things very hard to do efficiently.

You can contort C to trick it into being fast[1], but it quickly becomes an unmaintainable nightmare so almost nobody does.

1: eg, correct use of restrict, manually creating move semantics, manually creating small string optimizations, etc...


In the chance this is a speed of light joke, I'll add pedantically that C isn't the speed of light. Mathematics/Physics symbols are case sensitive.


Fortran has been faster than C, because C has aliasing, preventing optimizations. At least for decades this was why for some applications Fortran was just faster.

It's not just "a sufficiently smart compiler", without completely unrealistic (as in "halting problem" unrealistic, in the general case) "smartness".

So no, C is inherently slower than some other languages.


Nothing is faster than C in a vacuum, but depending on the context (medium?) that can happen.

In other words, someone should name a language Cerenkov


Gravitation is slightly faster than c in vacuum.


In GR, the speed of gravitational waves is _exactly equal_ to c.


In reality, speed of light is slightly lower than speed of gravitation, because gravitation slows down speed of light.


We were presumably talking about an ideal massless space [Minkowski] in which the speed of light in a vaccuum is considered -- that is what c is defined as.


Wtf, since when?

Besides the famous "C is not a low-level language" blog post.. I don't even get what you are thinking. C is not even the performance queen for large programs (the de facto standard today is C++ for good reasons), let alone for tiny ultra hot loops like codecs and stuff, which are all hand-written assembly.

It's not even hard to beat C with something like Rust or C++, because you can properly do high level optimizations as the language is expressive enough for that.


Tachyons?


Maybe if you reverse the beam polarity and route them through the main deflector array.


But that requires rerouting auxiliary power from life support to the shield generators. In Rust you would need to use unsafe for that.


C after an optimizing compiler has chewed through it is faster than C


Because it’s the only language that doesn’t get in my way / add another cognitive layer to deal with. My modules can be as simple or as complex (by combining simpler ones) as I want.


It’s “undefined behavior” because on certain embedded systems NULL (i.e. 0) is a valid memory address that can be read/written to.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: