News for hackers. Stuff that matters.
Re:BQN: An APL Variant from Marshall Lochbaum by mlochbaum on Saturday August 15, 2020 @08:27AM (#24168392)
That's me! It's a pretty exciting time for BQN because I've just put the self-hosted version online where you can try it out. In addition to exploring a lot of new APL ideas[0], BQN is also a test of the Co-dfns[1] approach to compilation, meaning that with an appropriate runtime the entire bytecode compiler could be run in parallel on a GPU. It's still in proof-of-concept stage, so that the online compiler is very slow and one running on dzaima/BQN, another implementation, compiles only about as fast as Go despite having a lot less features. However, having written several thousand lines of BQN I'm very happy with the language's fundamentals, and I feel it's a big advance over APL or J.

[0] https://mlochbaum.github.io/BQN/doc/index.html

[1] https://mlochbaum.github.io/BQN/implementation/codfns.html

Re:BQN: An APL Variant from Marshall Lochbaum by zerker2000 on Saturday August 15, 2020 @06:02PM (#24172809)
I've always been curious one decision pervading various APL: what are the relative merits of right to left evaluation order, vs more conventional left-to-right method chains? The core principles are incredibly elegant, but I must admit hitting "expressions are executed right to left, except if you hit a {} lambda, wherein separate statements are ordered left to right, but are themselves expressions going right to left again" is always kind of jarring.
Re:BQN: An APL Variant from Marshall Lochbaum by mlochbaum on Saturday August 15, 2020 @06:13PM (#24172881)
For left-to-right execution, the dissonance between execution and statement separators (including functions and list notation) is very bad as you note.[0] For right-to-left execution, assignment has a similar problem: the name really needs to be on the left to allow easily scanning definitions, but this conflicts with the evaluation order. Particularly statements with multiple assignments in them don't work at all. Right-to-left is usually framed as a more "declarative" or "functional" style (and note that application and composition of mathematical functions follows this order) while left-to-right is considered "imperative".

In my first major language, I,[1] I did change to a left-to-right order. For BQN, which is intended to stick much closer to traditional APL, I didn't want to make such a large break from the methods that have worked in the past. I do think I'll introduce some mechanism like a "pipe" that goes in statement order so that longer chains of functions and operators can be built up without such a discontinuous reading order.

[0] https://mlochbaum.github.io/BQN/problems.html#right-to-left-...

[1] https://github.com/mlochbaum/ILanguage

Re:BQN: An APL Variant from Marshall Lochbaum by zerker2000 on Saturday August 15, 2020 @07:51PM (#24173496)
> Parentheses may be used to specify the order, but there's a (usually) better way as well: whitespace! Fewer spaces means the function will be executed earlier.

Oh man, that is a fascinating idea I've played around with some, glad someone's put it more seriously into practice.

Re: assignments, Aaron sure seems to sprinkle them liberally inside lines - though not generally ones referenced in subsequent ones, to be fair. (I suppose another notable attribute of the co-dfns codebase is extensive use of ⊣ as a leftwards statement separator)

Mathematical functions are prefix, which imo is much harder to follow than either infix (OO/APL) or suffix (RPN/Forth), though this may be more of an english-speaking intuition than some manner of universal truth. I do at least observe a trend towards "imperative but functionally pure / side-effect isolated" in recent language design.

Re:BQN: An APL Variant from Marshall Lochbaum by zerker2000 on Saturday August 15, 2020 @09:13PM (#24173942)
Ah, I see ILang deals with the issue by… not having a name binding primitive, making you SKI-calculus your arguments into place. (Compare the piles of roll-swap-dup you get in varless forth dialects, though not as bad due to there being two directions args are passed in from.)

I suspect there is room here for an unprincipled "preceding word/pattern is defined by the following line/s" loose-binding operator, to restore skimability, and a separate inline destructuring let form that cannot leak out of lexical scope. Which I suppose would warrant lambdas - perhaps with ⍺ ⍺⍺ ⍺⍺⍺ to denote enclosing function input, rather than argument/operand/hyperand, though nonconcrete functions would stress the type system as is

Re:BQN: An APL Variant from Marshall Lochbaum by mlochbaum on Saturday August 15, 2020 @10:06PM (#24174235)
It does have : for assignment, although there's no scoping, and you have to assign to symbols that are surrounded in single quotes. You can see some examples at https://github.com/mlochbaum/ILanguage/blob/master/examples/... . They need extra parens, since : is an ordinary function and has the symbol on the left. Your overall point is right; I didn't really try to address any issues with assignment. And of course there are lots of things to try, and I hope some of them make it into some other language I design!
Re:BQN: An APL Variant from Marshall Lochbaum by 082349872349872 on Sunday August 16, 2020 @05:26AM (#24176412)
I think it's history: in the 1960's, machines were strongly card (or at least line) oriented, so pure right to left intracard yields a very small "parser" compatible with traditional mathematical notation, and the unavoidable intercard transitions become top to bottom on a teletype.

(FWIW in my array noodling, the equivalent of dfns are given in the haskell style of "expr where defs" instead of the strictly temporal "let defs in expr", which does result in a consistent right to left for those who wish to read bottom-up.)

Re:BQN: An APL Variant from Marshall Lochbaum by pritambaral on Saturday August 15, 2020 @05:18PM (#24172488)
Just curious: were you aiming for a ROT1'd name?
Re:BQN: An APL Variant from Marshall Lochbaum by mlochbaum on Saturday August 15, 2020 @05:58PM (#24172773)
I spent about an hour believing I'd succeeded; by that time I'd come up with the long form "Big Questions Notation" and realized the pun on "bacon" (paralleling APL and "apple"), so I certainly didn't want to correct the mistake.
Re:BQN: An APL Variant from Marshall Lochbaum by rmetzler on Sunday August 16, 2020 @06:05AM (#24176581)
The default program on https://mlochbaum.github.io/BQN/try.html returns an error on mobile safari.
Re:BQN: An APL Variant from Marshall Lochbaum by ludsan on Sunday August 16, 2020 @08:38AM (#24177259)
Lovely to see. Congratulations on all the effort you put in. I see, from the github README, that BQN supports trains. I'm curious how far you go with this? Monadic and dyadic forks and hooks à la J?
Re:BQN: An APL Variant from Marshall Lochbaum by mlochbaum on Sunday August 16, 2020 @08:50AM (#24177323)
BQN uses the 2-modifiers ⊸⟜ for hooks and, because data values (numbers, characters, and arrays) apply as constant functions, to bind arguments to functions. I find them very flexible and intuitive and would say they're one of its best features. For example, F⊸G⟜H is the function that applies F to its left argument, H to its right, and then G to the results together.

As in Dyalog APL (and subsequently NARS2000, ngn/apl, and dzaima/APL), BQN uses the two-train for simple composition, so that (F G) applies F to the result of G. The "nothing" indicator · allows a function's left argument to be omitted and can accomplist the same thing: (·F G) is another way to write that 2-train, and can be part of a longer train with more functions to the left. So it functions like J's Cap, but also works outside of trains.

Re:BQN: An APL Variant from Marshall Lochbaum by andrewnc on Saturday August 15, 2020 @05:24PM (#24172536)
I am a HUGE fan of J, so having new sibling languages is very exciting to me.

I look forward to giving this a try :)