4 ms·
Let's Destroy C
- moralestapia 2y agoFunny how the shittier it becomes the more it starts resembling some languages out there.
- tempodox 2y agoLet's see you write a non-shitty language.
- moralestapia 2y ago??? I have no interest in that at the moment.
- st_goliath 2y agoIn summary: someone with a GitHub account discovered that you can hijack the C pre-processor (give or take some GNU language extensions) to transpile BASIC/PASCAL/ALGOL like languages to C. They call their macro collection "evil" and ramble about destroying C, trying to create some form of mystique I guess. The idea by itself is nothing new and pretty much any novice C programmer eventually stumbles across it. Famously, the original Bourne Shell was written in a variant of ALGOL68, fed through a C compiler using macro based translation[1][2], which helped spark the idea for the IOCCC[2]. [1] https://en.wikipedia.org/wiki/Bourne_shell#History https://en.wikipedia.org/wiki/Bourne_shell#History [2] https://en.wikipedia.org/wiki/International_Obfuscated_C_Code_Contest#History https://en.wikipedia.org/wiki/International_Obfuscated_C_Cod...
- deleted 2y ago[deleted]
- tpmoney 2y ago>They call their macro collection "evil" and ramble about destroying C, trying to create some form of mystique I guess. It read to me more like a tongue in cheek statement in the same way that a car enthusiast might joke that they're about to destroy a Honda Civic by putting in a V8 engine and installing a body kit.
- shakna 2y agoYeah, it was just some fun. It's 'evil' because it should never be used for business. And yes, Bournegol was an inspiration and I mention it in a few places on the gist. I did also take it too far and wrapped it with tcc [0] into a "language". [0] https://git.sr.ht/~shakna/ogw https://git.sr.ht/~shakna/ogw
- musicale 2y agoCrazed hacker DESTROYS C language on github! If there were a novelty requirement to push to github (or to publish on HN for that matter) it would be much less fun. On the other hand, it is also fun to hear about the history. Personally I always enjoy abusing the C preprocessor for fun and profit. Just yesterday I was contemplating the potential amusement of using cpp (and cc) to generate custom assemblers, customized assembly language syntax, and assembly language interpreters.
- adastra22 2y agoCombine this with the sum types header library that is floating about, and it’s not a half-bad language.
- fanf2 2y agoThe coroutine hack is basically the same as Simon Tatham’s https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html Simon’s description dates from 2003 https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=9890c7a57a12c3c611ee0396474604e540a65dd3 https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=9... And it has been used in PuTTY since before the start of its version control history in 1999. And if you don’t like curly braces, Bournegol has been a thing since the 7th Edition unix shell in the 1970s https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh/mac.h https://www.tuhs.org/cgi-bin/utree.pl?file=V7/usr/src/cmd/sh...
- diggan 2y ago> Can we turn C into a new language? Can we do what Lisp and Forth let the over-eager programmer do, but in C? Show me an example where you turn the syntax into prefix notation instead, so turning the hello world example into (or something similar): (def main (displayln "Hello, World!")) Then I'll believe you :) Otherwise it just looks like another flavor of C
- musicale 2y agoHere you go: #include <stdio.h> #define print(_f) puts(_f); } #define Cdisplayln print(( #define Cdef int #define main main(){ Cdef main Cdisplayln "Hello, World!")) [For a non-joke approach (not mine) see: https://github.com/kchanqvq/CSP https://github.com/kchanqvq/CSP ]
- deleted 2y ago[deleted]
- EternalFury 2y agoLLMs are going to get a headache with that repo.
- tempodox 2y agoNah, they'll just hallucinate something and sound really authoritative about it.
- deleted 2y ago[deleted]
- smrq 2y agoHeh, I know that coroutine hack! The intro-to-C-and-ARM undergrad course at Indiana University used it for one of the lab assignments, at least in the late 2000s. It was clearly enough of a WTF that I remember it well, this many years later...