6 ms·
Several people here are questioning the utility and/or the comprehensibility of this. I'm no expert on array languages -- I've played with J and solved maybe a
by gcanyon 3y ago
Several people here are questioning the utility and/or the comprehensibility of this. I'm no expert on array languages -- I've played with J and solved maybe a few dozen project Euler problems with it, but here's my take:
1. Array languages aren't well suited to *every* problem.
2. They *are* ridiculously capable for many types of problem.
3. The people using array languages are generally insanely smart.
4. Learning how array languages work is a steep challenge. As shown in the linked article, it's possible to write "procedural" code in an array language, and that is a Very Bad Thing. It's like using a screwdriver as a hammer.
5. In particular, understanding how tacit programming works is an awesome mind-expander
6. Likewise when you internalize verb trains
7. Likewise when you realize how array-based languages handle *any* dimension array.
8. Likewise when you comprehend how "under" works
9. Likewise when you understand how function exponents work
There are many other awesome aspects of array languages; the above are just a few.
- deleted 3y ago[deleted]
- zozbot234 3y agoTacit programming is not unique to array languages, many FP and FP-like languages support it. Generally array programming languages will be a bit terser if you're working in problem domains that are idiomatic for the language, but FP languages can be more general and extensible. The "people using these languages are so smart" attitude is often criticized as it can devolve into gatekeeping, but at least FP communities make somewhat of an attempt to be friendly to outsiders.
- rak1507 3y agoFWIW I think array language communities are generally very friendly and helpful too. Not many programming languages/companies employ people to help people in chatrooms.
- mlochbaum 3y agoComplain about the language or documentation, but array language communities are absolutely friendly to outsiders! This tutorial lists some active forums, give them a try: https://github.com/razetime/ngn-k-tutorial/tree/main?tab=readme-ov-file#how-to-use-this-tutorial https://github.com/razetime/ngn-k-tutorial/tree/main?tab=rea... Also, have to shout out the APL Orchard, where Adám will give any visitor a personal tutorial: https://chat.stackexchange.com/rooms/52405/the-apl-orchard https://chat.stackexchange.com/rooms/52405/the-apl-orchard
- dan-robertson 3y agoAre there any type systems that work well for the array programming problem domain? Not the kind of ‘everything is an operator’ syntactic sugar, to be clear. More things like supporting the kind of general operators you see in array languages while also expressing the constraints on dimensions, eg for matrix multiplication you need the number of columns on the left to match the number of rows on the right. But the thing written at the end of this post presumably also does things on arrays of higher rank too…
- zozbot234 3y agoYou basically need types that can depend on program constants (like the size of an array) and to be able to do compile-time computation on these constants. These are emerging features of sorts, but languages like C++ and Rust support them. They're also inherent to dependently-typed languages. (Of course you can alternately pick array sizes at runtime, but then you'll be dependent on a runtime check wrt. correctness.)
- dan-robertson 3y agoSurely most of the time you don’t need program constants? You could already implement a slow matrix multiplication that is well typed in a language like Haskell or OCaml. It would have a type something like: val matmul : ((float,'a) fixed_length, 'b) fixed_length -> ((float,'c) fixed_length, 'a) fixed_length -> ((float,'c) fixed_length, 'b) fixed_length (And observe the similarity to function composition too: val compose : ('a -> 'b) -> ('c -> 'a) -> ('c -> 'b) .) This could work for dimensions that are unknown at runtime for Haskell or OCaml as their polymorphic functions can be implemented by a single machine code function where C++ templates / Rust generics must monomorphize (generate different machine code functions for different types). You would probably want existential types (though OCaml and Haskell have them). I think the problems are more things like: - that type only works on matrices, you can’t so easily express that eg * in APL works on two scalars, or two vectors of the same length, or a matrix and a rank-3 array so long as their dimensions line up appropriately. - handling operations that change lengths is hard: concat probably wants you to be able to unify through certain arithmetical expressions, and the filter operation (take an vector and a bitvector the same length, and produce the vector of elements where the bit was set) means you probably want a natural way to handle those kinds of existential types for lengths: you get a vector, and it has a length, but you’re not sure what it is.
- ithkuil 3y ago> function exponents Including negative exponents, namely automated computation of the inverse function!
- gcanyon 3y agoOh yeah -- when I first tried that out and it worked my mind was blown.
- leephillips 3y agoMy first (and only) programming course (1976) in college used APL. It was populated by normal undergraduates, most of them in humanities fields. It was fine. You don’t have to be a super genius, but a lack of exposure to boring languages may be an advantage. I still love APL.
- dcuthbertson 3y agoMy second introduction to programming was also with APL in 1976. My high school had a few APL terminals that had a dialup connection to a computer at the University of Rochester. The math department had a course in APL. It dovetailed well with their introduction to linear algebra. It was an eye-opening experience. In college, they were teaching assembly language (IBM/370) and Fortran. I dabbled with the APL interpreter on the mainframe, but had little time to do more. There just wasn't any support/community around APL on campus (that I was aware of). Nevertheless, I'm still very fond of APL.
- WhitneyLand 3y agoThese arguments could use a little more precision/evidence and some concrete examples. >1. Array languages aren't well suited to every problem. No language is suited to every problem? >2. They are ridiculously capable for many types of problem. Irrelevant? It only matters if it is more capable than other languages. >3. The people using array languages are generally insanely smart. Folklore. Impossible to quantify. Most of all, there are really smart people using all languages. >4. Learning how array languages work is a steep challenge. This is not persuasive. >5. It’s awesomely mind expanding. Like philosophy and psychedelics? People care about GTD. Seriously, I’m listening. What’s the real competitive, objective, case for k?
- stealthcat 3y agoHow do you trust numbers to “quantify extremely smart people”? Interviewers know to hire/no-hire within first 10 minutes of talking to candidates. Similarly, the best LLMs nowadays are probed only with some prompts. Just last time I see LLM midwit meme on quantifying best scores on all benchmarks vs idiots/geniuses who just prompt something for some while. Do not try to put numbers on everything.
- WhitneyLand 3y agoI’m not sure we’re disagreeing… I said it was impossible to quantify, not that it should be quantified. In general I just don’t think it’s a reason to decide on a programming language.
- gcanyon 3y agoI didn't say it was a reason to "decide" on a programming language. I started with a premise and then said "here's my take" but nowhere did I say "this is my take on why you should use K/J/APL for real work." It's just a list of bullet points about why J (in my case) is interesting.
- Bostonian 3y agoRegarding #4, an advantage of Modern Fortran is that you have array operations and the ability to write procedural code with loops without a speed penalty if the problem cannot be easily decomposed into array operations.
- anonu 3y agoLearning array languages makes you a better programmer in any other language. The way you think changes. We are taught to approach a problem procedurally. Actually the for loop is your enemy.
- theamk 3y agoyeah, but why mess with K for that? Grab python+numpy or matlab/octave - it's all the same stuff (likely inspired by K) but with readable syntax, bigger community and so on.
- rak1507 3y agoIf numpy/matlab/octave/... was 'all the same stuff' with none of the downsides and all of the benefits, why would k or array languages in general have such a passionate community? Either every arraylang-er is masochistic (only slightly true) or there's more to it than you think.
- theamk 3y agoThat's a weird argument... passion is not always connected to efficiency/practicality/usefulness, in fact I feel that in a lot of cases it's the opposite. As a great example, look at old computers: they are pretty popular (there is one link on HN front page right now about N64!) and people are super passionate about it, and yet you would not recommend "everyone to play at least one Nintendo 64 game". For non-computer examples, somehow a number of my friends are extremely passionate about super hot (as in spicy) sauces. They bring a new bottle for every meal, and they can talk about the kinds of peppers for hours. It's interesting to hear, but I would not want to try them myself, nor would I recommend this to everyone.
- rak1507 3y agoI'm sure people who are into retrocomputing or spicy food or any other topic could tell you why they prefer that to something more mainstream. Whether or not you would agree, you could recognise that they had different opinions. The issue I had with your comment was writing off k as simply an inferior version of numpy etc rather than trying to consider why people like it, and what it may even do better than the mainstream alternatives.
- buescher 3y ago>7. Likewise when you realize how array-based languages handle any dimension array. Deserves to be ranked higher, especially for the "blub" programmer. With specific examples. I not-so-recently saw an implentation of euler's method that replaced the ODE solvers of MATLAB for pegagogical reasons. I return to it when I want to think about generalizing in that way.
- deleted 3y ago[deleted]