Did a bit more work porting rply to #go this afternoon. Now I’m into building the parser things are getting tricky. #Rply is also barely commented at all so it’s often hard to follow. Also because #python is dynamic, there are no types for anything! So I have to be the human type inferrer. It’s been a bit frustrating working out what type a variable is (or what a dictionary holds) when I can’t see the raw values going in.
Remember I was going to try writing a language (either #braid, or something Braid-like) that compiles to #go? I decided that I should learn Go a bit more thoroughly before getting stuck into that, and I also wasn’t keen on using
yacc for the parsing stage — it’s really old, and has a weird syntax. So why not combine the two and start by porting
rply (rpython lex yacc, a modern implementation of those tools) to go? At first I thought this wouldn’t be a huge undertaking, and then of course I realised how little I knew. But tonight I got the lexer finished and working! It didn’t take too long at all. 🎉
I grappled with Go a little bit, but didn’t have huge problems. It’s mostly pointers I have to really think about. I agree with those who say the core language is easy to pick up, although I think people conflate (at least I did) “modern” with “high-level”. It’s really not high-level 😐 but that’s why we’re writing a language on top of it, right?
Maybe tomorrow I’ll start porting the parser.
Today I got some simple lexing set up using a package called
lexmachine. Next I’ll be learning to use
yacc so I can plug the resulting tokens into a parser. Small steps.
Reading about using #go as a shared library you can access from #python (with very little overheard in python 3, too). Even goroutines work. Seems like a nifty way of combining python with some more performant/concurrent code where needed. https://blog.filippo.io/building-python-modules-with-go-1-5/
Only tonight found out that #go has no support for default arguments. Look at the crazy shit you have to do to emulate them: http://joneisen.tumblr.com/post/53695478114/golang-and-default-values yuck.