Hacker News new | ask | show | jobs
by ogogmad 2009 days ago
How does using APL/J/K compare to using Julia, Numpy or Matlab? The fact that in the latter you still have the safety blanket of procedural programming makes it seem easier to learn and more productive.
2 comments

Control flow in APLs is mostly imperative, and with explicit code, /i.e./ code that mentions variables, you're effectively writing procedural code. I'd say that APLs are harder to get started with, but easier to use right. With things such as Numpy, you need to know lots of things about the API that might change without warning. With APL, you learn the primitives and you're off to the races. The downside is that less popularity means far fewer library efforts.
Dyalog APL has a safety blanket of procedural programming[1], it's another strange aspect of APL and the internet that it seems almost completely overlooked - unremarked upon and never discussed. e.g. this is roughly a prompt-for-username and validate-username code:

    ∇result←verifyUserName userName

     isValid←1
     message←''

     :If (userName≡'')∨(8<≢userName)
         message←⊂'Please enter a name between 1 and 8 characters long'
         isValid←0
     :ElseIf ' ' ∊ userName
         message←⊂'Please enter a name with no spaces'
         isValid←0
     :EndIf
    ∇result←isValid message



    ∇userName←getUserName
  
      nl←⎕UCS 13 10   ⍝ carriage return, newline
  
      :Repeat
          ⍞←'Enter a username: ',nl
          newName←⍞       ⍝ Read from keyboard input
      
          nameIsValid message←verifyUserName newName
      
          :If 0≡nameIsValid
              ⍞←message
          :EndIf
      
      :Until 1≡nameIsValid
    ∇userName←newName

It's unexciting compared to the dense showoffy codegolf APL which is normally posted on the internet, and what you still don't get with it is things like `string.Length` or `or` or `Console.WriteLine()` etc. That is, procedural/imperative APL looks like APL and doesn't save you from having to know APL symbols or execution model. But it could save you from having to wrangle some weird mathematical dodge around a simple :If/:Else branch or trying to use ⍣ when you really just want to write :For i :In 2 4 6 8 10

It has an OOP/Class system as well, but that doesn't save you from having to know APL either.

[1] I don't think NARS2000 does, and I'm not sure about the bigger IBM / Sharp APLs. I don't think J or K have.