Beginner Compilers: A Guide to Dealing With Skeptical Looks

Alright, folks. I know I’m new to this [the world of software development], and I know that Hackbright final projects are to be done in ~4-5 weeks. But you all need to stop looking at me like I’m insane when I answer “writing a compiler for a simple language I wrote” to the question “What are you doing for your project?” It’s what I’m doing, and the last thing I really need to hear right now is that you’re thinking I can’t.

I appreciate the concern, I really do. But while I know that you don’t want me to get overwhelmed and fail, I must disclaim that scaring me more really isn’t too helpful for avoiding that. Here are some things you might be thinking that you desperately want to communicate to me, along with my responses so that you’ll hopefully no longer feel said need:

  1. “You know compilers are…hard…right?”
    1. Yes. VERY MUCH SO, yes. But when has something being difficult ever been reason not to try? I know I might not get everything right, and I’m fairly certain it won’t be done the best way it could possibly be done (if not for other reasons, for at least the fact that I don’t have extensive exposure to enough programming languages to be able to compare much), but that’s what learning is for! And I expect this is pretty great foundation for trying again AFTER this one is done. Hopefully later iterations will be more artfully and skillfully done, for I know my passions will keep me trying.
  2. “You might get typecast[or the equivalent in the programming world--'pigeonholed'?] by writing a compiler–something not many people will be interested in. You should do something more people will find interesting and exciting and sexy for the times!”
    1. But…but this is interesting to me, so shouldn’t I find work that has people who find, if not the same things interesting, at least my own genuine interests and determination worth having around? I’m not very concerned with making THE MOST money or working for THE BIGGEST name–I’d rather do work that is exciting to me and be proud of what I create. To me, part of that is finding coworkers who can get excited about the same things or who have very different interests but then get excited about exchanging different ideas and skills with coworkers and friends.
  3. “Most compiler-writing courses are 10-week quarters or semesters AT LEAST. And you’re doing this (albeit full-time) in less than half that time…and as a newbie. What if you don’t finish?!”
    1. Honestly, that’s a genuine concern. I like to be confident in what I do because it keeps me driven and excited, but I might not finish it all in these 4.2 weeks! But I’m already learning so much, and of that, I must be proud. So I’ve come to accept that if I find myself at the end and I haven’t tied up every loose end, that’s just the way that it is. People won’t be able to see the finished product, but there’s a ton that I’ll have done that’s worth discussing, and it’s not like I’ll just give up on it once I hit the “due date” of our projects (3 weeks from today-haha). I’m going to work hard until I’m done, because I will complete it. If I’m okay with this, I like to think you all really should be too.
  4. “There must be other things that will showcase your skills that ISN’T as time-consuming as writing a compiler. Maybe you could find something like that?”
    1. Whelp. It’s a little too late for that. Not only am I pretty much past the point of no return in terms of time spent looking into this stuff, but I’m interested in this. I love a challenge and this is upwards of a challenge and a half. Grammar and logic and how computers work “behind the scenes” intrigue me to no end, so why would I stop myself from persuing it?

So, folks, if you are a budding Hackbright Student, an [Any-Other-Programming-Program] Student, a curious and self-taught newbie, or really anyone who’s writing a compiler for the first time, don’t be scared. PLEASE. I beg of you, don’t be scared. People will scare you (unintentionally or not), but no matter what happens you will learn from your mistakes and from your successes, and that’s more than enough to be proud of and consider it an experience worth having.

In fact, this isn’t aimed at just compiler-writers, but rather at those with any ol’ crazy idea. At the end of the day, it’s YOUR project, and if YOU’RE excited, I’m overwhelmingly excited for you. So go and be free, project-havers! You’re gonna learn some awesome stuff.

6 Comments

  • Brian Hurt
    April 17, 2013 - 5:51 pm | Permalink

    I say: go for it!

    Two things make writing compilers hard: machine code generation and optimization. Screw both of them. Compile to javascript, or the jvm, or .net, or whatever VM tickles your fancy- and most of the difficulties of machine code generation went out the window. As for optimization, screw that. So the first version of the compiler is unoptimizing. Optimizations you can add later as time and need arise. So the two hardest parts of writing a compiler just went out the window. Given that you can write yourself a scheme in 48 hours (http://en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours), doing a full-on compiler in 4-5 weeks sounds very doable.

    • Emily Gasca
      April 17, 2013 - 6:40 pm | Permalink

      Much appreciated outlook! Yeah, I think I’m going for compiling to Python VM and then once I get that under control I’m going to (probably past the aforementioned “due date”) start studying machine code and such and go from there. Thanks for the encouragement, I’m feeling a ton better/less guilty about not going all the way to machine code on my first go.

  • April 17, 2013 - 8:53 pm | Permalink

    If you do want to generate machine code eventually, just target LLVM IR, and let the LLVM stack deal with machine-code generation and optimization for you. It’s pretty easy with llvmpy: http://www.llvmpy.org/llvmpy-doc/0.9/doc/firstexample.html.

    • Emily Gasca
      April 17, 2013 - 9:18 pm | Permalink

      This is great, thanks! I’ll definitely look into this during later stages.

  • August 16, 2013 - 7:39 pm | Permalink

    Would be really excited to see how this turned out, if you’re able to post the results?

  • Leave a Reply

    Your email address will not be published.

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>