I never understand when some people defend one programming language or full stack and never wanna know about other technologies and learn more about their differences. You see, a programming language is just a tool.

During my career, I’ve met many people who would be very faithful to one kind of technology and ignore all the rest. Don’t get me wrong, of course we should become specialists in one kind of technology. But for example, if you stick to PHP only, you’ll be missing how beautiful Rails is, or if you stick to the Microsoft stack, you’ll be missing so many other technologies that don’t depend on the newest version of OS or IDE to work properly and in their newest version.

Technology is evolving all the time and it’s hard to keep up with all the trends that keep coming, so I believe we must be always willing to learn more and grow in the process. After having to learn .NET to develop some systems for the company where I work, coming from my mostly-PHP background, I started to believe that given enough time, anything is possible.

Recently I decided to get a task given to me in an interview for a Software Engineer position at Google and explore some programming languages with that idea. I thought about developing the same code with 10 different languages, just to practice, because I believe that’s the best way to learn a language for me.

I learn much better by doing (and practicing Google-fu, of course). The idea was to read an imaginary log file with a list of IP addresses and return the TOP 10 most repeated ones, along with their count. I decided then to use a real log file from a random day for that and parse it using the languages I chose for the task, which were C++, C#, Groovy, Java, JavaScript, Lua, Perl, PHP, Python and Ruby.

Python

fromoperatorimportitemgetterdefread_parse(filepath):ip_count={}withopen(filepath,"r")asfile:forlineinfile:ip_address=line.split(" ")[0]ifip_addressinip_count:ip_count[ip_address]+=1else:ip_count[ip_address]=1returnip_countip_list=read_parse("../apache.log")#The headerprint("RANK\tIP\t\tCOUNT")# Using enumerate() so we can have the iteration's index (rank variable), starting at 1# Sorting the items of the ip_list by their value in reverse order, but limiting the loop from 0 to 10# Ps: Python is beautiful =)forrank,lineinenumerate(sorted(ip_list.items(),key=itemgetter(1),reverse=True)[0:10],start=1):print("{}\t{}\t{}\t".format(rank,line[0],line[1]))

So, this is it for today. Lately I’ve been working a lot with the Ionic Framework, which is a framework built for hybrid mobile development and uses AngularJS and Phonegap/Cordova, and I’ve also been studying more about Rails and Laravel, so some of my next posts will probably be about these technologies.