Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

[OT] How do I really learn javascript?

by moritz (Cardinal)
on Jun 04, 2008 at 07:30 UTC ( [id://690074]=perlquestion: print w/replies, xml ) Need Help??

moritz has asked for the wisdom of the Perl Monks concerning the following question:

Please apologize my off-topic question, I hope it's still a tiny bit on-topic and I'll get great answers, as usual ;-)

I want to learn Javascript.

Now there are a myriad of tutorials and books out there, and I started with a few, and always given up frustrated.

I already now how to program, I'm familiar with C- and Java-style syntax, and when I read something on Javascript I don't want to be told what a variable is, and how a while and a C-style for loop work.

What I'm looking for is a Javascript introduction for non-dummies who were already exposed to other programming languages. I can write some javascript, but it looks infantile and is hard to maintain - just like in the old BASIC days. Heck I don't even know if Javascript supports closures.

So I'm looking for a book or an online resouce that is a mixture of "Programming Javascript", "Javascript Best Practice", "Javscript Hacks" and "Higher Order Javascript" (think s/Javascript/Perl/g here ;-); something that teaches me to write good, robust Javascript code.

I feel a bit embarrassed asking this because I thought that if I could write good perl code, it shouldn't be hard to do it other languages as well, but it seems I was wrong. At least for me it's not easy.

Update: thank you all for your good replies. I'll take a look at the book reviews of the recommended books, and I already skimmed over the various linked web sites, looks very promising so far.

And yes, i planned to do a project, but for me it's usually "book first", then a project (unless I have a really neat inspiration, which sadly isn't very often).

Replies are listed 'Best First'.
Re: [OT] How do I really learn javascript?
by Corion (Patriarch) on Jun 04, 2008 at 07:36 UTC

    Personally, I didn't find much to learn about JavaScript because most things in JavaScript are almost like things in Perl except that JavaScript is more verbose in important places like anonymous functions. The one thing that I found very instructive is the discussion of how to implement classical inheritance in JavaScript - that taught me the missing bits about how the object model is classless and how one can abuse it to implement real classes.

    I guess that the Rhino book is the definitive reference to JS, but I haven't looked into it.

    One day, I might actually write the Perl Traveler's Language Guidebook that teaches languages as "Differences from Perl"...

      The new book "JavaScript: The Good Parts: Working with the Shallow Grain of JavaScript" by Douglas Crockford (O'Reilly) has got very good reviews (I certainly do not like all O'Reilly books, this is no ad...)

      I use a bit Javascript too, but have never gotten too far into it and from what I read it seems that from this book you could learn some good practices about how to use Javascript as well as an overview what this language is / could be about from a higher perspective.

      In fact, I think I will read the book, soon.

Re: [OT] How do I really learn javascript?
by Erez (Priest) on Jun 04, 2008 at 08:02 UTC

    I would go with O'reilly's JavaScript: The Definitive Guide, (5th ed) (aka The Rhino book, ISBN 9780596101992).
    It aims at all levels, so it does have sections about what are variables, and loops and regexes and suchlike, but so do Programming Perl, and the K&R, and similar to those, it's the most comprehensive and correct reference material I'm familiar with regarding JS.
    I'm going to go with my usual recommendation regarding learning a language, and that is to create a project in it, with one hand on the book for reference. It usually helps you get along faster than cover-to-covering the book.

    I don't even know if Javascript supports closures

    It does. JavaScript's strongest point is what I like to call "Everything is Everything", meaning that almost every element in the language (functions, arrays, objects, assoc. arrays, variables, numbers, regexes) can be used, or assigned as any other, with very powerful results. The language was design to exist solely in a browser, giving it a sort of "sandbox" design where you can just go nuts with your syntax and achieve complex and powerful results (Similar to Emacs-LISP, if you're familiar with it).
    In this type of landscape, functions can be declared as variables, Objects, be interpreted as arrays/assoc. arrays and do some other things, which suggests a very strong "functional" methodology. JS is also very OO, although prototype-based, which goes very handy with the DOM structure it functions in. Its data-format, JSON, comes from the language itself, so no added tools are needed to read/write it. I find it to be very fun and cute language, if only it wasn't so inadequately and incompatibly implemented by different client-software.

    Stop saying 'script'. Stop saying 'line-noise'.
    We have nothing to lose but our metaphors.

Re: [OT] How do I really learn javascript?
by ikegami (Patriarch) on Jun 04, 2008 at 08:12 UTC
Re: [OT] How do I really learn javascript?
by dragonchild (Archbishop) on Jun 04, 2008 at 13:35 UTC
    Build something in it. Personally, I love Javascript. Other than a few admittedly major annoyances, I like it better than Perl for many tasks. For one, it's a better prototyping language than Perl if you don't need access to a DBMS.

    But, honestly, the best thing to do is to build something. A lot of programmers have a program they always write to learn a new language. I don't, but that's cause I don't collect languages (yet). :-)


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
Re: [OT] How do I really learn javascript?
by andreas1234567 (Vicar) on Jun 04, 2008 at 07:41 UTC
    Look to what others have done, e.g. The Yahoo! User Interface Library (YUI). Hey, it even has a testing framework!

    Another interesting project is the Lively Kernel from (Sun Labs), a crazy awesome web programming environment developed entirely in JavaScript.

    --
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
Re: [OT] How do I really learn javascript?
by derby (Abbot) on Jun 04, 2008 at 10:56 UTC

    Personally, I learned more javascript by reading through the prototype.js and jquery frameworks (and as someone else mentioned, yui).

    -derby
Re: [OT] How do I really learn javascript?
by Arunbear (Prior) on Jun 04, 2008 at 09:43 UTC
Re: [OT] How do I really learn javascript?
by Gangabass (Vicar) on Jun 04, 2008 at 10:28 UTC
Re: [OT] How do I really learn javascript?
by Joost (Canon) on Jun 23, 2008 at 00:06 UTC
    Javascript is a seriously unexplained language (as you've found). One of the the few people I trust on JS is Douglas Crockford (currently working at yahoo, if you care about that kind of recommendation - if you don't: see http://www.crockford.com/ - oh hell, see it anyway).

    It just so happens that he's recently written a book: javascript: the good parts. I haven't read it, though (haven't been able to get at it, yet); the semi-serious recommendation from comp.lang.javascript is still "Javascript: The Definitive Guide" from O'Reilly - which has some serious flaws but is a lot "wider", and probably the best book that handles "everything"- it discusses more or less anything with regards to browser-based javascript, but skips the really interesting details of the language. You should probably get both.

    update: just for kicks: here's a short writeup I did on javascript inheritance which hopefully explains more than most books do about the subject.

    update 2: just in case: yes javascript does support closures, but it has function scope instead of block scope, which makes for some pretty ugly constructs.

Re: [OT] How do I really learn javascript? (Higher-Order Javascript)
by pc88mxer (Vicar) on Jun 22, 2008 at 23:55 UTC
Re: [OT] How do I really learn javascript?
by Anonymous Monk on Jun 04, 2008 at 11:09 UTC
    Moritz, When I first started learning JAVA, I started a small project and used a website as my crutch. You might want to checkout JavaRanch.com. I spent quite a bit of time there during my "learning curve". They have 3 levels of forums & I'm sure you can skip the Beginners Forum (where I spent most of MY time). The site was 'almost' as helpful then as the Monastery is now ;-).
    Keep in mind, I'm a newbie in BOTH. Thanks, I hope this helped.
      The closest relation between Java and Javascript are four common letters in the name. Apart from that, they are very different.

      I already know some statically type object-oriented languages (Eiffel, C++, Java) and atm I don't feel inclined to work more with them. They are nice for some forms of engineering, but I'm not as productive with them as with dynamic languages.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://690074]
Approved by andreas1234567
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-19 19:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found