Live data from Hacker News

What you learn by making a new programming language

ntietz.com

101–110 of 137 posts

Re: What you learn by making a new programming language

#101
post #63

Earlier quoted context omitted.

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...

The Starlark spec discusses this, and I consulted it before I wrote my comment.

> It is a dynamic error for a function to call itself or another function value with the same declaration.

> This rule, combined with the invariant that all loops are iterations over finite sequences, implies that Starlark programs are not Turing-complete. However, an implementation may allow clients to disable this check, allowing unbounded recursion.

https://github.com/bazelbuild/starlark/blob/master/spec.md

I do kind of agree with you about this, though:

> At that point, just give your users a `while` loop for usability's sake.

I'm generally in favor of powerful, purpose-built configuration languages, including Turing-complete ones. And the goal of assuring users that their programs will terminate at all is definitely aligned with a fuzzier goal, less formalizable, that their programs will terminate in a 'reasonable' period of time, whatever that means.

Re: What you learn by making a new programming language

#102
post #95

Highly recommended! And I do mean new. Because having an opinion is good, and validating it is even better. I find it to be mostly educational, humbling and fulfilling; but occasionally VERY frustrating because there's just no end of things to fix and improve. https://github.com/codr7/sharpl

Nice, I really want to see a Clojure equivalent on .NET where its a Lisp language, but it fits in with its ecosystem.

There is https://github.com/clojure/clojure-clr

(I cannot testify for usability, the project is alive but it seems to need more contributors to really get going)

Re: What you learn by making a new programming language

#103
post #97

I still hope to make one, but a combination of ADHD, depression and so many things to do and learn keep getting in the way. At my current rate I'll know everything and be ready to get started on the day I die. But my feature wishlist is First class functions, Garbage collection, Transparent parallelism, Explicit parallelism, Type inference with strong type consistency, Dynamicly typed by annotation, Operator overload…

As someone with similar mental health barriers, what strategies do you employ to overcome them?

I have not overcome them. Currently on dexamphetamine, my partner has noticed an improvement, me less so. Have been productive for the last week or two so making the most of it.

List making, planning, routines, and pretty much anything that follows someone saying "You just need to ..." Doesn't work for me, or for any of the other ADHD sufferers I know of.

Re: What you learn by making a new programming language

#104
Making a whole new software/hardware ecosystem is what happens if you keep going... behold... the BitGrid.

Turing Complete, Actually performant, and possibly crazy enough to work

[1] https://esolangs.org/wiki/Bitgrid

[2] https://github.com/mikewarot/Bitgrid

And my latest attempt at things, because Pascal isn't popular enough, includes C and a Web emulator

[3] https://github.com/mikewarot/Bitgrid_C

Re: What you learn by making a new programming language

#105
post #63

Earlier quoted context omitted.

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),…

If possible, I'd say it's best to just stay at 12:00. Let them be "hard coded" in ~/.config/myapp/config.py or such so that it's very clear which edits should only be done by a wizard and which ones are suitable for a user. This way all your users are suitably placed on a slippery slope where one edit in the same language but to another file will transition them from user to contributor. Jail them in a separate langu…

> Besides, config languages never have the level of polish (re: tab completion and static analysis) that the main language does.

They don't have to!

> Why deny your users the niceties that you set up for yourself?

Don't do this, of course. :)

For instance, Nickel gained[1] an LSP implementation years before it hit version 1.0. When editing Nickel configs,byou get all the stuff you'd expect for a programming language: syntax highlighting, type hints, autocompletion, etc. But beyond static analysis, Nickel can also validate your configurations dynamically, according to arbitrary predicates-- and that too, integrates with your editor through the language server. Nickel ships with a command-line evaluator, REPL, pretty printer for data structures, code formatter, documentation generator, and CLI tab completions for Bash, zsh, Fish, PowerShell, and Elvish. Upstream distributes the tooling (which is, Go-style, a single executable with subcommands) as a Nix flake, a Docker image, and static executables for Linux aarch64 and x86_64 (CUE, an older (but not old) configuration language (very cool in its own right), likewise has great tooling. It ships with a command-line evaluator, a pretty printer, a formatter, package management based on Go modules (i.e., it has both a `mod` and a `get` subcommand), a few refactoring tools, and tab completions for bash, zsh, and fish.[4] It currently lacks a language server[5] but there is recent and ongoing work to enable that.

There's no reason that a configuration language can't have first-rate tooling!

There is a new crop of really innovative, powerful configuration languages out there. I hope they start catching on.

> This way all your users are suitably placed on a slippery slope where one edit in the same language but to another file will transition them from user to contributor.

> Jail them in a separate language and they'll stay users forever.

This, I admit, deeply appeals to me. It's one of the things I really like about the Nix language, wart-y though it may be: the tools you use to configure your NixOS computer are the same ones you can go on to use to extend NixOS. I think that's an enormous strength.

But I also like for simple configuration to look really simple, and not trouble you much with the details of the language (or, God forbid, configuring the runtime). Perhaps programmable configuration languages, then, are good fits for tools like build systems and packaging systems (where the 'upstream' code users might next want to play with is also essentially fancy, expressive configuration in a special domain), but embedded DSLs might be better for applications (and work for packaging and build systems, too).

Re: creating a continuous road for users to hack on the software they use, GNU is really trying to do something special there: with Guix you have application configuration, package management, and system configuration handled in a DSL in Guile Scheme. But then Guix itself is also written in Guile! And at the same time, Guile is the official extension language of the GNU project, so GNU applications all (hopefully?) have Guile bindings, so you can use the same language to plug into (hopefully?) all the other GNU applications on your system. It's a cool idea.

--

1: https://github.com/tweag/nickel/pull/405

2: https://www.tweag.io/blog/2024-05-16-nickel-programmable-lsp...

3: https://github.com/tweag/nickel/issues/1585

4: https://cuelang.org/docs/reference/command/

5: https://github.com/cue-lang/cue/issues/142

Re: What you learn by making a new programming language

#106
I just realised I went down the rabbit hole yesterday. I needed to track work to be done on my work project - so I started writing Todos. And then grepped them, and started extracting things from the todos - like a dotted name (foo.component.feature) and now I have realised it’s a DSL and I should have used lexx not regexes and … it’s a good idea through !

Re: What you learn by making a new programming language

#107
When I was in high school I learned about BNF and so i wrote a program that let you type in BNF rules and then it would run a recognizer on an arbitrary string to decide if the string met the BNF rules. I don't know if I could write that again, but it was a definite eye-opener and I learned a ton from that project ...

Re: What you learn by making a new programming language

#108

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…

The difficulty in learning a language is proportional to the SQUARE of the number of BNF rules! Let that sink in. When last I looked, C had 120 rules and C++ had 250. C++ was already out of control and has a bunch of really stupid features that nobody with any intelligence uses for anything other than showing off (and let me tell you - there are A LOT of showoffs at Google!) Anyway, that's why C++ is 4x harder to learn than C ... I call it ... "Don's Law".

Re: What you learn by making a new programming language

#109
post #20
post #13

I've had two projects that end up being "oops, I made an interpreter". It starts innocently enough, you just have a JSON that has some basic functionality. Then you decide it would be cool to nest functionality because there's no reason not to, so you build a recursive parser. Then you think it'd be neat to be able to add some arguments to the recursive stuff, because then you can more easily parameterize the JSON. T…

> and life is pain So glad you finished with this. Right now I’m working with a guy who wants to write an interpreter…

Skip straight to Lua

Re: What you learn by making a new programming language

#110

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…

> ultra-high-IQ people

I think that's much more stereotype than reality. People see all these parentheses and think that it must be a difficult language that requires a big mindset shift, like these purely functional languages with dependent types. In reality, it takes a week or two, plus an editor plugin that highlights matching parentheses, to get used to writing (function arg-one arg-two) instead of function(arg_one, arg_two). After that, it's smooth sailing. Just another decently designed language that's dynamically but strongly typed. Feels like writing Python, except with a bit of metaprogramming from time to time.

I think you're overestimating the importance of syntax and underestimating semantics. It doesn't take a very long program to get bitten by bad semantics. A few years ago, I was writing a game extension in Lua. It was only a couple hundred lines, and I still wasted hours debugging problems that would've been one minute fixes in Python or Lisp. All because of Lua's ridiculous idea of conflating arrays with hashtables, plus its habit of returning nil instead of raising an error when you do something that doesn't make sense.

Post reply on HN