4 ms·
In my experience the APL family of languages are extremely hostile to the kind of exploratory coding that people would do in e.g. Python, JS or even C. You do
by aaaaaaaaaab 8y ago
In my experience the APL family of languages are extremely hostile to the kind of exploratory coding that people would do in e.g. Python, JS or even C.
You do APL like you do mathematics: sit down with pen & paper and think. And yes, many times it’s hit-n-miss, and someone walking by will tell you how it’s trivial with technique X you were unaware of. But again, this is how people do maths too: Maxwell’s original set of equations for electromagnetism were 20 differential equations, and it was later that Heaviside came by and rewrote it in its concise vector form we all know. (And those four equations can still be simplified to a single equation via geometric algebra! https://en.m.wikipedia.org/wiki/Mathematical_descriptions_of_the_electromagnetic_field https://en.m.wikipedia.org/wiki/Mathematical_descriptions_of... )
- olzd 8y agoI disagree: it's not that hard to gradually get to a solution via the REPL.
- eggy 8y agoThis. The REPL allows you to incrementally discover the way to do it, and all the while you are exercising the language. You learn the other primitives quickly in the mistakes you make, so its all productive. Soon you know how to do certain things for future problems, and you just use these up to the next level.
- bordercases 8y agoIt's also not a characteristic specific to APL, it's specific to REPL languages.
- eggy 8y agoI know especially as an old Lisper, however, J's succinctness allows you to fit a lot on a one-line REPL idea. No blocks, curly braces, or indents like when using other languages' REPLs. Also a simple backspace, and you've deleted a noun, and one character or two, and you're creating a lot more than full words in other PLs. Tools for Thought by Ken Iverson, like using math symbols, but on a REPL.
- andrewflnr 8y ago> And yes, many times it’s hit-n-miss, and someone walking by will tell you how it’s trivial with technique X Substitute X/REPL.
- ken 8y agoI've played around with APL a bit, and I agree that it's not that hard to gradually get to a solution in the repl, but... The problem I have is that when I gradually get to a solution in Lisp/Ruby/Python, I end up with something which is also close to lots of other problems I want to solve (or that my manager or users ask for). In solving the problem, I've naturally built up tools for that entire problem space. In APL, I end up building a solution which is not at all close to other problems I might want to solve. I'll take an identity, flip this, zip it with that other array, reduce it with this function, and then poof, the final step slides all the puzzle pieces together and it's perfect (and only 17 characters!), but only for that problem exactly as stated. When I get a request for something slightly different, I almost have to start from scratch. I assume this is what the "beautiful diamond" / "ball of mud" dichotomy referred to.
- olzd 8y ago> When I get a request for something slightly different, I almost have to start from scratch. You don't really start from scratch though (at least I don't): most of the time you can reuse idioms with minimal adaptation.
- sheepmullet 8y ago> When I get a request for something slightly different, I almost have to start from scratch. Do you start over from scratch in terms of your mental model or just in terms of the actual code? I’ve found using APL helps me to generalize a problem but the underlying code will often look very different. I have found I waste a lot of time in other languages trying to re-use components that aren’t necessarily a good fit just because I have already written them.
- girvo 8y agoYour last point is something I fight my hardest to avoid. It’s hard, though, but leaning on small generic functional primitives and building solutions through those has helped a lot (see: Ramda, fp-ts, and others)
- 3rdAccount 8y agoYou can do APL with pen and pencil (or stylistic calligraphy with fountain pens like the APL god Aaron Hsu), but the REPL is great. I was able to easily and incrementally build up a solution with the tryapl.org REPL.
- geocar 8y agoWhat exactly is your experience in the APL family of languages? My experience is the exact opposite. A few years ago when I taught someone enough K (an APLish language) to explore a data-related problem and documented it here[1]. [1]: https://news.ycombinator.com/item?id=9122299 https://news.ycombinator.com/item?id=9122299 And for what it's worth, I don't do mathematics. I write software.
- avmich 8y agoYeah, I also disagree. My J projects include a lot of explorations in REPL - get this snippet to work, add some more, make sure it does what you need, refactor in a bigger primitive... repeat. You do think - but you also do a lot of experimenting in form of running pieces of code in the REPL.