views:

889

answers:

18

I'm primarily a server side developer, working professionally with PHP. For javascript I always use a framework (jQuery/mootools), will this be a professional disadvantage for me down the line? Should I put the time in to learning straight javascript, or are most developers moving over to frameworks anyway?

Thanks.

+2  A: 

Unless you want to make JS a core competency, I think you're good.

Ian Robinson
+8  A: 

Yes.

More often than not jQuery is slower at performing tasks. If you know how to do it in plain JS you can come back and optimize the slower parts of your page.

ChaosPandion
But doesn't this function fail to accomodate browsers that have a non-standard implementation of, say, getElementsByTagName? Surely this is the whole point of jQuery - it's an abstraction layer.
Paul Suart
You are correct but our company targets IE6 only so it's not a problem for us.
ChaosPandion
Hold on - first, client side development is already an order of magnitude faster than server side for most (client-focused, obviously) tasks. Second, you are using a *frames* example?? No one I know still programs with frames and JQuery's lack of support for them should be absolutely no surprise. I apologize in advance for being snarky but I can't resist: "YES, learn raw Javascript. When you're done, we'll give you the cubicle right next to the Cobol guy"
Mark Brittingham
I think you're an edge case here. IE6 has horrible javascript performance, so optimizing it has a high priority. Furthermore, you don't need the cross-browser compatibility, so that advantage is nullified. In general cases jQuery/MooTools is preferable, sometimes raw JS is better. I usually compare it to the C <-> C#/ruby/python difference. C is probably faster, but the others I mentioned are usually safer/quicker to develop with.
Erik van Brakel
But there's still a tradeoff. Your function is heavier (assuming the user has already downloaded jQuery) and, although you did a good job making it readable, it still takes more effort to read and maintain than the equivilent jQuery. Which is time and effort that could be spent on something else. Only if someone needs to optimize run time badly enough to make those tradeoffs would this be useful.
Nathan Long
Client side speed is important because you don't want the UI to lock up and give the user bad impressions about your page.
ChaosPandion
@Chaos - I agree that speed is important, but it's even more important that it **works** - in every browser, every time. "We didn't code for Firefox" gives a pretty bad impression, too. Maybe not in your case, but in most cases.
Nathan Long
Give me a little slack though... We inherited a piece of trash to work with.
ChaosPandion
The other thing about the speed argument is that it reeks to me of premature optimization. Do you really find a JQuery solution to be "slow" in general? I just don't see this...
Mark Brittingham
Who would have thought an example would give me so much heat.
ChaosPandion
@Chaos - sympathy given. :) A lot of the nerd rage comes from the fact that your answer was voted highest for a while, so people who disagreed became very vocal. If you're dealing with existing code and using a library isn't an option for some reason, that's tough. I think we're more concerned with best practices, though.
Nathan Long
@Chaos - sorry if my comment about speed/frames seemed like Nerd rage. I really almost didn't put in the snarky bit about Cobol (it isn't really fair after all) but it struck me as funny at the time. If you'd like me to delete it, just let me know.If anything, I feel a bit strong about this topic because I've been bitten badly by Javascript incompatibilities so many times that I've really become gun-shy about using it outside of applications where I'm damn sure I'm safe.
Mark Brittingham
I couldn't disagree more. If you are modifying the DOM you really should be using a framework like jQuery or prototype. You gain a great deal in terms of cross-browser compatibility that would take ages to work out/test on your own.
Wedge
+11  A: 

No.

The move to frameworks is driven by years of frustration over the browser-dependencies and sheer dislike for many of the original decisions made in the design of Javascript. Note that you are still working in Javascript though so it isn't really fair to say "learn Javascript" so much as "explore the areas of Javascript now handled by JQuery."

With respect to your attractiveness to a prospective employer, I'm pretty certain that JQuery would be a better skill to list on a resume than Javascript (I know it would in our shop). If you think about it, employers who care enough to do good client-side development will expect prospective employees to have experience with tools like JQuery. Those who don't care as much about client-side development simply won't make client-side skills - including Javascript - a priority. Indeed, if you are going to spend your time learning more about the client side, I'd recommend learning another client-side framework (e.g. YUI or Ext). Not only will it make you more valuable, it will almost certainly require a certain degree of exposure to more of Javascript's idioms due to differences in the frameworks.

Update - Rohan makes a good point about learning Javascript: that it may help you code more efficiently and effectively in JQuery. I agree in the abstract but I would personally be a bit hesitant to put too much effort in this area. As a long (long) time developer, I've learned to be very focused on the payoff from investments of time and effort. There is much to learn in the world, and only so much time to learn it. The time I spent learning how to write ISAPI dlls, for example, has paid very little compared to the investment.

Update 2 - A few people are making the argument that JQuery is slower than raw Javascript. Is anything ever new? This same argument about "raw" development versus frameworks has been going on for decades!

In this case it is especially perplexing, though. In my experience, people who adopt a client-side framework actually end up delivering client-side functionality. Those that don't tend to get locked into server-side solutions because of the inherent difficulty of handling DOM incompatibilities across browsers, Javascript idiosyncrasies, etc. Thus, recommending Javascript "for speed" misses the whole dynamic where a pure Javascript site is very likely to be slower because developers end up falling back on Server-side code just to stay productive.

Mark Brittingham
Saying you don't need to learn javascript if you know jQuery is like saying you don't need to learn Ruby if you know Rails. Well, you can sort-of blindly do web development in Rails without really knowing Ruby but that's not really a good idea. (note: By javascript I mean the core language which is highly compatible accross browsers. Not necessarily the DOM API which is highly incompatible accross browsers. For DOM manipulation you use jQuery)
slebetman
slebetman - it doesn't seem like you read beyond the "No" at the very beginning. As you'll see if you read on, I specifically say that you'll need to learn Javascript. Indeed, you have no real choice in the matter as JQuery is built atop it. However, to quote myself, there's little need to "explore the areas of Javascript now handled by JQuery". Which seems to be the point that you are making at the end of your comment. One of the discouraging things about Stack Overflow - illustrated beautifully here - is that lots of people pull the trigger on a downvote without actually reading the answer.
Mark Brittingham
+1  A: 

It's a good thing to know how to program well in JavaScript, because knowing jQuery won't protect you from writing insecure and inefficient code. It will just give you some tools to speed up your coding.

RaYell
+4  A: 

This is not specific to Javascript, but learning lower level concepts can often help when writing higher level code. It's about learning the whys as well as the hows.

So if you have the time and motivation, I'd recommend it.

Colin Pickard
+5  A: 

actually, yes. After a few years of jQuery, it's good to learn JS so that you know whats going on behind the abstraction layer that jQuery sets up. It will help you work better with jQuery or any other framework you might move to.. also it'll help you modify those frameworks if such a need ever arises.

Rohan Prabhu
A: 

I think it is certainly worth the time to learn the core language. If you only know the framework, then you're locked into the framework's way of doing things.

While the frameworks offer much more powerful and cleaner code in many cases, sometimes it is overkill and there is a much simpler solution to a problem in the core language.

chills42
You are talking about "core language" as if the language was assembler! JS is too easy. Libraries are for speed developing tasks not to replace or hide the core language.
backslash17
I was just speaking in generic terms, as it really applies to any language/framework pair.
chills42
"Core language" here refers to javascript itself, not the DOM parts (not document.getElementById() or some such). You'd be amazed at how many people know jQuery but don't know that `foo.bar` is the same as `foo['bar']`.
slebetman
A: 

It doesn't matter, so long as you remember the Law of Leaky Abstractions.

brownstone
+25  A: 

It depends. If you're asking about DOM manipulation, it has many quirks and inconsistencies across browsers. While it can be good to know these, most of the time you're shielded from having to worry about them by your framework. Learning everything on your own is rewarding, but difficult.

As to everything besides that in straight JS, such as closures, private functions, object syntax, prototypes, etc., you should definitely learn these, as they are just as applicable within a framework as without it. At the root, you are still coding in JS, just with the assistance of a framework for some common tasks.

Adam Bellaire
+5  A: 

Not where it overlaps

You already need to know some "pure" javascript for things like string and array manipulation, right? Beefing up on that stuff could be good.

And there may be specific cases - like making bookmarklets - where knowing how to find a DOM element with straight JS would be useful.

But for most production code, a good JS framework is so much better that I think using pure JS is silly.

Learn what you can actually use, but if it's purely academic, I'd say spend that time learning another, truly relevant, skill.

Nathan Long
+1 You make a good point regarding the fact that he already needs to know some "pure" javascript to be effective in JQuery.
Mark Brittingham
+1  A: 

I'm pretty much in the "don't bother until necessary" camp. In fact i consider it a kind of premature optimization to dive in the underlying language if not necessary. While you may indeed need to squeeze every millisecond out of a script, as long as it's usable i would say don't bother.

Even then, jQuery lets you wiggle for room with selector optimization and stuff like that.

Of course that could be me talking from the pain inflicted by "proper" javascript all those years before those wonderful frameworks :)

samy
+3  A: 

I think not knowing it can definitely be a professional disadvantage down the line. For example, I had a job where we used jQuery exclusively, and when I recently moved to a new job, they use YUI exclusively. If I didn't know "raw' JavaScript, I would have a much harder time picking up a new framework.

GSto
Upvote for the personal experience argument.
Nathan Long
A: 

Yes!

Using a library or abstraction layer means that you will be "abstracted" from the basic logic of the language, even when you need to acomplish any simple task. Libraries are made to speed the programming and developing tasks, not to depend always of them.

backslash17
+2  A: 

Unless you plan on being a JavaScript guru, I'd say no, there are better things your time could be spent learning.

JonoW
A: 

You should know what it abstracts from you, but you don't need to learn all of it. jQuery to "pure" javaScript is like ASP.net to "pure" HTTP. You should know the underlying concepts (especially since that helps to debug and solve some of the really hairy bugs and issues), but you don't need to become a guru in it.

Michael Stum
+1  A: 

IMO, you've already answered this question by saying "I'm a server-side developer." Do you want to do front end code as well? If so, learning JavaScript (and a framework) will make you stand out. Personally, I think it makes you a stronger developer if have a basic understanding of the opposite area you're working on - you can make better assumptions and coding calls when working on a group project when you understand what the front-end guys are working with (or possibly suggest a solution for them to run with).

Like everyone says - it depends on your long-term goals and what kind of developer you want to be seen as.

keif
+2  A: 

For javascript I always use a framework (jQuery/mootools), will this be a professional disadvantage for me down the line?

Probably not a disadvantage. You are simply standing on the shoulders of other libraries to get your work done. The only possible downside, is keeping your learned skills current as new versions come out, knowing version X that you learnt may well be out-of-date.

Should I put the time in to learning straight javascript, or are most developers moving over to frameworks anyway?

I'd say every JS developer is using some library or other, but they should still know the language they are using. A library/framework is just that, a library of code built upon the language. You still need to know the ins and outs of the language. For example, do you know what the difference is between == and === ?

Also, if there is a problem with the library you are using and you need to dig into it, wouldnt knowing the language help?

If you have the time I'd highly recommend something like this, a video from Douglas Crockford on Javascript.

Steve
+1 for the video. To me it's required viewing.
slebetman
A: 

If you're just a web designer using jQuery for wonderful graphical whizzle asked by the graphist not achievable in CSS stay with jQuery. You use it as a CSS complement and there a lot of marvelous packs for doing that.

If you want to write some of these packages or rework them. Knowing good syntax and good coding, should be a must.

If you want to get the total power of the new HTML5 elements, interact with your JSon AJAX blobs, and begin to pass a lot of data management in the client side, managing local database, launching Workers do a lot of tasks in background and create real javascript applications, you just keep jQuery where it is : a powerfull library agong the others, you'll use for DOM management.

Ivan Pierre