littlelogs

Keep a social journal of your work progress as you make and learn things.

February 2017

josh
josh

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.

January 2017

josh
josh

Remember my toy language #braid? I’ve been thinking a lot about making something similar that compiles to #go. Go has a lot of benefits, like good concurrency primitives, fast GC, cross-platform compilation, but it lacks some niceties like algebraic data types and generics. Maybe I could write a language that provides these and compiles to go, so it can take advantage of its benefits too, like the many interesting languages that compile to javascript. I’m not sure I can actually implement what I have in mind, but I’m curious to try, just for fun.

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.

June 2016

josh
josh

Earlier this week I deployed our #exist correlation changes, adding explanations to a lot of common combos. I haven’t had any feedback on that yet, but hopefully a few people have noticed them by now and are pleased. I’ll have to keep adding more though, maybe set a recurring tasks to do some each month.

Tonight, to procrastinate and avoid working on #braid, because I’m a bit stuck and the next steps are getting complicated, I wrote a thing for my blog about why it’s getting easier to write your own language. Trying to show that it’s not really that scary, as a lot of the hard work has been done for you. Feedback appreciated.

1 year, 1 week ago Braid exist

3 Heart 1 comment

May 2016

josh
josh

This weekend I’ve been tinkering with #braid some more. I found a very useful implementation of the Hindley-Milner algorithm in #python so I’ve taken that and built on it, incorporating it into my compilation as a new type-checking stage. It’s been mostly successful so far! I can remove all type annotations and let the compiler infer function and variable types, and then use those types in the #llvm IR-generation stage. Pretty happy with that.

josh
josh

Today and yesterday I did a little more on getting #braid to compile to #llvm IR. Tonight I achieved a small milestone — I can successfully compile and run a basic factorial function, and return the result as the exit code. I also learned how the phi instruction works, which is perfect for collecting the result of an if-expression. Next will be working out how to link the standard C library so I can use stuff like printf.

josh
josh

This afternoon I got #larder’s browser extensions updated to handle the upcoming trial changes. I’m still waiting on the #firefox one to be approved, then we can deploy the changes once all the various bits are in sync.

Tonight I made a little progress getting #braid to generate some #llvm IR. It wasn’t too hard getting this far — I hope I have a while yet before it gets beyond my understanding and ability.

josh
josh

Today and yesterday I spent a little time getting #llvm working with #python, and (sort of) revived #braid, my toy language project. My new goal is to compile my AST into LLVM IR which can then be compiled into a binary. Today this meant adding some type annotations because LLVM IR is strongly typed and I’d like Braid to be also.

I’ve given up using #rpython this time, which is such a relief, but obviously Python is not the best language to write a language in, speed-wise if nothing else… however, it is just for fun and to learn, so it doesn’t really matter, I think. If I really do keep at it, I can always rewrite it in something else, or use the first Braid compiler to write a new Braid compiler in Braid (bootstrapping!). We’ll see.

March 2016

josh
josh

Hope everyone is having a happy and relaxing Easter break, if that’s your thing! I’ve managed to avoid work for almost 3 full days straight, which wasn’t intended but was a nice change of pace.

Tonight, however, I prepped for an #exist-related #interview I have tomorrow for a How Stuff Works podcast, and took a look at #braid, my old little compiler/interpreter learning project. I’m thinking I might resurrect it with #LLVM as the back-end, but I’m not sure what language to use this time. No more Python. Maybe Rust? I’ve been reading some LLVM tutorials and docs I’ve saved for various languages’ bindings, and trying to work out what’ll work best for me.

August 2015

josh
josh

After a hiatus I attempted some #interpreter today. Worked out how to make Python functions callable from inside #Braid (my new working name), though it's hacky and they are stuck with taking a single argument. But still! It can read and write strings.