HN Distilled

Essential insights from Hacker News discussions

Klong: A Simple Array Language

Here's a summary of the themes from the Hacker News discussion about the Klong programming language, along with supporting quotes:

Terseness and Readability: A Major Point of Contention

A dominant theme revolves around the perceived terseness and readability (or lack thereof) of Klong and similar array languages. Many users find the syntax challenging, while others defend it as a strength.

  • Negative View: "If you try to use it, you will only get frustrated." - thomasmg
  • Counterargument: "Readability is a property of the reader, not the language." Some argue that familiarity and experience are key.
  • Defense of Terseness: "the terseness is magical when you are in the repl and it just takes typing 1, 2 or a hand-full of characters to try an idea you have" - tosh
  • Readability for Whole Programs: "and when you want to understand a larger program the terseness means you might be able to actually see it as a whole, in one page or screen" - tosh
  • A Practical Limitation of Readability: "I can't read anything that is too far out of my fovea... Beyond that, I am aware that there are letters and words, but no decoding takes place." - kazinator, highlights that even if code fits on screen, human vision has limitations.
  • Anxiety around readability "large programs and functions are significantly more anxiety-inducing for me to read and work on. I have to keep scrolling and scanning back-and-forth and easily lose my train of thought and get the feeling that I've forgotten something important" - t-3

Learning Curve and Adoption

Closely linked to readability is the debate on the learning curve and its impact on adoption. Some believe the steep learning curve hinders wider use, while others downplay its difficulty.

  • Steep Learning Curve: "Having a steep learning curve clearly prevents adoption. The language design actively contributes to the problem. I'm just not sure on why. Could it be that the authors of these languages do not want them to be used by others?" - thomasmg
  • Easier Than Perceived: "The learning curve isn’t steep. I’d argue the opposite. K is a tiny, tiny language. Put your mind to it, and you’ll be reading it just fine in a weekend. It’s just different. It’s optimised for its wheelhouse." - skruger
  • Analogy to Learning Music: "You could say you enjoy toodling on the piano but don’t understand why reading music has to be so hard. It doesn’t stay hard and it opens up new avenues." - gitonthescene

Array Languages vs. Scientific Computing Alternatives (MATLAB, NumPy, Julia)

A significant discussion point involves comparing Klong and similar array languages to more mainstream scientific computing tools like MATLAB, NumPy, and Julia.

  • Existing Alternatives: "do K/Klong/whatever proponents realize that there is already a huge community of people who appreciate and utilize powerful operations on arrays to do real work, but just prefer to write something like "max(diff(x))" instead of "|/--:'x"?" - etbebl
  • Reply: "APL dates back to about 1966, and even K from 1993 predates Numpy and Julia. But yes, we do not live in caves and are familiar with these languages." - mlochbaum. Context is important.
  • Another reply: "Oddly enough, the biggest mistake in how I presented BQN early on was thinking only APL insiders would be interested, when in fact the APLers went back to APL and people who hadn't tried other array languages or hadn't gotten far with them were were most successful with BQN. Plenty of people coming to BQN have worked with Numpy or whatever, but I don't think this has the same deterrent effect; they see BQN as different enough to be worth learning. Julia in particular is very different: I don't find that it culturally emphasizes array programming at all." - mlochbaum
  • Reply to the Reply: "I just noticed that the selling points in the introduction to the manual were not very compelling to me as a Matlab/Numpy user, and since sometimes people bemoan that array languages aren't more widely used, I just wanted to say, hey we do have powerful "array languages" that imo are strictly better on things that matter for most real work, so it's not surprising." - etbebl

Potential Use with LLMs

A novel idea is raised about the potential of terse languages like Klong in the context of Large Language Models (LLMs).

  • Token Efficiency: "I wonder if these extremely terse languages might see a rise in popularity with LLMs, since they save a lot of tokens." - haolez
  • Training Data Challenge: "The hard part would be training on them, since training data is not as comprehensive as JavaScript, for example." - haolez
  • Counterexample: "From terse languages surely there is a lot of training data for Perl." - Qem

Klong's Relationship to Lisp

A minor thread explores the similarities and differences between Klong and Lisp.

  • Question: "But can someone tell me why an array in Klong is NOT like an s-expression in Lisp?..." - emorning3
  • Answer: "No idea why emorning3's comment is marked [dead]. It's a good question and in fact Klong arrays are very much like S-expressions. In fact their implementation is pretty much the same, down to using CAR and CDR to manipulate them. Klong could easily be implemented as a bunch of LISP functions and macros." - nils-m-holm

Defining Monadic Functions in Klong

  • Definition Attempt "The braces around an expression denote a function. Because this function contains a single variable, x, it is a monadic function or a monad." - ljouhet quoting source
  • Clarification and Disambiguation: "A monadic function in APL-family languages is not related to monads from category theory, which are the ones you see in Haskell, nor to Leibniz's monads." - kragen
  • Further Simplification: "In this context it just means "one parameter function"." - kazinator