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.

The Rewards of Creating a Programming Language

148 pointsby StylifyYourBlogover 10 years ago

21 comments

t1mover 10 years ago
I was hired (a long time ago) to write a language for a Very Large Telco Equipment Supplier in Canada in order to support their automated regression testing effort for their digital telephone switches.<p>It was called, ingeniously enough, &quot;T&quot; (no, not <i>that</i> &quot;T&quot;). As far as I (and cursory Google searches) know, it was never released to the adoring public.<p>I used lex and yacc (half jokingly referred to as &#x27;ick&#x27; and &#x27;yuck&#x27;) and K&amp;R C for the compiler and VM.<p>The particular type of testing we were targeting involved writing test cases that would read&#x2F;write over serial lines to a telephone switch&#x27;s console program. Therefore, the language needed to have good serial&#x2F;terminal I&#x2F;O, and it needed to have amazing string&#x2F;pattern matching.<p>I wrote two features that I am still particularly fond of:<p>- regexps were a built in type. Strings were written like &#x27;hi there&#x27; and regexps were written like `hi ..ere` - supported standard unix regexps<p>- associative arrays. Lots of languages have these now, like python&#x27;s dict<p>The cool thing about it was how we tried to allow strings and regexps have a polymorphic relationship at the language level. The statements:<p><pre><code> x == &#x27;some string&#x27; or x == `some [^t]ring` </code></pre> would be valid for strings in x, though the regexp had other operators that didn&#x27;t make much sense with strings. It got really interesting when we combined the regexps with the associative array:<p><pre><code> dict[&#x27;hello&#x27;] = 4 dict[&#x27;help&#x27;] = 2 dict[`he.*`] == [2, 4] # true</code></pre>
评论 #9042928 未加载
评论 #9043679 未加载
evincarofautumnover 10 years ago
If you’re thinking of writing a language in earnest, you will create something much more valuable if you start from a novel semantics, and only then come up with a syntax to express those semantics, than if you were to start from syntax.<p>The world does not need yet another reskin of Java, but it could use new programming paradigms and new ways of solving problems.<p>As a learning exercise, implementing a language is worthwhile simply to gain the understanding that languages are <i>not magic</i>. To boot, you’ll pick up loads of useful techniques in the realms of parsing, data flow analysis, error reporting, and optimisation.
评论 #9042226 未加载
评论 #9043005 未加载
评论 #9042078 未加载
评论 #9043452 未加载
nemesisrobotover 10 years ago
The author says he turned to Coursera, but doesn&#x27;t mention the course(s) he took, but I&#x27;m going to guess it&#x27;s the the &#x27;Compilers&#x27; class from Stanford[0]. I&#x27;ve heard good things about the course and the lecturer (Alex Aiken) so I really wanted to take the course while it was being offered but was too busy last year. I hope they offer it again this year.<p><a href="https://www.coursera.org/course/compilers" rel="nofollow">https:&#x2F;&#x2F;www.coursera.org&#x2F;course&#x2F;compilers</a>
评论 #9042054 未加载
评论 #9042030 未加载
评论 #9043245 未加载
评论 #9042250 未加载
评论 #9042444 未加载
评论 #9041994 未加载
austinzover 10 years ago
Another interesting thing to try (and maybe complementary as well) is building an interpreter or compiler for a language you like, trying to match the spec and feature set as closely as possible, and (hopefully) gaining more insight into the tradeoffs the language designers made when deciding why things are the way they are.
评论 #9041990 未加载
评论 #9041959 未加载
WalterBrightover 10 years ago
I wrote this a while back on creating your own language: <a href="http://digitalmars.com/articles/b89.html" rel="nofollow">http:&#x2F;&#x2F;digitalmars.com&#x2F;articles&#x2F;b89.html</a>
评论 #9043519 未加载
zak_mc_krackenover 10 years ago
If you are a developer and you have never written a language, you owe it to yourself to do this at least once.<p>Writing a language (lexical, syntactic, semantic phase and then code generation) will teach you an incredible amount of things in much less time it would take you to read about these things.<p>What your language looks like is completely irrelevant, this is strictly about learning from the journey.<p>And once you&#x27;ve done that, make sure to mention it in your resume: I, for one, will instantly give you brownie points if you mention in your resume that you wrote a language.
评论 #9043599 未加载
bsurmanskiover 10 years ago
I&#x27;ve been working on a programming language in my spare time, also. I call it OWL. Its not quite ready, but here&#x27;s a link anyways: <a href="https://github.com/bsurmanski/wlc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bsurmanski&#x2F;wlc</a><p>OWL aims to be a low level object-oriented language without a garbage collector (albeit with reference counting).<p>The best &#x27;example&#x27; program using OWL right now is a game I made for the 48 hour game jam, Global Game Jam 2015: <a href="https://github.com/bsurmanski/ggj2015" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bsurmanski&#x2F;ggj2015</a><p>I agree with the poster that making a programming language from scratch is a great way to explore programming. On top of that, its a great experience seeing able to implement all of those features you wish were in your favorite language (or find out why they aren&#x27;t).
nilliamsover 10 years ago
&gt; Notice how not a single variable in this code has a name. They all only have types.<p>Pretty cool, never even thought about this being possible.
评论 #9042531 未加载
评论 #9043379 未加载
评论 #9041954 未加载
kolevover 10 years ago
I&#x27;ve recently discovered PEG.js [0] and prototyped a small DSL in the browser [1]. Amazing stuff! I&#x27;ve dealt with ANTLR [2] before, but PEG.js feels so much nicer although it may not be as powerful!<p>[0] <a href="http://pegjs.org/" rel="nofollow">http:&#x2F;&#x2F;pegjs.org&#x2F;</a><p>[1] <a href="http://pegjs.org/online" rel="nofollow">http:&#x2F;&#x2F;pegjs.org&#x2F;online</a><p>[2] <a href="http://www.antlr.org/" rel="nofollow">http:&#x2F;&#x2F;www.antlr.org&#x2F;</a>
评论 #9042556 未加载
评论 #9042006 未加载
element11over 10 years ago
I always wonder about the final conversion to assembly. Do you really need to learn all the instructions, the linking, the binary formats and all that stuff ?
评论 #9042976 未加载
emmabover 10 years ago
When your top-down parser gets caught in an infinite loop, you&#x27;ll need to convert the left recursion to right recursion. See here: <a href="https://en.wikipedia.org/wiki/Left_recursion#Removing_left_recursion" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Left_recursion#Removing_left_r...</a><p>Writing a compiler is a significant amount of work and should be pre-researched to avoid issues like the above.
damian2000over 10 years ago
I was reading something similar here about creating your own language using LLVM (and also using the Ruby bindings for LLVM as opposed to C++) ... <a href="http://macournoyer.com/blog/2008/12/09/orange/" rel="nofollow">http:&#x2F;&#x2F;macournoyer.com&#x2F;blog&#x2F;2008&#x2F;12&#x2F;09&#x2F;orange&#x2F;</a>
agumonkeyover 10 years ago
I&#x27;m curious how people feel about syntax. I tend to think everything should be written in sexp (I like [s]ml syntax too though). Much like this <a href="http://cs.brown.edu/courses/cs173/2012/book/Everything__We_Will_Say__About_Parsing.html" rel="nofollow">http:&#x2F;&#x2F;cs.brown.edu&#x2F;courses&#x2F;cs173&#x2F;2012&#x2F;book&#x2F;Everything__We_W...</a><p>Maybe I&#x27;m missing something, how many people felt that syntax made an idea pop differently and was part of the understanding ? To me it&#x27;s often the opposite, it conflates too many things in a few symbols and then you waste time discussing corner cases.
xjiaover 10 years ago
Inaccurately, programming language = syntax + semantics.<p>Do not waste your time on syntax, if you are going to create a new language, rather than a parser.<p>I&#x27;m not saying that syntax is not important. But I feel semantics deserves much more attention.
评论 #9042586 未加载
girvoover 10 years ago
Yes! I agree entirely, which is why I&#x27;ve been diving deep into creating (and playing with) new languages lately. Turns out a lot of problems that I have to solve at work can be fit into a parsing problem too, so it&#x27;s not just all theoretical, but the big part of learning how to build languages is appreciating how the ones I use every day work; I can extend them, understand bugs, and push them to their limits. I couldn&#x27;t do that prior: I always thought it was just black magic that greying neckbeard wizards did off in some ivory tower!
nubelaover 10 years ago
&quot;that types are often a great name for variables, which both the programmer and compiler can use to easily and effectively understand most common code.&quot;<p>This hit me, what if variable names CONTAIN types? int__i = 1<p>And of course, it can be made optional. I will much prefer to do optional typing in the var name itself rather than the ugly syntax that guido has proposed with python.
评论 #9043366 未加载
lifeisstillgoodover 10 years ago
the best happy-accident ... Months and months later, I realized that ... thanks to this simple idea, I could ...<p>That sentence is in every act of creation - something new just spawns something else that was not possible before the original act.<p>It&#x27;s marvellous to see and indicates he is on the trail of something good - all the best.
erikbover 10 years ago
I scrolled through the article and found some attributes of a language that is probably created by the author. But where are the rewards? I&#x27;m confused.
scotty79over 10 years ago
I wonder how much fun one could have with OMeta <a href="http://tinlizzie.org/ometa/" rel="nofollow">http:&#x2F;&#x2F;tinlizzie.org&#x2F;ometa&#x2F;</a> ?
davidwover 10 years ago
I had fun doing Hecl. It didn&#x27;t bring me fame and riches, but it did get used by a few companies, and it got me some interesting gigs.
bltover 10 years ago
currently stockpiling semantics ideas until I have enough good ones to justify the effort...