-
Image by 0k1n via Flickr
Earlier this week while under the influence of being stressed out of my mind being CEO of a startup and watching way too much Sherlock (there are only three episodes, watched every one at least four times) I decided that it was time for a new hobby.
The only requirements for said hobby were:
- mentally very bloody stimulating
- doable in polynomic time (rules out things like 'invent cold fusion')
- learn something new
Obviously the only real solution to this problem is designing a new programming language and making a compiler or interpreter for it. Sure, the other obvious solution is to find a cool opensource project and become an Important Contributor (tm). But I'm gonna do that anyway, contribute code I'm developing at Preona to opensource projects that is.
No I needed something completely different. Totally unrelated to my daily work and so on. Making a language it was!
Because @skatey reminded me of Monkey Island earlier that day the language is called Murray.
Murray is a talking demonic skull in Monkey Island.
This led to some interesting design ideas. Since obviously the language needs to be inspired by the demonic talking skull ... so let's make the whole thing behave like you're talking to the computer rather than programming.
Oh also I wanted it to run on Python and be inspired by Lisp, but without parentheses. No parentheses if at all avoidable!
Another big design goal is to eventually write a Murray-to-Python compiler in Murray. Right now I'm writing it in Python.
So let's recap the primary design goals
- functional
- no parentheses
- as akin to talking as possible
- can compile itself
- Turing complete
The hello world
The hello world turns out to be pretty simple.
say "Hello World"
Compiles to python and works. And no, no I'm not just using a regex to replace 'say' with 'print'. I actually wrote a parser for this thing.
Everything that sticks together is considered a paragraph of code and will essentially evaluate to a big function composition like so f(g(h(x))). Ok? ok.
So when I write this:
say "hello world" say "meow" say "hai"
It compiles into something a bit like so: say( "hello world", say("meow", say("hai")))
So the output becomes:
hai None meow None hello world
Which doesn't seem too logical, the None should go on the other side ... I should fix this.
But anyway, the None is there because 'say' doesn't return anything, we can fix the wonky output like this:
say "hello world". say "meow". say "hai"
What magic buffonery is this!?
Well the dot is another function again and Murray can understand one-char functions even when they are attached to something else. The dot is a simple function anyway, it sort of 'destroys' output by returning an empty string so it doesn't get in the way later on in the execution stack.
But what about them code paragraphs I mentioned earlier? Well their intended use eventually is to define 'functions', but I haven't figured this out too much yet. Right now they just do this:
say "meow1"
say "meow2"
This compiles into two distinct function calls so the output is like this:
meow1 meow2
Anyway, that's all I've got figured out so far. It's only been a few days since I started working on this and there's a long way still to go. Suggestions very welcome, contributors appreciated, everything is open source and living on github. Just fork and ping me about it if you're interested :)
Oh yeah, this Hello World is strange because it took me writing a compiler and making up a lot of stuff.
Related articles by Zemanta
- I Want A New Programming Language (kirkwylie.blogspot.com)
- Is Lisp secretly the world's most popular programming language? : programming (reddit.com)
- Re: Revenge of the Nerds (paulgraham.com)
- Lisp sans (((paren-theses ((hell))))) | Lambda the Ultimate (lambda-the-ultimate.org)
- lice! : On Parentheses (licenser.net)
- The Clean Coder: Why Clojure? (thecleancoder.blogspot.com)
- Why Lisp Still Hasn't Won - O'Reilly ONLamp Blog (oreillynet.com)
- Help me find something new to do with my time (ask.metafilter.com)
Continue reading about The strangestest Hello World I ever made
Semantically similar articles hand-picked by GPT-4
- Why people making compilers are superheroes
- Learning me a Haskell
- Dynamic languages have jumped the shark
- My brain can't handle OOP anymore
- Why I will always suck at programming [Grega Stritar]
Learned something new?
Read more Software Engineering Lessons from Production
I write articles with real insight into the career and skills of a modern software engineer. "Raw and honest from the heart!" as one reader described them. Fueled by lessons learned over 20 years of building production code for side-projects, small businesses, and hyper growth startups. Both successful and not.
Subscribe below 👇
Software Engineering Lessons from Production
Join Swizec's Newsletter and get insightful emails 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.
"Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"
Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.
Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.
Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.
Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev
Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization
Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections
Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog
Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️