Hacker News new | past | comments | ask | show | jobs | submit login
Goal: Embeddable array programming language with a bytecode interpreter in Go (codeberg.page)
85 points by tosh on Feb 5, 2024 | hide | past | favorite | 12 comments



Neat: Goal makes Go's regular expression support directly available to you.

That's great for Advent of Code and similar challenges where you have to do some ad-hoc input parsing but also super handy in general.


The feature I most want from little languages like this is safety: in addition to restricting what it can do, I want to be able to take a snippet of untrusted code and execute it with a strict limit on how long it can take and how much memory it is allowed to use.

I want this so I can build features for end-users to provide snippets of code while knowing they won't be able to break anything, either accidentally or maliciously.

This is a surprisingly rare quality!

A common failure point here is allowing infinite loops ("while true") or allowing unbound mathematical operations, like powers or factorials of really large numbers.


Have you had a chance to try out goal? How well do you think suits your … erm, goals?


For a language focused on math… giving up the natural division operator for comments seems like a really weird sense of priorities.



APL-family languages have a long history of using the symbol / as "over"; a reduction adverb. The composition +/ for taking a sum is mutually intelligible in APL, J, K, and Goal. It's only a comment, in this case, if it is preceded by whitespace.


Is that not a pun on the use of "/" for division, and how it's often expressed in spoken English? It might still be a weird sense of priorities, but an historical one rather than a new one.


No, it stems from North American use of ÷ for division, which is then ASCIIfied to %.


I get that, but why is / "over"?


  +/1 2 3 4 5
meaning

  plus over 1 2 3 4 5
meaning

  the plus reduction of 1 2 3 4 5
meaning

  1+2+3+4+5
meaning

  15
"over" (/) is a higher order function that takes the function "+" and applies it to "1 2 3 4 5"

over can also be used with *

  */1 2 3 4 5
meaning

  the product reduction of 1 2 3 4 5
meaning

  120 
"/" as "over" comes from a mathematical notation by Ken Iverson: APL (A Programming Language) [0][1] which Ken names "reduction" (h/t mlochbaum)

> An operation (such as summation) which is applied to all components of a vector to produce a result of a simpler structure is called a reduction.

"/" is known as "insert" in J [2] and "over" in k dialects (like Goal)[3].

[0] https://en.wikipedia.org/wiki/APL_(programming_language)#Mat...

[1] https://www.softwarepreservation.org/projects/apl/Books/APRO...

[2] https://code.jsoftware.com/wiki/Vocabulary/slash

[3] https://k.miraheze.org/wiki/Primitives


also see

"/" as "over" in k reference (see Chapter 5)

http://www.nsl.com/k/k2/k295/kreflite.pdf

and "over" in the Q reference:

https://code.kx.com/q/ref/over/


I wouldn't characterize languages in the K family as particularly focused on math. They have vectors, but do not have matrices or higher dimensional arrays, they don't have a built-in to compute factorials, binomial coefficients, roots of a polynomial or hypergeometric functions. And Ks do have dictionaries and tables. Maybe you're thinking of J or some dialects of APL?




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: