Live data from Hacker News

What is a primitive?

mlochbaum.github.io

1–10 of 19 posts

Re: What is a primitive?

#2
Author here if you have any questions. The main reason to write this document is people used to APL wondering why BQN leaves out certain primitives (answer: I don't think they're really primitives), but probably more HNers would wonder why it has so many that ASCII isn't even fit to keep them all (the full list is at https://mlochbaum.github.io/BQN/doc/primitive.html). Just as well; hopefully I've addressed both concerns!

Re: What is a primitive?

#3
When I write programming languages, I usually define primitives as "any value without children". Strings, numbers, booleans, are primitives. Collections and records are not.

Some edge cases: literal ranges would be primitives, because their ast is represented (in Haskell) as "Range Int Int". Ranges which take values wouldn't be primitives, because their ast is represented as "Range expr expr"

Re: What is a primitive?

#5

When I write programming languages, I usually define primitives as "any value without children". Strings, numbers, booleans, are primitives. Collections and records are not. Some edge cases: literal ranges would be primitives, because their ast is represented (in Haskell) as "Range Int Int". Ranges which take values wouldn't be primitives, because their ast is represented as "Range expr expr"

BQN uses the term "atom" for such values[0]. They include numbers, characters, and functions, as well as namespaces—really "atom" just means "non-array". These are the values that can't be split apart by array operations, but they might still be made up of multiple things, for example a function train[1].

In contrast, primitives are the starting point for programming, particularly tacit programming ("point-free" in Haskell). While the two names have a similar meaning, I think it fits a little better to call values that are indivisible from a particular perspective "atoms" and the ones that are meant to really be fundamental "primitives".

[0] https://mlochbaum.github.io/BQN/doc/types.html

[1] https://mlochbaum.github.io/BQN/doc/train.html

Re: What is a primitive?

#6

Along vaguely related lines is https://gist.github.com/chrispsn/b1020918a83a28ab8b4442d8aff...

The relationship is interesting. Chris is trying to find a minimal set of functions good enough to derive the rest (a worthwhile goal, and it mentions at the bottom that I did something similar in BQN). Part of my current thinking about primitives is that it's not important how many there are, more that each represents a coherent simple concept. But primitives that are too similar can cause problems for memory and maybe intuition.

Re: What is a primitive?

#7

When I write programming languages, I usually define primitives as "any value without children". Strings, numbers, booleans, are primitives. Collections and records are not. Some edge cases: literal ranges would be primitives, because their ast is represented (in Haskell) as "Range Int Int". Ranges which take values wouldn't be primitives, because their ast is represented as "Range expr expr"

Are you saying that you consider strings in Haskell to be a primitive?

Re: What is a primitive?

#8
post #7

When I write programming languages, I usually define primitives as "any value without children". Strings, numbers, booleans, are primitives. Collections and records are not. Some edge cases: literal ranges would be primitives, because their ast is represented (in Haskell) as "Range Int Int". Ranges which take values wouldn't be primitives, because their ast is represented as "Range expr expr"

Are you saying that you consider strings in Haskell to be a primitive?

No, Haskell is weird since a string is [Char]. If it was it’s own value, yes.

The languages i’ve written are pretty basic. e.g. the data types might be

- Number - String - True, false, null - Array of values - Record of fields (key + value) - Variant of options (key + value)

So the distinction is clearer.

Re: What is a primitive?

#9

Author here if you have any questions. The main reason to write this document is people used to APL wondering why BQN leaves out certain primitives (answer: I don't think they're really primitives), but probably more HNers would wonder why it has so many that ASCII isn't even fit to keep them all (the full list is at https://mlochbaum.github.io/BQN/doc/primitive.html ). Just as well; hopefully I've addressed both con…

What tool did you use to make those diagrams?

Re: What is a primitive?

#10
post #9

Author here if you have any questions. The main reason to write this document is people used to APL wondering why BQN leaves out certain primitives (answer: I don't think they're really primitives), but probably more HNers would wonder why it has so many that ASCII isn't even fit to keep them all (the full list is at https://mlochbaum.github.io/BQN/doc/primitive.html ). Just as well; hopefully I've addressed both con…

What tool did you use to make those diagrams?

BQN! The entire BQN website is generated with a markdown processor[0] that handles the parts of Github-flavored markdown I use and adds features like highlighting and the ability to drop into BQN to generate html or svg. Github doesn't display markdown source nicely, but you can scroll down to the [0] https://github.com/mlochbaum/BQN/blob/master/md.bqn

[1] https://raw.githubusercontent.com/mlochbaum/BQN/master/comme...

[2] https://github.com/mlochbaum/BQN/blob/master/svg.bqn

Post reply on HN