Saturday, September 12, 2009

The Way of the Future

I will start this very special entry with a very ugly truth I realized, "This is my last trimester, I'm getting out of school, finding a job, making some money and I just realized I'm already old news, I'm not the a fresh programmer but only the latest iteration from a dying paradigm."

Ok, the people who know me think I'm a talented individual so it may have shock them to read through that last paragraph. The truth is, it is all true, we are a dying breed.

I have always used a personal metric to find where IT was headed, I just read what new trend Microsoft have adopted (people can hate Microsoft but if something new is good, Microsoft will adopt it, buy it or copy it, either way they just end up using it), so when I found out about Microsoft making a big deal about concurrency in the upcoming .Net 4.0, I knew something was happening, something big.

So what's the big deal about concurrency? Well to put it simple we all know the future of processors is adding more and more cores, but what happen when your code's performance doesn't improve, when your code is 1% faster in a machine with twice as cores as before? You just have found the tip of the iceberg, and believe me it's a huge problem for us programmers.

It seems the problem is the way we develop today is just as von Neumann's theories said we would, one instruction at a time, but our hardware is already past beyond that point, it's just our code and coding skills that are outdated, we just aren't thinking parallel.

Multicore processors eliminated single cores because adding more frequency and speed to single cores was causing overheating and more power consumption, so multicore processors don't overheat as easily as single core processors does, but the more important reason is that they use less power (running those ubber datacenters spawning total airplanes hangars both in the US and in europe is posible now), point is we all agree more cores is the way Intel and AMD are gonna shape our future.

The answer to this problem is to think parallel, we need new skills, there won't be a magical compiler to handle parallelism for us (researchers are trying to achive that since the 80s), our current dominating and most used platforms (Java platform and .Net) can't solve this issue, nor can dynamic languages like Ruby (a personal favorite) or Python, we need new skills.

Why our most used tools and languages fail to solve this problem? Because they share the resources (RAM), so if A + B = C then C - A = B, we all know that's true but what happens when running on a datacenter using 600 nodes (servers) a la Facebook, one of those nodes change the value of B just when another is checking the second half of the equation? Bad things, so our answer is lock the memory, just as our DBs lock write access to a record to avoid this kind of problem (and the more and more cores of our datacenters are waiting because the resources are locked they can't do anything until the resource is free), so the problem is at the core of all our tools, some experts have said the problem is C itself and I ask you which of our modern tools have not used some of C ideas for themselves? (I'm assuming your language of choice ain't written in C). I hope you guys are following.

So what's the answer? At the moment we may not feel this pain in our daily jobs (unless you work for a huge company, Amazon and Google like, which may need to use concurrency to use all the power of multicore processors), our programs don't use all the power of our hardware but we can endure for a few more years (specially in DR where changes reach with a 8 years delay). Microsoft and Apple have made wonderful efforts to use the power of multicore procesors and to make it easy to jump to the bandwagon to the future, concurrent programming. Both companies have added APIs and libraries for use by devs in their current iteration of their operating systems, will that be enough? No, but it's a start. (Sorry Linux users, aparently at the moment Linux doesn't care about concurrency at all, which may make some devs leave that OS because of its lack of vision, my personal case)

So most of my personal friends in the IT world know I don't care about the money (which I need to eat and to "satisfy" all of my future GF's whims, yes ladies I'm single and yes Sab I know) but I care about what problems and what achivements I make programing solutions for me or the company I'm currently working for. So my personal solution is to learn concurrent languages like Erlang, F# (runs .Net) or Clojure and Scala (both runs on the JVM), I know most people don't have time but I'm learning with my little free time and I already see some benefits, I'm coming up with more sophisticated solutions because my mind has a broarder scope now.

So to end this article I conclude with the phrase that started it all, "This is my last trimester, I'm getting out of school, finding a job, making some money and I just realized I'm already old news, I'm not the a fresh programmer but only the latest iteration from a dying paradigm."

Last, I leave a very good link about this present problematic.

Is this a problem you 're facing or you don't believe this won't affect IT? Leave your comments.

Sunday, September 6, 2009

The CodeJam 5

Ok, the image doesn't look so good but the point of this post is to talk about the CodeJam 5. As many of you know Google Code Jam started this september (2nd or 3rd I don't remember) and me and my buddy ecin decided to go for it. Both of us made it through the qualifications round, we both used Ruby and that's that.

The CodeJam 5 is all the dominicans I could find in the competition (looking page by page and it would be nice if Google provided statistics by country which is why I started this post and added all 4 guys to my friend list in Code Jam), we all passed which speaks good about Dominican Republic (for a change) and we used diferent languages, one used Java, another used C++ and the chameleon known as cjoa used Perl, C++ and Python (he is ranked way above the rest and his ability to swing diferent language for diferent problems shows what I'm almost sure of that he will be the last one to get eliminated from Code Jam from the CodeJam 5).

But you maybe asking yourself, why am I talking about this in my blog? First, because I haven't blogged in a long time :) , second because it is important to growth as developers and as programmers. When I heard from ecin about Code Jam I freaked out, I thought "I'm so gonna loose in the qualifications round" so I decided to quit before even trying, after a lot of rethinking and the help from Scott W. Ventrella in his book The Power of Positive Thinking in Business I decided to give it a go, not thinking how embarassing it would be to loose in the qualifications round but thinking how much can I grow, how much can I improve, after all programming is not done in front of some IDE or text editor, programming is done with your brain.

To put it simple we all passed the qualifications round, I don't know if I'm gonna survive the next round but I will give it my best shot and see how much can I grow. Are you doing something to test your limits and surpass them?

Sunday, August 23, 2009

I'm taking JavaScript seriously

Well after reading an article by Larry O'Brien @ SD Times magazine (sorry no link, I read the physical copy) about how people aren't taking JavaScript (JS from now on) seriously, I decided to do blog about it.

So what's JS? It's a programming language mostly used @ client-side programming, it is the key to all those awesome effects you see or experience in your favorites websites, one of the crucial components in AJAX (which itself is only a technique), but as I called it: "The technique which built the Web 2.0", so AJAX is something important, we all know it, but JS is important too.

So JS allow us to add some nifty effects like changing the value of some of the HTML elements of a page, ok nothing out of this world, but if we add all the jQuery (include your preferred library here) DOM effects and AJAX-powered page dynamics and you got the current web, not only the current but the web we'll probably be building for the next 5 years (10 if the adoption of the semantic web or web 3.0 as Tim O'Reilly likes to call it takes longer). Again, you maybe asking yourself that I'm not saying anything you didn't know, but guess again you 're wrong.

JS is a programming language and as all languages have bad scripts and good scripts, I bet most of you don't optimize your JS code, probably if Firebug doesn't show an error, you are done working on that script, what about optimization? there's always room for that (yeah we the dinosaurs who know C++ are optimization freaks), JS is becoming more important on the web with each passing day, so is obvious that the future bottlenecks on websites will be because of bad JS code. So if you start know taking JS seriously, you probably will avoid these network traffic problems in the future, so the question remains what can you do?

The first thing to do is to learn that JS is an incredible dynamic and object oriented language and that the fault for the slow JS is in ourselves. Second you can start using tools such as YSlow and debugging, performance and benchmarking tools to see where your JS code is taking the hit. Finally we are all afraid to change our code, "it worked yesterday, now I made a couple of changes and bang it doesn't work. Darn it, let me clone the repo again.", yeah that's why programmers began using TDD and BDD (mostly TDD for this scenario) because with a full test suite you can change your code without fear (hell you can be Daredevil, the man without fear or Dan Dragon as that comic book is called in Spain), bottom line test your scripts.

Finally, I want to add that I can't make better JS code for you, you will always have to sit in that chair and code it yourself, good night.

Thursday, August 6, 2009

Google Docs will kill Microsoft Office...

Lately that's something I have heard everywhere I go, people come and run their mouth about how Google Docs is the future and Microsoft Office is older than the T-Rex. Lately Google launched a new campaign offering their Google Apps for workplaces, so you can all imagine how much some people have been commenting about it in the blogosphere.

As always I tend to go in the opposite direction of everything, so I began doing my own research about how this battle gonna end (of course I'm a simple mortal so I can't possibly predict how this is gonna end but I can give my opinion). I found out that, after reusing, Google Docs that it lacked many features and the speed that Microsoft Office has, of course that comparison is unfair one being on the desktop and the other on the web, but many people uses the accessibility that Google Docs possesses as a strong point when arguing about this topic, so why can't I use office speed as a strong point?

Google Docs is what we now days call a SaaS (Software as a Service) and is what many people calls "the way of the future" and that makes Google Docs a bleeding edge application, but is that enough to migrate from Office? In my honest opinion no, Google Docs lacks a lot of features, not a suite the size of Office and Google Docs lack ,what is in my opinion the most refreshing and interesting feature Office have, VBA (of course as a programmer I have a natural impulse to run away from anything VB but Microsoft in theory could add any .NET language and use the same subset of functionalities making a dream come true, a Microsoft Visio extension written in IronRuby).

This week I got reminded a very important lesson, programmers are suppose to write code that solves problems, be it some companies, users or personal problems. So we programmers now days tend to answer right away to every problem with "let's make a web application", but a web app is not the most efficient solution to all the world's problems, sometimes desktop apps can do the trick, let me express myself more clearly with the situation a close friend had recently. His father owns a small clinic, he is a cardiologist and he along with others doctors that work there needed a way to save their receipts and how much money each doctor made daily (yeah they pay daily over there), so my friend offered himself for the task, but there was a problem he isn't a programmer, all he knows is a little VB.NET (I'm teaching him programming but it is a slow process).

His approach was to extend Microsoft Excel's capabilities using VBA (Visual Basic for Applications) and store everything in the spreadsheet, of course when he came to me with the idea my suggestion was "let's make a web app", he then said to me that in his fathers clinic there was no Internet, making my initial approach totally worthless, I then offered to code (as I taught him) a desktop app, he said this people weren't very tech-savvy so we needed a new approach, finally I suggested to use Microsoft Access, yes I unleashed the horror unto the world again (we programmers usually hate Access as the DB for our projects) but my approach was a tricky one, this people were familiar with Excel and Word and I intended to leverage Access' power and usability based on the fact that almost all of the Office suite uses the "Ribbon interface". A few days later my friend came by to play a little hand of Cashflow and showed me the results of his work, I was amazed by how he learned to use Access and how much he had done using VBA, I taught him a few of SQL's commands and probably after he finish with some details about the application, he will have done a complete and functional application on Microsoft Access which real people are using to solve their problems, that is the true power hidden in Microsoft Office (average people only knows how to use a tenth of all of Office capabilities, far less knows how much VBA can help), a power Google Docs currently doesn't have (if I'm wrong please respond with a link) but on the IT industry nothing stays the same for too long, probably Google could add this kind of functionality offering some sort of JavaScript idiom, the point is, this is a great feature of Office today but tomorrow it might just be some standard all office suites offer.

At the end of the day the lack of features and applications (the suite is a lot bigger in Microsoft Office than the suite Google Docs offers) on the Google Docs suite makes it a no brainer for me to go with Microsoft Office as my preferred tool. The accessibility of Google Docs, as being a SaaS application, is not enough for me to migrate from Microsoft Office.

Saturday, August 1, 2009

Comet a.k.a. Reverse Ajax

OK, before we start with this post we need to explain what is Ajax to those "web developer" who have been living under a rock since the CGI-Perl scripts days.

The http protocol model includes the so called "Request-Response" cycle, so many years later each response included a full page reload, then came JavaScript and yada yada Ajax was born, so Ajax stands for Asynchronous JavaScript and XML. Ajax consist of updating certain parts of a web page asynchronously, always started by the client , without reloading the whole page so it doesn't interfere with the user experience, no awkward reloads. So, yeah Tim O'Reilly coined this with the awesome name Web 2.0, but you maybe asking what the hell is Comet?

Comet is a neologism to describe a process very similar to Ajax but in which the server starts the connection. Actually, Comet is an umbrella term for multiples techniques used to achieve this functionality, now you probably understand why some people decided to call Comet, Reverse Ajax. But why do we need Comet? why do we need something that turns the http cycle upside down? what benefits could we gain from using Comet?

This very same questions were asked by friend of mine one day when I told him what Comet was, so I came with a good example and decided to make a post about it.

The example includes making a chat online in your website, something like gtalk inside gmail, so how would you implement it? has to be real life chat with near instant responses or the users gonna complain a lot and probably never use it.

So one idea would be to use Ajax to achieve this:

So putting it simple, make a lot of Ajax calls to the server and when there is something in the queue, update the chat component in the client, does anyone else see the problem with this approach? Making calls every second will create unnecessary traffic and if we make our web app to make calls every 5 seconds what happens if a response from the other user comes right after a couple milliseconds after our call was made, the client will wait 5 seconds waiting for a response that's already on the server. Obviously we need a new approach to achieve our goal.

Second idea, use Comet:












So how about using Comet and make the server talk to us when he receives the response from the other user? We won't need all those Ajax calls, instead we would only need one call to keep the chat cycle going, the server's.

But Comet, can't be all roses, we need a way to implement it. In this example I'm not gonna code it but I'm gonna use the theory behind Ajax long polling to detect new information on the server. It consists in simply making Ajax calls wait longer than usual for a response from the server, in our example it uses a lot less Ajax calls to achieve our goal and it doesn't produce too much traffic.

Well, hope this post was of some interest to some of you, I hope you can leave your comments about where to use Comet and how much resources would that save.

This was Darryl Almonte, thanks for reading, Namaste.

Coder Girl...

Following some links in the Heroku site, I found a link to the Erlang Factory and Kings of Code conferences, so after watching a little videos of my personal interests, I came into a very interesting video.

All I can say is enjoy.

Tuesday, July 28, 2009

Engine Yard contest



Ok, many of you may not have heard about it but this july, EngineYard made a contest consisting on finding Hamming distances between one 12 word string and one you could make choosing 12 words randomly from a 1000 word dictionary and including a 13th word made of 5 random characters, the team or individual with the lowest distance wins.

So a good friend of mine, ecin, sends me a message about the contest, he says he wants in. Obviously I ask "how? we don't have all that computing power", he responds: "let's steal our school's PCs and who knows maybe we win", I said game on. Prior to the day of the contest we contacted our good friend projectnoa (taking his twitter name because I don't wanna mention real names), told him about the contest and he decided to join us.

We had over 120+ PCs for something like 15 hours running the code and sending the combination that got us the lower HD to our server (ecin's MacBook), the above pic is of one of the labs we hijacked for our operation.

At the end we didn't win the contest (we got 38 HD and the winners got a distance of 30), but it was a nice experience all along. And we wanna thank INTEC's lab manager ecabrera for supporting us in this adventure.

Another contest by EngineYard taking place on september, we'll be there, hope some of you decide to join too.