views:

504

answers:

10

Possible Duplicate:
Is it a good idea to learn JavaScript before learning jQuery?

I am about to start learning JavaScript. However one friend suggested me to go in for jQuery instead since he says future is jQuery. I heard that jQuery is created from JavaScript.

In short, give me one simple reason why developers like me should invest in JavaScript. What is its future?

A: 

you can read this


edit

However one friend suggested me to go in for jQuery instead since he says future is jQuery.

If you go for jQuery, of course you are still learning Javascript...
You can not understand jQuery if you can not understand how Javascript works.
Some programmers learning jQuery wihtout the knowledge of javascript thought that they are learning a new programming scripting language. But they did not know that jQuery is not. They are just using jQuery as a tool. They are still coding Javascript...

If you want your Javascript codes to be cross-browser,

with less hassle, go for jQuery... but still you need the basic (or at least) knowledge of Javascript.

Reigel
Basic knowledge is all you need imo
Sir Psycho
+17  A: 

jQuery is JavaScript and yes, it makes things a lot easier for you and you can use it without much JavaScript knowledge, and yes, it will probably become even more popular in the future.

BUT: Wherever is jQuery, there will be JavaScript. jQuery is "just" a tool. You still need "plain" JavaScript to solve some problems, e.g. string manipulation.

Imho: You cannot master jQuery if you don't master JavaScript.

And there will be situations where jQuery might be not the best solution, e.g. when you really need high performance.


For me, this is similar to other questions I read here on SO about web frameworks and programming languages, like: Do I have to learn/know PHP if I want to use [Zend | symfony | CodeIgniter].

Seriously: If you don't understand the basics, you cannot use a tool efficiently.

Felix Kling
+1 `If you don't understand the basics, you cannot use a tool efficiently.` - its sure is..
Reigel
and furthermore, cannot use a tool *effectively*
Mark E
@Mark: Ah, I think this is more what I meant ;)
Felix Kling
+1 answer. I personally think that jQuery encourages a very specific pattern of coding that makes a lot of older JavaScript programmers cringe. For example, jQuery encourages the most ridiculous nesting and chaining of commands (e.g. `$('div.id1').parent().css({'display':'inline'}).end().hover(function(){$(this).css({'border':'1px solid blue'})})`. There are good reasons to do this, but it does sometimes make it very difficult to make sense of. I think jQuery is great for projects big and small, but for larger projects you really benefit from knowing how JS really works.
Andrew
Thank you very much sir for your answer. It will certainly help me and other developers who will look at this thread.
ScG
+2  A: 

jQuery will come and go.

You are a web developer, right? Javascript is huge. Think how much time people spend using a web browser. The entire time they are interfacing directly with html dom, css, and javascript. Or, less and less, flash and "actionscript" (which is basically javascript).

Learn javascript, learn css, learn the dom. Refer to ecma-262 versions 3 and 5 and publications by w3c and whatwg. Read mozdev, cross-check msdn.

After that, take a look at jQuery if you want. You will probably find that you don't need it for 99% of the stuff people use it for.

no
jQuery makes things easier, and takes away the pain of worrying about cross browser compatibility. Of course you don't _need_ it, but it is certainly helpful.
Nick Presta
Nick: jQuery deprecates old browsers fairly quickly, and doesn't seem to be future proof either as they constantly update with each new browser release. It's good for quickly getting stuff out now that works now, but, in my opinion, it doesn't represent a stable foundation for serious projects. YMMV.
no
Pfft - 1. deprecates old browsers quickly? They still have support for IE6 which is ANCIENT!2. If you have a 'serious' project, I really hope you update it in it's lifespan - not just what you write today. 3. jQuery has been releasing updates on a regular basis, fixing bugs, new features and so forth. 4. I think even my grandmother secretly wants to use jQuery.
Marko
And let's be honest, 99% of the time -jQuery is EXACTLY what people need. or should we maybe write our own animation engines, selector engines for each project. God bless my employer if they'll invest in such activities. Meh
Marko
1. The support is buggy. Check c.l.j. 2. There is a difference between updating a project for the sake of updating a project and updating a project because a new browser came out that broke your library or one of its plugins. The second case, obviously, is not something you'd tend to hope for. 4. I'm sure that speaks in jQuery's favor as a programming library. And let's be honest... you only need to write that stuff once. I wrote stuff like that years ago and still reuse it in my projects today, often with little to no modification.
no
You do have an argument but SO is not the right place - hence why this question was initially closed as 'subjective'. So I'm going to behave and not go further. Just note that you would've received some upvotes if others agreed with you.
Marko
99% ? That's a bit silly, your saying people would rather reinvent the wheel every time they need to perform a comon task? Old habits die hard it seems!
Sir Psycho
Does atrocious spelling count as an old habit? Again, you only need to write stuff like this once, not every time you perform some common task. I don't understand the attitude that it's ok and natural to reuse someone else's code, but forget writing your own code in a reusable way, bc it's "reinventing the wheel", so you're always relying on someone else's library, and you never fully understand the inner workings of your own app. Not 'you' personally, of course, just in general.
no
+6  A: 

JQuery is a library, written in Javascript, the language. It is almost always the case that learning the library without learning the language is impractical if not impossible, irrespective of the library and the language in question.

ykaganovich
+1  A: 

Every browser has its own implementation of Javascript ( the language ) and the DOM ( library for manipulating elements on the page ). Because of the inconsistency of each browsers Javascript + DOM with another, jQuery ( created with Javascript ) was created as a wrapper that internally deals with these inconsistencies so you can use the easy API.

Underneath the hood, most of your problems are already solved for you so you don't have to think about issues like:

  • invoking functionality for the DOM ready event
  • a consistent way of attaching event handlers for click, mouseover and other events, attaching multiple functions to the same action
  • returning the proper values for elements as well as viewport ( window ).

Because jQuery is a Javascript library you won't master it without mastering Javascript. See my previous answer for recommendations for learning Javascript.

meder
Thank you very much.
ScG
+20  A: 
  1. Part of being a good programmer is having an interest in understanding how things work. You can't understand how JQuery works without knowing JavaScript.

  2. A good programmer has a diversity of skills. Knowing both the JQuery way to do things and the JavaScript-only way makes you more versatile.

  3. Most employers who are looking for someone who knows JQuery are probably also looking for someone who knows ordinary JavaScript.

  4. You can never achieve true expertise in JQuery without understanding JavaScript.

  5. Sometimes even a fairly lightweight framework is more than you need.

  6. If you don't ever learn to do things the hard way, you won't appreciate what's so great about doing it the easy way.

  7. Moreover, if you start by learning to do things the easier way, you'll have that much harder a time motivating yourself to learn to do it the hard way.

  8. Learning the language first without the fancy frameworks builds character.

  9. Who knows, maybe you'll want to make your own framework someday. Or even work on a new version of JQuery. To do that, you'll need to know the language.

Tim Goodman
To the point and an excellent answer
ScG
@ScG: Thanks. I'm glad you found it helpful.
Tim Goodman
+1 Very nice list indeed :) I would vote you up more times if I could.
Felix Kling
+1 for a great post. P.S. Did you know there's a numbered list in the formatting options? lol
Marko
@Marko, @Felix: I'm glad you liked it. @Marko: Good point on the numbered list formatting. I've edited to use that format.
Tim Goodman
Additional point that you can add to the list: `node.js` requires that you know javascript. Whether you will be using `node.js` today is a different matter altogether. But you can create an entire web app using a "javascript only" stack without the need to learn another server side language. Ofcourse node is still in its infancy. In gist, `node.js` for server side and `jquery/prototype/dojo/Google closure/mootools` on the client side.
Shripad K
A: 

As you progress in your programmer expertise you would find that you go from library writer to library user. This is quite natural and OK. When you are starting off, all you have is the basics. You write your code in terms of those basics and over time find that you need to bunch common code in a library for easier reuse.

Sometime later you find that someone has already done just that and created a library that's even better than yours. You then switch from being library writer to library user. jQuery is one such library and you really need to know JavaScript to be able to draw a line in your head as to where jQuery is and where JavaScript is.

My advice, in light of the above, would be to learn the underlying technology before getting started with the library (which is what jQuery is). However in this case I would make an exception - skip DOM manipulation. DOM is a stupid abstraction and will have you tear your hair out in no time flat. jQuery wraps it up quite nicely, might as well get stuck into that after you understand JavaScript basics.

Igor Zevaka
Thank you very much sir for your answer.
ScG
A: 

You do not need to know JavaScript in order to use jQuery.

This depends what you want of course.

If you want to put together web pages and don't consider yourself the 'programming type' or you simply don't like JavaScript, then don't bother, spend your time where it will matter most.

Your also asking this question on a site where majority of users are developers so your going to get a lot of people who say you should learn JavaScript, I say learn it if it interests you.

There are pleanty of jQuery solutions out there and support so that you don't need JavaScript.

Sir Psycho
This makes no sense. jQuery **is** JavaScript. You can't write jQuery code without writing JavaScript.
Tim Down
jQuery is an API written in JavaScript, there is a difference. jQuery almost has it's own syntax and style of coding that does not resemble typical JS.I could use css selectors, attach events and create DOM elements without using any JS like syntax and that's what makes jQuery powerful.
Sir Psycho
Seems like you're having the same argument with Alex JL in the comments to his answer, so I'll leave this alone :)
Tim Down
+1  A: 

jQuery IS JavaScript. When you are writing jQuery, you are writing in javaScript. All a library like jQuery consists of is a premade collection of functions you can use in your JavaScript programs.

So, you have to know JavaScript syntax and the core language in order to use jQuery at all. A good book for that is Douglas Crockfords the Good Parts.

What you do not need to know as much about is the DOM API, since that is mainly what jQuery smooths over for you. It helps a lot to understand the concepts of the DOM, though. You still need to know what an element is, and what attributes are.

You also need to know about CSS in order to use jQuery effectively. The key concepts here are classes, IDs, positioning, visiblity and display, among others.

Alex JL
Thank you very much for the book reco
ScG
Crockford made some really great videos with this same material, too. Just search Google for 'crockford video' and they should come up.
Alex JL
jQuery is written using JavaScript just like the C compiler is written in assembly. You wouldn't say C is assembly would you? jQuery has it's own 'syntax' and API that clearly sets it appart from JS.
Sir Psycho
@Sir Psycho - No, it's not really like that at all. jQuery is a library written in JavaScript - a set of JavaScript functions. The syntax is JavaScript syntax. Show me where jQuery syntax differs from legal JavaScript? It has it's own API, being a library, but it is JavaScript, and is interpreted by JavaScript parser. jQuery is not a language, and does not have an interpreter or compiler, so it's not at all like C being written in Assembly. It's more like a C library, written in C like GTK+ or thousands of other C libraries.
Alex JL
I have this opinion because I'm a C# developer who learn't jQuery before learning JS and I could have kept using jQuery without ever needing to know JS. And by 'knowing' I mean more than if's and for loops. You don't need to know JS in depth in order to use jQuery. I stand by my opinion :-)
Sir Psycho
@Sir Psycho - One is learning JS by learning jQuery. Callbacks, vars, closures, functions, arrays, objects, dot notation, loops, booleans, whatever - it's all the same thing! Sure, you don't need to know it in depth, but that's not the point. You don't need to know plain JS in depth to use do whatever, either.
Alex JL
Anyone can learn jQuery by example without knowing exactly what is going on or copy paste code to get a task done. Not everyone want's to be a programmer, some just want to get things 'done' and that's important to remember.
Sir Psycho
Alex JL
If you're writing jQuery, you are writing JavaScript, so it seems you're using JavaScript without realizing it, or something. I don't knwo why you perceive that JavaScript is more advanced than jQuery (which is paradoxical), but it isn't. It might seem easier, but really it's just smoother over for cross browser issues, and has a lot of convenience functions. I'ts not magic or something, and certainly not a different language. There is plenty of advanced JavaScript written with the help of jQuery. It's definitely not something for beginners or people who um, don't want to learn JavaScript.
Alex JL
A: 

Yes you CAN use jQuery without knowing JavaScript. In fact, I knew very little about JavaScript originally but by using jQuery it sparked my interest to learn it and so I did. Years later I can say I am very proficient with both.

John Strickler