Live data from Hacker News

The Rewards of Creating a Programming Language

mikedrivendevelopment.blogspot.com

11–20 of 88 posts

Re: The Rewards of Creating a Programming Language

#11
post #8

I've recently discovered PEG.js [0] and prototyped a small DSL in the browser [1]. Amazing stuff! I've dealt with ANTLR [2] before, but PEG.js feels so much nicer although it may not be as powerful! [0] http://pegjs.org/ [1] http://pegjs.org/online [2] http://www.antlr.org/

Related side-project : http://peg.arcanis.fr

Like the demo version, but doesn't lock your browser with infinite recursion, and supports Ctrl+S! PegJS is a really great/fun tool.

Re: The Rewards of Creating a Programming Language

#13

The author says he turned to Coursera, but doesn't mention the course(s) he took, but I'm going to guess it's the the 'Compilers' class from Stanford[0]. I'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. https://www.coursera.org/course/compilers

A self-paced version of that course is (still) available now:

https://class.stanford.edu/courses/Engineering/Compilers/Fal...

Re: The Rewards of Creating a Programming Language

#14
post #7
post #2

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.

Yes, I've written tools for existing languages, and found just getting the parser right to be a challenge, be it with Emacs highlighting, flex/bison, what have you. Real languages aren't as tidy as the textbook examples.

When I do PL these days, I always start with the editor; e.g. see:

http://research.microsoft.com/en-us/people/smcdirm/managedti...

Co-designing your editor with your language allows for a better experience.

You are right in that all of this is basically undocumented in textbooks. Even their presentation on on parsing is mostly unhelpful (if you want an error tolerant incremental parser for your editor, recursive descent works very well).

Re: The Rewards of Creating a Programming Language

#15
post #3

> Notice how not a single variable in this code has a name. They all only have types. Pretty cool, never even thought about this being possible.

It’s not a novel idea, but Wake does it quite well. Most variable names aren’t that useful—they’re just one of many possible syntactic ways to plumb values around.

I've been playing around with an idea to replace variable names with brands. So say you have an argument to a procedure:

    brand position 
Position is a point, but is not a distinct type. You can document it centrally and not for each time it is used as an argument to a procedure or as a variable. E.g.

    def Set(position): ...
You have define brands before you can define your procedure, but multiple procedures can share brands they use to declare their arguments.

Re: The Rewards of Creating a Programming Language

#16

The author says he turned to Coursera, but doesn't mention the course(s) he took, but I'm going to guess it's the the 'Compilers' class from Stanford[0]. I'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. https://www.coursera.org/course/compilers

I did this class. It is quite challenging (and rewarding). If you plan to do it make sure to allocate a significant amount of time per week. My recommendation would be to do the Java version of the assignments over the C++ version, even if you know C++. The codebase provided is pretty crufty.

Re: The Rewards of Creating a Programming Language

#17

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. The world does not need yet another reskin of Java, but it could use new programming paradigms and new ways of solving problems. As a learning exercise, implementing a language is wo…

Agree. I'm (trying!) to do one, and now I only focused in the AST and trying to build the features. Is a waste of effort to rewrite parser/lexers/etc if the core is in constant change:

https://www.reddit.com/r/coding/comments/2ocw2r/how_to_creat...

Re: The Rewards of Creating a Programming Language

#18
I've been working on a programming language in my spare time, also. I call it OWL. Its not quite ready, but here's a link anyways: https://github.com/bsurmanski/wlc

OWL aims to be a low level object-oriented language without a garbage collector (albeit with reference counting).

The best 'example' program using OWL right now is a game I made for the 48 hour game jam, Global Game Jam 2015: https://github.com/bsurmanski/ggj2015

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't).

Re: The Rewards of Creating a Programming Language

#19
post #3

> Notice how not a single variable in this code has a name. They all only have types. Pretty cool, never even thought about this being possible.

It’s not a novel idea, but Wake does it quite well. Most variable names aren’t that useful—they’re just one of many possible syntactic ways to plumb values around.

The canonical example is how it's done in Forth: Ask for a number and it's already on the stack. Ask for three numbers and you push onto the stack three times. Upside: Terse code. Downside: Stack juggling can be a big maintenance burden.

FWIW I've realized that in languages that are variable centric, an anonymous naming convention is often preferable to a human name because it centers one's concerns around the algorithm. After studying the options for a while I now flip between descriptive word style and "single letter and number." So I have a lot of "x0, x1, i0, s0, a0" in my function arguments. Where it's a record type, I'm deciding between abbreviation and descriptive - which ultimately depends on how often and densely I expect the data structure to be accessed(short names imply it gets used in a dense, idiomatic style).

Re: The Rewards of Creating a Programming Language

#20
post #19

Earlier quoted context omitted.

It’s not a novel idea, but Wake does it quite well. Most variable names aren’t that useful—they’re just one of many possible syntactic ways to plumb values around.

The canonical example is how it's done in Forth: Ask for a number and it's already on the stack. Ask for three numbers and you push onto the stack three times. Upside: Terse code. Downside: Stack juggling can be a big maintenance burden. FWIW I've realized that in languages that are variable centric, an anonymous naming convention is often preferable to a human name because it centers one's concerns around the algori…

Yep. I am working on a statically typed stack-based language, as I quite like the Forth style. Stack manipulation sucks, so I mainly use locals for auxiliary parameters, to get them out of the way of the main data structure or values that a definition is manipulating implicitly. For example:

    define do_the_thing (Foo bool -> Bar):
      -> should_log;

      if (should_log):
        dup log_foo

      foo_to_bar

      if (should_log):
        dup log_bar
Post reply on HN