HipHop Your Way To PHP

A few days ago facebook released (under opensource) their HipHop for PHP source code transformer. I remember first reading about this from an interview with a facebook employee on reddit. She mentioned that one guy was pretty much rewriting PHP to work on C++, which at the time sounded like they were working on some compiler. The actual product though is different, they basically convert the PHP source into C++ code, and then you can use your compiler of choice (probably g++) to get it up and running. I know something about this area as my final year project at uni I created a code transformer that would take a web script in PHP -> JSP -> ASP and convert it into any of the others. You could basically go in any direction – plus you could add in new modules for other languages that would allow you to transfer between even more. This was far from completion (I had it working for about 50% of common functionality) but I proved that it could be done – I also showed that you could optimize the code quite significantly. I basically added rules that would find common coding patterns and transform these in the AST (abstract syntax tree). Transforming to the new language was relatively easy as the tree was already in a good shape and the transformer knew how to properly express the tree in the most optimized way. The way I see it – HipHop has the opportunity to not only transform but optimize the hell out of the code as well. They say that in practice they are seeing a 50% CPU decrease and much better memory overhead.

I believe that the current version is compatible with PHP5.1 and they are quickly looking to get it compatible with 5.2. There are also some bits that it wont do, such as the rarely used eval() statement and function exists checking – these are things that they cant link to as they don’t know they exist, therefore can’t compile against

I have always liked PHP and have watched it get better and better to the point of it being a very professional tool in the right hands. I still regularly use PHP for my own applications that I need to get out the door quickly and effciently. What makes this interesting to me is that I can also look at it as a tool of choice for applications where I wouldn’t have before used PHP. I will have to play with it a bit and see what it can do. I think it will get more interesting when they get a version that can run on Apache/lighttd etc.

Go and get the code for yourself and check out the video for further information.

For more information on the technical challenges they face scaling Facebook, take a look at this article which goes into a deep enough description.

Chrome OS. Google’s Distraction Move.

googlevsmicrosoft

As you must know by now Google have announced that they are going to release an OS aimed at the netbook market built around their Chrome browser. It’s a good move because netbook’s are one of the fastest growing segments of the computer industry at the moment. The thing is though I don’t see how Google would hope to beat Microsoft at their own game. If you remember, netbook’s were meant to be Linux machines and at first they were. Cheap and cheerful is what people wanted they said. Figures now say that ~94% of netbook’s have Microsoft Windows. Microsoft managed to completely grab this market from what is a free OS. How did they do this? Because users are more familiar with Windows. People will obviously pay a premium to use an OS that they recognize and can run their apps on. So if they managed to do this how will Google manage to grab those users back with what is afterall just another interface on top of Linux? So this leads me on to what I think is Google’s actual plans.

Google dominate the web. Microsoft dominate the desktop. But Microsoft also have a pretty strong foothold on the web as well and their newly rebranded Bing search engine is gaining more users – no where near Googles but it has still been gaining and is receiving a majority of good reviews. But what happens if Microsoft manage to gain a large enough percentage of the web? What do Google have then? They dont have a major dominance in any other software area, which is another reason why I think they created Android when they did. I believe they are just trying to distract and pee off Microsoft, just enough for them to take their concentration away from the web for a while. Just remember that while you may have all the market the only way forward is to loose users, when you have no market share the only way forward is to gain users. All the while this is chipping away at Google and they need time to sort something out properly. It’s a clever move because it may distract Microsoft’s attention and/or it may work out and they get a foothold on the desktop. The same applies to Android. Microsoft certainly are not dumb and I guess they are fuming at the news, so I am interested in what they can and will do about it.

Also remember that if Google has a cash cow, then Microsoft has cattle.

Update: Google announces hardware and Software Partners

I have just read on el’ Reg that Google has announced who they are going to work with for the hardware to run their new OS. It appears that they have all the big names on the list including Acer, ASUS, Freescale, Hewlett-Packard, Lenovo, Qualcomm, Texas Instruments, and Toshiba. Strangely Dell are missing from that List. They have also announced that Adobe will be a software partner.

Want Some Guice? Yes Please..

I don’t know if you guys ever watch the Google IO presentations but if you don’t you should because sometimes you find a gem. Guice is one of those gems. Guice is a lightweight Java dependency injection framework (not another one I hear you cry) but it does look very interesting. Take a look at the video if you have time.

Those of you that read this blog regularly will know that I have been moaning about Java web development for a while because it takes more time setting stuff up than it does actually coding the thing and it puts me off. I have been threatening the world that I would be working on my own framework but I now may not have to because Guice actually seems to have most of the things that I was looking for. I am going to take a further look and see if their are any more cool things or any concerns.

It fits well with the new Java app engine api as you would expect and the very cool thing I liked is GWT with GIN that can actually compile your modules/injections to Javascript so that they can be used to write the client side interface. I found that rather cool. There are a few pieces missing such as the ability to compile down method injections but in the video they confirmed this is coming soon. I now think that the app engine has finally reached the stage where I would be interested in releasing apps onto it and would recommend it to others. Yeah there are plenty of concerns about data privacy but the same can be said with any cloud environment and especially one that is hosted in the USA. As far as I see it, as long as your app is not storing data critical to national safety I don’t see a problem :)

So, I am currently setting it up, will write an app, release it onto the app engine and write something about it here with any insights I may have.

Hadoop (When Adults Do Open Source)

I was reading through HackerNews when I came across an article (from ElReg) explaining Hadoop. Althought I wouldnt have expected so the article is pretty funny and worth a read. In case you were wondering, Hadoop is a high level Apache project for an open source MapReduce (Google) cluster system written in Java. It was designed by the same guy that brought us the amazingly good Lucene indexing system.

I have to quote a part that I found particularly funny when he was comparing Hadoop (when adults do open source) to Starling (Twitter’s messaging system).

Twitter decided they would be cute and trendy. They wrote their code in Ruby: the official state language of the hipster-developer nation. Doug Cutting, on the other hand, decided he would get shit done, and wrote Hadoop in Java. Starling was hidden away in some corner and forgotten (it’s hosted at RubyForge…what the fuck is that?). Hadoop lives prominently at the Apache Software Foundation. Starling is a re-hash of an existing Java Enterprise API called JMS that has several open source implementations. Hadoop is an implementation of Google’s MapReduce, a system that publicly only existed on paper. Hadoop has the added benefit of actually working.

Perhaps this is a feast of apples and oranges. Starling is a messaging system, Hadoop is a distributed data processing system. Don’t worry. There’s plenty of failure to be had elsewhere in the open source world. Let’s take, for example, a project called Starfish), which is a pure-Ruby implementation of MapReduce. Eh, well that’s not entirely accurate. Starfish is a MapReduce-inspired framework that’s simple enough for even Ruby developers to understand. That means there’s no actual “reduce” phase in the MapReduce, and it works on MySQL database records. In other words, this project is virtually useless in every way, aside from getting the author a quick beatoff from the blogosphere. It’s a half-baked implementation of an algorithm from Google, it’s written in Ruby and it integrates with Rails. That’s so warm and fuzzy it could turn Clint Eastwood gay.

Well you cant get more honest and plain talking than that ;) . The guy who wrote it is Ted Dziuba who is a co-founder and the CTO of pressflip.com which happens to be a search engine that will keep on searching for results even after you have finished (if you ask it to) in the hope that it will learn more about your search habits to fine tune the results and It would appear that they are using Hadoop for their application. I must admit that I have (and do) hope that someone can actually produce a new search engine that could compete with Google, but unfortunately there is nothing (in my opinion) that really seperates them any of them apart, especially in the browser space. I still think that there is a good possibility of getting somewhere in other search spaces such as mobile phone/mobile internet device areas. The results that you want in your phone are usually very different to those that you would want to get in a normal web browser and I think that excellent usability is something that could win in these areas. Take a look at Taptu which I think is a great mobile search engine.

Basically though, why cant more internet companies use their talent to try and solve some problems that people actually have. There are a million problems out there that must need solving but most of the startups tend to be in the same space with the idea of selling out to Google in a couple of years (or months) with no clear idea of how to make money now. Wouldn’t it be a crazy idea eh, that companies might start to create things that people actually want and are willing to pay for? Businesses that actually make money, now that’s something new ;)