| ▲ | Making your own programming language is easier than you think (but also harder)(lisyarus.github.io) | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 points by ibobev 3 days ago | 28 comments | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | sieve 2 hours ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
Anyone trying to do this... the first thing you do is avoid lex/yacc/bison/antlr. You do not need all this ceremony. A recursive descent parser that uses Pratt parsing will work for a vast majority of cases. The lexer/parser is never the bottleneck. In fact, you can write those two by hand over a single weekend for a largish language. With LLMs, it takes 15 minutes if you have an unambiguous spec. The biggest time sink, and the reason you will fail for sure, is the inability to restrict the scope of the project. You start with a limited feature set and produce the entire compiler/vm toolchain. Then you get greedy and fiddle with the type system, adding features that you have never used and probably never will. And now you have to change every single phase from start to end. I mostly give up at this stage. | |||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | amelius 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
Making a programming language is easy if you just copy ideas already existing in other languages. Coming up with new ideas is hard. Especially since you have to test them in the real world. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | sheepscreek 2 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
Easier than you think to get started, but harder than you think to turn into something truly usable that isn’t a toy of an experiment. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | coldcode 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
I wrote my own interpreted language about 25+ years ago to write online surveys. It made it easy to create complex surveys with many branches. I think I wrote it in Objective-C. The team implementing the survey system wound up using the same language to implement the runtime portion, something I never expected or designed in. I don't recall anything about what it looked like now. I do remember it was a lot of fun to write. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | gobdovan 4 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
I had a similar surprise about how approachable PL is, but from going from 'the bottom up' instead from a normal language. I wrote a compiler toolchain and debugger that takes a Turing machine description plus input string and emits an encoded tape runnable by a Universal Turing Machine [0]. I had some prior PL experience, but never did an end-to-end compiler pipeline, at least not this low level. It started as a joke/experiment, but I couldn't believe how fast it pulled me into designing: - a small low-level ASM for building the UTM - an ABI for symbol widths and encoding grammar - an interpreter used as the behavioral oracle - raw TM transitions for each ASM instruction, generated by having an LLM iterate on candidate emissions and checked against the interpreter oracle - a CFG-style IR to fix the LLM mess once direct ASM -> TM emission became too hard to keep sane (LLM did a decent job actually, I don't think I would have done a much better job without the IR either) - a gdb-style debugger for raw transitions, ASM routines, and blocks - a trace visualizer - a bootstrapping experiment where an L1 UTM/input pair was itself run through an L2 UTM - optimisation experiments And every step came quite naturally and was easy to tie in with everything else. Each one was just the next local repair needed to make the previous layer tractable. [0] Repo: https://github.com/ouatu-ro/mtm | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | wg0 2 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
Strange to read that C++ can be someone's favorite programming language. Only thing that goes for C++ is that it has acceptable (not straightforward) C interop. I don't like C# and X++ because the language surface is huge but if you use a limited subset than needles to say, very useful and handy languages too. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | chrisaycock 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
Yes, it's true that someone can put together a simple language like in a university course. The difficulties, as mentioned at the bottom of the post, are things like metaprogramming features or optimizing compilers. The tail ends of a language implementation (parsing and code generation) are a fixed cost; the "middle end" can grow unbounded as more production-quality items are added. My language: https://www.empirical-soft.com | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | Decabytes 2 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
Like most things in programming, handling the easy stuff is easy, but it’s all the edge cases that kill you. I’m writing an IDE in flutter right now, and all of the defensive programming I have to do to handle the unhappy path, is where 50% of my code goes. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | nithinbekal 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
I've been having a lot of fun building my own programming language [1]. Getting to the point where you can write programs in your own language was surprisingly easy. The language, Sapphire, is Ruby inspired, so the most interesting part is digging into the internals of the latter when I'm trying to figure out how something should work. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | virexene 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
this project is pretty interesting, although i'm wondering how they're planning to address the "easy sandboxing" design goal in a compiled language with raw pointer arithmetic and clib interop... in that regard i think lua would have been a lot easier to sandbox, despite the author's concerns. (also, they might want to look into lua userdata, since that would address their concern about the overhead of converting between native and lua data structures. the language is designed to be embedded in C programs after all) | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | atan2 2 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
This URL was posted two days ago: https://news.ycombinator.com/item?id=48040422 | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | Tomokisan 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
I watched a lot of youtube videos explaining in detail how to do it but i admit i never tried myself. I'm kind of curious and want to try it for fun as long as i get some free time ^^ | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | ecto 4 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
There are many like it, but this one is mine https://loonlang.com | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | Razengan an hour ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
For years I've been fantasizing about a language designed specifically for gameplay development that doesn't try to be like C. Maybe AI is good enough now to help me with that.. The last time I tried, Claude couldn't even help me build a syntax highlighter for a hypothetical language. | |||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | smitty1e 6 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
If I were to make my own programming language, it would look an awful lot like Python. Roughly 100%. | |||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | unnouinceput 5 hours ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||||||||
Making you own language is easy. Creating the library that will actually solve problems without forcing the developers to reinvent the wheel is the crux. There is a reason why C++ / Java / JavaScript etc are established, it's the already proven libraries around those languages that allows them to be so successful. | |||||||||||||||||||||||||||||||||||||||||||||||
| ▲ | Imustaskforhelp 6 hours ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||||||||
I have only read the first end of the article but I can't help but think that a project like libriscv[0] would've/could've worked for their game project too because fun fact but the creator of librsicv, the legendary fwsgonzo is also making a game. I highly recommend for people to check out their discord server. But my main point is that libriscv is one of the fastest libriscv emulators and then something like C/C++/lua could've been used with sandboxing purposes for the purposes of the game then. Am I missing something? Although, making a programming language is one kind of its own projects and that's really cool as well :-D but I would also love to hear the author's opinion on libriscv as it feels like it ticks of all the boxes from my understanding | |||||||||||||||||||||||||||||||||||||||||||||||