Art == Programming == Solitude

I am a programmer, not a writer. But I enjoy good writing. There is something in the process of writing or any kind of artistic activity that attracts me a lot. I always try to follow the process to make my programming look like art. To express my feelings through programming! Wait, is that possible… I don’t know yet.

But there was something always bugging me. The way an artist create is totally opposite of a programmer. They create in emotion, while we create in system.  And you can make a lot of differences between us. Of course there are some similarities as well. But what joins these two fields is solitude.

Why solitude? If you search Google with the word solitude, you will find a definition like – “the state or situation of being alone”. And that phrase says it all. We both create our best work in solitude. Our ideas, design, creativity, work, innovation flourish in solitude and we come with our masterpiece.

It’s not easy as I wrote it. Not even possible for everyone (like me?), but you can try it. Be with your solitude.

Ending The Year With Compilers

So… Last day of 2013. Not really thought of posting something today, but when browsing something reminded me my blog and I thought I should share what I am doing at the last day of this year.

For past couple of days, I am furiously reading about Compilers. How to make one? From scratch or with tools? Starting points? Which books or tutorial? etc.

Now I will share what I have learnt in these days.

It is not true that I didn’t know about how compilers or interpreters work before, but that wasn’t sufficient for making a compiler (trivially). First, I started with Language Implementation Patterns book. This is an awesome book by the creator of Antlr. From this book I learnt about LL(1) and LL(k) parser, how to build a lexer with input buffering, building parse tree, homogeneous and heterogeneous AST (Abstract Syntax Tree) and how to walk those trees.

But there was a problem, in that book the author showed you the data structure for different kind of AST, but he didn’t show you how to build one from the parser. So my search began again, I tried the famous Dragon book, a little filled with theory (and I like theory),  but I didn’t found what I was looking for. Then reading some recommendation from stackoverflow, I tried Modern Compiler Implementation in Java. But alas! Nowhere to be found. Another book I tried was Engineering A Compiler, 2nd Ed, this book had that part, but it focuses more on pseudo algorithm rather than some implementation in a particular language.

Then suddenly I found a book which filled the gap. Programming Language Processors In Java. It has most of the things I found in the patterns book PLUS building AST from the parser part.

Now I am reading about Symbol Tables and Scoping from both the books (patterns and processors) and comparing the approaches.

Hope the new year will bring a new programming language out of me.

Happy New Year

Steve Jobs Again !!!

It’s a very long time since my last post, but nothing has changed much. I am still the same. My last post was a video of Steve Jobs which inspired me so much, today I want to share one of the lectures he gave. Am I becoming a Jobs fan? Or am I trying to find something in his words, which will change me, I won’t be the same anymore…

Here is the link, read and be enlightened-

How to pass leisure… Haskell!!!

After the end of Spring 2013 in my university, it seems like there is infinite leisure and no work to do. Not sure when the next semester will start, so I thought of doing something interesting. After some frustrating search in Google, I decided to look into Haskell and believe it or not, it’s good. This language is actually smart, let’s see if I can outsmart it.

By the way, this is the book I am reading right now to learn Haskell. Real World Haskell. This is the free online version of the book. Enjoy functional world🙂

Component Entity Systems Again!

In a previous post of mine, I just denied the term CES (Component Entity Systems). Yes, I denied the term, not the concept. But after posting, I thought I should research some more about the topic and find some concrete example which validates the term CES.

From what I found out (thanks to GameDev, GamesFromWithin, T=Machine, Chris Granger), it’s clear to me that I didn’t really understood what CES actually is.

I am a OOP programmer from the start, so I think in terms of classes and objects. That is what stops you from accepting CES.

I knew that entity is an unique ID, so I thought like this:

class Entity


int id;


This is a very simplified version of what I thought, but you got the idea, right? I thought of Entities as class.

But now I know they are pure int.

Components can be class or struct, but they must contain only data. They actually represent state.

But how about combining that id and a list of components. Maybe we should make a class that has an int and a list of components? That’s what I though, that’s what every OOP programmer thinks.

So if this is not the solution, then how can we approach this? Let’s refactor the above question. Instead of saying the word combining, if we say that, how about mapping that int and a list of components. You got it right? It’s a familiar data structure, a Map. The int and list of components will be the key value pairs.

Then again, games need logic which alters the states. And that is what systems are for. They alter the state.

But what are they, a class with list of entities and an update method? No way, it will just be a function which takes every entity that has an component which this function will update.

Let’s be a little bit more specific, if we have a renderComponent then there will be a function named renderer which will take entities with renderComponent and that renderer function will render that entity.

So that’s it, No more classes, no more inheritance, just a data structure and some functions to manipulate them.

But what are the CES good for? and where do they fall apart? umm… needs some research😀 But at least I know what I am going to post next!