What’s the fuss about

Emergence

One thing that I just feel, I am getting good at is
“reading and understanding other people’s code”#notprasingmyself

In this summer I have explored unlimited repository out there on GitHub. some for solving any kind of issues I was facing in using them or some for just sake of learning anything new, be it any new language(Ruby) or a new field(Vim) for me.

One interesting recap is that I was working on a project for my team(SDSLabs) and I was using a ruby library as HTTP client, Rest-Client. I started facing issue(obviously) as I was new to Ruby. So I started reading code of Rest-Client just to take a look that what are the ingredients and their quantity in this library.

finally I completed Rest-Client with a better understanding that solved all my issues with it and gave me introduction to a new field, which is :
> How does HTTP and REST clients works

Also while learning about the large world of Vim, I started developing on a rough idea in my mind. which was to develop a Pong like game, playable in Vim editor itself. I tried it, under the name of vingvong.. But I was unable to complete it because Vim does not support Asynchronous subprocesses, so I stopped the development.

May be you have any other way of implementing same or I’m wrong somewhere. If so, please let me know.

Before that day, I have seen many people starring the stream-handbook in my GitHub feed. But I was like this thing does not belongs to me, right now.

But that day I opened stream-handbook with a motive to learn something. I started reading it and found that Streams is a nice topic to learn.

Suddenly my mind searched something from it’s index and showed me result in form of an idea. It was :
> Why don’t you just restart that Pingpong thing with this Stream ?

That’s all I wanted.

Development

when I started thinking about Developing, shaping it as a Node Module was the only and right option. I knew already that writing a Node Module in CoffeeScript is both fancy(for world) and easy(for me).

There was another reason for Choosing CoffeeScript, my experience in CoffeeScript was only limited to write some hubot scripts for customizing internal communication at SDSLabs.

I was a cool opportunity to learn and do more things in CoffeeScript, so finally I was like :
> OK, lets move with CoffeeScript.

PS : this tree structure is generated from treegen, my own attempt as the alternative of the great tree command.

you can see, main things are inside /src directory.

1. objects.coffee

Object class keeps the game objects, including ball, paddle and data to be rendered on screen. It also helps to populate the data initially according to terminal size.

2. game.coffee

Game class combines all available things at one place and makes it possible to play the game. It also invoke things in other classes on some particular events like left/right or SpaceBar key press, that enable pause/resume or movement of paddle.

3. movement.coffee

4. status.coffee

status.coffee carries all variable and their values that different classes use throughout the game. which includes, velocity of ball, paddle positions, ball positions, state of game etc.

5. source.coffee

Source class is leading character in the movie. This is the place where all that Stream thing shows the magic. What it does is to pipe the data to the stdout that is to be rendered on screen. That’s why I named it as Source. Other classes just work together and periodically update the data.

Learning

finally the thing is that, was this all worth doing ?

Answer is : Obviously, Yes. It’s always good to be pragmatic.

Now I feel as good with CoffeeScript as I feel with my love, Python.

as the Book says, CoffeeScript is a little language, but it’s pretty cool one.