Live data from Hacker News

Show HN: I wrote a Java decompiler in pure C language

github.com

51–60 of 104 posts

Re: Show HN: I wrote a Java decompiler in pure C language

#51
post #27

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…

Interesting. Someone should come up with a language that prevents these sorts of mistakes!

If only there were a couple of OSes implementated during the 1960's with such programming languages....

Re: Show HN: I wrote a Java decompiler in pure C language

#52

I 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?

In my experience, although many of the other programming languages do improve some things compared with C, they also make many things worse and avoid some of the benefits of C programming.

I can't recall anything in that sense regarding Modula-2 and Object Pascal, other than not bringing UNIX to the party.

Re: Show HN: I wrote a Java decompiler in pure C language

#53
post #12

Very cool project! Love the idea of a Java decompiler written in C — the speed must be great. Any plan to support `.dex` in the future? Also curious how you handle inner classes inside JARs.

The "jikes" compiler from IBM https://github.com/daveshields/jikespg > was written in C++ and was for the longest time screaming fast. It also had its own parser generator lpg which was fun to play with, if you're into those things https://github.com/daveshields/jikespg > It seems someone liked it and made a "v2" along with LSP support https://github.com/A-LPG/LPG2#lpg2

Certainly not everything on Jikes, given that it was one of the first bootstraped Java toolchains.

https://www.jikesrvm.org/

Re: Show HN: I wrote a Java decompiler in pure C language

#54
post #27

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…

Strings! The bane of C programming, and a big reason I prefer C++. :D

Re: Show HN: I wrote a Java decompiler in pure C language

#55
post #50

I 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?

i only write in C. if id build a car it wouldnt have seatbelts. boring, put in ejector seats! not safe? no problem for C :).

ejector seats in C car?

goto eject; ...more code we are going to ignore, it could be important but nah, ignore it, what could be happen?...

eject: up_through_the_roof();

:D

Re: Show HN: I wrote a Java decompiler in pure C language

#56

I 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?

I moved from C++ to C and I am more productive. I also think this "no seat belts" meme is exaggerated, as there are plenty of tools and strategies to make C fairly safe to use. (it is true though that many people do not put the seat belts on).

Re: Show HN: I wrote a Java decompiler in pure C language

#57
post #27

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…

Interesting. Someone should come up with a language that prevents these sorts of mistakes!

I think he is using memory pools, so this is ok.

Re: Show HN: I wrote a Java decompiler in pure C language

#58
post #20

Earlier quoted context omitted.

I am writing the part of decompiling dex and apk. The current speed is about 10 times faster than that of Java, and it takes up less resources than Java. And the compiled binary is smaller, only about 300k. Thank you for your attention.

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

#59
post #27

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 function defs and another that replaces malloc by bumping the local arena data pointer that the prior macro injected.

Re: Show HN: I wrote a Java decompiler in pure C language

#60

I 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.
Post reply on HN