HNHacker News
TopNewBestAskShowJobs

writebetterc

135 karma · joined January 16, 2025

submissionscomments
writebetterc··on I don't like traveling anymore
You're wrong :-). I hate that stuff, and I'm technically not even in my 20s anymore!
writebetterc··on Apple needs a Snow Sequoia
REPL-ify your command line then? There's nothing that says you have to be stuck on bash for your command line needs. https://www.nushell.sh/
writebetterc··on My Favorite C++ Pattern: X Macros (2023)
IDEs understand preprocessor macros, so IDE features (jump2def, etc) work with this. IDEs also can expand the macro invocations. So, I prefer the macros when possible :-).
writebetterc··on Robust Wavefront OBJ model parsing in C
Why isn't the conclusion "There is a far better way of using C, which the stdlib doesn't promote... But could"? The fact of the matter is that any sufficiently large C codebase will do this stuff anyway, it's not a language issue.

Good Rust code will also care about memory allocations to the same degree as the C code, the difference is that Rust will help you out in making sure your thinking is correct. My experience is that good systems programming has thinking about memory allocations not as an annoying side issue, but as a main concern.

writebetterc··on Robust Wavefront OBJ model parsing in C
This way of writing programs is also quite a lot faster than depending on fgetline and the like. The integer and float parsing is probably slow, though.

My question is: Does the author actually use Windows XP?

writebetterc··on Why Clojure?
Ain't nothing wrong with Swing or JavaFX :).
writebetterc··on Undergraduate shows that searches within hash tables can be much faster
Good, but that can also be noted in a subtitle right below the authors (I've seen this in papers myself!)
writebetterc··on It is time to standardize principles and practices for software memory safety
No reason to be rude, it was really not clear that you knew that as null pointers have nothing to do with memory models.
writebetterc··on It is time to standardize principles and practices for software memory safety
I believe that the parent is talking about how Java, and in turn the JVM, defines its memory model, which describes formally how memory reads and writes occur in the presence of multiple threads of execution. For example, data races are well-defined in Java: Either you read the old or the new value, you'll never read a mix of two values.

Having a well-defined memory model is important when running on infra with very different models, such as x86 and aarch64.

writebetterc··on I'm Done with Ubuntu
Don't use Fedora if you have a nvidia gpu, or if you have ample of free time.
writebetterc··on The young, inexperienced engineers aiding DOGE
>pioneer something when somebody pioneers something, they are one of the first people to do, discover or use something new.
writebetterc··on The young, inexperienced engineers aiding DOGE
> In fact, it was the United States that pioneered this in the modern age.

This was instituted in Sweden in the year 1766. Source: https://sv.wikipedia.org/wiki/Offentlighetsprincipen

That's 10 years before the USA declared independence.

writebetterc··on Hard Mode Rust (2022)
You sure can write C which makes you less prone to making memory safety mistakes, yes. Knowing how to do that is a skill issue. As you say, sometimes our skills fail us, and that's where tooling comes in. ASan, borrow checker, whatever. There's a reason that a lot of Rust programmers find their programs filled with Arc<Mutex<T>>. That's because they didn't have the skills to write memory safe systems programs in the first place.

To be clear, of course I'm also not immune to fucking up :-).

writebetterc··on Understanding Memory Management, Part 1: C
Memory will always be the limiting factor here. A strong adversary can ensure that you must know the whole list in order to sort it.

You can always mmap the file instead and let the OS page in and out parts of the file, however :-).

writebetterc··on Understanding Memory Management, Part 1: C
This post caused me to create an account. This C code is not good. Writing C is absolutely harder than Python, but you're making it so much harder than it has to be. Your program is buggy as heck, has very finicky cleanup code, and so on.

Here's a much easier way to write the program:

1. Dump whole file into buffer as one string

2. Find newlines in buffer, replace with NULs. This also let's you find each line and save them in another buffer

3. Sort the buffer of all the lines you found

4. qsort the buffer

5. Print everything

6. Free both buffers

Or, as a C program: https://godbolt.org/z/38nq1MorM

← PreviousPage 3 of 3