I created a programming language and this blog is powered by it

Why did I do it?

Mostly for fun.

If you follow my blog or take a look at some of the posts that I made, you will see that I was building a programming language called Grotksy. Just a toy programming language that I made based on the book Crafting Interpreters, which I totally recommend buying and reading if you haven't yet.

I wanted to build something interesting but simple enough that could be made with Grotsky. I tought that replacing Jekyll with my own engine was a task worth a try. There is nothing groundbreaking or innovative being made here, just a little experimentation.

I have to give credit to the project lith, because the 'templating' engine for the blog is inspired by it. Also I borrowed some of the colors and the design of HN.

How did I do it?

That's a good question.

Originally, this blog was powered by Jekyll, that translated markdown to html and hosted by Github Pages. I decided that I was going to build a templating engine and generate html to keep things simple.

But also, as a challenge I made a simple HTTP server to use as a dev server when trying the blog locally.

HTTP Server

For the purpose of having a custom HTTP Server I had to add support for TCP sockets to the language. I wrapped the go standard library in some functions and exposed that to the Grotsky language. In grotsky looks something like this

let socket = net.listenTcp(host + ":" + port)
let conn
while true {
	try {
		conn = socket.accept()
	} catch err {
		io.println("Error accepting new connection", err)
	try {
		# Call function that handles connection
	} catch err {
		io.println("Error handling connection", err)
	try {
	} catch err {}

This means that the server listens on a socket, accepts connections, writes some text/bytes to the connection and then closes the connection.

Template Engine

The templating engine is built using the native support Grotsky provide for lists. A regular page for the blog looks like this:

let base = import("../")
# Create new Post Object
let post = base.Post(
	"Brief description of blog post.",
	"Author Name",
			["class", "content"],
				"Content line 1",
				"Content line 2",

It's pretty straightforward: the first element of the list is the html tag, the second is an array of properties for the tag and the last one is a list that contains what will be the *content* of enclosed by the tags.


If you want to take a peek, the source code for both projects is available on github: