views:

452

answers:

9

I learnt HTML/CSS a good few years back, then PHP a little later. I've recently become interesting in web development again, just started playing with frameworks like Django and RoR. I'm curious as to how much time/effort I should spend learning straight JS before looking at frameworks. I've been reading through a let of articles called Mastering AJAX by Brett McLaughlin which seems quite good, but I'm seeing a lot of stuff (such as cross browser compatibility - even for things like XMLHttpRequest) coming up which look like they would be non-issues if using a framework.

So, should I keep reading through these articles and try to build stuff using basic JS, or should I just start looking into jQuery and the like?

Also, I've been watching a few videos regarding GWT from Google I/O. I've been learning Java over the last year, built a few medium sized apps in it. I'm wondering if GWT is something that's worth going straight to, along with gQuery?

+20  A: 

Starting with the basics of JavaScript is a good idea, IMHO.

Read JavaScript: The Good Parts, by Douglas Crockford. Very, very good book.

Cover for JavaScript: The Good Parts by Douglas Crockford

You should also check out Douglas Crockford's web site.

I also had to come back here and mention this in an update:

Douglas Crockford presented an illuminating talk about JavaScript - past, present, future - at the Microsoft MIX10 conference earlier this year. You'll find the full video for Crockford's talk at Microsoft MIX10 - The Tale of JavaScript. I Mean ECMAScript.

Chris W. Rea
+1 For jstgp: You can also watch the video: http://video.google.com/videosearch?q=javascript+the+good+parts
OscarRyz
Andreas Grech
I like Flanagan's book too, but I would still start with Crockford's. Crockford is very clear about pitfalls to be wary of or avoid, which is quite important with JavaScript, IMO.
Chris W. Rea
Crockford's book is not really a beginner's book...to avoid pitfalls you first need to know the language; He even says so in the Preface (xi): "This is not a book for beginners. Someday I hope to write a 'JavaScript: The First Parts' book, but this is not that book" :)
Andreas Grech
If Crockford is referring to "beginners" as in general, i.e. new to programming, then I agree it's not a friendly first book. But otherwise, I disagree. Readers who have done some web development and/or know comparable languages likely have the requisite experience to hit the ground running. The issue I have with any other JavaScript book first is they tend to all take a browser-centric approach. Why learn that the Sun revolves around the Earth only to unlearn that later? Crockford looks at the language first and foremost and for that reason it's a good foundation to build on.
Chris W. Rea
+1  A: 

Yes, jumping straight to framework-based programming instead of DOM is a good idea.

I started doing JS before any major frameworks like jQuery came along, and was reluctant to switch at first, but when I first started using jQuery, it felt so good to be able to write selectors and stuff and not have to worry about cross-browser compatibility.

However, there are some areas of JS where frameworks wouldn't be available. One of them is in userscripting, where you have to make your script work on a site you don't control. Another such one is the use of JavaScript in applications such as XUL.

Overall, I suggest you start with some trivial JS applications, then switch to jQuery instead of going on to the complex topic of DOM.

MiffTheFox
A: 

It depends on where you want to invest your time. Ideally, we're all expert in assembly language, but that's not realistic or practical. We have to pick our battles. Then generally we attack each other for picking the wrong battle, which we call "cargo cult coding."

Personally, out of all the things I could spend a lot of time banging my head against, the intricacies of cross-platform JavaScript seemed less interesting and rewarding than other choices, so I decided to jump straight to jQuery. I'm happy with how it worked out.

Ethan
He said gQuery, not jQuery.
Nosredna
So he did. Thanks.
Ethan
Assembly reference is not fair we are not talking compilers. Would you "jump" into JSF without Java knowledge? I knew quite a few people who did and I don't want to even remember the mess I had to clean up.
DroidIn.net
+6  A: 

No.

Just as when you are learning to program you are taught first C/Pascal then Java/C++ and finally Python/Ruby/Smalltalk/Lisp, and when learning any language you start with simple language constructs, you should first learn ECMAScript, then learn DOM and finally frameworks.

Why? Because you'll have a deeper understanding of the language, and will be able to debug things that might seem odd unless you've got that learning experience.

If you are a seasoned developer, you can speed up each phase, but don't skip them, or you will have problems due to not fully understanding the small oddities.

Javascript is an interesting and fun language, but can act rather odd at times (Date has bitten me a couple of times in the ass).

Use frameworks to avoid repetitive tasks and to simplify your code, but not as a starting point. Simplicity is a final goal, not the starting point, and frameworks are for that, simplicity, not for learning a language. Frameworks are intended for simplifying things for experienced developers.


Learning the differences between browsers (DOM implementations) will allow you to debug your framework. That is priceless.


I've been learning Java over the last year...

Javascript is not Java. Never was never will.

Even if you can compile to Javascript from Java, it's still a framework, don't jump into it unless you already know what you are doing.

voyager
It's amazing that I also wrote in my post to learn the language first, then DOM and finally frameworks. :) +1
SolutionYogi
java is to javascript what car is to carpet
Here Be Wolves
A: 

I had the same background as you. After 6 months of MooTools I found out that mootools was indirectly teaching me "vanilla" javascript.

I've heard people say that mootools feels more like plain ol' javascript than jquery (after all, jquery's tagline is "jQuery is designed to change the way that you write JavaScript.").

I'd recommend starting with a framework. Plenty of the best javascript developers use frameworks. Once you're comfortable there you'll likely be able to pick up the others frameworks and plain ol' javascript quite readily.

rpflo
+1  A: 

I think "both." Mix it up. Play around with a framework. You'll get stuck when you try to do something real, so you'll pick up some JavaScript to figure it out.

A lot of the good jQuery books teach you JavaScript along the way.

Nosredna
+1  A: 

What makes you think that the frameworks are the good stuff and the JavaScript is not?

If you ask me, I will say that JavaScript is a real fun language and you should learn it first. JavaScript has received bad rap because it was mainly used for browser scripting and those browsers were buggy making people think that JavaScript sucks.

Crockford says that JavaScript is the world's most misunderstood language.

If your prior experience is with PHP (or any non functional language for that matter), the concept of 'first class functions' will really give you an 'aha' moment. 'Closure' will be another tool which will simplify your code and will make you wonder why all languages don't have it. Prototype inheritance will show you that there are alternatives to OOP. I would definitely suggest that you learn JavaScript first before you jump to any frameworks. I must add that you will also have to learn the concepts (first class functions/closure/prototype inheritance), to use any JS framework efficiently as all frameworks exploit the features of JavaScript.

To learn JavaScript, get Crockford's 'JavaScript, The Good Parts' book and try to learn the language using a standards compliant browser (say Firefox [with FireBug], Safari, Chrome) without focusing on DOM manipulation. This presentation by Simon Wilson is also good.

Once you have a good feel for the language, move on to the next step i.e. manipulating the DOM. I would personally suggest that you try to do some DOM manipulation using bare bone JavaScript to get better understanding of the DOM and the pain points involved. [E.g., when I attach a method to onClick of event, 'this' doesn't refer to what I think it refers to?]

After you have suffered a little bit of pain by doing DOM manipulation by hand, move on to a JavaScript framework which removes all the pain and makes JavaScript fun again. Personally, I would highly recommend jQuery over other frameworks.

And if you have any questions while on your JavaScript journey, you can always ask them on SO! :) Good luck.

SolutionYogi
+2  A: 

This is one of the best videos for beginner javascript developers that understand how to program in other languages:

It's a talk the John Resig did last year at Northeastern, most of it is devoted to talking about core javascript, then the last quarter of the talk jumps into jQuery:

http://video.google.com/videoplay?docid=-7485992465859932389&ei=jhZUSu73OpfSrQLgyYV3&q=john+resig&hl=en

It's actually a really interesting tech talk and presentation since he does live examples and Resig is pretty good at presenting.

Like others in this question, I also highly recommend reading Javascript: The Good Parts for a better understanding.

strife25
+1  A: 

I wouldn't touch any framework in any language until I have good basic understanding of underlying technology. Worth type of coder is one that uses tool without a knowledge. JavaScript has somewhat sad history but in its latest incarnation it's surprisingly powerful and even fascinating language. I say - learn it well, then use whatever framework suits your current needs

DroidIn.net