So i hear much about angular.js , and that its good and all that. ATM i’m in the process of learning vanilla JS, only been working with jQuery before.
I would like to know how learning things like angular.js would benefit someone like me. I mostly freelance, and work on small to medium size projects, often alone rather than in a team. CSS, html, jQuery and a bit of PHP (for wordpress) is often enough on the projects I work on.
Is angular something you only use on big projects or could it benefit a smaller one aswell? Like if i make a wordpress site for a small/medium sized company , would angular benefit me in some of the usual tasks when creating a site?
Be wary of following the masses, as often the m is silent.
While frameworks like Angular are popular, they basically trash web standards, progressive enhancement etc. by putting more than necessary in the hands of JavaScript. Yes, they can be used to build pretty cool sites/apps, but tread carefully, only use them where really necessary, and don’t be so rosy-eyed that you overlook their shortcomings.
Angular is great for application development with a known user-based – where progressive enhancement doesn’t matter, and client-side scripting is more convenient than server-side.
But it’s completely unsuitable for ordinary content-driven websites, or for anything where standards or accessibility matters (which is most of the web).
The purpose of all the MV* frameworks, are to help better facilitate building interactive web applications that feel more like desktop apps than web sites. Like @ralphm and @brothercake, they are not really meant for highly accessible sites, blogs, or general purpose sites. They are meant for things like Discourse or your Facebook feed or things like that.
MSNBC is built with Angular, but if you disable JS you can see that they are able to handle this and still give you a pretty site. Handling that can be time consuming.
There are quite a few JS MV* Frameworks. Discourse (the forum software used here) is built on Ember, Facebook uses React. There is also some other popular ones like Knockout, and Backbone. Each offer different things and do things differently.
This site: http://todomvc.com/
Will give you the same ToDo List in pretty much every one of them out there. It also offers the source code for each.
I should also mention, that if you’re looking to learn one now is probably not the time to learn Angular 1, Angular 2 will be completely different. (this has made a lot of people mad)
I would classify sites as static content or semi-static content (like blogs or news sites), with very little user interaction other than reading and a few clicks here and there. No real processing for the site to do either on the front or back end, other than maybe some visual stuff. They don’t really take much programming, just style, CSS, and HTML. Maybe a few JS scripts that provide some functionality.
Discourse and Facebook on the other hand are very interactive and process a ton of user input, even without the frontend JavaScript.
But yeah, that’s a fuzzy line. I would consider that MSBN site or Google News apps, just because of the sheer amount of user interaction that’s available. The line gets even fuzzier with some of the more talented and more read CSS3 people. Like this: http://www.sitepoint.com/community/t/noscript-ux-tech-demo/109354?u=mawburn
To answer your question more directly, no it wouldn’t benefit you in building small/medium sized sites in terms of speed of development or future maintainability. In terms of anything really. In fact it would probably be an impedance to you and anyone in the future doing fixes/additions.
Now, stepping back and looking at the bigger picture: you would absolutely benefit from learning it…you benefit from learning anything. Just reading through and messing around with the demos on the todomvc @mawburn linked to would teach you a great deal, not to mention broaden your perspective on what’s even possible with JavaScript. When I first started, I didn’t even know half the stuff I know could be done no matter how skilled you were!
Haha and thanks for that @mawburn, but I’m not actually that good. It’s the graphics that make it look good
As a sort of aside: not sure why, but most of the time I go to Facebook the pages won’t load properly (on a Mac, using Chrome and FF). That prevents anything on the page from working, even though quite a bit of the content loads. It’s very frustrating, and seems quite unnecessary to me.
Developers who use a lot of JS might scorn the idea of people having JS turned off, but they forget about the (fairly common) situations where JS doesn’t load properly (for whatever reason). That’s when their super cool sites become virtually useless and somewhat embarrassing.
Yeah Facebook is a pig without JS and the latest browser.
I tend to think of the distinction in terms of content – if the primary purpose of the site is to consume content, then it’s a web site; if the primary purpose is to create or manage content, then it’s an application.
Things like Facebook and Discourse have high levels of interaction, but even so, the primary purpose is to read stuff, not to create it. I think you’d struggle to find many people on FB who post more than they read.
But to get back on topic ( ) … I would also echo what mawburn said – now is not a great time to learn Angular. And for the kind of work the OP is doing at the moment, it’s not necessary or beneficial.
I think your best bet is to focus on getting comfortable with the language. Learn as much vanilla JS as you can, and try not to become overly reliant on jQuery or any frameworks (so that you understand how to do things without them, and that way you always have the choice).
That’s my aim, and it’s frustrating when you are reading some really interesting JS and then suddenly find a $( … ) in the middle of it, meaning that it’s harder to get a true sense of how the script works. (I’ve nothing really against jQuery, but when learning JS, it kind of gets in the way, IMHO.)
You’ve probably seen me mention it before and saying it’s my favorite, because it is. It’s a good reference and it’s something that takes a long time to learn, because it changes the way you go about solving problems and structuring your code. If the code is designed the right way and some of it doesn’t load properly or part of it breaks, it shouldn’t effect the rest of the code on the page. Which can happen with a lot of poorly designed JS.
Yes, I saw you mention that a week or so ago, and it reminded me to read it as I’ve been intending to for a good while. I’ve been reading through it this past week, and although a lot of it is over my head, it really gives a great insight into JS and how people choose the various patterns, which is something I was confused about before. (Books tend to teach the basics, but it’s hard to make the jump into real world JS without having an introduction to these kinds of patterns.) Definitely a great read.
So what can be done to reduce the danger of abusing patterns? One thing that can be done is to improve your ability to detect code smells. Not only will that help you to spot good places for applying certain design patterns. It can help you to recognise situations where simpler is better too.
Thanks Paul. Yes, good point … although I thought that was pretty clear from the book. I was more interested in how to structure JS to make it more efficient, and I often don’t know how to start going about that—so understanding possible patterns is really useful. So far, no matter how much I read, I still find it hard to do much beyond declaring variables and writing functions as needed … while knowing that the code could be a lot more concise and efficient, if I just understood how.
How can you link those and not FizzBuzz Enterprise Edition?
This sort of thing runs rampant in the Java world. I really hate old Enterprisey Java code, I much prefer stuff like Play or Jersey. The old stuff is more like:
I’ve found that the Clean Code book has been amazingly useful to work through. It may focus on Java, but the types of issues that it deals with cross right on over without much trouble at all.
Additionally, using unit tests for your code can help to ensure that things don’t get too far out of hand, and helps to ensure that things are well structured.
Most importantly though is to expose your code to other people. You may not like some of the feedback that comes in, but it can certainly help to inform you about areas of improvement.
I couldn’t agree more with this.
It’s a bit scary and you have to be receptive to constructive criticism, but the potential benefit to your development as a coder is huge.