7 ms·
There's never been an easier time to write your own language (2016)
- tmin 6y agoBut why would you do that?
- throwawaygh 6y agoIt's a great learning exercise.
- Ygg2 6y agoYeah, basically a fun exercise in parsing/compiling/optimization. OTOH what makes a language usable is literally everything else - package manager, IDE support, compile/parsing.
- dragonwriter 6y ago> Yeah, basically a fun exercise in parsing/compiling/optimization. Among other things, sure. > OTOH what makes a language usable is literally everything else - package manager, IDE support, compile/parsing. You have parsing/compiling in both categories. It's easier than ever to add IDE support for your homemade language, too, because of things like the LSP. Package management isn’t easy, but if you are building a specialized DSL and bundling the parts key to the domain, or if you are exposing a bridge to an existing ecosystem with strong library availability and decent package management, a language-specific package manager is probably not super important for usability.
- mpweiher 6y ago> OTOH what makes a language usable is literally everything else But that could be because we haven't had any real innovation in languages for ages, so except for some superficialities and details, the languages are essentially the same.
- efnx 6y agoMany reasons! Languages are tools for solving entire spaces of problems. There are languages for music synthesis, database relations, templating , mathematical proofs, etc - but the list is by no means exhaustive and new languages are always needed, and I bet there are wonderful languages in our future that we didn’t know we needed.
- throw_m239339 6y agoBecause every programmer should at least once. Writing a compiler/interpreter is the ultimate exercise for any CS student/professional. that and maybe a file system/database or toy OS or server, because it encompass most aspects of CS. Anybody that can do this things can probably take on any programming job, because they require a fundamental understanding of how computers and programs work. Furthermore, It also help when suggesting realistic features to other language developers, or write proposals, or assess languages themselves.
- YorickPeterse 6y agoBecause why not? It can be a fun an very insightful process, as you'll learn about and have to apply techniques you may not have heard of otherwise.
- chrisseaton 6y agoIf nobody made their own language, we wouldn't have any languages, and you'd have to write in machine code.
- mamcx 6y agoWhy not? Programming languages are not a solved problem (or parsing, or diagnostics, or...). We are today, barely, getting practical solutions to how write safely, fast and ergonomic (for example, rust) and yet: - Compiling performance is abysmal in most compiled langs (except pascal family) - And errors... - And debugging... - And interactive compilers... - And ... (thousands of other stuff) Somebody must try to do this stuff, because if not, forever will be at mercy of C, C++, JS, the shell, unix, etc. Who wanna the cobol effect forever?
- blackrock 6y agoWhy is Pascal better at compiling performance?
- jodrellblank 6y agoNicklaus Wirth cared about not wasting machine resources. He also wrote “a plea for lean software”: > “Abstract: Software's girth has surpassed its functionality, largely because hardware advances make this possible. The way to streamline software lies in disciplined methodologies and a return to the essentials. The paper discusses some causes of "fat software" and considers the Oberon system whose primary goal was to show that software can be developed with a fraction of the memory capacity and processor power usually required, without sacrificing flexibility, functionality, or user convenience.”
- mamcx 6y agoIs made to be fast. Also, C/C++/rust is made to be slow. One recent article that touch it (for rust): https://pingcap.com/blog/rust-compilation-model-calamity https://pingcap.com/blog/rust-compilation-model-calamity
- blackrock 6y agoIt seems like one problem with rust is that it is a single threaded compiler. We’ve reached the ends of fast CPUs. To gain performance improvements, we need to use multiple cores, and process it in parallel. I wonder if this is an opportunity for github or Microsoft to host a cloud compiler? Just check in your code to github, and the cloud compiler will compile it across thousands of servers, all running in parallel. Cost: $100/month per engineer.
- efnx 6y agoThe article takes the approach of gluing together disparate solutions to write a language. With a functional language as your base, writing a new language can be quite elegant and fun! A great series by Stephen Diehl http://dev.stephendiehl.com/fun/ http://dev.stephendiehl.com/fun/ covers the subject in good detail and the fvg Lang https://github.com/Lemmih/fvg https://github.com/Lemmih/fvg is a nice reference.
- chrisseaton 6y ago> The article takes the approach of gluing together disparate solutions to write a language. But so does Diehl! It's no different! He pulls together a 'disparate' parser library (actually he implements it himself, but it's a copy of an existing library) and he mentions using literally exactly the same backend (LLVM)! What do you think the difference is that using a functional language makes? It looks like exactly the same process to me.
- a1369209993 6y agoTo be fair, they didn't say that using a functional language made it different from gluing together disparate solutions, just that it made it elegant and fun. Though admittedly, even that is at best subjective.
- unnouinceput 6y agoIt was always easy to write your own language. Hard was making that language be a mature one with plenty of libraries for mundane tasks covering all needs people want. And harder was to make said language to be adopted and become mainstream.
- sys_64738 6y agoThis applied to languages. https://xkcd.com/927/ https://xkcd.com/927/
- TuringTest 6y agoCreating a programming language is nothing like building a new standard to replace all the others. If anything, it's like writing a new novel. Why would anyone do that, when there are so many already written?
- jodrellblank 6y agoCan you answer that question? There are more novels than a person can read in a lifetime. More crime novels alone than a person can read in a lifetime. Must be approaching that for any given category or niche soon, if not already. Are they named “novels” because they are novel? If so a novel experience is a distance from where you currently are, and can plausibly be had backwards in time by reading an old book as well as forwards in time reading a new book, or sideways reading a new genre.
- TuringTest 6y agoNew novels are not written because the writer thinks people have the need to read that particular story, but because the writer has the need to tell that particular story.
- coding123 6y agoDon't forget IDE support (syntax highlighting and completion), debugging support, and last but not least marketing.
- xpe 6y agoIt seems to me that IDE support, at least with regards to syntax highlighting and completion, is also easier than ever. There are great examples in VS Code, Atom, Sublime, JetBrains, and so on.
- xpe 6y agoMarketing may or may not be in scope, depending on one's goals with a language. Some might use it for internal projects and not see a need for external uptake. Others might eventually want more attention but may prefer more organic (word of mouth) growth.
- poidos 6y ago+1 for LLVM. It's hard to grok at first, but the Kaleidoscope ([0]) tutorial lets you hit the ground running. After that, it's very rewarding to learn LLVM's API by googling, poking around their excellent source code, and having clang emit IR for you (`clang -S -emit-llvm -O0 test.c`) [0]: https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index.html https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index...
- xpe 6y agoAnother option that may be useful: transform a custom syntax to an existing language. And while you are at it, why not try to write a parser to reverse the process? :)
- _hardwaregeek 6y agoThis article is bugging me for some reason. I don't disagree with it. It's certainly easier to make a language now, even more so than in 2016 when this article was published. But it feels like saying "it's easier to make a bridge than ever". That statement isn't wrong. I'd much rather make a bridge with modern technology. But it's still a damn hard task. And citing parsing isn't a great example. Parser generators have been around for ages. And they're usually not the hard part anyways. Defining a simple grammar and parsing it, even manually, isn't that terrible of a task. Getting decent error messages and figuring out recovery? That's trickier. Code generation has certainly gotten easier. But you still need to go through the process of figuring out how to lower your abstractions. My language is still extremely basic but I've still had to map my high level types and control structures down to WebAssembly. LLVM won't do that for you. There's also more that your average user expects if you want a language that people use. Decent tooling is important, so a language server and some syntax highlighting packages in different editors. Good error messages. Decent type inference. Most of these you can eschew in the first few iterations of your language but eventually you'll need them. I feel bad criticizing this post because writing a language has been one of the most instructive experiences I've had. I've learned so much about code generation, typechecking, the WASM spec, etc. But it's still a lot of tough work to get to something people can use. I'm not sure parser generators and LLVM make it that much easier.
- amelius 6y agoWriting a competitive concurrent garbage collector is probably the hardest part these days.
- MaxBarraclough 6y agoWell, you pretty much can't. A lone hobbyist simply isn't going to throw together a state-of-the-art garbage collector, any more than they're going to outperform LLVM's optimisations and code-generation. The choice is between leveraging existing GCs, such as by compiling to Java bytecode, or making do with an inferior garbage collector (or the choice of several inferior garbage collectors), the way D/Nim/OCaml do.
- 6y ago
- Vaslo 6y agoWe don’t need yet more languages - it’s like the fall of the Tower of Babel now.
- codr7 6y agoUse the Forth, Luke! https://github.com/codr7/gfoo https://github.com/codr7/gfoo
- vincent-manis 6y agoI'm all for writing one's own language. However, anyone who does this should be sentenced to writing a significant program in this language afterwards. Only then can they discover how wonderful or (more likely) horrible their creation actually is. Writing Towers of Hanoi in it doesn't count. Also, if this language isn't just going to be a toy, they need to write some sort of specification document about it. I'm tired of seeing new language websites announcing version 0.9 of the new language, accompanied by a statement that “we haven't yet written a language manual, but here are some example programs and some obsolete papers about prior versions”. I used to work in a senior position at a multinational firm. At one point, I went to the site of a company that had been recently purchased by my employers. Their major product was a large online system that was substantially written in a custom language. At that point, since the principals in the original company had left, there was not one employee left who understood this language completely.
- 100-xyz 6y agoOur platform lets users create animations in minutes. We use natural language in our scripts. Eg. Cowboy say "Hi there." Wait for 2 seconds. Cowboy run to Point P2 in 3 seconds. It has been an eye opening and learning exercise. The advantage is even first time users can start using our language. Disadvantage natural language has such a wide variety of usage styles that it's a challenge. https://toonclip.com https://toonclip.com
- hassancf 6y agoOff-topic: do you think this could be used to learn coding (by an 8-year old)? Especially a kid who easily gets bored with things like Scratch (MIT). Thanks in advance.
- 100-xyz 6y agoYes. I am using it to teach small children the basics of coding. It helps them understand simple abstractions
- Someone 6y agoI am not sure I agree with the claim. What’s really easier with the proposed approach (using a python port of lex and yacc and generating LLVM) than using yacc and lex (with all their warts) to generate C code for your own language was in 1980? Yes, if your language doesn’t fit C, your implementation could be more efficient (potentially a lot), but getting there isn’t easier. I think we got a lot of complexity and options since then that distract from “writing your own language”. I think a claim that we can do better than lex and yacc nowadays (e.g. using Haskell) would be a much stronger argument for “it’s much easier now”
- b20000 6y agolike we don't have enough programming languages already?
- xchip 6y agoPlease don't