News for hackers. Stuff that matters.
Re:Is APL Dead? Not anymore by robomartin on Sunday May 03, 2020 @11:33AM (#23059592)
Having used APL professionally for ten years from the early 80's to early 90's I am a big fan. I used it for a wide range of applications, from business systems to DNA sequencing. I even published a paper at a conference eons ago.

So, yeah, I am an "APL guy". And, yeah, I think it's dead.

Well, not really, but, yes really at the same time.

Let's start with the most glaring issue:

https://www.dyalog.com/prices-and-licences.htm#devlicprice

Yeah, $1,600 USD for a language license? No. Thanks. Go away.

In addition to this:

"In addition to a current Developer Licence, a Run Time Licence is necessary if:"

Yeah, no. Go away.

And then...

"When several users use one or more applications on a shared server, a Server Licence is required."

No. Definitely no. Please, pretty please, with sugar on top...go away.

I could go on. Just have a look at that page and see how you could possibly justify getting into this monster of a business case for your particular business or any other business who's financials you understand.

If you are still interested after that, take a moment to go browse the source here...

Oh, wait. Yeah. No. Go away.

That said, I still do love APL. I love the language, the ideas, what it represents and the superpowers it gives you. It truly enables the creation of computational solutions for complex problems at the speed of thought once you learn to think in APL (which likely takes about a year to fully internalize).

During the 80's I often dreamed of designing a purpose built computational engine (hardware) specifically designed to execute APL commands in one clock cycle. Hey, I was young and stupid. While I was using APL I was also coding embedded systems in C and assembler. I would often wonder "wouldn't it be amazing to be able to execute this APL statement in one clock cycle, like some of these assembler instructions on this tiny little MCU?".

Anyhow, let's end this on a positive note. Here's a list of language improvements I authored a long time ago. This list isn't exhaustive (it was a five minute stream of consciousness exercise). Also, some of what's on this list might already exist in modern variants of the language. Feel free to criticize, no problem, and comment. Understand I am issuing advance notice that this is not a perfect list or even a current one.

  APL should go FOSS or adoption will forever be limited to esoteric high-ROI
  applications where it might make sense or legacy APL code already exists.
  
  The option for compilation would be very interesting.

  Within a function, variables are global by default.  Huge pain in the ass.

  Objects. Yet be careful to avoid the mess OOP can (and often does) become.

  A language-defined interface to C (or some other suitable language) for 
  when you need to speed things up.

  Inline C or Python, or both, as a first class citizen. Make it first 
  hybrid high level language.

  An extension to nested arrays that allows you to create C-like structures.
  I am going after the self-documenting nature of having structure members 
  have name-based access.

  An extension to function definition to allow for more than two arguments. 
  This would require a little language re-thinking.

  I would also look into making a hybrid that includes some C-like syntax
  with an APL core.  C/C++ -like comments and conditionals with bracketed
  groupings of APL code would go far in making code easier to read and 
  organize.

  Native C-like switch() primitive with APL-inspired extensions.  For example,
  switch could take a vector argument.

  APL-run-time-definable comparison operator.  Sometimes I want to apply a complex
  evaluation function to data rather than the simple equal, not equal, grater/less
  than, etc. operators.

  The ability to enforce data types if desired.

  A means of telling the compiler/interpreter to optimize code 
  --at the statement level-- for speed or resource (memory footprint) and 
  other criteria.  Certain operations can explode into huge multidimensional
  memory-sucking arrays which isn't always the best idea.

  Real-time extensions integrated into the language.

  Ability to use and request GPU resources for computation.

  Ability to use and request CPU cores for computation.

  A simple-minded example of the above two would be wrapping a code
  section with "CPUn{}" or "GPUn{}, where "n" is the core or GPU number.

  Standard interface for custom hardware-based acceleration (read: custom 
  FPGA boards). FPGA's are amazing, make them first class cititzens.

  True binary vectors and arrays.

  More flexibility in multidimensional array indexing.

  A rethinking of the workspace model to better support multi-developer 
  environments.

  Genetic and Evolutionary computing primitives built into the language.
  
  Neural Network primitives built into the language.
  
  Language native image processing (think OpenCV integrated right into the language as a first class citizen)
  
  Same with NumPy. APL should be able to do all of this and more.

  Built in primitives for multi-threaded/multitasked computing.

  Built in primitives for network access and processing.

  Built in primitives for multi-core and distributed computing.

  Built-in primitives for data exchange.  For example, ingest or output 
  nested array data from/to JSON, SQL, XML or other modern data formats.

  Better pattern-matching primitives.  I'm thinking at least regular 
  expressions. 

  A general cleanup of the notation to remove lame text-based "fixes" 
  from an era when rendering non-ascii characters required custom ROMs 
  on the graphics card.  All APL notation should be symbolic.  ASCII 
  should be limited to strings, function, variable, object and other 
  constructs that require text. I'm talking about a lot of the quad
  stuff, etc.

  Make it open source and make the open source version far superior to 
  any available commercial version.
    
I'll end with a slightly edited portion of one of my HN posts from about seven years ago:

One of the reasons I abandoned languages such as APL, Forth and LISP, languages that I used extensively for many, many years is that they became less and less practical and relevant.

I can apply C to nearly everything from embedded to workstations/servers and even in modern hybrids where FPGA's are integrated with capable microprocessors. I can hire people, even entire teams, both locally and around the world to work on anything from embedded to web projects in many of the the C-like languages. Trying to do the same with APL, Forth or LISP is very close to impossible (and the quality and capability choices you have are much reduced).

On the hardware front languages like Verilog are very reminiscent of C and, as long as you understand that you are actually describing hardware and not writing software, are easy to pick-up with the appropriate background.

You move up to languages such as C++ and other layers open up. PHP, Python, Objective-C when I absolutely must and Java if I have no choice.

All of these are very flexible and relevant tools that have, for the most part remained relevant and useful for years. This range of applicability will never be achieved with something like APL.

If an APL-like language is going to come to the forefront it will be for very specialized applications where it makes sense. It will not be to run a shopping cart on a website or control a servo on a robot. That's just reality.

I love APL. I devoted a huge chunk of my professional life to it. I can't see using it or the wanna-be variants for anything today. Sorry.

Re:Is APL Dead? Not anymore by gandercrews on Sunday May 03, 2020 @01:03PM (#23060268)
I tend to agree with your broader points. In my personal life I often reach for APL to do ad-hoc data analysis. It has grown on me in the last year and has fundamentally changed how I perceive and write code. However, I don't think I could introduce it to a company.

For specific points, I would love to see an APL dialect that adopts parts of J, K & haskell. Something that retains the symbolic notation, that provides a deeper & more fluid interface to asm/C, adds some ALGOL-like control-flow constructs, and takes advantage of the intervening decades of programming theory.

APL to me is an alternate history of what programming could have been. Its not perfect by any means, but it boldly challenges assumptions about what it means to communicate mathematical thought. It was ahead of its time, and its unfortunate its taken this long for languages to superficially adopt its insights.

PS: gnu apl is a great FOSS implementation that is enjoyable to use and rich in features.

Re:Is APL Dead? Not anymore by teleforce on Monday May 04, 2020 @07:16PM (#23074498)
Hi Martin, thanks for sharing your insightful comments and the improvements list. I think if anyone can do that, the impact will be probably nothing less than the impact of introduction of spreadsheet to do PC industry, and arguably it is still the killer computer application to beat until today.

Just sharing about the improvements of array based programming language from the academia inspired by APL. Two of the most promosing approaches are the Single Assignment C (SAC) from Hertfordshire University, UK (proprietary) and Furthark from Copenhagen University, Denmark (open source). SAC try to the introduce better syntax (as in Algol C) for functional programming array based language with concurrent multi-core CPU support. Furthark also try to better the syntax for programming array language for GPU parallelism by being the more intuitive intermediate language.

From non academic, I would say the closest to your improvements list will be the D programming language. Unlike Python and NumPy, where there is a clunky impedance mismatched, using D it is feasible to create a seamless array based integration by virtue of its CTFE and metaprogramming capabilities including native support for object oriented, imperative and functional programming paradigm. For initial work check the Mir GLAS library for the native D implementation where it has managed to outperform the venerable BLAS/LAPACK Fortran based linear algebra library where normally Python or other programming languages depend on [1].

Additionally D also support native nested functions that can be handy for processing nested multi-dimensional arrays.

I have got the feeling that for seamless CPU, GPU, FPGA and TPU programming integration, there will be based on the Static Single Assignment (SSA) form that is currently being proposed independently by MLIR (from LLVM team) and LLHD (from ETH Zurich). If you have noticed that the SAC is also utilizing this compilation technique as well.

[1] http://blog.mir.dlang.io/glas/benchmark/openblas/2016/09/23/...

Re:Is APL Dead? Not anymore by robomartin on Tuesday May 05, 2020 @02:10AM (#23077025)
Thanks for the comment. I'll look into the items you suggested and see what I can learn.

My perspective on APL going forward is that it must retain symbolic notation. This is a very important element of the value delivered by this language and one of the aspects that tends to be difficult for non-APL-ers to understand (the value) from what amounts to casual contact with the language. You have to live APL for a while before the "tool for though" realization --and the importance of the symbols-- can be understood.

In the '90's Iverson developed J to get around the difficulties technology of the era had with symbols. This was a huge mistake and something that went exactly opposite the "Notation as a tool for thought" idea he promoted for years when describing APL. I watched him give this lecture in person at one of the APL conferences in the mid 80's.

The problem with any language --APL being no exception-- is that a business case must exist for wide adoption. Engineers tend to get lost in the technical minutiae, which is important when you are doing the job but it isn't a requirement for the job to be done. Or put more precisely: IF there is no quantifiable need for APL and a mechanism for better ROI, it is hard to justify shifting entire teams to this, or any other language, simply because we like the technical aspects of it.

At the end of the day things are simple: It either makes sense or it does not. I would LOVE for APL to become relevant again and for it to find mass adoption. I love the language. And yet I understand business and know the probability of this happening is so close to zero it might as well be zero. Sadly.

Re:Is APL Dead? Not anymore by abrudz on Sunday May 03, 2020 @03:47PM (#23061350)
> Having used APL professionally for ten years from the early 80's to early 90's

That might be part of problem. Things have happened since then:

Dyalog has made the full product available for free, only asking for 2% of any profit you make once you cross a certain threshold. Open-sourcing the interpreter is under consideration.

Dyalog has a built-in compiler.

Dyalog's new function form, dfns, has variables local by default.

Dyalog has fully integrated C#-style OO system.

Dyalog has ⎕NA for seamlessly calling C functions as if they were APL functions.

Names Associated (⎕NA) C functions can be called inline

Dyalog namespaces are objects that are not class-based, but with named members

Dyalog's tradfns allow name-lists for multiple required arguments (and results)

True, there are no multi-line comments in any APL yet, but Dyalog allows writing {condition : result if true ⋄ result if false}

Dyalog has :Select which is similar to switch but allows case-lists.

I'm not sure what you mean by "APL-run-time-definable comparison operator", but any function can be used in place of the built-in ones. (This wasn't always the case, but certainly is now.

It is quite easy to check for the data type of given input, e.g. using the Data Representation function (⎕DR).

Putting the statement in a named function allows you to compile it separately from the surrounding code.

Right, no real-time extensions integrated into the language.

The co-dfns library allows you to offload computations to the GPU.

Dyalog's 1111⌶ allows you to select how many cores to use.

Right, no built-in interface for custom hardware-based acceleration

Dyalog's binary arrays use true bit-binary representation.

Dyalog's at operator @ and the index function ⌷ combined with the rank operator ⍤ provide full control over and flexibility in multidimensional array indexing.

Dyalog has supported SCM monitored text files for many years, and the built-in tools are only getting better and better.

Not sure what you have in mind with regards "Genetic and Evolutionary computing primitives built into the language."

The stencil operator ⌺ is a Neural Network/Cellular Automaton primitive built into the language.

Dyalog has some native support for image manipulation, has various libraries too, and deep integration with .NET.

Much of NumPy is of course APL breakfast, and there are math libraries for certain other things. In the worst case, use PynAPL to call Python.

Dyalog has the spawn operator & for multi-threaded/multitasked computing.

I'm not sure network access and processing would be suitable as primitives with glyphs, but Dyalog's Conga library provides this, and may well get further integrated into the interpreter in the future.

Dyalog's multi-core and distributed computing primitives are currently accessed with cover functions, but the ¤ and ∥ symbols have been reserved already.

Built-in primitives for data exchange? ⎕JSON, SQAPL, and ⎕XML etc.

Dyalog's ⎕R and ⎕S provide Perl-compatible regular expressions.

I'm not so sure all quad names should have symbols. Many of them have related or prefixed names, e.g. ⎕Nxyz for file functions and ⎕Txyz for thread-handling. That said, plenty of new Unicode symbols have been added lately.

Re:Is APL Dead? Not anymore by robomartin on Sunday May 03, 2020 @05:24PM (#23061967)
> That might be part of problem. Things have happened since then

Of course.

> Dyalog has made the full product available for free, only asking for 2% of any profit you make once you cross a certain threshold.

Not good. People will pay for tools, not languages.

If Dyalog wants "APL for all" make it FOSS and support it with tools, etc.

I realize there's a business and, behind it, people and families to support. I get it. That said, today's reality is that large scale adoption of languages requires FOSS.

Put a different way: People are not going to bet the farm on a language that is fully dependent on a single company for it's very survival and existence.

I have a simple example of this. In the 80's there was STSC APL. I used it extensively. In fact, I used STSC APL for my work in DNA sequencing during the human genome project.

They evaporated from the planet. I hope the code-base got picked-up by someone. I haven't followed the ecosystem as closely as I used to back when I was attending meetings with the likes of Ken Iverson.

From my perspective, if Dyalog wants to propose "APL for all" and be the leader in this domain --have their flavor of APL become the standard-- they have to let go. How they mutate their business in order to make that happen is another question...and it could be an impossible task.

Not saying I have all the answers. All I know that as an APL guy it would take a major change in the APL community to get me interested in risking my business on the language.

The simple fact is that, as much as I love the feeling of programming in APL (it's like playing music, your thoughts become code) I am mature and experienced enough in both technology and business to understand that business and technology decision need to be made as objectively as possible. This is why, as an example, I am happy to pay JetBrains license fees for their excellent tools rather than screw around with vim and the deep dark organizational hole that shit can become.

One of the interesting items to note about your reply (which is excellent and this is not a dig) is that it is 99% features and 1% benefits or business.

This is how we engineers tend to relate to the world. I was the same until multiple encounters with entrepreneurship forced me to understand nobody gives a crap about features, not because they don't care, but rather due to the reality that their forcing function isn't feature-based but rather benefit or value based.

You can deliver tons of value and benefits with any language. Just look at the myriad large, medium and small companies out there delivering such value in the internet ecosystem, from consumer to industrial, as evidence.

Another way to put it is: Nobody needs APL to deliver value. Sure, maybe a few corner cases here an there. OK. Outside of that, nobody is clamoring for it. That means the road to promoting scale adoption is incredibly steep, if not impossible, to climb.

No, APL is dead, sadly. Again, I say this as an APL guy.

I still think it should be taught in school, along with Forth and LISP. Beyond that, who knows?

BTW, I continue to be puzzled by how often APL threads make it to page one on HN. Not sure what it means, other than it is an interesting curiosity.