Live data from Hacker News

What you learn by making a new programming language

ntietz.com

81–90 of 137 posts

Re: What you learn by making a new programming language

#82

Every program expands until it becomes a compiler or checks mail. Emacs's sin was doing both.

> Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule

It's especially prevalent when expanding configuration capabilities.

Re: What you learn by making a new programming language

#83

One of the most fundamental experiences I ever had was attempting a graduate level course at the end of a long series on compilers. You really get an eye opening view of how languages are translated into the language the machine understands. After going through a few toy languages and then finally tackling creating a simple JVM, here is the #1 thing I would go back to myself and scream until I was blue - Make your in…

Building an interpreter for myself, can confirm. Saying "no" to feature requests is especially hard because I'm the one requesting them!

Re: What you learn by making a new programming language

#85
post #11

Earlier quoted context omitted.

Is this a joke I'm not getting? Any examples of such software?

I think the point is that - you write some piece of software - then you add a straightforward configuration language - then you add variables because you don't want too much copy/paste - then you add if statements to allow conditional configuration - then you add loops because you are sick of seeing configuration that consists of unrolled loops - ... At some point your configuration system is Turing complete, so coul…

But if configuration is the example, a full fledged Lisp program as your configuration is TOO MUCH. Do you want configuration files functioning as malware vectors?

And what about Lisp is enduser friendly? Configuration files are intended to address people that are programming-lite to poweruser-not-programmer level. Lisp s-expressions are recursive tree structures with prefix ordering, which is a "great filter" for the IQ of users.

Greenspun's law, being a joke of Lisp users, actually indicates the inability of the Lisp community to understand why their language is niche to ultra-high-IQ people. If syntax patterns, formats, and programming languages survive for decades, there is a grassroots practical reason for their existence that ironically the ultra-smart all-knowing Lisp hacker just can't properly fathom.

Re: What you learn by making a new programming language

#86
I've had a pet idea for a long time that is nonsensical but I still wish existed. I'd like a programming language that encodes the "why", like forces you to compile in the business reason for the code in question. And then it'd automatically survey you, and if your prior business assumptions are no long true, then compilation would fail, forcing you to remove or rewrite until the code fits your "why" again.

Re: What you learn by making a new programming language

#87
post #63

Earlier quoted context omitted.

I'm basically in charge of maintaining and developing a product that (on purpose) started at 9 o'clock. We've resisted the call to implement loops and such in our DSL but I can hear the wolves howling and I doubt I have much longer...

I think the world needs programmable config langs because slinging YAML and JSON quickly becomes miserable (as is extending them through templating alone) and general-purpose programming languages usually have shitty ergonomics for writing configuration. The only question in my mind is whether our common config langs should be Turing-complete (e.g., Nix, Nickel, Jsonnet, Pkl) or not (e.g., HCL, CUE, Starlark, Dhall),…

Hate to burst your bubble, but because of `break` and early return, Starlark is basically Turing-complete.

https://gavinhoward.com/2024/03/what-computers-cannot-do-the...

Re: What you learn by making a new programming language

#89

Earlier quoted context omitted.

See also the Configuration Complexity Clock: https://mikehadlow.blogspot.com/2012/05/configuration-comple... . This is why I have a separate config language and code language. My config language is essentially JSON with newline separators and a first-class binary type (base64). I added little else. When I get the temptation to add code to it, I just pull out my other, general-purpose language instead.

I'm basically in charge of maintaining and developing a product that (on purpose) started at 9 o'clock. We've resisted the call to implement loops and such in our DSL but I can hear the wolves howling and I doubt I have much longer...

I've hit this point a few times, and I always advocate for cutting the losses and switching to embedding an existing interpreter. Lua and Lisp both have embeddings for most popular languages, Starlark is Python-y and embeddable, many languages can embed a Javascript engine.

Imo, users asking for stuff like loops is a signal that they want a real language and not a bolted-on DSL. I've seen far too many cases of "extending a DSL until it's a full-flegdged but awkward and horrible language".

Ansible's YAML and Terraform's are my prime examples. Both have grown into basically full languages featuring imports, for loops, etc, and both suck to use because of how awkward reaching for them is. I don't want to have to remember Ansible's bastardized, YAML-encoded for loop syntax, just let me use a Python for loop.

Re: What you learn by making a new programming language

#90

Earlier quoted context omitted.

I think the point is that - you write some piece of software - then you add a straightforward configuration language - then you add variables because you don't want too much copy/paste - then you add if statements to allow conditional configuration - then you add loops because you are sick of seeing configuration that consists of unrolled loops - ... At some point your configuration system is Turing complete, so coul…

But if configuration is the example, a full fledged Lisp program as your configuration is TOO MUCH. Do you want configuration files functioning as malware vectors? And what about Lisp is enduser friendly? Configuration files are intended to address people that are programming-lite to poweruser-not-programmer level. Lisp s-expressions are recursive tree structures with prefix ordering, which is a "great filter" for th…

> And what about Lisp is enduser friendly?

It's not, it's developer-friendly. A basic Lisp interpreter is like a few hundred lines of code, so it's a very tempting system to embed. I think Lua is similar, but I haven't messed with it.

It's also powerful enough that most things aren't incredibly awkward to specify in it. YAML/JSON/TOML/etc have issues expressing repetitive things that can be solved in a for-loop/map in Lisp.

I don't even think Lisp should be an IQ filter. I wouldn't call myself a great or even good Lisp programmer, but the prefix syntax and s-expr's aren't all that hard to pick up. I don't think it's any more difficult than JSON, although it is far less common.

Post reply on HN