AllocPPx.pl -> A Perl script that preprocesses C with garbage collection! (gist.github.com)
from ChubakPDP11@programming.dev to programming@programming.dev on 15 Apr 2024 08:51
https://programming.dev/post/12797447

Automatic garbage collection in C is possible with libraries like libgc, but with allocppx.pl, you can just preprocess your file into generating heaps, and these heaps can be used for memory allocation. The type of GC is used, mark and sweep + reference counting. Every memory allocation MAY have a trace, and this trace can be used to ‘refget’ and ‘refunget’. Heap items that are NULL or have 0 refs are collected via mark and sweep.

The generated code is very readable, you can just look at it to get a clue. However, this Perl document is annotated with POD so you can view it in man pages etc. I have submitted an ASCII render of the manpage in Gist.

I hope you enjoy this.

#programming

threaded - newest

solrize@lemmy.world on 15 Apr 2024 09:25 next collapse

It’s cool that someone is still using perl. It’s sad that anyone is still using C. (Yes I still use it myself, but…).

ChubakPDP11@programming.dev on 16 Apr 2024 07:12 collapse

Why ‘exactly’ is it bad that people are still using C, a language with 4 decades of toolchain and library build-up, instead of a shitlang like Rust that is mainly used to create garbage webapps?

Cyberflunk@lemmy.world on 16 Apr 2024 13:18 next collapse

Rust is a “shitlang”?

Ok.

lolcatnip@reddthat.com on 16 Apr 2024 13:44 next collapse

Ooooh, luddism is so edgy!

And no, Rust is not primarily used to generate web apps, shitty or otherwise. You’re thinking of JavaScript.

ChubakPDP11@programming.dev on 16 Apr 2024 15:29 collapse

Cool, as I just said, Rust is more of a ‘fandom’ than a ‘compiler’ really, it’s also not much of a ‘language’. I use C because it’s standardized by ISO, not some basement-dwelling incels who keep RFCi’ing their ideas instead of implementing it their own.

lolcatnip@reddthat.com on 16 Apr 2024 20:24 next collapse

I’d say you’re misinformed, but it requires some real idiocy to be that badly misinformed and that deliberately insulting to a whole programming language community.

hascat@programming.dev on 16 Apr 2024 22:05 next collapse

If C is so great, why do you have to hack in garbage collection?

UlrikHD@programming.dev on 17 Apr 2024 00:18 collapse

Please refrain from using slurs and disparaging people for no good reason on our instance.

ChubakPDP11@programming.dev on 18 Apr 2024 20:47 collapse

Alright sorry. I’m just trolling people. If you go to my profile I have a lot of Rust projects. @hascat @FizzyOrange

FizzyOrange@programming.dev on 16 Apr 2024 21:24 collapse

Wow, I would love to understand what leads to such insane views. Like, did Rust kill your father or something?

I’m actually serious, why do you have such love for a bad (by modern standards) language like C and such hatred for a great language like Rust?

hardkorebob@programming.dev on 16 Apr 2024 11:38 next collapse

Man I C this Perl is so awesome! Thanks for this cool tool!

ChubakPDP11@programming.dev on 16 Apr 2024 12:41 collapse

No problem my good man. Have fun.

hardkorebob@programming.dev on 16 Apr 2024 13:48 collapse

Check out my DSL I made for Python in Shell. github.com/dislux-hapfyl/shimky I checked out all your projects on GitHub. You are a Super Programmer for sure.

ChubakPDP11@programming.dev on 16 Apr 2024 15:28 collapse

Cool. I can’t see the implementation though? Thanks a lot man. Really means a lot. @Corbin knows a lot more though. (since I called Rust a ‘shitlang’ I realize you may be ironic — Since Rust is more of a ‘fandom’ than a ‘compiler’, but I’m not going to offend you by assuming so. If you are truly giving me props, it’s really appreciated! :D )

hardkorebob@programming.dev on 16 Apr 2024 16:50 collapse

I am a n00b so I really dont have fandom. I just learning and sharing. No offense taken.

bluey@lemmy.world on 17 Apr 2024 07:22 collapse

why not glib ?

…gnome.org/…/glib-Miscellaneous-Macros.html#g-aut…

bitcrafter@programming.dev on 17 Apr 2024 11:34 collapse

Because it looks like that functionality uses special compiler functionality only available on GCC and clang?