News for hackers. Stuff that matters.

Show HN: Learning Project: building an imperative language

Hi! I am doing a learning project, attempting to build an imperative language (and interpreter). The end product will be useless for others, I just want to learn and better understand how to build imperative languages. :) If someone else shares this interest and want to give some good hints on good resources I would be grateful. Currently I am looking at an awesome text by Bob Nystrom. All suggestions and tips on resources are most welcome. I am very much a beginner in this, but I find this topic very fascinating. Mail me or post links here! Cheers!

You can try a beta version Online at https://herebeseaswines.net/crudelang/.

GitHub: https://github.com/bergsans/crudelang

( 11 comments | 36 points | on HN )
Re:Show HN: Learning Project: building an imperative language by DylanSp on Monday October 05, 2020 @03:59PM (#24691399)
Always cool to see people experimenting with languages! I'm doing a similar thing with wheel-lang [0], which started as pretty purely imperative, but is starting to grow some object-oriented features.

Nystrom's Crafting Interpreters is a great resource; I've also liked Compiling to Assembly From Scratch [1] and Write You a Haskell [2].

[0] https://github.com/DylanSp/wheel-lang/

[1] https://keleshev.com/compiling-to-assembly-from-scratch/

[2] http://dev.stephendiehl.com/fun/

Re:Show HN: Learning Project: building an imperative language by inetsee on Monday October 05, 2020 @04:33PM (#24691704)
There are other variations for functional programming languages. Lisp [1]. Scheme [2]. Lisp Interpreter written in Python.

[1] http://buildyourownlisp.com/

[2] https://upload.wikimedia.org/wikipedia/commons/a/aa/Write_Yo...

[3] https://norvig.com/lispy.html

Re:Show HN: Learning Project: building an imperative language by bergsans on Tuesday October 06, 2020 @02:14AM (#24695155)
I love Norvigs text. I built a minimalistic lisp (https://github.com/bergsans/one-page-lisp) to learn more after reading the text. Thanks!
Re:Show HN: Learning Project: building an imperative language by bergsans on Tuesday October 06, 2020 @02:17AM (#24695167)
Cool! And I hope as well learn a lot (from building wheel-lang)! Thanks for the links!
Re:Show HN: Learning Project: building an imperative language by prettyracketta on Monday October 05, 2020 @03:56PM (#24691379)
Might not be exactly what you want but the pay-what-you-can (free to read) online book Beautiful Racket[0] is an amazing resource for learning how to build languages. In the words of Alan Kay, "Lisp isn't a language, it's a building material".

The last project is implementing an extended version of BASIC that supports interop with Racket, so as imperative as it gets.

[0] https://beautifulracket.com/

Re:Show HN: Learning Project: building an imperative language by bergsans on Tuesday October 06, 2020 @02:13AM (#24695147)
> The last project is implementing an extended version of BASIC

Thanks! This sounds very interesting! Cheers!

Re:Show HN: Learning Project: building an imperative language by krueger71 on Tuesday October 06, 2020 @02:26AM (#24695216)
Re:Show HN: Learning Project: building an imperative language by thesephist on Monday October 05, 2020 @07:31AM (#24686655)
Did this myself with Ink [0] and learned a lot. I also wrote about the experience on my blog [1] with links to resources I found helpful under the "Implementation" heading.

[0] https://dotink.co/

[1] https://thesephist.com/posts/pl/

Re:Show HN: Learning Project: building an imperative language by bergsans on Monday October 05, 2020 @07:56AM (#24686840)
Cool, will check it out! Thanks. Yeah, you learn a lot from it. :)
Re:Show HN: Learning Project: building an imperative language by throwaway_pdp09 on Monday October 05, 2020 @05:00AM (#24685860)
> The end product will be useless for others

I like your honesty!

Well, it looks like you've got something working so you've accomplished your goal, where do you feel you are falling short?

Also there are a ton of good tutorials out there I assume, have you not found any? (not checked as I don't need them, but it's the interweb so...)

Re:Show HN: Learning Project: building an imperative language by anonymoushn on Monday October 05, 2020 @04:31AM (#24685707)
I think you've already found the best resource out there.

For fun I'm making a language that's a superset of Lox and Monkey, the language from the book by Thorsten Ball.