3 ms·
This is actually very standard syntax for array languages. Precedence rules may be uncommon, but extremely simple: right to left, that's all; and finding the me
by yiyus 7y ago
This is actually very standard syntax for array languages. Precedence rules may be uncommon, but extremely simple: right to left, that's all; and finding the meaning of each symbol just requires checking in a table. In your c-style example, you are actually using different precedence for each operation (is it (x -> ...) == 1 or x -> (... == 1)?), you have symbols like the dot which mean different things depending on context, a function of two arguments like % works totally different to another one (map), and so on.
The only reason you find the c-style version simpler is because that's what you are used to. But while you have been able to interpret the Klong expression with no experience at all, ask yourself if someone familiar with array languages (and only array languages) would be able to understand the c-style version in a few minutes without having to read an extensive tutorial.
I do not agree simplicity is in the eyes of the beholder. If a language can be totally specified by a few paragraphs and a table, it is simpler than a language that needs a long specification. However, this does not mean the simpler language is simpler to use. That, indeed, is a subjective matter.
- e12e 7y ago> The only reason you find the c-style version simpler is because that's what you are used to. Well, yes. But we're taught infix notation early (x+y), and function application quite early too (y=f(x) - and in combiation (also note short-hand eliding multiplication): f(x) = 2x + 1). I still find array languages to be too dense for me - but I do understand that they are simple from a certain point of view.
- smabie 7y agoI did too, but just try them out for a week, you’ll love it. Moreover array based language like Q do have infix notation. f(x)=2x+1 In Q is f:{1+2*x} You could call it with: f 5 or f[5]. It’s really not any different.
- e12e 7y agoHm, I could see myself playing with it - but I'm not quite seeing how I'd fit it into my day job. I do occasionally work with some simple aggregation and filtering - but usually in an sql db - and barring embedding an array language, I'd have to fetch all the data into eg: klong first, then process. It's hard to imagine a scenario where that would make sense. Otoh, I'm still considering working through advent of code - such domains should be well suited, I guess.
- smabie 7y agoIf you're writing business logic, I'm not sure how helpful array-based languages are. The code would look very similar to a normal language, but without the classes or methods or objects. For advent of code, it really shines though. Read in some big chunk of data, do a bunch of matrix and list operations to get the answer.
- e12e 7y agoReally like the introduction by the way, it reads better than most I've read on apl/k - with a suitable mix of motivation and explanation - and not too much "pride" (like, lisp pride, or apl pride, where authors cannot imagine any reason why other languages exist. Seems especially common when run-times are written in such a language; namely C...). To be clear, a little language pride is always warranted :-) Other than that, I find it a bit funny that the factorial function is singled out as an example of why naming (short) functions are redundant - seeing as how it's one of the first "complex" functions/operands thaught/named in mathematics, and heavily used to shorten notation for for example combinatorics (that is "n!"). But I think this just reflects on the (for me) somewhat alien culture of array languages - its not wrong, but it is different.