4 ms·
I remember a year or two ago I was struggling with an AoC problem, and the best I could come up with in Python was a one or two hundred line program. Then I sa
by pmoriarty 7y ago
I remember a year or two ago I was struggling with an AoC problem, and the best I could come up with in Python was a one or two hundred line program. Then I saw an answer for it in about 20 characters of J. That was impressive, though I do still wonder how readable the language is in practical every day programming, as opposed to toy problems in a programming contest.
- icen 7y agoI can't speak to j, but using q, its cousin, at work looks quite a lot more like the graph APL posted above. It's spread out over several lines, and heavily commented. Most problems are also much simpler, and don't require any heavy one-liners.
- kick 7y agoFor readers who are unaware of what q is, it's a language on top of Arthur Whitney's k, made to be accessible to your average human, and mostly for SQL queries. I don't think Arthur is as passionate about it as he is k, and he barely has anything posted on it. It's great in some ways but usually lags behind k for people familiar with array languages.
- kick 7y agoJ is incredibly readable. For example, here's an (old) implementation of 2048 in it that's fairly small: https://github.com/tikkanz/2048 https://github.com/tikkanz/2048
- gmfawcett 7y agoTrue. I'm not sure how I'd feel about maintaining a 2,000+ line J codebase. It definitely feels like a "programming-in-the-small" kind of language. It is impressive how much logic you can fit into so few characters. Even other terse languages (e.g. Haskell) seem wordy in comparison. Of course this is especially true when the problem has a fairly natural array representation, and that might not be true for many real-world problems. I haven't tried it, but I feel that a literate-programming style might work well for J. The code itself is very dense, so I think it might work well to have a long-ish, plain-text explanatory document with bits of J interspersed throughout it.
- chongli 7y agoPerhaps the approach to maintaining a large codebase of terse code (such as J) is to keep the files very small and narrow in focus. This could end up very similar to a Unix userland code tree. Of course, lots of documentation could also help. Maybe a style similar to R/Python notebooks would work.
- gmfawcett 7y agoThat's an interesting point. I wonder if the small, focused approach is (or was) common in professional APL/J/K development. It turns out that there is a Jupyter notebook implementation for J [1]. I might play with that! I suspect that you're right, notebooks would be a good fit for terse languages. [1] https://code.jsoftware.com/wiki/Guides/Jupyter https://code.jsoftware.com/wiki/Guides/Jupyter