Monday 29 December 2008

December Tech Meetup - web analytics, casual games and online spreadsheets

The December meetup started earlier at 6:30pm like last time. The turn-around was smaller (40) this time, possibly because its December and many people are on holiday and students/professors are preparing for exams. For people working in retail-related industries, Christmas season is the busiest time of the year, while others are preparing for the holidays.

Even then this tech meetup was one of the best we have had since we started. We had two great demos, an interesting talk, and lots of pizza and beer for everyone...



We started early like last time (6:30pm) and the initial chat and pizza took us an hour. We started with the presentations by 7:45pm. We had initially planned on each demo/talk taking 15 mins including questions, but it took much longer and in the end, all talks finished only by 9:30pm.

But the quality of the discussion was really good, be it Andrew explaining policies of Google and use of analytics, or Thanasis defending Java and the design decisions behind his game, or Gordon explaining their plans to take over the world of Spreadsheets.

So let us get to the talks...

Web Analytics

Andrew Hood who founded Lynchpin Analytics gave a quick rundown on Analytics, what it is and why to use it. He explained how advanced analytics can help websites track the sources of traffic and the flow within the website. Analytics can also track how successful various marketing campaigns (like AdWords/AdSense) and referral strategies have been. In today's world of cut-throat competition for attention on the web, successful marketing campaigns are critical to a websites' fortunes. But failure or success can only be understood and replicated if hard statistics are available for the decisions being made. Online Analytics is a way to achieve this understanding.

Here's a video of Andrew's talk...


Lynchpin from Sam Collins on Vimeo.


Crazy Space

Casual Gaming is a pretty big industry ($2.25 billion in 2008) and is growing fast. The industry consisting of small and easy to play games like Solitaire (Microsoft), Tetris (Tetris Holding) and Bejeweled (PopCap Games) is aimed at "non-gamers". These games are intended to be for relaxation and quick entertainment, and are mostly aimed at women (comprising 75% of the sales). The reason we don't hear a lot about these games is that these gamers don't tend to talk a lot about their gaming habits and they usually don't identify themselves as gamers...

Thanasis Theocharidis who has been working on casual games for many years, gave a demo of his game "Crazy Space". Crazy Space is a "Othello" inspired game which has been engineered ground-up. Thanasis wrote his own libraries for online AI calculations and fast hardware acceleration in Java. The game can also run on Google's new Android mobile platform.



Even though I'm not part of the intended audience, I found the game pretty addictive after playing a while :-)... You can download/play the game online.




Hypernumbers

The charm of starting a start-up is to dream big and think different. But alas, even in the startup world, very rarely do we see ideas that are truly original and ambitious. And this is what excites me most about Hypernumbers.

The whole idea of Hypernumbers is a little hard to grasp in beginning, and it looks like another online version of Microsoft Excel. But its purpose is to build a platform using which any non-developer/non-programmer can easily build their own websites. You say: Hold on... what?

In Hypernumbers, every cell in a spreadsheet has a unique URL and hence can be used as a variable to be programmed with. This means that any element on a webpage can map to a cell in a spreadsheet. For eg, each textbox, dropdown or checkbox on a webpage would map to a cell in a spreadsheet in the backend. So, if you can program an excel sheet you could potentially create your own website!

The point is that this allows a huge number of non-technical people who know how to use and write macros in Excel, to easily create websites.

Gordon Guthrie, Dale Harvey and Hasan Veldstra have created a highly scalable architecture in Erlang from scratch. They have written their own parsers for Excel documents (along with 100k compatibility tests) and Gordon tells me their system has recently crossed 90% compatibility.

Hypernumbers were funded by SeedCamp in 2007 and are looking to launch their first beta product this year in March. So stay tuned at http://hypernumbers.com/.

See slides of Gordon's previous talk on Erlang.


Photos


I was in-charge of the photos this time and didn't do a very good job :-(. But I did take a lot of pictures and by the "law of large numbers", some of them did turn out to be good... They are here.

The Website

Colin has been working hard on the Tech Meetup website, and it should be functional and up pretty soon... Do send us any feedback as it is supposed to be used by you guys...


The next meetup is on 14th Jan. Hopefully everyone will be back from holidays and we will have a great Tech Meetup again...

Previous meetups: First (September) Tech Meetup, the October Tech Meetup, and the November Tech Meetup

November Tech Meetup - Virtualization and time travel!




I was about to title this post as "November Tech Meetup - another success" but then thought that it was getting cliched... Nonetheless the November Meetup was pretty "successful" with about 60 people attending. We had enough pizza for everyone this time... :-)


Trial of Corners Idea

This time, on popular demand, we finally tried the corners idea. We labelled five corners in the room as "Games and virtual worlds", "Cool AI applications", "Databases and scaling", "Web design" and "Employers and job seekers". Though it seemed to be working in the beginning, and many people were asking what and where the corners were, towards the end most corners were empty. We think the reason was that even though people came to these corners, they saw no one there and went somewhere else. So it seems that it takes people dedicated to a corner to start a community around it. This may be something we can think about and try again in the future...

This time we had only one talk, but it was a good one...

Virtualization

Virtualization, or V12n (as there are 12 chars between 'V' and 'n', I didn't know that), is one of those buzzwords in the IT industry that you hear a lot, but very few people really understand what it means.

So it was great to hear Dan Shearer explain V12n, esp. since he is really passionate about it. Dan is a veteran of open source (he once told me, he first started developing software when I was 2 yrs old), and is a founder of the Samba foundation. But apart from all that, he is one of the smartest people you'll meet. So I was really looking forward to his talk...

Virtualization first began as a mechanism of testing software. As a software developer it has always been a pain to develop and test over all kinds of electronic devices out there. There are different chip sets, operating systems, motherboard and device configurations, and you can never be sure if what you have written works "fine" on all of them. So virtualization began with a purpose of simulating all kinds of hardware, with software. As for the software being tested, it doesn't matter if the underlying system is "real" or "virtual".

So Virtualization is essentially "Abstraction". You can simulate electronics and hardware, physical interfaces, people (how users interact with the system) and even time (speed up or slow down the computation to test for faster devices, and even change the direction of time)...

"All software is crap" (Dan says, not me... ;-) )

The point here is that even if software is perfectly written and tested on all current hardware/software configurations, we never know how it is going to perform in the future on unknown configurations like hardware that is 100 times faster or physical interactions that have not yet been imagined and created!

But these impossible configurations can be "virtually" created and the software can still be tested on these virtual configurations. So, Virtualization gives us a powerful method of preparing and testing for all kinds of strange future situations.

Time travel (oh yeah!)

If we take snapshots of a system every say 10 secs, we could restore these snapshots every second and make time run 10 times faster! Or we can restore these snapshots in reverse and even make time run backwards (virtually of course)...

This can be of tremendous help esp. while debugging. I have always feared programming in C++, as after you have removed all the obvious bugs, the scary part starts... If there are any memory leaks or hidden bugs in the system, the program crashes while running online (and taking down 10 other systems in the process). And there is rarely any way of recreating exactly what happened (unless you have heavy logging). But such backward time-travel could allow you to go back from a crash to see exactly when, where and how the problem started.

I can't wait to actually try out one of these debuggers...

Here are the slides for Dan's talk:
Virtualization - Dan Shearer
View SlideShare presentation or Upload your own. (tags: shearer tech)



Apart from many amazing new attendees we were very happy that Randy Haykin of Outlook Ventures, and who was the author of the original Yahoo strategy in the 90's, joined us.

I hope we continue to attract cool people to the Tech Meetup, and it evolves to be the hub of technologists and tech-preneurs in Edinburgh and Scotland.

</rant>

Previous meetups: First (September) Tech Meetup and the October Tech Meetup

Tuesday 9 December 2008

December Tech Meetup - 10th Dec

The Tech Meetup for this December is scheduled for this Wednesday, i.e. 10th Dec. The venue and time are the same as last time...

Venue: 8th Floor, Appleton Tower, Edinburgh
Time: 6:30 PM

There is lots to look forward to as this time we'll have demo's from Hypernumbers and Dot-Red Games and a talk on "Web Analytics" by Andrew Hood of Lynchpin Analytics.

Can't wait...

update...

Sorry for not posting in a while... there were a lot of things happening...

My visa application (for UK Tier 1 visa) was rejected while the previous visa was about to expire. Apparently, the UK Border Agency doesn't recognise any income made through Paypal and Paypal statements are not considered valid. And hence, I did not have sufficient "valid" or "provable" income for the past one year to clear their minimum requirements (even though I have payed tax on it).

So it seems, my mistake was not taking a "regular" job after graduating and trying something different...

Anyway, am still in the process of sorting everything out. Fingers crossed...

Will get back to posting soon.

Monday 27 October 2008

Second Tech Meetup: another success...

Edit: Added an older video of Yann's demo




It seems the Tech Meetup has caught the attention of the techie folk around Edinburgh, and the second meetup on 8th October was also a big success. We had about 70 people attending, which was a lot more than we expected. Consequently we also ran out of pizza and beer...




So as the self-designated official blogger for the event, I'll try and relate the happenings of the night...



Like last time, we started around 7 o'clock with people filtering in till 7:30. This, lets call it 'group chat time', was useful as it is a good way for people to chat with acquaintances and meet with people they already know. On the other hand, it also takes up a lot of initial time. So for the coming meetup in November we are going to start earlier at 6:30 instead of 7:00, so that we can do the introductions earlier, which means people can start meeting new people earlier.

Introductions

After pizzas had arrived and everyone had had a slice or two, we started with the public introductions like last time. Going through all 70 people did take time, but we think it was pretty useful as it helped break the ice. Even though this might not scale as the number of attendees grows, we still want to carry this on for as long as possible. The main objective of the meetup is to get people meeting and chatting to people they don't already know. A public introduction helps this because even though people don't remember each and every person's name, they can still remember their faces and then come and chat to them afterward.



We are looking for ways this can scale in the future. We are trying to avoid name-badges, etc as that would make the Tech Meetup feel like yet another formal conference or a networking event. Having peoples' profiles and interests on a website beforehand might be a way, but people will still not know who the person is that they want to meet in the crowd (unless we have clear photos on the website, or use name-badges... ).



Many have also proposed a "corners idea", which we are going to try out this time. Basically the idea is to designate certain corners of the room to certain topics where people who want to talk about that can gather. I think it is a good idea. Coming up with a general and yet interesting set of topics for the corners is the hard part. We would love to hear more feedback on this...

Demos



We had two demos again like last time. We had more lined up but sadly had to cut short as we ran out of time, and it was getting late. So, this time starting earlier would help...

Wii Loop Machine

In the first demo, Yann Seznec gave a great demo of his Wii Loop Machine software. Yann's application allows users to create new electronic music using a Wii remote. A big part of producing electronic music is to do with looping music samples and mixing them in a good rhythm. Yann's software allows you to control, mix and match these loops, just like a DJ would, using a Wii remote. It also looks fun because you start dancing with the Wii remote, while producing music.



Here is a video from Yann's blog:


Wii Loop Machine 2.0 :: an intro from The Amazing Rolo on Vimeo.

Technically, Yann mentioned that he is using aka.objects library for accessing Wii remote developed by Masayuki Akamatsu. Yann also has plans of porting the Loop Machine to the windows platform soon. All in all, it was a fun demo.


Erlang



Gordon Guthrie of Hypernumbers gave a high level yet interesting talk on Erlang. He focussed on the philosophy behind Erlang which was designed from ground up to be a concurrent & distribution-oriented programming language. Even though Erlang syntax is similar to many other functional programming languages, it provides native concurrency and multiprocessing capabilities. So an application written in Erlang can scale easily to a large network of computers.

As scalability is one of the biggest concerns for any successful and growing software application, having this functionality inherent in the design since the beginning is a big plus.

Here are the slides for Gordon's talk:

Erlang
View SlideShare presentation or Upload your own. (tags: programming erlang)



Photos


Thanks to Adam Yates, we have some great photos of the meetup. Here are some of them (all throughout this post). I have also uploaded them to the Facebook group.



Future plans

  • Dates: The next meetup is fixed for 12th of November which is a Wednesday again. We have also decided to hold meetups in the future on the 2nd Wednesday of every month, so that it doesn't conflict with most of the other events.
  • Website: We have a plan for a getting a full-fledged community website up for the Tech Meetup. It will have videos of demos, photos, member profiles and facilities to contact each other, forums, Job listings and Event registration. This looks like a lot of work, but we hope to roll it out in phases soon... All suggestions are welcome...
  • Venue: If we continue to grow, 8th Floor of Appleton tower will soon be too small. Bigger halls in the new Informatics Forums are an option. We have decided to stay with Appleton tower for the coming meetup, and see if we do actually outgrow it...

All in all, it was another great meetup with lots of new people coming this time. Can't wait for the next one...

Friday 24 October 2008

Python

This is a presentation I gave at work on Python. It is a quick overview for anyone interested in the language. I tried to keep it not too technical (but there are still some jargon in there)...

Why Python
View SlideShare presentation or Upload your own. (tags: python programming)




For more on Python, I recommend these articles:

Interview with Guido von Rossum: Making of Python

Eric Raymond: Why Python?

Data structures in Python

Python: Myths about indentation

Peter Norvig: Spell Checker in Python in 21 Lines

Performance computing in Python

Monday 6 October 2008

Second Tech Meetup on Wednesday

So, its been a month already... the second meetup is set for this Wednesday (8th October) at 7pm. The venue is the same: Appleton Tower, 8th Floor.

Expecting lots more cool people this time...

Friday 5 September 2008

First Tech Meetup: success!

Thanks to everyone who showed up yesterday! The tech meetup last night went great. We had a group of about 50 people all interested in technology, talking about technology. Even though there were many startuppers and some investors in the crowd, the business chat was to the minimum...

The two demos were great too. Tom Griffiths from Hubdub gave a quick run through of their very popular website and some insight into prediction markets. Matt Aylett from Cereproc also gave a great demo of their Speech Synthesis software and how it can mimic George Bush as well as generate West Bromwich accents.

Special thanks goes to Andrew Mitchell, Colin Adams, and the University of Edinburgh for letting us use their space, and sponsoring the Pizza and Beer... The space on the eighth floor of Appleton Tower was actually very well liked by everyone.

I know many people couldn't make it to this event because of the short notice. I will do a more detailed post about what went on soon. But if you are interested in coming and meeting all sorts of cool techies, just drop us a line...

Wednesday 3 September 2008

First Tech Meetup in Edinburgh - Sept 4th 7pm

I hear networking is important, but networking sounds like waiters with trays of finger food and paper napkins. Ian Hogarth wrote about "Hackers Need Friends Too!" (http://uk.techcrunch.com/2008/08/21/hey-hackers-need-friends-too/)
on TechCrunch UK, and we've decided to do what they do in London: get all the developers, tech heads, and tech startups together and build a functional community.

This gives everyone a community where we can learn from each other, hear what's going on around us, demo some stuff, and really try and bring together the wealth of tech talent we
have in Scotland and of course, enlighten others who may be interested.

So the first meetup on September 4th is to see what people think and what we can do to make an easily accessible and friendly community of tech minds, skills and startups around Scotland and connecting with London. We're hoping to have a meetup maybe every month and to find a way to connect with Ian's meetup in London (and other cities as they start).

So come along at 7pm to 8th Floor of Appleton Tower (Edinburgh Uni).

The response so far has been really encouraging. Thanks to Sam Collins for setting this up, Andrew Mitchell and Edi Uni for sponsoring it and Ian Hogarth for the support.

Friday 15 August 2008

Great Generals: Hannibal takes on Rome III - Battle of Cannae

I finally got to writing about the third and the greatest battle of Hannibal against Rome - The Battle of Cannae. The essay is long, but the battle is truly amazing ...


After being defeated at Trebia (Dec 18, 218BC) and Trasimene (Jun 24, 217BC), the Roman Republic was already cornered. There was an enemy rampaging through Italy and yet they could not stand up to him. Fabius Maximus who was appointed the "dictator" after Trasimene, decided not to take on Hannibal (probably a wise decision) and chose to rely on cutting off his supply lines, raiding his camps and basically wearing him down. But his Fabian strategy, as it was known, soon became unpopular with the Roman public. General public was, as it still is, impatient and wanted revenge. So, in 216BC, the Senate did not renew Fabius as a dictator and elections were resumed. As a result, Gaius Varro and Lucius Paullus were elected as consuls, apart from Geminus and Regulus (who were consuls before Fabius become dictator).

Rome's preparations

Usually each consul would go to a battle by himself taking two legions that belonged to him. Each Roman legion consisted of 5,000 soldiers (or legionaries) and were generally accompanied by an allied legion of equal size. So, among the 4 consuls they commanded 16 legions (Roman + Allied), which along with about 4,000 Cavalry and other meant about 87,000 troops.

The Roman Senate decided to send all of these legions to fight Hannibal. Never before in Roman history had all four consuls gone to war at the same time. The terror of Hannibal amongst Romans was so great that they had raised an unprecedented army of almost 90,000 to take him on. They believed their strength in numbers and the strong infantry would overwhelm Hannibal's eclectic army of barbarians (as they called them).

In contrast, Hannibal only had about half as many men (40,000 heavy infantry, 6,000 light infantry and 8,000 cavalry), about 55,000 in all.

Seeing that Romans were raising a huge army, Hannibal decided to take them on sooner rather than later. He moved first by capturing the Roman supply base at Cannae, and placed himself between Romans and their supplies. This provoked the Roman army to move, confident as they were in their large army.

The stage for the epic battle between Hannibal and Roman army was set.

Know thy enemy


The two newly elected Roman consuls, Varro and Paullus were commanding the 16 legions as they moved towards Cannae. But there was a problem: who would take the overall command of the army? Neither of them would be a subordinate of the other. So, by Roman law it was decided that Paullus and Varro would take charge on consecutive days (so one day Paullus and then one day Varro, and so on). It sounds ridiculous now, but this actually happened... To make matters worse, the difference between the two generals' ways was big. Varro was a rash and arrogant general while Paullus was patient and cautious. Even though Paullus was against fighting head on with Hannibal, he wasn't able to convince the hot-headed generals who were itching for a fight. Hannibal knew this.

For two days the armies stood facing each other, but neither would attack first. When Hannibal sent a challenge to Paullus it was promptly rejected. But on the third day, when Varro was in charge, Hannibal ordered his cavalry to cross the Euphidus river and attack the small Roman camp on the other side. They attacked the Roman water supply line from the river and caused a lot of mayhem in the Roman camp. This succeeded in getting Varro angry and got him to cross the river to the other side with all his army. And Hannibal had already prepared for it...

Know thyself and prepare

Hannibal knew that his army was outnumbered 2:1, but he still had the advantage when it came to Cavalry, in numbers (8,000 as opposed to 6,000) and also in strength and experience. So, if his cavalry was able to destroy the Roman cavalry quickly, they would then be able to circle round and attack the Roman infantry from behind. When this happened, it would be essential to prevent the Roman army from spreading or escaping (and later regrouping). So, Hannibal came up with an idea of encircling the Romans from both right and left, a Pincer Attack.

Hannibal knew his soldiers and their weaknesses and capabilities very well. The Carthagian army was made up of warriors from all over the world:
  • 8,000 strong core group of Libyans and Africans who had been with Hannibal for a long time. They wore Roman armour.
  • 8,000 Iberians (Spaniards) who fought with cutting and thrusting swords and javelins. They used large oval shields for protection.
  • 16,000 Gauls who carried long slashing swords and small oval shields.
  • 8,000 skirmishers who wore light armor and used long range weapons like javelins, bows and slings. Their main aim (like present day Artillery) was to disrupt the enemy line by long range attacks and cause casualties even before the battle began. Once the battle began, the skirmishers would usually fall back and let the heavy infantry go forward. Knowing this, Hannibal ordered his cavalry to attack and kill the skirmishers first when they arrived behind the Roman army.
Infantry planning:
Hannibal also knew that his Spanish and Gallic infantry were not as strong and battle hardened as his African unit, but they were still much larger in number (24k vs 8k). So, he decided to form a thick line with Spanish and Gallic in the center and kept the African infantry on the two sides. Their job was to perform the pincer attack from the Roman right and left when the cavalry reached the Roman rear.

He further ordered his central line to advance and meet the Roman center first, in an Echelon or more specifically a V-formation (used by fighter jet squadrons). This had three purposes:
  1. As the battle began, the center would slowly begin falling back and drawing the Roman center into the semi-circle thus formed.
  2. Because the fight would have already started in the center, Romans would also not be able to notice the two African divisions behind on the right and left.
  3. This would give time to the Carthagian cavalry to defeat the Roman cavalry on the right and left flanks and then attack behind the Roman center.

Cavalry planning:
To ensure that his cavalry would be able to quickly destroy the Roman cavalry, he gave his commander Hasdrubal on the left, 2/3rd of his cavalry (6,500), and Hanno on the right was made in charge of the Numidian light cavalry which was 3,500 in number. While Hanno's light cavalry would hold off half the Roman cavalry, Hasdrubal would destroy the other half on the left and then circle round and attack the Roman cavalry on the right from behind. After finishing them off, the combined cavalry would attack the Roman infantry center from behind.

The framework for one of the greatest planned battles in human history had been laid. Hannibal was going to turn his enemy's greatest strength into their biggest weakness.

Stand in the eye of the storm and coordinate


When the battle began, Hannibal himself led the the center formed by the Gallic and Spanish infantry to an advance and tackled the Romans first. They bore the brunt of the Roman attack. Many soldiers were getting killed as they went head on against the strong Roman infantry charge. But being there himself, Hannibal was able to motivate his soldiers and control them to a coordinated retreat. As the central line kept falling back, the initial V-formation changed to a crescent.



In the meantime, the strong Carthagian cavalry was completely destroying the Roman flanks. As planned, they first finished off the left and then the right flanks and then attacked he Roman skirmishers from behind.

Hannibal now sprang the trap that he had laid. He ordered his battle hardened African troops (who had stayed out of the battle until now) to attack the Romans from the two sides. Maybe Romans could not see them because of all the dust caused by the battle, or the Roman generals lacked the quick judgment to respond, nobody knows for sure, but the Roman infantry was now surrounded. Without their flanks, Roman infantry drove itself deeper and deeper into the crescent shaped alley formed by the Carthagian line. Soon, they were completely encircled and running out of space to fight.

Corner and finish


The Romans in the center were packed so close to each other that they could not move their arms or lift their weapons. Only the soldiers on the outer circumference fought and were soon killed where they stood. To cause even more confusion, Hannibal ordered his soldiers to kill all the Centurions (officers) first.

As killing so many Romans was taking a lot of time, Hannibal ordered his soldiers to cut the hamstrings of the Roman soldiers to make them incapable of fighting, and then move on. After finishing the fight, they could come back and kill them at leisure.

Result


Tens of thousands of Roman bodies were all over the battlefield when darkness brought an end to fighting. Some Roman soldiers even killed themselves by burying their own heads in the ground, to escape the pain. In all about 70,000 Roman soldiers were killed and only 14,000 managed to escape and 4,000 were taken prisoner. 600 Roman soldiers were killed every minute that day.

Paullus along with two previous consuls was killed (ironically Varro survived). 29 out of 48 military tribunes and 80 out of 300 senators (in all) were killed in one day. Only 1 out of every 6 Roman soldiers who entered the battle, survived.

The Carthagians on the other hand only lost 16,000 men, most of them Spanish and Gallic who formed the center line.

The Battle of Cannae was the costliest battle in human history uptil then. It still ranks as the second most costly formation battle in human history.

Aftermath

Even though Rome was in complete disarray after Cannae, Hannibal didn't attack and lay siege to Rome. This maybe because he believed that Rome still had significant resources, and also because of his experience from his first battle when he laid siege to Saguntum (refer the introduction to the Battle of Trebia). He was criticized by many in his camp for not taking this opportunity and destroying the Romans completely. But Hannibal's objective of fighting might not have been destruction of Rome, but to dishearten it and force it into a moderate peace agreement.

Hannibal sent a delegation to Rome to propose a peace treaty on moderate terms, but the Roman Senate refused to talk. Instead they mobilized their entire male population and started raising new armies. The word 'peace' was prohibited on the streets of Rome and only women were allowed to cry in public.

At last they had learnt their lesson. Instead of fighting head-on with Hannibal, they went back to attrition strategies of Fabius. In the meantime, the Oligarchy in Carthage was growing more and more jealous of Hannibal, his achievements and his growing popularity. After a few years of maneuvering around Italy, they refused to send Hannibal reinforcements, and Hannibal was forced to pull back.



Hannibal's story

The rest of Hannibal's life story is sad. Even after such huge victories and with unrivaled strategic genius, Hannibal could not carry on winning, because of lack of support from home and loss of most of his good soldiers (either dead or tired from fighting). In 202Bc, fourteen years after Cannae, Hannibal with a much weaker army was finally defeated at the Battle of Zama by Scipio Africanus. The Second Punic War ended with the battle of Zama, and Carthage conceded defeat.

After the war ended, Hannibal tried to become a statesman and was also appointed the Chief Magistrate because of his popularity. But the oligarchy in Carthage were still jealous of him. When the Romans demanded that Hannibal surrender, Hannibal knew that the oligarchy would not support him. He decided to go into a self imposed exile. He offered his services to King Antiochus III of Syria and then the king of Phoenicia.

But the Romans were determined to hunt him down, and in the end one king (Prusias I of Bithymia) agreed to give him up. Determined not to ever fall into the hands of Romans, and to keep the promise he had made to his father on his deathbed (to fight the Romans till death), Hannibal took the poison he always carried with him (in his ring). Hannibal died in 183BC at the age of 64.

Thursday 24 July 2008

Great Generals: Hannibal takes on Rome - II , Battle of Lake Trasimene

Previous: Battle of Trebia

After the defeat at Trebia the Roman Senate was shocked. The reality of someone crossing the mountains and attacking them from the North was something they couldn't grasp. But still, they continued to underestimate Hannibal's strength (which wasn't just in numbers). The Senate decided to sack Sempronius (the defeated general of the previous battle) and brought in two new consuls: Gnaeus Servillius Geminius and Gaius Flaminius. Servillius was given charge of Scipio's army and Flaminius was made in charge of whatever was left of Sempronius's defeated army.

The job for Flaminius was to protect the city of Rome and prevent Hannibal from reaching the city. So he hurried his army back from Trebia towards Rome. But Hannibal followed him even faster and eventually overtook him. And before Flaminius could try to hurry back again, Hannibal cut him off using the first recorded Turning Movement in history. Hannibal's plan was to lure Flaminius into battle before he could reach Rome or receive help from Servillius. He started rampaging the countryside to provoke Flaminius. He hoped that destroying the very land that Flaminius was sent to protect will entice him into battle. And so it happened...

Flaminius like Sempronius was a rash and arrogant general. Even though all his advisers suggested that he only send his cavalry to temporarily stop Hannibal and wait for the other consul to arrive, Flaminius decided to take him on.

Meanwhile, Hannibal had come across a road that was bordered on one side by a Lake and hills on the other. In his eyes, this was the perfect place for an large-scale ambush.

Here is the Map of the area in the north of Lake Trasimene where Hannibal placed his trap. The waters of the lake have receded a little now, and so there is more space now between the hills and the lake than there was at that time.


View Larger Map


In the cover of the night, Hannibal placed his cavalry and Gallic infantry in the hills where Romans would be entering the valley from. Their job was to suddenly attack the Romans from the left and close the way back. He hid his light troops along the hills all the way to Tuoro Hill. Finally, he himself stood with his heavy infantry on top of a slight elevation where Romans could see them. He also asked his soldiers to light massive campfires on Tuoro Hill at night, so that the Romans would imagine that he's far away.



The next morning, in the fog, when Romans started approaching the road from the West, Hannibal's trap was set. To further entice Flaminius, he sent a skirmish force ahead to start fighting and then retreat to lure the Romans deeper into the valley (and into his trap).

As soon as the Roman army entered the valley, Hannibal's cavalry crashed down upon them from the hills and closed the road behind them. Now the Romans were surrounded from all sides, with their backs to the lake. The battle started even before they had time to draw up their battle lines. The Roman army was split into three parts, the west, center and the east.

Hannibal's army quickly destroyed the west flank, and heavy infantry led by Hannibal crushed the east flank. Now the Roman center was exposed to attack from all sides. They fought for about three hours but the whole Roman army was completely annihilated.

Off the 40,000 soldiers that the Roman army had in the morning, 30,000 were either killed (by the afternoon) or drowned in the lake. A few soldiers who escaped were later captured by Hannibal's brother Mahirbal the next day. Flaminius himself didn't live to regret his decisions and leadership on that day. The massacre was so intense that the soldiers didn't even notice that an earthquake occurred that morning...

Compare Roman losses to those of Hannibal's forces who lost only 1,500 soldiers out of their original strength of 50,000.

Hannibal had now planned and executed the greatest ambush in history. But this was still not his best...

After the shock of another huge defeat, Romans first gave dictatorial powers to Fabius Maximus. Fabius was smarter than the other consuls before him, and knew that going head-to-head with Hannibal was a mistake. He implemented his 'Fabian Strategy' where he avoided direct battles and tried to wear Hannibal down by harassing him.



But the Roman people and the Senate didn't have the patience to keep this up. They again removed Fabius and got two new consuls Paullus and Varro. These two would lead Romans to their biggest defeat ever - at Cannae...

Image Sources: Google Maps, Department of History, United States Military Academy.

Update: Others in the series: Battle of Trebia, Battle of Cannae

Tuesday 8 July 2008

Pride and the Search for Happiness

What are you proud of? When your boss looks down upon you, or when a boy/girl you like treats you badly, or when a group you identify with is disrespected, or someone completely unknown shouts at you on the street, why is it that you are hurt? I feel bad in such situations, but when I honestly ask myself, 'what am I so proud of', I don't have any answers for myself.

What is so special in me that gives me a right to get upset when I am disrespected or not loved? Why does it hurt so much?

Religions tell us we are special in the eyes of God, or there is an essence, something special within us that makes us and our lives special. Are they sure? Even it is true, it is just a reason, an explanation for a feeling we had since we were kids and didn't know anything about God or Religion, a feeling we have always had.

If not, am I proud of those little achievements I have made in life. The achievements are mostly relative to other people around me. does that mean that if not for those people, I wouldn't have any pride. But I was still proud, even before I did any of those things. These so called "achievements" are just re-affirmations of the pride I have always had.

This pride or self-respect (maybe a better term), I have always carried with myself as long as I can remember. When something good happened or I succeeded in something, it became stronger and I felt confident and happy. When I lost, or thought that I was rejected, I felt hurt and sad. It was difficult for me to understand why my happiness was so dependent on what other people thought and did. Why did I have to prove myself to so many people? Why did I have to be approved of in order to be happy? I never understood...

The pain and happiness caused by this pride, was simple to deal with when I was a kid, but as I grew up, the effect of these somehow became stronger. Or maybe I started feeling it more. So, I came up with many ways to deal with it in my mind (many times without knowing). Some of them were:

1. Rationalize: When someone says something bad, I started thinking that they didn't actually say anything bad about me, but about how I did things. So if I do things differently, they would come to like/respect me again. So, I tried to change and went back again and again. This does work sometimes, but sometimes it takes you in the wrong direction. I had gotten too attached to getting approval and love rather than doing things right. As you learn in life, some people really do hate you, and no matter what you do, you can't change their minds.

Another way to Rationalize, is to think that there is something wrong not with me, but with the other person. So, fuck them. This is the next stage of frustration. If you don't care about other people, they can't hurt you right. A morphed version of this is when you only care about good opinions of yourself, start thinking that everyone else is wrong and is a loser. Now, its easy to see why this can be bad. Even people like Presidents suffer with this problem.

2. Don't push yourself: Don't get too involved, don't trust anyone completely, and stay away from any kind of commitment. So, in the end if you fail, and anyone criticizes you (or you criticize yourself), you have an excuse. You can tell yourself that you didn't give your all - if you had, you would have done much better. You remain mediocre forever, but hey atleast you know you could have done much better right. And so, your status or position in society does not reflect the real you. So, you are free to live in your own world. As you don't recognize what the world says about you, you can be free from requiring their approval.

A corollary of this approach is to run away as soon as things start to look bad. Bail out before you get hurt. Ditch the other person, the other job, before they get a chance to ditch you. The problem with this approach is that, you usually end up with nothing at all, because there are hard times in every relationship and every work.

3. Push yourself too hard: The opposite method also works. If you are really hurting, get involved in something and don't let yourself think about anything else. Shut your mind, keep doing something unless it gets back in. Its not that you have to enjoy what you are doing, but just keep doing it all the time. To hell with sleep, food, friends, life... In the end when you cross your limits, you are so exhausted that you begin to hate the very thing that you once enjoyed. You think you are working hard, or giving your best, but in reality you are just scared and running away from yourself.

4. Hedge your commitments: Another way of go around disappointment is to do 10 things at the same time. So, if you loose in some of them, you still have others. So have two girlfriends, and three jobs. This may work well for some time, but if either of those girlfriends or bosses find out that you are not committing everything, you risk loosing both of them.

You could be honest with them from the beginning, but then neither you nor they will be happy without a full commitment. You will have to start lying to atleast some of them. The issue of commitment will come up again and again until the relationships become bitter. Very few people are able to successfully pull this off.

5. Take pills, drink, eat food, or watch TV all day long: Do anything you can to forget about your hurting insides. You won't be hurt by things, events and people around you if you are not aware of them right. You have an addiction, even better... you don't have to force yourself any more. Accept that you can't fight with yourself and what you feel like doing and just do it. The only problem is, when you are not drunk, high or feeding the addiction, your pride and your heart hurts even more. Now to make yourself forget, you have to drink, eat or watch even more... and it never stops...

Why don't any of these methods work and why are they usually wrong? I don't think there is a clear answer to this question. But I'll give you some of the answers that I got...

I think that's because they are the 'easy ways out'. The best thing to do when you fear your pride being hurt is to take a moment and think what is the hardest (or atleast harder) thing for you to do at that moment. And do the hard thing. Face the fear and once it is all over, you will come out feeling better yourself. Results might not be as you expected, but atleast you were better than you expected.

In the end, the root of all pride or self-confidence, is the feeling of being alive, the feeling of existence of 'I'. The essence of being alive, is an inherent tendency in all living things to independent, to rebel against nature and to carve one's own path. At its roots, Life is the fight between will and circumstances. And pride comes from this feeling of independence. All other kinds of supposed pride are just complications on top of this, that arise from ego, arrogance, and most of it just imagination. But this basic happiness of being, is at the core of every thought, it is the proof of our existence.

So, we must keep on living, keep on fighting, and do the hard things. Pride is hurt not because someone treats us bad, but because we take the easy way of feeling bad at that instant, we take pity on ourselves.

I am still looking for answers to these questions, but I guess I am truly myself when I make the tough choices.

Monday 7 July 2008

Great Generals: Hannibal takes on Rome - I , Battle of Trebia

I want to start the series of posts on great battles and generals with three battles of Hannibal of Carthage. Hannibal was one of the greatest generals in History and some even call him the 'Father of Strategy'. His greatest achievement was when he led his army across the Pyrenees and the Alps and attacked and defeated Roman armies multiple times at home. And if this was not enough of an achievement, he did it all using a massively under-matched and eclectic army formed with soldiers of different cultures and nationalities. He defeated Roman armies in a series of battles that are still considered to be strategic masterpieces. Students of military strategy all over the world still learn about Hannibal and his battle tactics.

His impact on minds of future generations was so great that Napoleon (another contender for the title of 'Greatest General in History') said that he learnt from him, and General George Patton of the US army during World War II, thought of himself as a re-incarnation of Hannibal. When German military commanders wanted to come up with a plan to invade France in early 1900 (before WWI), they came up with a large scale re-enactment of Hannibal's Battle of Cannae, also known as the Schlieffen Plan. They tried a version of the plan in the initial stages of WW1, but couldn't pull it off. Later, Hitler's generals also used a version of this plan when planning an attack on France again in WW2, but this time succeeding.

But before we get to the Battle of Cannae, I want to talk about Hannibal and his march into Italy. When he came into Italy after crossing the Alps he defeated Roman armies in two impressive battles at Trebia and Trasimene. These two battles lay the groundwork for Cannae. We will start with them...


Hannibal and his march into Italy

Hannibal was born in Carthage as the son of Hamilcar Barca, a powerful general and statesman. Carthage was a city state in North Africa on the coast of the Mediterranean, in present-day Tunisia. Carthage used to have control over Sicily and Sardinia, but when Rome took them in 3rd century BC, a war broke out between Carthage and Rome called the First Punic War. After distinguishing himself in the First Punic War, Hamilcar Barca rose to become a powerful general in Carthage. Legend has it that when fighting the Romans in Spain (called Iberia then), he founded a town called Barcino which has now become Barcelona.

His father taught Hannibal how to fight and command armies as well as to hate Romans. Legend has it that he made his son swear on his death bed, that Hannibal will fight the Romans to his death. After his father died, Hannibal took charge of the Carthagian forces and attacked the coastal Spanish town of Saguntum in 219BC after the previous treaty with Rome fell through. The siege of Sagantum was hard for Hannibal and it took eight months. After this experience Hannibal was always vary of laying sieges to cities. This could be one of the reasons he didn't lay siege to the city of Rome directly when he was in Italy.



Hannibal was now determined to take the fight right to the Romans inside their own country. He had greatly admired Pyrrhus, a great Greek military leader who attacked Italy (and whose name dons the phrase 'Pyrrhic Victory'), and he was convinced that it was possible to fight Rome inside Italy. He decided to invade Roman territories of Iberia (Spain) and Gaul (France).

Hannibal took 50,000 infantry, 9,000 cavalry and 37 war elephants with him to cross the Pyrenees and Alps to attack Italy from the North. Even the thought of such a feat had never crossed anyone before, but here was Hannibal who was determined to do it. After braving harsh weather, ambushes from local tribes, problems with food, water and shelter, Hannibal was able to make it to the plains of Northern Italy. Only 38,000 infantry, 8,000 cavalry and 30 elephants could make it through the journey.

On reaching the other side, the first thing Hannibal did was make some treaties with the chiefs of the local Gallic tribes, before Rome had a chance to talk to them. He got a lot of them to join his army and thus bolstered his army back to 40,000.

Battle of Trebia

When Publius Cornelius Scipio, the Roman General who was sent to track and fight Hannibal in Spain, found out that Hannibal was crossing over the Alps to Italy, he hurried his army though the sea route to Italy to stop him. In a small confrontation at Ticinus, his army was defeated and he got severely injured.

When the Roman Senate heard of this, they sent Sempronius Longus, a consul (there used to be two consuls in the ancient Roman republic who ruled the country - chosen by the senate) to fight Hannibal and give support to Scipio. But, Sempronius had his own agenda. The consul elections were coming up, and he wanted all the credit of defeating Hannibal for himself. He wanted to defeat Hannibal before Scipio and his army could recover so that he would look good in the eyes of the Senate back home. As you can figure, he was an arrogant and an impetuous man.

Unfortunately for Sempronius, Hannibal knew of his impetuosity and impatience. Gallic spies that Hannibal had sent into the Roman camp were giving him all the information about Sempronius, his camp's location, their strength, their strategy and even rumors about the general Sempronius. Hannibal decided to use this weakness and exploit it by setting up a trap for Sempronius' army. In the cover of the night, he sent his brother Mago along with 1000 light cavalry and 1000 Numidian cavalry to hide amongst the dense trees and cliffs further along the river. In the morning, Hannibal sent his cavalry across the Trebia river to harass the Roman soldiers and then retreat, so that hot-headed Sempronius would follow them and walk right into their trap.



And as Hannibal had expected, Sempronius obliged. When Hannibal's cavalry came to harass him, he first sent all his cavalry after them, and then later sent all his infantry after them too. By the time they had crossed the Trebia river, Roman infantry was cold on the winter morning, hungry(as they had not eaten) and unprepared to fight. Meanwhile, the Carthagian soldiers taken all night to prepare and Hannibal had setup his army formations at a place of his liking.

Head-to-head, Hannibal had a slightly smaller infantry (30,000 compared to Roman 40,000) but a relatively much larger cavalry (10,000 vs 4,000). So, Hannibal's strategy was to break the Roman cavalry flanks (left and right) with his stronger cavalry and then attack their infantry centre.

When the battle began and the two infantry centers were battling it out, Hannibal's cavalry started destroying the Roman cavalry flanks and then turned to their infantry. Hannibal also sent all his war elephants against the Roman allies, the Gallic light cavalry. The allies were so surprised, and afraid after seeing the mighty beasts that they got demoralized and retreated, thus leaving a large portion of the Roman center vulnerable.

And to top it all off, Mago's unit hit the Roman legions from behind in an ambush, and thus giving them no place to run. Surrounded from all sides, cold and hungry, the Roman infantry was cornered, trampled and butchered. Some of the cornered Roman soldiers were able to break the Carthagian line and escape ahead to a nearby town of Placenta. But, in all 20,000 roman soldiers were killed that day (more than one third of the Roman army).

Sempronius was shamed and sacked when he returned to Rome. The Roman Senate appointed two new generals as Consuls: Gnaeus Servilius Geminus and Gaius Flaminius, the second of whom lead the Roman army during the second battle at Lake Trasimene.

Hannibal on the other hand, headed on into Italy.

This marked the first decisive victory for Hannibal in Italy over Rome. But this was just the start for him....


Next up: Battle of Lake Trasimene (or how to lay an even bigger trap)

Image Source: The Department of History, United States Military Academy

Update: Others in the series: Battle of Lake Trasimene, Battle of Cannae

Wednesday 2 July 2008

Starting the History Series

Starting this week, I will be writing a series of posts about history, about interesting battles, people who fought them and how it affected the way our world, our history and our society developed. I'll start with writing about some important, decisive and 'cool' battles. I know battles and wars are bloody and cause hardships to all involved, but they are also interesting in the sense of how the kings, generals and soldiers tried to to win.

If you put yourself in the position of these people, you'll find that they had many decisions and often many choices. What did they choose to do and what was the outcome? Thats what we will try to analyse...

And maybe, we can learn something in the process...

Here is my potential list:
  • Hannibal and how he defeated Rome
  • Alexander's last battle on the borders of India: Battle of Jhelum (Hydaspes)
  • Napoleon and the Battle of Austerlitz, defeating both the Russian and the Austrian Empires
  • The Second Battle of Panipat, which led to the establishment of Akbar the Great and the Mughal Empire in India
  • and more... (suggestions are welcome)
Hold your breath... :-)

Tuesday 1 July 2008

Hacker News network of users (based on commenting behaviour)

There has been a lot of discussion lately on trust measures, reputation and groups on Hacker News. So, I decided to run some experiments on the crawled dataset of stories released by Xirium (http://news.ycombinator.com/item?id=182374).

Of course, the real database of voting history of users would have been much better, but this is all I could get...

Calculation

The trust values were calculated as follows:
  1. For each story the submitter gets +1 from all commentors. I know this is naive, but bec. of lack of voting history (on the story), I had to go with this assumption.
  2. Each commentor gets ( votes_on_that_comment / total_votes_on_all_comment ) for each comment on that story, from all other commentors. (Again I know this is naive).
  3. Trust values are added up for (object, subject) pairs across all stories.
  4. The votes on the story were recorded as votes from a virtual user 'HNCROWD' for the submitter. After adding up, the trust value from HNCROWD for a user reflects the 'Karma' of the user on the website.

The resulting file is downloadable in CSV format here (http://www.sendspace.com/file/mw59f7).

So with these values I tried running some experiments:

1. Clustering:

An interesting experiment would be see if there are clusters of users among commentors. I used the Markov Clustering Algorithm (http://micans.org/mcl/) for clustering graphs as it does not need the number of clusters as initial input.

Unsurprisingly enough, most of the Hacker News community belongs to a single cluster. This makes sense as Hacker News is quite a focussed community interested in practical hacking related to the web, entrepreneurship and startups.

Other explainations are that users who comment are themselves quite interested in the stories and the community and are hence closely connected and similar. The users who are dissappointed with the website, might not be commenting at all... Again, using voting statistics would have been better.

2. Trust-Rank:

Second, I tried applying a variation of the TrustRank algorithm ( http://www.vldb.org/conf/2004/RS15P3.PDF ) to the trust values data.

The result here was also unsurprising. The ordering of users was very similar to what is generated using Karma on Hacker News website.

Further work:

1. The method of calculating trust values (based on comments) is very basic and needs to improved (like taking into account threads and opposing opinions).
2. I want to see if this information is actually useful in tasks like News-Story Recommendation.

Conclusions:

Without the availability of voting data, it is hard to say if users on a focussed site like Hacker News have diverging interests. I am sure, as the community grows people of different interests are bound to join. But, the whole idea of a democratic voting site only allows stories that are interesting to the most active users to be selected. And so, other users will find the website boring, and not contribute and maybe leave. This might be an example of a community maintaining itself...

Giving highly trusted users down-modding power will strengthen this emergent behaviour, and the community will become more focussed (towards these users) than it is now. This might be both good and bad depending on if you are in this majority...

P.S. Thanks to Xirium for sharing the dataset.

Monday 30 June 2008

Quick: email current page using Gmail

Quick post further to my previous post where I shared a quick bookmarklet that allows you to email the current page. Here is a link that allows you to email using your Gmail account:

Gmail »

Again, just drag and drop this link to the bookmarks toolbar in Firefox.

Monday 14 April 2008

Enjoying History


Recently, I am beginning to get more and more interested in History. I have found that I can spend hours reading Wikipedia and other historical websites. I am even bringing books on history back home from the library (which is a big deal for me)...

But what is most fascinating to me, is that I used to dislike history in high school. I found it so boring back then, that I could hardly read two pages of my history textbook without feeling sleepy. It usually happened like this: I started to read the book on my study table, but started getting sleepy, so I moved to my bed so that I could read comfortably there. Sitting on the bed soon changed into leaning, then reclining, then reading while lying down, and finally putting down the book and actually sleeping. :-)

Back then, history was about dates and a bunch of numbers which didn't mean anything. We had to remember these dates along with some events of the past, that had nothing to do with us. What does the story of some random king, in an unknown country in a remote part of the world (that I will probably never visit in my life), have to do with me? Who cares if people fought with swords or bows and arrows, or if they thought fighting on horseback was the cutting edge in military technology... It had nothing to do with me...

What changed? Am I reading a different history now from what I was reading back then? Maybe. But mainly, I think what changed was the way I looked at History. And the seed was planted by something that my father said to me long ago.

We were chatting about political history once, and I remarked how same things happen again and again. I said the history of the world is like a cycle. For eg. when rulers abuse their Dictatorial or Authoritarian rule, it always leads to revolt by the people and some form of Democracy is adopted. This has happened in ancient Greece, Rome, France and America (during revolutions), and freedom movements in many former colonies like India. But soon, democracy gets corrupted, where criminals,
the rich and powerful and those who know how to manipulate the common people, rule. They don't allow capable and honest people to rise. Democracy then becomes an impediment, rather than a savior of the people. When this happens, usually a person with will and ambition emerges and starts fighting against the status quo. He takes the power in his hands, and then passes his judgment onto the society that is struggling to save itself. Julius Caesar, Napoleon, Hitler and Mao Tse Tung and examples of such people. Their personal beliefs may be different, but they all represent the same will to gain power. After a while, this absolute power corrupts (as Lord Acton famously said) and again leads to Authoritarian rule that exploits people. So, is this a cycle that is deemed to repeat again and again?

My father asked me to take a closer look. He said that history is not exactly a cycle but a spiral. Things that happen in the past, affect those that happen in the future. Knowing past events affects the minds and the judgment of people making decisions in the present (even if to a small degree). So, even if flow of events looks similar on a large scale, they are actually different. So, to prevent the same things happening, we must understand history, and learn from it. But how do we understand history?

To truly understand history, and why people behaved the way they did, we have to get into the minds of these actors. What did these people see in the world around them? What were their choices? What was it that motivated them, and what was it that they lived for? What were the forces acting on them, and circumstances which they had to face?

When we start imagining history as something alive, as something that we can see and be part of, it suddenly becomes a whole lot exciting. We can be almost sure, that someone somewhere was faced with decisions similar to what we are faced with today. What did he/she choose, and why? What were the consequences? Were they in control of their destinies, or were they just pawns in the overall scheme of the world?

Imagine yourself in history, and history will tell you amazing things. It will tell you
great stories of extraordinary people in ordinary circumstances, and also great stories of ordinary people in extraordinary circumstances. History is a chronicle of how people just like us lived, how they fought against a hostile world, how they molded their destinies, and how they died. Were they able to achieve anything? Were they happy in the end?

In the end, it is all so that we can answer our own questions... Will we be able to achieve anything? Will we be able to make the right decisions? How will others in the future look at our lives? What will our history be like?