TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

There's never been an easier time to write your own language (2016)

77 pointsby lowmemcpualmost 5 years ago

15 comments

_hardwaregeekalmost 5 years ago
This article is bugging me for some reason. I don&#x27;t disagree with it. It&#x27;s certainly easier to make a language now, even more so than in 2016 when this article was published. But it feels like saying &quot;it&#x27;s easier to make a bridge than ever&quot;. That statement isn&#x27;t wrong. I&#x27;d much rather make a bridge with modern technology. But it&#x27;s still a damn hard task.<p>And citing parsing isn&#x27;t a great example. Parser generators have been around for ages. And they&#x27;re usually not the hard part anyways. Defining a simple grammar and parsing it, even manually, isn&#x27;t that terrible of a task. Getting decent error messages and figuring out recovery? That&#x27;s trickier.<p>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&#x27;ve still had to map my high level types and control structures down to WebAssembly. LLVM won&#x27;t do that for you.<p>There&#x27;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&#x27;ll need them.<p>I feel bad criticizing this post because writing a language has been one of the most instructive experiences I&#x27;ve had. I&#x27;ve learned so much about code generation, typechecking, the WASM spec, etc. But it&#x27;s still a lot of tough work to get to something people can use. I&#x27;m not sure parser generators and LLVM make it that much easier.
评论 #23726282 未加载
评论 #23727950 未加载
评论 #23725831 未加载
评论 #23726274 未加载
vincent-manisalmost 5 years ago
I&#x27;m all for writing one&#x27;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&#x27;t count.<p>Also, if this language isn&#x27;t just going to be a toy, they need to write some sort of specification document about it. I&#x27;m tired of seeing new language websites announcing version 0.9 of the new language, accompanied by a statement that “we haven&#x27;t yet written a language manual, but here are some example programs and some obsolete papers about prior versions”.<p>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.
poidosalmost 5 years ago
+1 for LLVM. It&#x27;s hard to grok at first, but the Kaleidoscope ([0]) tutorial lets you hit the ground running. After that, it&#x27;s very rewarding to learn LLVM&#x27;s API by googling, poking around their excellent source code, and having clang emit IR for you (`clang -S -emit-llvm -O0 test.c`)<p>[0]: <a href="https:&#x2F;&#x2F;llvm.org&#x2F;docs&#x2F;tutorial&#x2F;MyFirstLanguageFrontend&#x2F;index.html" rel="nofollow">https:&#x2F;&#x2F;llvm.org&#x2F;docs&#x2F;tutorial&#x2F;MyFirstLanguageFrontend&#x2F;index...</a>
efnxalmost 5 years ago
The 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 <a href="http:&#x2F;&#x2F;dev.stephendiehl.com&#x2F;fun&#x2F;" rel="nofollow">http:&#x2F;&#x2F;dev.stephendiehl.com&#x2F;fun&#x2F;</a> covers the subject in good detail and the fvg Lang <a href="https:&#x2F;&#x2F;github.com&#x2F;Lemmih&#x2F;fvg" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Lemmih&#x2F;fvg</a> is a nice reference.
评论 #23725404 未加载
Someonealmost 5 years ago
I 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?<p>Yes, if your language doesn’t fit C, your implementation could be more efficient (potentially a lot), but getting there isn’t easier.<p>I think we got a lot of complexity and options since then that distract from “writing your own language”.<p>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”
100-xyzalmost 5 years ago
Our platform lets users create animations in minutes. We use natural language in our scripts.<p>Eg. Cowboy say &quot;Hi there.&quot; Wait for 2 seconds. Cowboy run to Point P2 in 3 seconds.<p>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&#x27;s a challenge.<p><a href="https:&#x2F;&#x2F;toonclip.com" rel="nofollow">https:&#x2F;&#x2F;toonclip.com</a>
评论 #23726073 未加载
unnouinceputalmost 5 years ago
It 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.
xpealmost 5 years ago
Another option that may be useful: transform a custom syntax to an existing language.<p>And while you are at it, why not try to write a parser to reverse the process? :)
codr7almost 5 years ago
Use the Forth, Luke!<p><a href="https:&#x2F;&#x2F;github.com&#x2F;codr7&#x2F;gfoo" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;codr7&#x2F;gfoo</a>
coding123almost 5 years ago
Don&#x27;t forget IDE support (syntax highlighting and completion), debugging support, and last but not least marketing.
评论 #23725421 未加载
评论 #23725419 未加载
tminalmost 5 years ago
But why would you do that?
评论 #23725151 未加载
评论 #23725435 未加载
评论 #23725018 未加载
评论 #23725183 未加载
评论 #23725420 未加载
评论 #23724983 未加载
评论 #23724976 未加载
b20000almost 5 years ago
like we don&#x27;t have enough programming languages already?
xchipalmost 5 years ago
Please don&#x27;t
sys_64738almost 5 years ago
This applied to languages.<p><a href="https:&#x2F;&#x2F;xkcd.com&#x2F;927&#x2F;" rel="nofollow">https:&#x2F;&#x2F;xkcd.com&#x2F;927&#x2F;</a>
评论 #23725457 未加载
Vasloalmost 5 years ago
We don’t need yet more languages - it’s like the fall of the Tower of Babel now.