Live data from Hacker News

Ask HN: Resources for building a programming language?

news.ycombinator.com

51–60 of 87 posts

Re: Ask HN: Resources for building a programming language?

#51
post #44

Here's a cool programming language in a live-coding environment that I developed with my interns two summers ago. It enables natural language programming which is great for introducing young kids to computer science. It is built in Java and uses a recursive descent parser to parse sentences like "draw a red circle at 300, 300", and is well commented because the intention was for advanced students at my education prog…

That idea runs into scaling problems quickly. See COBOL-60 and HyperTalk, which are are surprisingly similar. A useful question: you want to talk to a computer conversationally, and get beyond the Alexa/Siri level of tasks. How would you do that? Fully general natural language requires strong AI. Could you come up with some more restricted form with enough expressive power but understandable by a computer? The comput…

Correctable dead-ends are better educationally than crafted successes. I don't think the goal is to teach students how to parse english, or making a conversant programming language, but it could show why programming languages use something other than natural language.

Re: Ask HN: Resources for building a programming language?

#52
post #13

If you're looking to create a dynamic language with reasonable performance, you could look at implementing it with RPython [1], which is used for PyPy, or for the Parrot VM [2], which is used for Perl 6. Once it becomes a little more mature, Zeta VM [3] may also be a good target. [1] https://rpython.readthedocs.io/en/latest/ [2] http://www.parrot.org/ [3] https://github.com/zetavm/zetavm

Another option is to target Lua. The C version runs everywhere and the LuaJIT version is super fast.

Re: Ask HN: Resources for building a programming language?

#53

https://interpreterbook.com is a pretty good resource to hit the ground running, with unit tests and little magic. Once you've gone through it, you'll probably want to use the magic tools as they're well tested at this point, and make your life easier. Still, understanding what they're doing for you is a massive boon. I should note, it uses Go but not in an idiomatic way. Strings instead of using an error type, etc.…

Author of the book here. Thanks for the shout out! I'm happy to hear that you appreciate the book exactly in the way it was intended to - little magic, lots of code and unit tests. I'm also super curious about your "not in an idiomatic way" comment. If you have a minute, feel free to send me a longer version - me at thorstenball.com. I'd really love to hear what you'd do differently and what could be more idiomatic.

Sent an email from my username at gmail.

> I'm happy to hear that you appreciate the book exactly in the way it was intended to - little magic, lots of code and unit tests.

Yeah, that's exactly what I wanted out of it, and my coworker recommended it at the best possible time on top of that.

Re: Ask HN: Resources for building a programming language?

#55
To keep motivation, you need to have result quickly while focusing on topics you are interested in. You should choose the high level language (with at least a GC) where you are the more proficient. Have very small exigences in error diagnostic. If your interest is mainly in language syntax and semantic, you can either write an interpreter or target an existing language (C++ was initially generating C).

Re: Ask HN: Resources for building a programming language?

#56
Many suggest resources for compiler implementations, i personally would start prototyping the language itself, think about it's type system and its runtime properties. There are many possibilities in terms of type systems, from static to dynamic and everything in between, concepts like linear types, algebraic types, etc. Runtime properties are things like it's memory model (garbage collection, yes or no). All of this depends on the purpose of your language.

The second part would be choosing a platform to run on (so you only have to write a compiler frontend). There are many great technologies to host a language, but i'd advocate two specific ones here:

* https://github.com/zetavm/zetavm (shoutout to @love2code)

* https://llvm.org/

ZetaVM is a great target for dynamicly typed and/or jit compiled languages like python or javascript. LLVM is used in many low level / near metal languages like C, C++, rust and so on.

None of both must be your final targets, your compiler frontend can be moved to target another platform like the JVM later.

As a last part, implement your compiler frontend. This involves lexing/parsing source code, type checking if needed and generating your target's intermediate representation. I personally prefer hand-written recursive descent parsers using a parser combinator framework (like https://github.com/Geal/nom) over parser generators. For further processing like type checking, there is the common monolith aproach and the nanopass framework/approach https://www.youtube.com/watch?v=Os7FE3J-U5Q Also there's a great series on compiler frontends by Alex Aiken: https://www.youtube.com/watch?v=sm0QQO-WZlM&list=PLFB9EC7B8F...

Hope this gives an overview. :)

Re: Ask HN: Resources for building a programming language?

#57

Using Forth as a substrate lets you focus on the more interesting aspects to an even higher degree than Lisp. The last thing you want is detailed instructions; unless you're just building another whatever, which never really made sense to me. Build the most simple and naive thing possible that works the way you want it to, and go from there. That's how Snabel was born: https://github.com/andreas-gone-wild/snackis/blo…

Therein lies my problem with Forth. Yes there is a ton of power, but that is inaccessible to a lot of users. I know I can look at Jones Forth & MeCrisp, but I honestly couldn't see where to start. I'd like to see a tutorial start with either an assembly or C base and then teach Forth fundamentals such as how to start your dictionary and choose between direct/indirect threading and how to implement each. I'm always cu…

I came into Forth with 32 years of mixed experience from Lisp, Smalltalk, Haskell, C++, C, Java, Perl, Python, Clojure, Scala and more; it's difficult for me to judge anything from that perspective.

I've never written a standard Forth program in my life though, never installed any other implementation. The second I was introduced to Forth, it clicked; Lisp took me much, much longer to get by comparison.

Like I said, I'm not very much into rebuilding what has already been built better by someone else. Anyone who's written any amount of code is bound to have own ideas, and the nice thing about Forth as a substrate is that doesn't come with that many ideas of its own.

I've written a few blog posts explaining design choices (https://github.com/andreas-gone-wild/blog/blob/master/forthy...), there's more interesting stuff to come now that the pieces are falling into place; I've only been working on Snabel for a couple of months.

Re: Ask HN: Resources for building a programming language?

#58
post #27

Here's an ebook on the subject: "How to Create Your Own Freaking Awesome Programming Language" http://createyourproglang.com Here's what some programming luminaries had to say (lifted from the website): “The book I want to read.” — Matz, creator of the Ruby language “I really love this book.” — Jeremy Ashkenas, creator of the CoffeeScript language

"The book I want to read." - that's a rather odd testimonial.

Re: Ask HN: Resources for building a programming language?

#59

Many suggest resources for compiler implementations, i personally would start prototyping the language itself, think about it's type system and its runtime properties. There are many possibilities in terms of type systems, from static to dynamic and everything in between, concepts like linear types, algebraic types, etc. Runtime properties are things like it's memory model (garbage collection, yes or no). All of this…

[deleted]
Post reply on HN