Live data from Hacker News

What you learn by making a new programming language

ntietz.com

91–100 of 137 posts

Re: What you learn by making a new programming language

#91
Last year I tried to build a language and I wholeheartedly agree - it's amazing how much it teaches you. My particular language was merely meant to be transpiled to other languages, so I didn't get into the runtime or compilation stuff. But I quickly learned why braces and ignoring whitespace is so important. I also had to think extremely hard and carefully about the exact syntax and what each token meant. It's a very rewarding intellectual activity.

One thing I'd like to add is that even though you can totally write your own parser, it's an absolute joy to use Tree-sitter:

https://tree-sitter.github.io/tree-sitter

I plug it every time I get a chance. It makes refactoring your grammar incredibly easy, and lets you just focus on your syntax.

Re: What you learn by making a new programming language

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

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 language and they'll stay users forever.

Besides, config languages never have the level of polish (re: tab completion and static analysis) that the main language does. Why deny your users the niceties that you set up for yourself?

Re: What you learn by making a new programming language

#93

Are there some good resources for learning type theory?

I would suggest Robert Harper's "Practical Foundations for Programming Language". [1] This take a relatively thorough approach to the development of language semantics, with particular emphasis on Type Theory. Addition work on Type Theory is scattered throughout academic work, but Harper is good place to start. The implementation of 'normal' type systems in mainstream languages are for the most part just semi-performant straight forward instances of the more formal algorithms presented in the literature. Searching for lectures by Neel Krishnaswami on YouTube will yield some decent results on developing Type Systems as well.

1 - http://www.cs.cmu.edu/~rwh/pfpl.html

Re: What you learn by making a new programming language

#94
I built Crumb (https://github.com/liam-ilan/crumb) a year ago, before starting university. It completely changed the way I conceptualized programming as a whole. You start feeling deja-vu every time you open a new language, and the "ah-ha!" feeling you get when you see something in another language you had to think about when implementing your own is super rewarding.

A year later (this summer) I used Crumb to land my first job at a pretty cool startup! The payoff was way more than I could have ever expected.

Re: What you learn by making a new programming language

#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

Re: What you learn by making a new programming language

#96
post #47

I think many people underestimate how easy it is to get started writing a language. It is a bit like improvising music: it's just one note followed by another note followed by another. Almost any intermediate level programmer can write a program that parses a hello, world program and translates it into the language they already know. Once you have hello, world, you add features. Eventually you realize you made mistak…

Yeah, the high stakes are part of the thrill, because it's oh so easy to paint yourself into enough of a corner to have to throw the whole thing away and start over.

Re: What you learn by making a new programming language

#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 overloading (every language should either have vector/matrix operators or the ability to build them)

And a few more that I can't recall just now. I've made it hard for myself.

Failing that maybe just a hacked JavaScript without implicit type conversion between objects/strings etc. (the source of most "Wat?"), frozen array tuples, operator overloading. Implied "this." on identifiers defined and used inside class definitions.

Re: What you learn by making a new programming language

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

Re: What you learn by making a new programming language

#99
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?

Re: What you learn by making a new programming language

#100

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…

> Make your initial grammar SUPER simple.

I would go further and say don't write a parser at first, unless what's novel and interesting about your language is it's syntax. Use the configuration language of your choice (like TOML or YAML) to write your ASTs directly, so you can focus on writing the runtime/backend and playing with the semantics of your language (where the novelty probably is).

When you feel it's the appropriate time, you can circle back to the frontend and implement a parser. But if you're writing a DSL, a config language may well be good enough. An additional bonus is that your config language syntax will make it easier to write certain unit tests.

I've had several experiments in writing a new language, and the first few times I got completely bogged down in parsing. I learned a lot about parsing, which is great, but it made it difficult for me to get at the meat of a project.

Post reply on HN