I am always curious how different C programs decide how to manage memory. In this case there are is a custom string library. Functions returned owned heap-allocated strings. However, I think there's a problem where static strings are used interchangably with heap-allocated strings, such as in the function `string class_simple_name(string full)` ( https://github.com/neocanable/garlic/blob/72357ddbcffdb75641... ) Somet…
Many command line tools do not need memory management at all, at least to first approximation. Free nothing and let the os cleanup on process exit. Most libraries can either use an arena internally and copy any values that get returned to the user to the heap at boundaries or require the user to externally create and destroy the arena. This can be made ergonomic with one macro that injects an arena argument into func…
Show HN: I wrote a Java decompiler in pure C language
61–70 of 104 posts
Re: Show HN: I wrote a Java decompiler in pure C language
#62I cannot help but wonder why starting a new project in C in 2025. It’s like driving a car with no seat belts. You sure you want to do that?
We need people who can (and do) write in C, assembly, and all these low-level languages. Otherwise, software will just get slower and slower.
Re: Show HN: I wrote a Java decompiler in pure C language
#63Earlier quoted context omitted.
This has been my life experience with things written in C/C++, so speed doesn't matter. Or, I guess from an alternative perspective, it ran very fast, but exited very fast, too :-D $ ./objdir/garlic $the_jar_file -o out-dir -t $(nproc) Progress : 85 (1024)Segmentation fault: 11
Is it? This is my experience with Python. The C/C++ programs I use daily never seem to crash (Linux, bash, terminals, X, firefox, vim, etc.). It must be years ago one of those programs crashed while I used it.
Re: Show HN: I wrote a Java decompiler in pure C language
#64Re: Show HN: I wrote a Java decompiler in pure C language
#65Earlier quoted context omitted.
Many command line tools do not need memory management at all, at least to first approximation. Free nothing and let the os cleanup on process exit. Most libraries can either use an arena internally and copy any values that get returned to the user to the heap at boundaries or require the user to externally create and destroy the arena. This can be made ergonomic with one macro that injects an arena argument into func…
That might be true, but leaking is neither the critical nor the most hard to find memory management issue, and good luck trying to adapt or even run valgrind with a codebase that mindlessly allocates and leaks everywhere.
Re: Show HN: I wrote a Java decompiler in pure C language
#66Earlier quoted context omitted.
That might be true, but leaking is neither the critical nor the most hard to find memory management issue, and good luck trying to adapt or even run valgrind with a codebase that mindlessly allocates and leaks everywhere.
Pretty sure you can just disable leak checking.
Of course literally running valgrind is still possible, but it is difficult to get useful information.
Re: Show HN: I wrote a Java decompiler in pure C language
#67Re: Show HN: I wrote a Java decompiler in pure C language
#68https://opensource.stackexchange.com/questions/10737/inclusi...
Re: Show HN: I wrote a Java decompiler in pure C language
#69Earlier quoted context omitted.
Is it? This is my experience with Python. The C/C++ programs I use daily never seem to crash (Linux, bash, terminals, X, firefox, vim, etc.). It must be years ago one of those programs crashed while I used it.
Also a segfault IS the protection layer intervening, it is equivalent to a exception in other languages. The real problem is, when there is no segfault.
Re: Show HN: I wrote a Java decompiler in pure C language
#70Earlier quoted context omitted.
Pretty sure you can just disable leak checking.
But for example verifying that memory is not touched after it is supposed to, is much harder when you can't rely on it being freed. Of course literally running valgrind is still possible, but it is difficult to get useful information.
That's the beauty of the never free memory management strategy.