3 ms·
Is this supposed to be a specific coding style or paradigm? I’ve never seen code written like this in real-world projects — maybe except for things like the "b
by romperstomper 11mo ago
Is this supposed to be a specific coding style or paradigm?
I’ve never seen code written like this in real-world projects — maybe except for things like the "business card ray tracer". When I checked out Arthur Whitney’s Wikipedia page I noticed he also made the J programming language (which is open source) and the code there has that same super-dense style https://github.com/jsoftware/jsource/blob/master/jsrc/j.c https://github.com/jsoftware/jsource/blob/master/jsrc/j.c
- rcxdude 11mo agoIt's similar to J and that family of languages (K is another). Those are inspired by APL, which also has this super compact nature but in addition it largely uses non-ascii symbols. Apparently it is something you can get used to and notionally has some advantages (extreme density means you can see 'more' of the program on a given page, for example, and you need fewer layers of abstraction).
- tom_ 11mo agoPossibly related(ish): video about co-dfns, prompted by a previous HN thread (links in video summary), not written in C but put together in a similarly dense style: https://www.youtube.com/watch?v=gcUWTa16Jc0 https://www.youtube.com/watch?v=gcUWTa16Jc0
- jacquesm 11mo ago> I’ve never seen code written like this in real-world projects Lucky you. I've seen far worse (at least this is somewhat consistent). But this isn't C anymore, it is a new language built on top of C and then a program written in that language. C is merely the first stage compilation target.
- taneq 11mo agoAnd everyone says you can't do DSLs in boring old languages. :P
- rbanffy 11mo agoYou can certainly do DSLs in C. That’s what SystemC is.
- robotresearcher 11mo agoIIRC, C++ started out this way, or at least its precursor ‘C with classes’. A compiler came later.
- leoc 11mo agoI believe it’s usually referred to as ‘OCC’. ;)
- romperstomper 11mo agoCould you elaborate? :) I found OrangeC Compiler but I'm not sure this is the OCC you've mentioned.
- leoc 11mo agoI’m sorry, I was just making a silly https://en.wikipedia.org/wiki/International_Obfuscated_C_Code_Contest https://en.wikipedia.org/wiki/International_Obfuscated_C_Cod... joke.
- romperstomper 11mo agoAh, that's cool! Thanks!
- leoc 11mo agoThere's C which complies with the MISRA C standards, and there's C which complies with the IOCCC C standards. (There may also be some overlap.)
- susam 11mo ago> Is this supposed to be a specific coding style or paradigm? This is indeed Whitney's distinctive coding style, well known for its use in his various array programming language interpreters. His coding style is famously minimalist and idiosyncratic often fitting entire implementations of interpreters in a few pages. This has been discussed a number of times on HN. I have collected some of the interesting comments on this topic from previous threads here in this meta comment: https://news.ycombinator.com/item?id=45800777#45805346 https://news.ycombinator.com/item?id=45800777#45805346
- romperstomper 11mo agoThanks! I can't imagine how to code in this style everyday, tbh :)
- shawn_w 11mo agoI imagine that if you do it enough it starts to become second nature.