Web frameworks (*very* geeky)

I’m hoping there are some people in a similar position to me, with similar responsibilities / experience (most people I know who I could talk about this to are either research computer scientists, so have a very different view on how ‘normal’ people write code, or people who can barely write HTML, so don’t have enough experience to offer constructive advice)

So… I’d quite like to redo one of the many websites I maintain. I think I should bite the bullet and go for a full MVC framework, that hopefully my couple of thousand lines of handwritten PHP/JavaScript can slot into without too much work. I’m having massive trouble trying to decipher the practical differences (apart from the language!) between angular.js and CakePHP / CodeIgniter. I know node.js is also becoming popular; I had a conversation with a professional web-developer recently who says he now uses node.js for backend, and angular.js for frontend - I was too shy to show my ignorance about what he meant by backend and frontend in that instance.

Maybe some questions would help:

  • The example on the node.js homepage is really abstract. Can I use (/install) node.js on a share host, or would I need a dedicated server?
  • what is node.js for?!
  • Are there clear cut cases where angular.js (which I assume is client-side?) is better/worse than server-side frameworks (CakePHP / CodeIgniter)
  • can I mix server-side and client-side frameworks? (i.e. even if it is technically possible, is it a good / bad idea?!)

I’m not intimidated by the programming (I’m a computational chemist by day, mainly writing python but having to dabble in everything from tcl/tk to Fortran to Matlab / R), but I don’t want to spend an inordinate amount of time writing something that goes out of fashion, or uses a framework which is likely to become obsolete for technical or practical reasons.

(Before anyone suggests them, I want to stay away from off-the-shelf CMSs, because a) in my experience they require as much of a learning curve as a frameworks for someone already proficient in programming to implement custom modules / themes; b) their GUIs require a steep learning curve for other members of ACO staff, whereas I have a very simple one; c) I’d like it as a learning experience, to widen my programming skills d) I’d quite like the selfish satisfaction of doing it myself…)

Any constructive advice / comments welcome!

I don’t understand a lot of your post, but I’d always tend to go for server-side - if nothing else it’ll be far better for search-engine crawling.

I tend to use php for all content stuff, and only really use js for display if I can help it.

Yeah - I’d always been a server-side guy, but one of my research compsci friends (in fact, someone who works in the same web dev research group that [name drop] Tim Berners Lee is in) has said that minimising the amount of code in different languages (i.e. virtually everything in js, if you use angular) is better for performance / overall usability. I just don’t know if this is an extreme view because of his job, or if js frameworks really are as popular as he’s trying to tell me they are.

Extreme view, probably.

Remember that with server-side stuff such as PHP the user’s browser just sees some html - it’s not going to cause performance issues!

Yes yes, I know that’s the traditional view; I think his argument would be that downloading the angular.js code (which is highly minimised, current version is 36 kb - compare that to images which get downloaded!) is a very small overhead considering that much more then happens on the client, there are much lower number of HTTP requests, leading to a more dynamic user-experience. But, is there anything else to consider?

The main deciding factors really are who and what…

Who is working with the code? If you are working within a team then MVC Framework is essential - it allows the web designer to be designers and programmer to be programmers rather than having to mix the two skills together. If it’s just you developing by yourself then really it comes down to how you do your coding. If you are ‘particular’ about the way the code looks behind the design then you should adopt an MVC approach, if not then just leave it how it is. MVC code or OOP code is also easy to maintain or update rather than having to dig through tons of procedural code where everything is thrown in the mix.

Frameworks are there to help you hit the ground running. If you want to deploy a website in quick time, use a framework to cover all of the usual bases (e.g. database connections, validation, security, templating). If you already have constructed your own CMS that works I wouldn’t bother making the switch. Creating your own framework will depend on how often you find yourself constructing new websites.

Be aware, if you are using a widely used framework then often the security flaws are published online, so you need to make sure you update your website with any security patches which are subsequently released. Else someone may find a vulnerability in your site to exploit.

If we are talking about an ATC website then the traffic your site receives isn’t going to be that significant and therefore minor performance tweaks will make hardly any difference to the speed your visitors see your website. If you are just talking about an interface for your staff to update your website then there is definitely no point pursuing this route. It ends up being a lot of YOUR free time used up for minimal gain when there are more important issues to deal with e.g. what the website actually looks like, and does it actually work?

I use OO PHP for controlling my websites and server side validation, HTML5 for page structure, CSS for design elements, JavaScript for Client-Side validation. A MySQL database is used to hold all of the web content. In order to build a website you have to use multiple technologies. What is not good is to keep jumping in and out between two languages tags as that does knock down performance. Process all of your logic in PHP and output all of the HTML at once.

For node.js, you’ll need a dedicated server or VPS (not seen any shared hosting offering this yet).
The way I think of node.js is back-end (server side) javascript, essentially acting as a service.

A good example I’d found previously for a small project is http://www.html5rocks.com/en/tutorials/eventsource/basics/ Where node.js can be used to push events from the server to the browser, without the browser actually requesting the data. Useful for things such as interactive user chat, where the client doesn’t then have to keep checking for any new responses.

I’d seen that node.js can be used for push-applications too - I wasn’t sure if there was much else it could be used for (or if it was used for anything else it would just be over-engineering it the solution).

I’d also noticed the the angular.js tutorial requires node.js to be installed, but it isn’t clear whether angular.js itself depends on node.js (and hence node has to be installed on any server where angular is used as a framework)