I have recently been forced to do some research on frontend programming because of past bad experiences, and I have seen that there has been a huge landslide on the frontend world towards JavaScript (please check github and sourceforge etc.).

In our case, I have naturally recommended to split the system into subsystems/applications; mainly, backend service application (PHP and SQL serving JSON), web frontend application (HTML, CSS, JavaScript), and a suite of mobile applications (for Android, iPhone, and possibly Windows). This way we could achieve an efficient distribution of programmer/developer resources together with quality in each system.

For backend, it was quite straight forward for me, because a light-weight/fast PHP MVC framework (i.e. YAF) coupled with an advanced relational database management system (i.e. PostgreSQL) would do the job perfectly. There has been battles for many years among PHP frameworks; but module/controller/action structure, views (and/or a template engine) and plugins (regardless of the terms e.g. “dependency injections”) and PDO were my selected parts of the solution; more or less same approach by most developers.

The epic on the frontend front just started a few years ago, I heard. Even though there is a desperate struggle to enforce MVC paradigm on web frontend programming, I know that such a task is never easy: in my opinion, the combination of HTML, CSS and JavaScript is a very bad idea, but we can not change the past! Certainly, there are well established libraries and toolkits (e.g. Dojo, YUI, ExtJS, jQuery, etc.) but they are never perfect and stable in ever-changing world of web programming. I remember having stuck with YUI 2 and never had the strength to upgrade but YUI 3 has always portions of code in “beta”. Dojo is full of weird patches/bodges that developers are trying to adapt to the new requirements. ExtJS is commercial and has gone too far on the widgets and it is difficult to customize the look and feel of a web application with it. jQuery has mislead many novice developers to write powerful spaghetti codes.

It is a very confusing battle among the new breed of JavaScript frameworks. Backbone.js has been using the tactics of flexibility (just like Zend Framework used modularity tactic in PHP world). But people must be daft not to see some major flaws on basic things like models and collections. Still, Backbone.js has the popular lead and advantage. Google’s Angular.js has a totally different approach and they are trying to change the (HTML/CSS/JS) world by inventing their own mark-up (ideas coming from the ages of Dojo) but I’d rather stick with “new” HTML5 tags and attributes for now. Fortunately they have Google behind them; but Google, like any other corporation such as Microsoft (Silverlight) and Adobe (Flash), can ditch their “child” (technology) any time. Unfortunately, for others like Ember.js and Meteor.js they could not even make the first release yet and web developers have to pick/try a framework and move on.

Template engines are inseparable parts of frontend programming especially if you want programmer to write code and user-interface designers and developers prepare user-interface components, elements, sections, partials, fragments, widgets, etc., you name it. Mustache, Handlebars and Dust are worth mentioning here.

To note, I hate it when some high-class developers write their own OOP/namespace-oriented code (black/magic boxes) and do not encourage others in the lower level “casts” to do the same! I like the ones like Sugar.js improving the programming language. You need to be on top of your code – HTML/CSS/JavaScript code, you should not be alienated and if something goes wrong you should be able to find the issue and fix it. If things do not go according to the plan you and your team should be able to switch to another framework easily.

Then, nice separation of your code is a must. The way I see it is like this:

Frontend programming

Next, we need to discuss how JavaScript (through node.js) is invading backend programming, whether it is a (stable) threat or not, or how it can be used as a complementary system.

Happy coding!