Comment by graboid
4 months ago
I assume that in most array languages, you also create "words" or however you want to call functions, to reuse code. I wonder about a purely aesthetic issue: how does it look to interleave those symbols with user-defined words that by nature will be much, much longer, i.e. "create-log-entry" or "calculate-estimated-revenue".
I never did any real programming in APL, but I studied it over about 2 months. When you get used to the symbols, reading spelled-out words feels like reading in slow motion, or being stuck in molasses.
Most (not all) APL code I've seen uses very short names, often one letter names, for function names. And APL programmers are famous for cataloging "idiom" which are short phrases for common subroutines. In other words, it's best practice to repeat 3- or 4- symbol phrases instead of defining a subroutine.
Of course, there's nothing about an array language that requires using symbols; but for some reason most do.
>Of course, there's nothing about an array language that requires using symbols; but for some reason most do.
The idioms become words and you read them like words, you don't step through each letter of a word when you read it, you recognize the shape. The same thing happens in APL and its ilk, any commonly used sequence is instantly understood as its function without having to parse each individual symbol and what it does.
Yes the symbols in a way are the letters of APL, and the phrases are the words.
1 reply →
> i assume that in most array languages, you also create "words" or however you want to call functions, to reuse code.
sure, that's a very useful feature, like elsewhere.
> I wonder about a purely aesthetic issue: how does it look to interleave those symbols with user-defined words that by nature will be much, much longer, i.e. "create-log-entry" or "calculate-estimated-revenue".
strictly speaking, dashes and underscores in k can't even be a part of identifier - they are core language primitives. it is very uncommon to see java-like identifiers like CalculateEstimatedRevenue, why would you want that?
to your question:
here's a bit of an oddity: all user-defined functions and core language operators can be called using functional notation:
but there is an important distinction between the two. you can't use your `add` function infix, you must call it as a function, and there are good reasons for that:
that said, mixing language primitives with function calls looks and reads just fine:
hope this helps!
How does that scale up to program that's thousands of lines? What if you have a hundred different vectors? You're not going to be calling them v1, v2, ...
So does it end up as
Or, do you just not do that sort of stuff in these languages? I'm not very familiar with them, but I have ended up with some pretty long programs using Pandas in Python.
> Or, do you just not do that sort of stuff in these languages?
i tell you more. it is very much recommended to avoid doing this sort of stuff in all languages.
no:
to produce a "factory" for well-formed spl objects is a no-brainer as well.
why we don't use v_ prefix:
very important things should have short names. locals you're immediately operating upon should have short names. short names should be used in a consistent way.
less important things can have longer names. variables in a broader scope can have longer names.
if you have a hundred different vectors, don't just dump them in a pile; put them in dictionaries, tables, namespaces, or scopes.
1 reply →
It depends on the language and the programmer.
https://github.com/mlochbaum/BQN/blob/master/vm.bqn