When I dreamt of being a Game Developer

You read it right! It was back in my school days, early days of when I had laid my hands on computer. I knew only QBASIC and Microsoft Visual Basic 6.0 back then. Like any kid, I loved computer games, and more than that used to think of building one. Game concepts used to come in my mind, I could see myself standing in those 3D worlds of fantasy.

Few days back I managed to lay my hands on the game that I had created back in class 9. Pardon me, but it were the days of Macromedia Flash back then, and I had just played enough with Flash 5, that my dreams of making a game re-ignited again. And there I was, played around with ActionScript and cropped graphics from various sources (video games, rendered images from Maya 4, etc.). Oh well, I didn’t know of any game engines, so I hand-coded the full player movement to collision detection. It was definitely a learning exercise. And what is a game without sound? Hence, ripped off sounds from various sources, put my own fading effects to simulate distance in the game. And here is what I ended up with:

lonely_island

Sorry, cannot give it out in public due to multiple copyright infringements it will have if I do (otherwise how will I get my favorite sound track in my game? ). But what I ended up with is a game fully developed by me and one month wasted for it.

Back to today

I run away from game development, though I encourage anybody who wants to build one. Maybe the experiences from my first attempt haunt me!

Take care, it’s Floating Point Arithmetic

Yesterday night, I was just idling on IRC and happened to come by an interesting discussion that was taking place there. The original issue was that doing Taylor approximation used to give identity for very small numbers, which gradually turned out to be an enlightening discussion. Thanks to Boris Zbarsky for clearing my doubts on this topic.

This post is a note to self (and others as well) so that I can keep them in mind in future.

For example we want to calculate e^x - 1. By the normal Taylor Series expansion of e^x, we would get:

But if we want to add them in a computer as x + \frac{x^2}{2!} + \frac{x^3}{3!} + ... then you would probably get a correct answer. But if you were to do the same for a very small x you would probably end up getting x, which is not correct.

The correct way out of the problem would be to use something like \frac{x^3}{3!} + \frac{x^2}{2!} + x. The reason being for a very small x the correct answer is “basically x“. So for this we would need to use:

  • Next term error estimation to decide how many terms we would want
  • Add the terms from smallest to largest

This gives as some important insight into floating point arithmetic. For example we just want to add the following floats 1, and 2^{25} instances of 2^{-25}. So what is 1 + 2^{-25}?

You would say almost 1 (even I thought so). But to the computer that is exactly one. This where floating point arithmetic turns evil, because single precision floats only have 23 mantissa bits. So the rest of the thing is rounded off, and you get one.

But if you start off by adding with the smaller guys, they can actually accumulate and give the correct result. So if we add 2^{-25}, 2^{25} times and then add 1, we would get 2, quite opposite to the previous result.

Floating point arithmetic is not arithmetic we learnt in school. Its not commutative nor associative nor distributive. It also implies that just because these properties are not satisfied compilers can optimize floating point operations either. The same reason why you have -ffast-math to tell gcc just to do you floating point operations fast and not care about the correct answer at all.

Comments on Hacker News.

Bootstrapping Mozilla Devs – Mozboot

This February our college fest Ignus witnessed the meet-up of like minded people who wanted to contribute to FOSS and Mozilla – reason Mozboot @ IITJ – a flagship event to get people introduced to the world of free and open-source software and give them a head start to contribution to the development of Mozilla Firefox.

Photo0410

The first day was utilized for getting the attendees acquainted with the world of Free and Ope-source software and the freedom it provides you. We organized a mini-hackathon to get them the feel of using open-source tools.

Next day, the day of the prime event, we started off full fledged with Mozilla. Saurabh Anand joined us all the way from Delhi to get people started with development of the Mozilla Firefox. We talked a bit why contribute and general terminologies like the mozilla-central repository, Bugzilla, etc. Obviously Josh Matthew’s FOSSDEM slide deck saved the day. Then we guided the participants to setting up their system, getting the dependencies and the mozilla-central source tree. Once done, we started the build process. In the meantime we had Shree Kant Bohra and Paras Kuhad to introduce people to Python and Django.

 

Once the build process was completed, Saurabh talked about the brief procedure to work on a bug, the review process and how to create a patch. We then showed them Bugs Ahoy and select a bug of interest and start reading about it. After sometime most of the participants had one bug selected and were reading about it. We told them to ask questions on IRC in case they faced any problems.

We used an Etherpad to share links and put up the bugs selected by the participants. The Etherpad can be found here.

The event was a success with the first of its kind by the Mozilla India Community, where people actually selected the bugs they wanted to work on and were getting involved with it. To ensure that their participation is maintained we are following up with them to track their progress. We generalized the event and have come up with a format to organize the developer events by the community here.

And this was one of the big events by Programming Club, IIT Jodhpur – one event that brought a lot of people from different colleges together.

At the end of the day going to Mehrangarh Fort to see the spot from which Bruce Wayne rose from the well in Dark Knight Rises didn’t hurt either.

Photo0419

Back to Bangalore

This January I was back to Bangalore once again. This trip was a great one. There is something different about Bangalore – the kind of awesome people you get to meet there, and the ambiance as a whole is great!

MIT Media Labs Design Innovation Workshop

One workshop, that I will never regret attending. From the MIT guys we interacted with to the other attendees, the bunch of people that this workshop brought together is incredible. I was in the Tangible User Interfaces track with my instructors being Anirudh Sharma and Daniel Leithinger. I got introduced to the values of inter-disciplinary work and the level of innovation that can be reached through it. A way to find innovative solutions to problems from our daily lives or how we could make certain things easier.

My project was to design a human posture detection kit, something that could trace how we move our hands, whether the posture we are in causes strain in the body, etc. With this we planned to study the ergonomics of the human body.

biosense-poster

Finally we came up with our prototype system – a gloves equipped with flex sensors and haptic feedback mechanism connected to an Arduino board. A couple of hand-made pressure sensors that we made by sticking together sponge strips and aluminum foil. What we generated was interesting data on how different hand movements and working conditions affected the stress conditions on our hand. Using the pressure sensors that we made we could generate pressure gradients for seats, using which it was possible to figure out how people sit generally. Our haptic feedback mechanism, we could provide feedback to the user in case of any erroneous or potential harmful posture.

We have open-sourced the code at https://github.com/sankha93/biosense/.

Firefox OS App Days

A trip to Bangalore is always incomplete without some open-source or tech meet-up. Last time I came here it was JSFoo 2012. This time it was Firefox OS App Days, a series of global events conducted by Mozilla to get people to know and develop apps for the Firefox OS platform. It was a great experience interacting with Matt Basta and Arun Ganesan who flew all the way from the Mozilla HQ to Bangalore for the event. Moreover, it was my first time as Mozilla Rep I was attending an event and meeting the full Mozilla India community.

After the little intro by Matt and Arun about Firefox OS, it was Hackathon and people came with real cool apps for Firefox OS. Few of us were busy providing tech-support and getting people started on building apps for Firefox OS. By the afternoon, I could see people presenting apps on education, real-time content sharing and information search apps powered by Wolfram Alpha, etc. And guess what? All the teams with great apps won a free Firefox OS Developer Preview Phone.

So another trip to Bangalore, well spent! (And a few other incidents that happened and I am not blogging about! ;) )

It’s (never) over

It was over. He knew it.

He gradually started moving memories of her out of his life. He changed his 57 passwords. He changed his SSH passphrases to refer to “the-brown-fox-who-jumped-over-lazy-dog” instead of her. He stopped the SMS updates on Facebook. Moved her to a less important list. He stopped coming online at that specific time of the night. He reworked his schedule so that he did not have to meet her every now and then. He did not unlock the phone’s screen every now and then to check if he had missed any messages from her.

He channeled all his emotions elsewhere: towards anger, towards solitude, towards work, towards football, towards coding. Anything except her.

It seemed to work. He was forgetting about her.

A week later he saw her again. He knew that he couldn’t have her, because he was too chicken to go grab it when the opportunity was there. He saw the biggest failure in his life ever.

He will never get over her again.

- Adapted from “It’s (never) over” from yuvipanda.in

The power of Communities

Communities are awesome! Not because I am saying so, but because I have tried and tested this out. I am talking about our own Programming Club.

There was a time when, people would say there was no flow of information from the “pro”-s to the people who wanted to learn. They didn’t know where to begin, where to start. The need was there to bridge this gap.

At the same time, Facebook was one thing that was used the most in our institute ( I don’t need to give any justification for this ;) ). So why not make Facebook a medium for consumption of information, make it the channel for everyday discussions that should be there?

So, one random day, the Programming Club, IIT Jodhpur group was born, over a random idea that spawned when Nishchay and I were talking. The group started out small in number. We did not add everybody we knew. We wanted the group to evolve – to grow into a community. We started out by posting different links ourselves, commenting on each others post and so on. Reason? For the culture to start of asking questions out in a group and sharing stuff that we discover, somebody has to take the initiative and do it.

It evolved just as we expected, it behaved as a community a mini-social network. The people we added, added their friends and this ripple effect grew. So the group that stood at 15 members for the first few days now stands at 329, and we are still growing.

The spirit of sharing knowledge also came by itself, it was not only us that shared the links, but people came and shared tid-bits of info that found all over the web. They began to ask questions. And it worked better than StackOverflow, where things are formal and you are answered by somebody you do not know, here you would get instantaneous answers by the seniors themselves, or anybody who knows the solution.  That’s the power of the community – you know you help, because next day when you will need help there will be somebody else there for you. It connected seniors, juniors, alumni, outsiders and even faculty alike on the common ground. We could see our group becoming useful when we used to see teachers as well as alumni joining the discussions.

Sometimes discussions have been productive, sometimes inflammatory. Newcomers have asked questions and got their answers. But what we have accumulated in the process is perhaps a vast knowledge base of our collective efforts. Its perhaps greater than any wiki could provide. We can scroll down the group to see the posts back in the early days or use the search feature in the group (I wonder how many of us use that) to throw us the relevant information.

That’s the power of creating a community around which people want to connect and share. Join the Programming Club community now.

Trends in Developers

I tried to measure the relative trends that go on in respective developer communities. Say for example, whether Ruby people are more active than Java developers. How do they compare with each other, by the use of different metrics and if we could deduce any important conclusions from that.

Before I begin, I would like to make an important confession: I am in no way any data scientist, nor have too much of education in statistics. I have just tried to analyze the trends using standard tools and techniques. Maybe my inspiration was:

The best way to get started in data science is to DO data science!

First, data scientists do three fundamentally different things: math, code (and engineer systems), and communicate. Figure out which one of these you’re weakest at, and do a project that enhances your capabilities. Then figure out which one of these you’re best at, and pick a project which shows off your abilities.

- Getting Started with Data Science by Hilary Mason

I wanted to try some real world data collected by me, so I turned to the Github APIs and collected the following metrics about some random 2,600 projects for the languages Java, JavaScript, Ruby and Python:

  • Watchers -  People who are following the project, but not contributing code to it
  • Forks – People who have created a fork and making their own contributions to the project

Both my assumptions are the ideal case. I assume the watchers are following the project, while people who fork are contributing code (though in many cases, people may not make any changes to the forks).

I first wrote a Python script to pull out data from Github on some projects for each language and store them into CSV files. The Search API came of help here.

This creates datasets for the languages with columns in the order – name of project, owner of projects, number of watchers, number of forks, if the repository is a fork or not. Since Github doesn’t list projects by language without a search keyword, we iterate over all the alphabets to get a list of 2,600 repositories.

Next just to compute it by the number of forks for Java vs. JavaScript, I sort the datasets for Java and JavaScript by their 4th column, ie. the number of forks and then plot one against one. I tried to fit a linear model in the data with a zero intercept to find the best fit line. These computations were done using R.

Java vs. JavaScript

Java vs. JavaScript by Forks

Java vs. JavaScript by Forks

It yielded a linear model:

javascript = 3.609 * java

Thus we can notice that the tendency to fork is more in the JavaScript developers than Java. JavaScript folks like to take some project and then make changes or contribute to it more easily compared to Java.

I did the same computation for the number of watchers by sort them by column 3 of the original dataset and make appropriate changes to the code.

Java vs. JavaScript by Watchers

Java vs. JavaScript by Watchers

This yielded a linear model:

javascript = 7.22 * java

This result confirms that the there are lot more JavaScript developers who follow other JavaScript projects compared to the Java developers.

Java vs. Python

After trying to compute it by the number of forks for Java vs. Python here is what I got:

Java vs. JavaScript by Forks

Java vs. JavaScript by Forks

The linear model came out as:

python = 0.7672 * java

Thus we can see the trend-line is more oriented towards Java, giving us a conclusion that Java developers fork repositories more than Python devs and try to make changes or contribute.

On doing the same analysis for watchers,

Java vs. JavaScript by Watchers

Java vs. JavaScript by Watchers

This result was a bit surprising, the linear model came out as:

python = 1.423 * java

Thus in the Python community there are more watchers for other projects compared to the Java community. So Python people love to follow a project more, when Java devs prefer forking it and contributing it.

Python vs. Ruby

The results of the number of forks for Python vs. Ruby is:

Python vs. Ruby by Forks

Python vs. Ruby by Forks

This gives a linear model:

ruby = 2.743 * python

The trend-line is more oriented towards the y-axis, ie. Ruby, concluding that Ruby devs fork a repo much more are compared to a Python developer. Rubyists like to jump into it, and make changes right away.

For the number of watchers:

Python vs. Ruby by Watchers

Python vs. Ruby by Watchers

This gave us:

ruby = 2.329 * python

I don’t need to say much. Rubyists follow others projects more than the corresponding Python devs.

Conclusion

We can figure out important trends between different programming languages by comparing different aspects together and we can figure out certain important facts, like Java developers like to fork more than Python developers while Python developers like to follow others projects more. Rubyists fork and follow the projects more as compared to Python people, etc.

Its a nice way to learn and analyze different trends developer communities. More can be done, this is just a scratch on the surface.