Programming

My Choice of SCM: Git vs. Mercurial

If you Googled “Git vs. Mercurial”, you will see a long list of pages that compare Git and Mercurial. Well, I think I’m writing one of those too.

In past, normally when I was developing, I will just use local copy and backup and use diff/WinMerge utility to compare and merge files. My life change when I starting to know SCM/VCS.

I started using SCM for the first time when I start looking into Robocode’s source (as per Pavel Savara’s request to be a tester), which use Subversion. I know basic of the operation before (commit and checkout mostly), but I had never use any of it prior than that time. As I continue using SVN for Robocode’s source,  I slowly learned more about SVN including what is branches, tags and trunk. I learned about patch later.

Since then, every time I develop some project, I need to have a VCS repository for my code (either local or hosted), all are SVN since I don’t know others. I knew that there is CVS, but its idea really confused me. I also knew that CVS is dated, and many projects that used to use CVS have already migrated/are migrating to SVN or other VCS.

My view of VCS changed when simple-php-framework moved to GitHub. I learned that there are also Git, Mercurial and Bazaar, which are DVCS. I still perfectly happy with SVN, so I didn’t really care about them, as long as GitHub provide a tarball link for me.

My first project which I use hosted SVN is napv-ce. I use Subversive plug-in for Eclipse as my SVN client. I hosted my project on Google Code. As I develop, the commit part really annoyed me since sometimes it just fails. And sometimes I don’t want to connect to the internet. The idea of DVCS starting to get back into my head.

I know before that Google Code has launched Mercurial server, but many projects use Git. I read many of comparing article including Google’s one to decide. The reason for this mainly is that cafe-grader had just moved to Gitorious.

Since I’m starting a new project, I need to decide whether to continue use SVN, or switch to either Git or Mercurial. (Bazaar wasn’t on my list at all since it’s way too slow). Git has several advantages: its large use and stable project hosting, and many of project which I am watching use Git. Mercurial has another advantage: it is supported by my old project hosting, Google Code. SVN has another advantage: most developers know how to use it =)

But I considered one more thing: If I use Git I will have to hosted my project on either GitHub or Gitorious, which is space limited (Google Code also has space limited, but I can request for more). I wasn’t considering SourceForge.net at all since I have already decided to abandoned that place. It is really sloooow.

Still, I could’t decide. Just then, I saw this web page. Then I decided, I’ll use Mercurial on Google Code =)

Anyway, despite the fact that I have chosen Mercurial for my project, I have TortoiseCVS/SVN/Hg/Git/Bzr just in case so I can checkout/clone any code from any project which use any VCS. Because I still have to clone/pull some Git repository so I can peek at their source code (they hosted in their own Git server), and I still have to use SVN for Robocode =)

OOP Learning Process

Three years ago, I started to learn Java and OOP. That time, I found OOP quite interesting because it is a grouped functions. I slowly learn it from time to time.

Next year, when my teacher knew that I was into OOP, he told me to search about MVC, which I found it also quite interesting.  I searched about PHP MVC and I found several PHP framework. The one which attracted my eyes the most is CakePHP, so I decided to give it a try.

At first everything seems to go well and I love it. Separation of design and code and all of it. But as I use it for a while, I started to think that by having to many DBALs to my database, I have to learn about it all. So later I use my own Module-View design for my relatively small web, which I have Module as Controller and Model together.

Recently, when I have to code real web and I use Module-View, my webpage get dirtier and dirtier with SQL request, so I remember the MVC and move things to Model. That’s how I know the real reason of MVC.

Second thing: ORM. I was never able to understand the need of ORM library until recently. I found that ORM make my life easier if I use it with light DBAL.

I wrote this all because I want ones who fall under the smiler route with me that in order to understand the reason behind each invented things, you have to use it yourself.

SCORE Computer : analysis on failure of the contest environment

Well, firstly to whom doesn’t know yet, on the 4th of December my school hosted a programming contest called ‘SCORE Compute Contest’. It is just a basic programming contest that the competitor have to write a C program to solve given problems. To make this more fun and not IOI-like, the Head make an extra system for it, but that’s out of scope for this post.

I’ve been assigned to write a contest environment (i.e. grader). It is a system, mostly web-based, for the competitor to submit their solution to be compile and grade using the restricted environment (i.e., sandbox-ed). My code was MVC-based PHP code that I use very clear variable name, for I have little time and it must have as less bugs as possible.

While I was testing it, I have fixed almost all important bug. It ran very well that time. But the problem come when the real competition was started. Some solution putting the grader in full-locked situation! I don’t know what caused that, and I’m very stressed, so I blame the sandbox which I use the Moe Contest Environment’s. So far, our Head have a solution, and therefore the contest end pretty well.

After many hours of sleep, my head went bright and I realise what caused it. Guess guess guess…. It is the IPC!?! Old way I use is to pipe the sandbox process’s output through streams. I carefully check that I have already closed all stream before terminating the process (proc_close(), my grader is written in PHP). But somehow I realise, that IPC may caused deadlock if not very well implemented. And I’m not sure that the wrapper for piping process’s I/O I quickly cook was really bug-free. So far yesterday I come back to the grader and change from piping through the stream to piping to filesystem. And it works!

UPDATE: The working system I wrote can be found at http://napv-ce.googlecode.com/ There will be no more update to it.

A Contest Environment Writing – Part I

OK, I know I’m lack of update. But that is because I have been busy writing the ‘Contest Environment‘.

This part I’ll explain what the contest environment is.

The Contest Environment is a system that allow you to upload a source code that solve tasks, compile your submission, run it with the test cases and grade the result. The one of the well-known contest environment around today is the Moe Contest Environment (formally known as mo-eval). This Moe system’s most famous is its sandbox, which is used in many competition around today, including many of the IOI (International Olympiad on Informatics) contests such as the recent POI (Plovdiv International Olympiad on Informatics: IOI2009) and also on Thai contest environment — the cafe grader.

More >