First glance onto distributed computing

A recent post on the computer science blog about distributed database management systems fired up the curiosity in me on distributed computing again.

Even though I have attended the parallel computing course while I was still a student, I have always thought cloud computing as worked by some sort of magic :P. I learned how I can distribute parts of a problem but I don’t understand how a single infrastructure (the cloud), can solve many problems thrown at it and balancing between them but not let them interfere with each other, and all that with no special modification to the hardware in the while.

Also contributed in part to my confusion is perhaps the name of the course, “parallel”, which reflects in my brain as a pair of something going on together. The truth is, parallel means asynchronously, many things can get done at the same time.

Well, there’s no magic after all, it’s our common perception about programming that is bended by our habit. After reading about MapReduce and watching a lecture from Google Code University, I finally get it.

There is no data types, there’s just data!

Similar to what I’ve learned, distributed computing is about “diving and conquer” problems. You’ll have to acquire quantization skills to break down complex problems in to simpler problems with which the two core function can work with:

  • Map (to process and break something in to smaller things). At the core of map, there’s some sort a halt condition to be executed when the problem can’t be broken smaller anymore.

Map is processing green stuff and creates red stuff (illustration courtesy of the University of Washington)

  • Reduce (to combine multiple small things to more usable things).

"Reduce" is combining red stuff and green stuff to produce some result

But these two function alone is not enough. How would different type of data treated when there’s no concept of type? The answer is, you make function that take data and return data but process them in a specific way.

Take the example mentioned in the Google lecture above, to process characters in a string, a bunch of data that represent a string (but is not a string since we have no typing system here) is passed into a function called explode, which will return some data that represent characters. And if the processing is to return a string in the end, a function called implode will be needed. This function do the reverse, take data that represent character and strings and return data that represent strings.

By solving the data typing and transitioning, the above paradigm of distributed computing paved way for cloud computing: while distributed computing systems is built to solve a single, specific problems with steps well-defined when the system is constructed. Cloud computing, on the other hand, is simple a collection of the most primitive functions described above, leaving the decision of how to use them to the developer.

So the good news is, developers will still have much to do creating and maintaining cloud systems, and they should be simpler to maintain. But the bad news is, our perception of data will need to renew itself to prepare for the future.

about:programmingLanguages

“Which programming language is the best?” It’s the kind of question that you will keep getting from aspiring programmers (maybe with some minor variations but it’s essentially the same problem). It’s a difficult question to answer. Although as old as the question itself, the debate is still alive today as evidenced by:

this
this
… and this

I’ll have to warn you, if (just in case) you don’t have a sense of (developers’) humor: they are just jokes, really. There’s no such thing as a “best” language. Everything is there for a reason, including programming languages. So the answer to the question above is: it depends on what you really want to do. All the languages involved in the debate are general-purposed, which means they can be used to do just about anything. For example, you may think that C++ could never be used to produce web pages, Actually, you can always write a C++ program to listen for  HTTP GET requests and then send HTML to the client. Alternatively, if you are Microsoft-savvy, you can always write an ISAPI application for ISS to intercept requests and process them.

A second thing worth noting in the arguments used is the ability to bootstrap the language with itself, that is, you can make a compiler for a language by writing code in that same language. I agree with a contributor on Wikipedia:

The definition of a language by a self-interpreter is not well-founded (i.e., cannot be used to define a language), but a self-interpreter tells a reader a lot about the expressiveness and elegance of a language. It also enables the interpreter to interpret its own source code, the first step towards a reflective interpreter.

Why bother really? PHP and Ruby did their jobs well with the compilers written in C.It’s a waste of resources both in manpower and computing power’s term trying to reinvent the wheel.

Someone have sum up the desirable characteristics for an ideal language

The language should

  • Have an intepreter for rapid prototyping, ease of debugging, and maximum fun.
  • Have a native code (not just byte code) compiler that produces fast code that can be run stand-alone or be called from the interactive environment.
  • Have good support for vectors, multi-dimensional arrays, strings, hash tables, etc. in the standard library.
  • Have a free implementation.
  • Work under Linux and Windows (so I can transfer code easily between my desktop and my laptop).

But that’s a person dream. For most of us who doesn’t have quite enough formal description enough to write anew language, we’ll have to make it with existing ones. Below is my stance on some of the (more popular) languages but if you wont a more detailed comparison of each language’s characteristics, this may be interesting to you.

C and C++

They are used to make just about anything. The difference between them is C++ have a more extensive set of libraries, which is expensive in term of storage space to implement so it’s not as popular on embedded devices as C. Their application may range from programming microchips to a whole operating system (you name it. Linux, Windows and Mac may seems all different but they are all in C and C++).

A common misconception is that there’s something a language cannot do. If you haven’t seen anyone write web pages in C and C++ then try to type your DSL modem’s address into your browser. You should see a web page that allow you to configure the device. Such a device wouldn’t have enough processing power for the additional abstraction layer of a web server’s but instead its role is encompassed by the firmware. The firmware itself, is of course, written with you-know-what.

In short, they are good if you are going to deal with hardware programming.

C#/Java

Considered high-level languages, they are the most promising platform to implement 4th generation languages. Notice that I wrote “platform” and not “language”. This is because C#/Java is merely an interface for a lower language, the common language for .net and bytecode for Java. The additional abstraction gives the developer the freedom to move the application across platform. Input and Output are not necessarily specific devices anymore. You can output to a screen or a printer, it’s the same to the language. You can have a language run on a mobile device or a PC without changing anything in the code, the virtual machine took care of it. You can use a module in a desktop application in a web service without any modification, increasing reusability and reduce the amount of work required to write code.

Because these language was designed later than C and C++ and targeted developer instead of computer scientists, you are no longer required to remember the difference between pointer and variable, don’t have to freak out with memory management and other trivial matters. Package and variable names are also neatly named according to a naming standard, since these language is controlled by a singe entity.

In a nutshell, choose them if you want to properly apply development paradigms and produce quality software that run fast and reliable, anywhere. But you will grow dependent on the managing companies though (namely Microsoft and Oracle)

Ruby and Python

Developer-to-developer languages. They are written with only one goal: get things done, as fast as possible. And as such they employ a vast number of libraries and add-on (and you will have to remember all their syntax). Professional developer seems to have no problem with that though, so they are quite popular among the web community. That’s why ruby thrives on rail and Google is built off Python. They have a different syntax from C (which is also different from all the languages above) though, so switching to them may be a problem for newcomers.

PHP

Started as a collection of script and the result of a developer disgruntled with his boss, PHP is released for free because it can’t be sold at first but accidentally, it’s just that that make it popular. Because it’s free, it’s a convenient platform to implement open-source projects that the user can download a whole platform off the Internet and have it running free-of-charge. Googling for WordPress and Joomla is enough to demonstrate PHP’s popularity.

Since PHP seems to have matured (its main version number stayed at 5 for two years now and had no significant changes since), it’s a good language to learn if you are intending to go freelance serving small and medium enterprises (SMEs) who doesn’t have enough financial ability to employ powerful servers and expensive softwares.

http://www.cs.ubc.ca/~murphyk/Software/which_language.html

Apple versus The world

Three days ago Apple published a post by Steve Jobs defending their decision to not allow Flash on their shiny mobile devices (namely the iPhone, iPod and iPad). To sum up, here are the reasons:

  1. Apple’s solution is being more “open” than Adobe.
  2. Missing flash doesn’t hinder the user’s ability to browse and enjoy the web as the world is submitting to Apple’s “innovative” interface.
  3. Flash is a security menace.
  4. Using flash for video would drain battery because there were no hardware decoders.
  5. Flash doesn’t fit in Apple’s touch agenda.
  6. Apple thinks there should not be anything between its operating system (OS) and application so developers could exploit the full potential of the OS.

There has been various long and detailed arguments counter and support Jobs’ view. Mine is below.

No doubt Jobs is very convincing. It’s his job! The article gives you the feeling Apple is the good guy here and they have been benevolent to Adobe so far. Adobe just can’t live without Apple and Apple has been the source of innovations all along.

Really?

While it’s true that Apple had helped Adobe to exit their “proverbial garage”. Apple didn’t get out of it on their own. Say, where did the interface for MacOS came originated? And while Apple is busy praising their “novel” concept of a touch interface, I have been scrolling web pages under the touch of one finger on my p990i for years. To give Apple credit for the touch interface is like giving a wheel rim manufacturer credit for inventing the wheel  while in fact all they did were making golden rims. Should we stop using iron-cast rims when there’s the golden rim? That is a change but not such a big one. Marketing hype did the most part of the job! (Introduction and point 5)

Criticizing Adobe for not publishing Flash as a standard and emphasizing Apple’s role in the creation of HTML5 doesn’t make Jobs look better :/. Who are using the web? The users or some technical manager at Apple? Don’t they deserve a choice on what to view and what not to? Would excluding Flash make their device crash-free? It’s the device we spent our money on, and we don’t have a damn right to crash it? :/ If Flash had crashed that much and is such a big security exploit, why doesn’t Opera, Firefox, Chrome or Safari block it? 😐 (Point 3)

And who forced us to pay to use the proprietary H.264 format by rejecting a free and open alternative? While I would agree that HTML5 is the future, Apple’s conservative stance is making it worse! (Point 1 and 4)

As a developer, I just hate the time when you need to do something a bit advanced on Windows, you have to go online and asks for some hidden API buried in some stupid-named dll. What kind of name is MCEWMDRMNDBootstrap? And how come when I wanted something to run on Linux I have to fork a new code path and recompile it? I’m just glad there were Java! To prohibit flash in favor of MacOS’ API is like prohibiting Java to run on Windows. Imagine that! What is the big idea in this step back? 😐 (Point 1 and 6)

And to say Flash is complex and all content developer should abandon it to produce faster, richer application is like telling all Word (or iWork) users to write documents with notepad and automate with C++! The designer’s job is to design, not to learn objective-C! There are thousands application on the App Store but how about millions of games already there on the internet? Are you absolutely sure that everything the world will ever need is in the App store? (Point 2)

By the way, speaking of the App store has just reminded me of how paranoid Apple is to Google (and to changes). First they rejected Google voice to “ensure a streamlined experience to our users”. Meh, why don’t they just say that their own voice application is trash and they are afraid of competition? 😐 And then they threatened a third party developer for a one-line mention of Google’s Android! Plain drama! (Point 1 again)

In conclusion, from my point of view Apple is not the only mobile manufacturer in the world. We still have a lot of alternative choices, make yours wise. Would you trust your data in the hand of a dictator who won’t even allow you to to have an extra battery for your phone? 😐

Avatar 3D

Yes, I went out to see the you-know-what avatar. The hype is still so high that four months after its release you can’t infer immediately that the topic is about some internet forum anymore. Instead you have to think twice when someone asks you “did you see the avatar”? Even a person who had never been to a Cineplex, who had kept a record high time of abstaining from being influenced by marketing hype – like me had to come and see. Enjoying life is always the first priority :p

Avatar’s poster

I don’t want to curb my reader’s enthusiasm so soon, so the good news first: it’s good! It’s worth its 300 million funding, it’s worth your money, and if you’ve never seen a 3D film before; or have had sore eyes experiences from that old pure red / cyan glasses years ago; then this is a good time to step into the current film era. Even though I can’t say the 3D effect will bring your viewing experience to a whole new level, it’s worth trying!

The story is motivating, the action is timed just right: not too slow but not too fast either. Though it’s not that deep into the eons-old topic of love like Titanic (one of Cameroon’s previous works); it still brings you light-hearted moments in the form of subtle jokes, which I prefer to romantic scenes. I know a few people who is dying to be called skxawng too :p. Most people in the theater I was in burst into laugh when a kid from the back told his dad “Seeeee? They kissed”.

All that being said, life is not all pink; it doesn’t looks like magenta or cyan either, yet when you want to enjoy 3D in Vietnam you’ll have to accept it as such (that life is magenta and cyan) due to the projecting technology employed. Maybe that’s why the picture appears darker compared to DVDs. I’m a bit disappointed too because after 10 years in between of the 3D hypes I expected them to come up with something better, like circular polarization glasses. And they could have done a better job cleaning those glasses, I have a blur in my view the first time I tried the glasses on :(. Well, I guess I can’t really complain considering the ticket fee in Vietnam is still 3 times cheaper than in the US.

A few other reasons why 3D film isn’t perfect just yet (at least for Megastar’s current technology):

· Yes, you can see depth on the screen, but you can see depth on photos in the film too. For example the scene when Jake opened the refrigerator with an avatar’s photo stuck on to it. Maybe in the future photos will be in 3D too but for the present it looks more like an excessive application of 3D CGI.

· It’s a bit blurry when you tilt your head, but maybe it’s just what you will get sitting as near the screen as I am.

· The 3D effect let you feel the depth, but doesn’t allow your eyes to wander. It brings an artificial feel when you tried to focus on some object in the background but it’s still blurry. It’s jittering on scenes with fast action also; maybe due to the projector’s frame rate isn’t fast enough to cope with 3D projection’s requirement.

· The skin the big leopard-like creature attacking Jake from the first part of the film is just too glossy, a reminiscent of early 3D technology without texturing. It’s the only creature with such an attribute though; most others are pretty well modeled and rendered.

And finally, the 3D effect is the most enjoyable in outdoor close-up scenes, otherwise you’ll just forget it’s there fifteen minute into a dialog montage. But hey, isn’t the action the most important part of a sci-fi? :p

Though it’s not the ultimate cinematic experience those PR guy told you, I’m still glad I’ve had the chance to enjoy it (on the last day it’s shown here :”>).