News for hackers. Stuff that matters.
Re:A look at the J language: the fine line between genius an... by Verdex on Monday August 17, 2020 @11:00AM (#24187942)
I've learned a bunch of different languages[1], but J (and its friends APL and K) has been both the one that I don't feel I have the patience to learn AND the one that I feel like I might fall in love with if I actually learned it.

The incomprehensible programs just seem to hint that there is some sort of maximal information density where every keystroke provides maximal productivity.

There's also something artistically appealing about starting at a program and making a deliberate one character change that makes all the difference ... although on the other hand, that's kind of scary too.

Here's a video that really illustrates the power of this paradigm: https://www.youtube.com/watch?v=a9xAKttWgP4

[1] - I learned (in this approximate order): C, Java, Lua, C#, Ruby, Python, Lisp, Forth, Prolog, Clojure, OCaml, Haskell, Erlang, F#, R, Racket, and Rust. I also took a look at languages like: ATS, Cyclone, C++, Idris, Agda, D, and Perl 6. Of all those languages it really feels like APL/J/K are the strange ones.

Re:A look at the J language: the fine line between genius an... by TurboHaskal on Monday August 17, 2020 @11:46AM (#24188314)
I struggled a lot too. I think the main issue is the problem domain in which these languages excel at.

I like compilers, systems programming, distributed systems... but math? statistics? I'm admittedly terrible at that and find it really uninteresting. It doesn't help that most literature on J tries to teach its language concepts showing you how to solve math problems. I have no need for a fancy calculator.

For what it's worth, I like K and Klong and found them very approachable. Basically because you can get away by writing Scheme with m-expressions.

Re:A look at the J language: the fine line between genius an... by vchak1 on Monday August 17, 2020 @02:33PM (#24190264)
Actually, it seems that compilers is a domain that APL can potentially excel at.. https://github.com/Co-dfns/Co-dfns
Re:A look at the J language: the fine line between genius an... by ashtonkem on Monday August 17, 2020 @12:58PM (#24189104)
My general belief is that these languages would be far more useful as embedded languages; occasionally there is a need for the core of some complicated system to take advantage of their power, but the same design that makes them good at math makes them horrible for writing APIs or database access.
Re:A look at the J language: the fine line between genius an... by beagle3 on Monday August 17, 2020 @02:30PM (#24190239)
They work better than databases for accessing databases - nsl.com has examples like tables.k , a reasonably efficient in memory ordered-and-mostly-relational database in all of 14 lines of K.

And a variety of spreadsheets, from 2 to 100 lines.

They were sort-of-ok for API access, but Shakti’s FFI is actually incredibly straightforward - comparable to writing a C extern definition only much terser (‘cause it’s Arthur...)

Re:A look at the J language: the fine line between genius an... by jodrellblank on Tuesday August 18, 2020 @01:58PM (#24201921)
APL isn't always written (⊂∘⍋⌷⊢), APL has a traditional notation which is like other procedural languages:

    :If databaseResult.Rows.Count > 5
    :AndIf warnOnLargeData
        
        :For Row :In databaseResult.Rows

            logToFile 'Careful, that's a lot of data, e.g. ', Row[1]

        :EndFor
    :EndIf
and Dyalog APL is a .Net language, which has extended this style with :Namespace and :Class and :Access and :Signature ways to build objects and methods to make your API and export it as a .DLL for use by other .Net languages, or plugin to ASP.Net and make a web service[1], or accessing most things C# can[2], e.g. if you want to use a System.Collections.ArrayList it's right there:

          ⎕USING←'System' 'System.Collections'
          arr←⎕NEW ArrayList
          tmp←arr.Add ⊂'Test'
          tmp←arr.Add ⊂'Hello'
          tmp←arr.Add ⊂'World'
          arr[0 1 2]
    ┌────┬─────┬─────┐
    │Test│Hello│World│
    └────┴─────┴─────┘
          arr.RemoveAt 0
          arr[0 1]
    ┌─────┬─────┐
    │Hello│World│
    └─────┴─────┘

and that means things like System.Data.DataTable and SQL Connections for your database access. .Net isn't as popular as JavaScript and Rust, but it is a pretty large, stable, capable and established ecosystem to be able to hook into.

The core of APL symbols more or less /are/ an embedded language in the wider APL, just that wider APL is not showy for codegolf and is not unusual and pretty symbols, and you can't use it /without/ the symbols.

[1] See the examples shipped in the install folder like "C:\Program Files\Dyalog\Dyalog APL-64 18.0 Unicode\Samples\asp.net\webservices\"

[2] I expect not /everything/ C# can; C# is the first-class .Net language, but if you have things written in C# you can use them.

Re:A look at the J language: the fine line between genius an... by smabie on Monday August 17, 2020 @07:54PM (#24193691)
What makes them bad for APIs or databases? Both k and q are very practical general purpose languages (J and APL less so) that would be an appropriate choice for almost any kind of app, imo.

q especially looks mostly like a normal procedural language, and can be used like one too.

Re:A look at the J language: the fine line between genius an... by Cactus2018 on Monday August 17, 2020 @11:42AM (#24188280)
> Here's a video that really illustrates the power of this paradigm: https://www.youtube.com/watch?v=a9xAKttWgP4

Amazing game of life code!

Re:A look at the J language: the fine line between genius an... by Verdex on Monday August 17, 2020 @12:35PM (#24188841)
The first time I watched the video my response was that he was literally doing magic or that it was some sort of joke. Over time the video has become more approachable and I have a pretty good idea of what is going on. However, if I was asked to approach game of life in APL myself then I think I would still be pretty lost.
Re:A look at the J language: the fine line between genius an... by dTal on Monday August 17, 2020 @04:30PM (#24191664)
It's a kind of sleight of hand. It purports to be showing off the power of APL; what it's really showing off is the cleverness of someone who realized that the rules of Life could be expressed as a series of array operations.

APL has a kind of mystique, but all it really is is a bunch of NumPy functions with a quirky DSL (of course, APL came first and heavily inspired NumPy). But we've quietly been doing the APL experiment in the background, by pressuring programmers to avoid pure Python in favor of NumPy functions for speed, and the results are in - you can indeed push the array paradigm very far. But not quite far enough to be general and efficient.

The jury is still out on whether the quirky DSL is worth anything. My suspicion is that having names for array operators is very valuable indeed, but dedicated symbols for them much less so, and cryptic ASCII digraphs are barking completely up the wrong tree. But if you really want the weird syntax - well, it's not exactly a difficult language to parse, and Unicode is a thing now. If the notation is worthwhile, there's no real reason why any language couldn't have APL built-in as a DSL, just like regex.

Re:A look at the J language: the fine line between genius an... by lmm on Monday August 17, 2020 @07:47PM (#24193638)
Rank polymorphism is genuinely important and useful and a lot of languages are missing it.

Cryptic symbols, I agree, less so. If your language doesn't arbitrarily restrict identifiers then you can just define the APL operators as functions and write code that looks like APL - I tried doing this in Scala once, and it worked ok. But it's hard enough to convince people to take the time to learn what "map" or "filter" or "<* " does, never mind anything further in that direction.

Re:A look at the J language: the fine line between genius an... by leprechaun1066 on Monday August 17, 2020 @08:22PM (#24193925)
Lisp has April, which I thought was pretty cool. https://github.com/phantomics/april
Re:A look at the J language: the fine line between genius an... by Cactus2018 on Monday August 17, 2020 @02:04PM (#24189931)
Re:A look at the J language: the fine line between genius an... by jxy on Monday August 17, 2020 @03:19PM (#24190767)
Have you learned Chinese, Japanese or Korean? Perhaps try classical Chinese.