Remix.run Logo
romperstomper 3 days 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

susam 3 days ago | parent | next [-]

> 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

romperstomper 2 days ago | parent [-]

Thanks! I can't imagine how to code in this style everyday, tbh :)

shawn_w 2 days ago | parent [-]

I imagine that if you do it enough it starts to become second nature.

jacquesm 3 days ago | parent | prev | next [-]

> 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.

robotresearcher 2 days ago | parent | next [-]

IIRC, C++ started out this way, or at least its precursor ‘C with classes’. A compiler came later.

taneq 2 days ago | parent | prev [-]

And everyone says you can't do DSLs in boring old languages. :P

rbanffy 2 days ago | parent [-]

You can certainly do DSLs in C. That’s what SystemC is.

rcxdude 3 days ago | parent | prev | next [-]

It'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_ 3 days ago | parent | prev | next [-]

Possibly 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

leoc 3 days ago | parent | prev [-]

I believe it’s usually referred to as ‘OCC’. ;)

romperstomper 2 days ago | parent [-]

Could you elaborate? :) I found OrangeC Compiler but I'm not sure this is the OCC you've mentioned.

leoc 2 days ago | parent [-]

I’m sorry, I was just making a silly https://en.wikipedia.org/wiki/International_Obfuscated_C_Cod... joke.

romperstomper 2 days ago | parent [-]

Ah, that's cool! Thanks!

leoc 2 days ago | parent [-]

There'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.)