Last year, I have helped building an AJAX web application, where the web client was composed of only one web page and tons of javascript. The 1 web page for a site approach is similar to Gmail and many full AJAX sites. This approach looks quite elegant. Using JSON (and JSON templates) we were able to separated fully presentation logic and business logic and componentization seemed to occur naturally.
But I remember how often I complained on how bad Javascript was to code. I find it does not encourage good practices at all. The object orientation of Javascript is really a pain to use. If I had not a small experience with Python before, I would have thought scripting languages were really bad at building applications, even not so big ones. I find that even for good programmers, Javascript is a challenge, as it seems to always be a struggle to organize properly your code with it.
I was recently relieved to see that around me, almost nobody likes Javascript either. It is very sad that Netscape chosed such a bad language in 1995. Firefox appears like a miraculous program to me as a lot of the UI is done in Javascript.
Ah! If ever it had been Python all the way.
They didn't choose it. They invented it. It started out very simply (much simpler than Python) which is important because it also simplified security. As for Javascript as a language, it is different, but I like it.
ReplyDeleteJavascript is a great language, and often misunderstood. If you want to see well organized and componentized javascript, look at the prototype library. A feature that I really like is being able to extend standard language types such as Array and String. If they don't have a function that you commonly use you can just add it by updating the object's prototype.
ReplyDeleteI find prototype library badly named as prototype is a javascript keyword. However I agree that their code quality is good.
ReplyDeleteIt is possible to extend standard language classes in most dynamic languages, Ruby and Python come to mind.
Could they change it at this point?
ReplyDeleteI mean, people have to generate different Javascript and DHTML depending on the browser now anyway. If Firefox implemented Python or Ruby or something different as a scripting language then developers could target it. Maybe a complete break would be easier in some way? What do you think.