You can play with the stack machine I made by going to:

observablehq.com/@thor/stack-m

See the parent post for further elaboration.

@masterofthetiger ^^^

A loop that iterates from 5 to 0, executed on a stack machine implemented in JavaScript.

One stack machine you might be familiar with is PostScript.

A stack machine works by pushing values onto a stack and performing operations on the values by popping them off the stack again.

It's very simple to write an interpreter for a stack machine. All you need is two arrays; one for the code and one for the stack.

Stack machines are very close to being idiomatic Turing machines.

I keep telling myself that this will be the day when I stop getting lost in details, but it’s not working.

This is a problem I’ve had ever since I started treatment for ADHD.

I definitely need the drugs, because I get mentally exhausted fairly early in the day without them, but they make me very obsessive, and it’s difficult to let go of things or jump from task to task.

There’s a phenomenon in psychology research that might best be described as narrow behaviourism.

Narrow behaviourism is when a study focuses solely on behaviour and draws conclusions from that alone. In this paradigm, thought processes don’t exist and every behaviour is a reflex. How the subject feels and how he interprets the situation doesn’t figure into it.

I feel that this can result in some very wrong conclusions. How do such studies even get published?

About a year ago, I wrote a very elaborate RouterOS script for deploying a shared configuration across a network of Mikrotik routers.

Unfortunately, the RouterOS script language has turned out to be a moving target. They keep changing the semantics, and scripts break all the time.

It’s rough at the edges, and uglier than Perl, but it’s a full language with blocks, functions, scopes and data structures.

I’ll have to find another way of doing it that won’t break across firmware updates.

Much of the so-called "news" I see on "news" sites isn't news at all. Sometimes, on the Norwegian sites, the front page is about a soccer match. At other times, nothing happened in Norway that day, and all the "news" is international, and yet, it still isn't news.

News is information about the current state of affairs, and before the "news" media hijacked it, it carried much more weight.

"I bring news of your brother-in-law. He has fallen in battle at Hastings."

TypeScript is pretty much there to help IDEs perform static analysis on your JS code.

With a language like JS, I would much rather have dynamic analysis...

...and why don’t we give it a REPL or notebook interface while we’re at it? How about hitting a button or key to update a function you just edited in the running code?

I think I have a vague recollection of at least one Lisp being implemented on a stack machine.

I’m wondering if one couldn’t implement the whole notion of scope with just a stack, an accumulator and a few basic list operations.

(continued)

There is only one scope, and it's the global scope, but that's all you need, because the scope itself is accessible as a built-in variable.

So, if you wanted to enter a new scope temporarily, where would you put the old one?

That's what the global stack is for. It can store anything you want, but there is only one stack. It exists only so other language features can be built on top of it.

I'm having too much fun with this.

So far, I've found that you only really need one facility for substitution in a Lisp, namely evaluation by reference:

(set <variable-name>
(quote <expression-template>))

(<variable-name>
<exp1> ... <expN>)

The variable name is resolved to a value that holds an expression template.

Placeholders in the template are substituted with argument expressions, without evaluating them.

The resulting expression is then evaluated in-place.

(continues)

I have spent an entire day trying to figure out what the minimum number of special forms (built-in constructs) for a LISP dialect is, without resorting to a ton of recursion everywhere.

If you add a bajillion built-in constructs to a language right away, you just end up with an inflexible REPL that keeps growing.

My goal is to learn exactly which forms are necessary.

Thank goodness that I actually nailed it down. It’s been driving me crazy. It’s easier to cope with an emotion you can put a label on.

I think I was finally able to nail it down as general anxiety due to medications because I took a bit too much today, and the feeling was suddenly more pronounced. This, interestingly, made it easier to recognise. It had been a bit low key and vague up to this point.

It took me several months to figure out this new emotion I’ve been having.

Think of a movie scene where a character can sense trouble, or just a scene with a creepy character in it, and the feeling you get from that.

It’s like that, except there’s no apparent cause.

I think this is what they call generalised anxiety.

I can see where Edvard Munch was coming from when he painted The Scream. It’s nowhere near as bad as that, but I can recognise the feeling now.

Since mom died and I began treating my ADHD, I can’t shake this feeling that something is terribly wrong.

I know what being depressed is like, but that isn’t it. Depression is helpless or melancholic. This? It’s unnerving, disturbing, uncanny.

It’s anxiety.

I’ve had low key anxiety for as long as I can remember. It would only turn up sometimes, such as when I’m up too late, or it’s too quiet.

The ADHD drugs make me more alert. That’s their job. I suspect they’re causing all of this.

One-liner that takes zero or more boolean arguments and turns them into a bitmask.

This is basically a workaround for the fact that JavaScript, even in modern incarnations, lacks switch statements where the cases are predicate expressions.

Cool teardown video from Applied Science that reveals how analog era snapshot cameras printed the date on the film negative:

youtube.com/watch?v=ezME4_xMMn

With the segmented digits, you'd think it's a tiny fluorescent display, but it's actually more interesting that that.

I’ve come to the point where I’m removing stuff from my Lisp interpreter instead of adding it, as a sort of challenge.

Some Lisps have the conditional forms

(when <predicate> <expression>)

(unless ...)

which are complementary.

It turns out that you can define “when” and a standard “if-then-else” form in terms of “unless” alone.

I should hardly be surprised. All logic gates can be implemented with NAND gates. “unless” is NOT and conditional evaluation is AND, so...

You can see a physical disability, but you can't see a mental disorder.

The funny part is that mental disorders are actually worse than physical disabilities. A disabled person can overcome his disabilities if he is determined enough.

A mentally disordered person cannot overcome anything, because the brain, the organ that has to do the overcoming, isn't working as it should.

Social intelligence: A person with profound autism treats humans as scenery, because a brain growth stage was stunted.

Executive function: A person with profound ADHD is unable to gather thoughts and execute plans, because a brain growth stage was stunted.

Growth is variable. Being short isn't a disease, but stunted growth is.

We aren't all the same height, and this is also true of brains. Countless variables affected how we all developed as children, but we ignore that every time we judge.

IQ is a thing that helps you solve difficult puzzles, but it's virtually useless on its own. Unless your IQ is markedly below average, it won't matter to your success.

What matters far more is your outlook on life, your social abilities and your executive function.

Show more
mastodon.cloud

Generalistic and moderated instance.