Firefox Uninstall Bug (Windows)

Try the following:

  1. Install Firefox (any version)
  2. Wait for another major version and upgrade from the update facility
  3. … then you will see in Add/Remove programs two entries for Firefox. One for each version.
  4. If you try to un-install any version, both will be deleted, and firefox will be uninstalled.

#fail

Appengine APIs are Missing C/C++ Implementations

Recently I was messing with Appengine’s pull queue and noticed the following. They did not offer a C/C++ API. All the other usual suspects are there, like python, Java, go, even PHP and Obj-C.

What happened to C/C++? It is not worth offering and maintaining any more an API for these two languages? Or google wants to promote go!, and pat the iOS developers with the Obj-C?

No, you cannot have a native app. That’s it! Maybe, because C/C++ do not offer by definition an HTTP protocol implementation.

Thinking in jQuery

Recently I was doing some heavy-duty Javascript stuff for a web project. It was quite a while since the Firefox plug-in and in many ways, it was rather enjoyable experience (and in some other ways boring 🙂 ).

If you want to do some cool stuff in the web nowadays, the adoption of a Javascript library like jQuery is typical. I had some experience in the past, but the development process showed me that I was not so experienced as I thought. jQuery has good documentation that can be used as a reference, but it is not very usefull, when you want to understand some basic concepts and you are in a hurry of doing some stuff to work.

So, this blog entry has one goal, to transfer my experience of doing stuff with jQuery as a set of rules/advices that will save time to inexperienced users like me.

Rule #1: “When you are using jQuery, forget low-level Javascript functions”

It is a good practice to use always jQuery’s functions to do the stuff you want. Never rely on the low-leve Javascript function. The reason is simple. jQuery offers an encapsulating object for all the elements of the DOM tree. If you select some nodes with the jQuery selectors and then try to access their children with the common DOM function offered by the standard Javascript API, you are done for. You lose that encapsulation and you are back in black.

Rule #2: “Use # for the ‘id’ selector, ‘.’ for the class selector and always use backslashes in front of dots in ids”

No special reason, just remember these three examples:

  • $(‘#theCoolId’) – id selector
  • $(‘.myBigFatClass’) – class selector
  • $(‘#theCoolId\\.With\\.Dots’) – more complex id selector

Rule #3: “When you have to insert code into an element, use html()”

Simple as that, select the node and paste the code:

$('#theCoolNode').html('

Hey Stranger!

');

Rule #4: “By default the ajax() call is asynchronous”

… so if you want to load something, be sure to disable async, or else you will try to access something that is not ready. How can you do that? Simple!

$.ajax({
	type: "GET",
	dataType: "xml",
	url: "data/strings.xml",
	success: function(xml) { /* success */ },
	error: function() { /* error */ },
	async: false /* I will wait to load the XML */
});

Rule #5: “insertBefore() and insertAfter() take the selector as the parameter”

I do not know about you, but I always thought that it is logical for the insertAfter() and insertBefore() to select a node, then append the node. But this is not the way they are implemented. A small example:

$('

Hey Joe!

').insertAfter('#theCoolNode')

Rule #6: “It is always your fault”

Usually it is, accept it and try to understand how things are working :), instead of trying to convince everyone that you are Mr. Right!

The Devil’s Advocate: Ajax

Recently I decided to move on with my web programming skillset, and see (at last) a little more modern approach that include much client side coding, with Javascript. The first thing you learn when studying such approaches is the XMLHttpRequest, which is used to send/receive data with the web server.

To aid me, i purchased the Head First Ajax, a really nice book, focused in practical things, than in theory and specifications.

Imagine my suprise when in the first pages of the book i found this code?

function create_request(url) {
    var req = null;

    try {
        req = new XMLHttpRequest();
    } catch (tryMS) {
        try {
            req = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (otherMS) {
            try {
                req = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (failed) {
                return null;
            }
        }
    }

    return req;
}

In my previous article, I stated that web programming is a little chaotic (the way it is), and the problem is the diverse technologies that are used, among with the ad-hocracy of the browsers.

And voila, one more snippet to my wall of fame, which shows the rubbish approaches that are used in some implementations. Internet Explorer decided that he should have another way to implement the http functionality object and with two different ways, making the programmers, trying to initialize 3 objects in total, with nested try/catch statements.

I really do not know, which great business policy is served with this implementation … maybe I lack the big picture management thing that exists in the head of some people, that take those superb decisions.

Devil’s Advocate: The Web

Everyone that has a living (and networked) computer in his house has seen it. The revolution of our century in computing, the World Wide Web (WWW). Many consider it the next big-bang platform. Google, YouTube, and Facebook among others, deliver a variety of services for all kinds of taste. Social networks, video, music, and e-commerce is now done by web applications.

In addition, many traditional kind of applications are also web-ified, such as government facilities that have all transformed into e-Government. Yes, it is true. You don’t have to run anymore, two more clicks from your chair, and your dreams may come true.

Back then …

… i was a student. I remember surfing the web, that was comprised of simple, for today’s standards of course, HTML pages, downloading C compilers, and recent patches for video games. I also learned of dynamic content, CGI based applications with Perl and later with PHP. I even developed some web applications myself. Then i heard of Java and applets, more dynamic content in a stateless world. Cookies, hidden parameters, hashes, sessions, all concepts that gave birth to the modern era of computing.

Best effort …

… is what the standard says about HTML rendering. In simple english, “do the best you can” and in a more simple manner “write the worst code ever, it is my fault, not yours”. What happens if you open the <b> tag and never close it? Nothing at all. What even happens if you do not know what <custom_tag> means? Just ignore it.

In this platform, we based our dreams regarding the future of our applications, and to make it worse we decided to make it even worse. And we did it beautifully, we took the task of web design from the computer scientist and we created a bunch of incompatible technologies.

The Tower of Babel

Indeed the world-wide web consists of a bunch of unrelated, badly coupled technologies. For example, we have CSS and HTML. What was the key idea behind them? Who knows? We created HTML that followed a specific notation, that obeyed the tag open – tag close rule and then we decided (years later) to defy it and create something like the X configuration files. Why is that? Nobody knows, and keep in mind that they were proposed by the same organisation, W3C.

In all this, we tried to give more juice to it by adding a javascript, that simply added HTML in the start, and later of modified the DOM tree of a page. Superb idea, we created a scripting language that is domain-specific but not exactly to serve its purpose. Javascript has the design concept of a general-purpose programming language, yet we use it like XSLT, to modify XML data. I am sure it is fun to traverse node lists and create new tags the hard way.

At the end, to complete our divine masterpiece, we made the ultimate move. We created incompatible web browsers, that had unique features. So it is nice that a web developer, must have Internet Explorer, Opera, Safari, Firefox, Chrome and Camino to check if the web site works and is displayed correctly. And yes each browser it is like a platform with unique add-ons, interpretation and implementation of the web standards (what?). So what if the menu is an inch lower in Internet Explorer? We have to live with it.

I will not refer to Java applets, flash or Silverlight. All those technologies are helping to increase the complexity not reduce it, introducing more and more diverse features.

Give the Web Back …

… to the computer scientists, because now it is a playground. Everyone can do whatever he wants and get away with it. The web is now built on unstable ground, and it will soon collapse. See all the web apps, like gmail. Try to estimate the effort behind the creation of it. You think it is fun or creative to do it? Or do you think that it would require half the time of creating it in a decent development platform? No, I’m not trying to estimate the development time here, i know it is a very difficult task.

Programmers Love the Web …

… and they want the web to love them back. I do not think i have the required skill to propose things to do it better, so i want you to add a big IMHO (In My Humble Opinion) just before every bullet that follows. So i think that it is time to …

… to enforce the standards. And i mean no best effort service anymore. The web has now penetrated all households and all businesses, time to mature.

… to create a compatible platform. No more dozens of browsers with unique behavior. I want it to work the same way in each one of them. Why LaTeX does it? Do the same.

… to find a decent scripting language. I think javascript is not enough. We create specialized languages for this kind of work.

… to try and find a common syntax for all the related technologies. We like XML notation? Stick with it! Do not create more and more languages that cause diversity. We like humans to learn and use it.

… to find ONE standard for HTML. I do not care who will it be. But it is funny to see standards like, XHTML, HTML 4.01, strict, and transitional.

In the End …

… we all use it. Even the most non-technical user knows that <b>text</b> prints the text bold. We all like blogging, forums and googling. Let’s make it work the right way.