

Ask Hackers: How to become the best JavaScript programmer? (q by 12yr old) - javascripter

I love everything about the web and web 2.0 and I would love to become the best JavaScript programmer ever!<p>Can you give me hints and tips to become one?<p>PS. I am 12 years old
======
pg
The way to become a good programmer is to have projects that drive you. So
build stuff. You'll find you learn very fast when there is something specific
you want to do and you don't know how. So you should read books, certainly,
but don't just work your way through books.

It doesn't matter super much what language you learn initially. So if you have
some friend who is an expert in another language, you might be better off
learning that, then switching to Javascript once you know the basics of
programming.

~~~
tel
I'd reiterate that you it doesn't matter what language you learn first.

You wont _really_ understand any language until you've learned a couple of
others and are able to see programming from several perspectives.

------
gruseom
Get Firebug and play with it. (You probably know this, but just in case...)
Firebug is a Firefox plugin with a Console tab that lets you enter any
Javascript you want and shows you what it evaluates to. If you type 2+2, it
will say 4, and so on. It will also let you explore the internals of web pages
and fiddle with them to learn how they work.

The best way, in fact the only way, to learn programming is to read and write
a lot of code. An interactive environment like Firebug makes that easy. If I
were you, I'd get myself a good Javascript book and type in the examples as I
read them. Then I'd try modifying them to do cool things. Good luck!

Edit: when you get stuck, ask questions. I taught myself programming when I
was your age and my biggest obstacle was not having anyone around who could
help me when I got stuck. Nowadays that's not a problem since there are lots
of people on the web who are happy to help.

~~~
cstejerean
+1 for Firebug. Getting out of my Python comfort zone and writing Javascript
used to be scary. But now that I have an awesome debugger and the ability to
experiment at runtime (and jQuery) I feel comfortable writing enough
Javascript to make my applications suck less.

~~~
Spyckie
+2 for Firebug. Firebug should be your number 1 priority to get familiar with.

jQuery... I have mixed feelings about it.

On the one hand, its very good for high level thinking and writing good,
readable code. On the other hand, it slows down your javascript code by at
least 2x, which is particularly noticeable if you're doing a javascript
intensive application. Then again, the future of browsers is speeding up
javascript, so this may not be an issue in a couple of years.

My experience with Prototype is that it handles the speed issue much better -
however, it is a bloated monster of a framework.

~~~
nostrademons
I usually approach JavaScript frameworks the same way I approach high-level
languages: write the app in whatever way is most convenient, then profile and
rewrite the performance-critical sections without the framework. I've never
had performance problems with JQuery, because I usually just write my
mouseMove handlers so that they operate on the raw DOM without it.

(I wrote something to this effect on Proggit once, and John Resig reply was
something like, "Of course. JQuery's not intended for performance-critical
code - usually you don't want to be using _any_ framework for that. JQuery's
meant to make the _other_ 90% of JavaScript development go faster.)

BTW, I won't go near Prototype (after having used it pretty extensively at a
past employer) because it messes with Object.prototype. When libraries do
that, you have no way of knowing which libraries are compatible, which means
that you'll suddenly get bitten by very odd, hard-to-track-down bugs.

~~~
jeresig
I should say that /any/ framework is not intended for performance-critical
code. A framework is designed to be an abstraction - abstractions implicitly
remove you from what you're trying to do, causing a performance hit of some
sort. If performance is your #1 priority then you should be writing everything
from scratch.

Now if development time is a greater priority over performance then I think
the choice is pretty obvious.

------
ken
1\. Become a great programmer: <http://norvig.com/21-days.html>

2\. Then learn Javascript.

------
aneesh
1) Work on challenging problems. Try to do something you're not sure you can.

2) Find a good mentor - it could be a prof at a local university, family
friend who is a hacker

3) Practice, practice, practice - write javascript to make stuff for fun.

4) Go to websites you like and de-construct their javascript code and figure
out what it's doing.

5) Don't be shy to reach out for advice, like you're doing now.

~~~
pibefision
6) Go to school, even when you are not going to learn Javascript there, you
are going to learn a lot of things that are very important for your projects
too.

~~~
llimllib
> Go to school... you are going to learn...

The learning will not come to you, you need to go out and get it. Don't just
go to school, attack school, suck the juice out of the fruit, and have fun
doing it. Make it fun and hard.

------
JofArnold
1) The #1 secret to good JS is mastering crazy-yet-delicious object-orientated
prototype madness. You won't get anywhere just learning how to write
functions, but learning how to use prototyping well is a esoteric skill, so
that's where Crockford comes in:

2) Check out the videos on <http://developer.yahoo.com/yui/theater/> There's
2.2gigs of them for you to digest. Crockfords are especially good, and will
teach you good practices.

3) Use a framework like mootools to save you time on real projects. However, I
advise against assuming these frameworks are "perfect"; they all have faults.

4) Don't copy other people too much - many JS devs, including me, are terrible
programmers :-P

5) Learn JS by creating AJAX projects as it's so important to web apps.
"Professional Ajax" by Zakas is a decent place to start.

6) Enjoy it! JS is a fantastic language, and the quick returns can be
incredibly rewarding. It has its faults, but it is amazingly powerful and
quite unique.

~~~
jcromartie
_Don't copy other people too much - many JS devs, including me, are terrible
programmers_

One of the biggest problems with JavaScript is its community. I'm not talking
about N.YC readers who _think_ they are bad programmers. No, I'm talking about
the fact that there are reams and reams of plain old bad advice on JavaScript
out there that still outrank the good stuff in most search engines.

99% of the time a Google search on a JavaScript problem will score you pages
of hits with antiquated, non-standard, buggy or IE-only approaches.

~~~
engtech
SO TRUE.

------
dfranke
Hi javascripter. First of all, welcome to news.yc!

There's at least one thing you're already doing right: you're starting out
with a problem that interests you. However, I don't think you have quite the
right goal. You don't want to be the best Javascript programmer ever. You want
to be the best programmer ever. Javascript should just be one weapon in your
arsenal, and a rather specialized one at that.

That said, you have to start somewhere. Usually I recommend that people start
with Scheme and read SICP (online at <http://mitpress.mit.edu/sicp/full-
text/book/book-Z-H-4.html>), but since you've indicated that you're interested
in web programming, that's probably not the right first step for you. The
trouble with web programming is that it's _messy_. Any non-trivial website
requires you to understand a whole alphabet soup of different programming
languages and markup languages, some of which were designed for each other and
some of which weren't, and then to top that off you get to worry about
Internet Explorer dain bramage. If you're just programming for an audience of
you and nobody else and you choose carefully what to work on, then you can
ignore some of these issues, but sooner or later they'll leak in and it's
going to seem overwhelming. (This isn't necessarily bad; coping with
information overload is one of the most valuable skills a hacker can learn.)

So, here's what I suggest. Start by learning Python. It's a clean, reasonably
powerful, easy-to-learn language, and it's very good for web programming. I
assume you already know HTML; if not, learn that first -- it'll take you a
couple days max. You can make a pretty capable website using just Python and
HTML. You could almost write news.yc, except for the AJAX up-arrows which
require Javascript. A site like this would be pretty big as a first project,
though.

I'll let someone else recommend a Python tutorial. I just learned it from the
reference manual, so I don't know a good one.

Once you feel confident making web pages using Python and HTML, then it's time
to start learning Javascript. It might also be a good time to go back and
learn to write standards-compliant XHTML-strict and CSS, since this will make
working with the Javascript DOM a bit less of a headache, but this is optional
and you can do it in parallel with learning Javascript if you do it at all.

Finally, here are some bits of non-technical reading I recommend:

<http://www.catb.org/~esr/faqs/hacker-howto.html>

<http://www.catb.org/~esr/faqs/smart-questions.html>

<http://paulgraham.com/gh.html>

------
christo
I know there's some redundancy in this advice but I thought I'd mention it to
support the great tips already here.

Practice. Read and write a lot of code. You might try to work your way through
set problems like Project Euler or the Ruby Quiz or other competitions.

Learn the "laws of physics" of programming - some things are harder to do than
others. all programming is an interplay between making a tiny, trivial and
deterministic step on one hand and managing complexity through abstraction on
the other.

it's most instructive to try things for yourself - even if you fail - but on
the other hand make sure you attempt things you will definitely succeed at too
because the feeling of success will fuel your passion. you will never be a
great developer without passion!

Watch Douglas Crockford's JavaScript videos.

use Flanagan's Rhino book.

Try and use different programming patterns and styles in javascript:
imperative, functional, object oriented, continuation-passing, dependency
injection, fluent interface.

Always use var and semicolon.

Never use "with" or "eval".

Plan to learn another programming language (which smart people recommend you)
and it will also greatly assist your javascript programming - you should not
be too tied to a single language that you can't change. If you really like web
2.0 you should learn a good server side language as well. As a second to
JavaScript for a youngster I would recommend Ruby or Python, (or PHP if you
must). Other languages are really great for that purpose but these will be
easier to learn first and will be readily available on cheap hosting
providers. Those others may include: Lisp/Scheme, Smalltalk, Java, C#, Scala
etc. Do not learn VB.

Get firebug.

Read "The Pragmatic Programmer".

Reuse code.

Write automated tests. You can use a unit test framework.

Write lots of cranky cryptic puzzle code right now. Get it out of your system.
Then seek to write clean comprehensible code forever more.

Port code from another language.

Recognise that lots of people in professional development have absolutely no
idea what they're talking about. Others are absolute genius gurus who's words
you should memorise and meditate on. Good luck telling the difference!

Use the force.

------
juanpablo
Read a good book about Javascript, like "Head First Javascript".

After you've finished reading it, learn what can Javascript libraries like
Mootolols or JQuery can offer.

And of course: practice, practice and practice. Working in your own
challenging projects is the best way to do that.

Enjoy it.

------
jcl
I've been learning JavaScript myself, and I've been finding Douglas
Crockford's site useful:

<http://www.crockford.com/>

(Note that to become the best JavaScript programmer ever, you'll probably have
to pick up some other languages along the way. But JavaScript is both a good
language to learn and a good language for learning, so it's not a bad idea to
learn JavaScript really well first before learning others. Keep an open mind.)

~~~
mcxx
"some other languages" a.k.a. Lisp, really

------
tlrobinson
_JavaScript: The Definitive Guide_ (a.k.a. the Rhino Book, published by
O'Reilly) is a great place to start as well as a great reference.

In fact, Douglas Crockford (mentioned elsewhere in this topic) says it's the
only JavaScript book he can recommend.

~~~
riklomas
Another great place to start is Jeremy Keith's DOM Scripting book (published
by Friends of ED), it's really well written and a great introduction to
unobtrusive, clean Javascript. There's a sample chapter on his site:
<http://domscripting.com/book/>

On a side note, don't learn a library as the first thing you do as you'll be
learning how to code in jQuery, Prototype, etc, rather than in Javascript.

------
crashmoriarty
I started learning programming at 12 years old. An ideal year in my opinion.
Experiment with everything you have the time to learn about. You may be
surprised at what you can do with an otherwise bland tool or function.

------
miksago
Ignore what others say about your interests, put your head down, do a bit of
hard work (but mostly play,); get involved in communities (eg, your favourite
javascript library's community), get recognised for your work, learn from the
masters, but don't ask for answers, ask for tips.

That's all I could say, I'm 16, and currently working along side some very
cool people. I've been in it about 3 years.

------
watmough
Congratulations on picking a great language to learn with.

Lots of people have recommended the definitive guide, David Flannagan's book.

I recommend, also, John Resig's book, Pro JavaScript Techniques, and also take
a look at his website.

If you'd like to learn some functional programming, and write some of the
coolest code possible, take a look at Oliver Steele's website.

------
jsmcgd
To become the 'best' Javascript programmer you'd probably need to know
everything about Javascript. Also you'll need to know its limits. To know its
limits you should probably learn about other things that aren't Javascript but
closely related to it eg other programming languages, web browsers, HTML, DOM
etc.

Good luck!

Let us know how it works out.

------
kajecounterhack
I hope you understand that while javascript has its uses, most web
applications are built on server side scripting languages. Much to the chagrin
of the hackers here at YC, I personally would recommend learning PHP or
Python. Probably PHP though. (Cue Ruby fanboys and anti-php lynch mobs).
Really, it is the place to start if you're interested in Web 2.0 application
development. Javascript is a tool you can pick up later that allows you to do
cool things with your site. But I mean, wouldn't you rather jump right into
doing things right? Starting with javascript will end up being sort of
like...taking a class in school; you have to learn a bunch of things first,
figure out something to make, embed with HTML and toy around and in the end,
do you even get anything functional? How bland is that?! Now, if you start
with a server side scripting language, you get your "hello world" experience
and you jump right in.

Just my 2 cents...

------
1qaz
(make sure you know HTML)(heres a good cheat sheet
<http://www.webmonkey.com/reference/HTML_Cheatsheet> ) im 13, i know it. the
best way is to learn it here <http://www.yourhtmlsource.com/javascript/> go
thru it all then think up ideas for scripts and try them.

these are wat i did (you may not know enof from that site) -a personal
greeter- a form that lets people write thier name is a box clik a button and
it displays a greeting w/ thier name included in it \- a coin flip script.-
that displays a RANDOM heads or tails alert -a dice roll script- that display
a RANDOM number 1-6 -any of your ideas

Simple as that =] ___Jasello___

------
jonnytran
In addition to all those other things that people mentioned, write a
JavaScript interpreter.

You can't truly master a language until you know it inside and out.
Implementing the language is a great way to do that. That's how I learned ML
and Haskell. That's how I'm learning Lisp.

------
axod
First of all, do NOT start by using a javascript library (prototype, jquery,
etc). Learning a library isn't half as useful as learning the language.

So, get a copy of O'Reily Definitive guide, Start working through that. Watch
the Douglas Crockford lectures from Yahoo.

Install firebug and start messing around.

"Hrm I've read about the arguments.callee property. Lets play with that for a
few minutes and see how it works" etc etc

The main thing is just to explore, get down to the nuts and bolts, see how it
all really works. Try things out, and see if they work or not.

------
oyejorge
One of the most difficult parts of JavaScript and web 2.0 is getting things to
work on all the different browsers. Install the most recent versions of the
most widely used browsers:
<http://www.w3schools.com/browsers/browsers_stats.asp>

Quirksmode.org has some really good compatibility tables as well:
<http://www.quirksmode.org/dom/compatibility.html>

------
bprater
Good luck man. I've been programming all my life and _still_ love it.
Javascript is a great language to dive into.

Always be working on a project. Come up with an idea, like tic-tac-toe and
start hacking on it, until you are finished. Then cook up another idea and
hack on it. Without an idea, you'll just float around. Get Firebug and learn
to love jQuery, it's magic.

And if you want to be great, you don't want to be a programmer, you want to be
a hacker. :)

------
wave
This might help Best Practices in Javascript Library Design
<http://www.youtube.com/watch?v=0LKDImgRfrg>

------
notphilatall
Much respect to you, young coder! I avoided Javascript for far too long, but
when I needed to learn it, the o'Reilly Javascript & DHTML cookbook was a
great resource.

Firebug is nice, but Venkman's Javascript Debugger for FireFox is my favorite.
The interface is a bit weird, but your mind should be flexible enough to
figure it out. :)

Good luck!

------
gmercer
I'd suggest learning Flex. For the longterm, I think this is the true winner.

If you are absolutely determined to learn Javascript \- I agree with others
read the articles by Crockford and watch the Yahoo UI videos \- Read the code
for dojo. Alex is one sharp javascript guy. \- For ajax frameworks look at DWR

Good luck... and have fun !!

------
xirium
You've already got the atitude to be an excellent programmer. Your success is
assured if you learn more than one programming language. For you purposes,
learn Pascal, learn C, learn Perl, learn JavaScript. This will minimise your
learning curve and risk of failure while giving you increasing power and
understanding.

~~~
dfranke
Ugh. Pascal? What for?

~~~
xirium
A langauge with strong typing and bound checking is ideal when you're learning
algorithms. A newbie coding a bubble sort in Pascal encounters less mysterious
failure modes than a newbie coding a bubble sort in C. (Consider the off-by-
one gotcha at the end of the inner loop.) I know that strongly typed languages
are unpopular on this forum and I've been downmodded for mentioning one.
However, consider the suggested progression of languages to be like riding a
bicycle and then having the training wheels removed.

~~~
dfranke
I like static typing, but Pascal seems like a weird choice. Why not ML, or
even Java?

~~~
xirium
I don't have direct experience of ML but I'd definitely recommend against Java
because there's a tsumani of information. It is overwhelming for a newbie.
Pascal is small and concise. The grammar is unambiguous. You know when you've
outgrown it and you'll move on. When you master Pascal then C looks trivial.
When you master C then Perl looks positively slack. This can be done while
minimising information overload.

------
mixmax
You're 12, you want to be the best javascript programmer ever, and you post on
hacker news.

You're my hero...

------
Prrometheus
I just realized that I have about 10 years to do all the hacking I want, and
then the current crop of 12-year-olds will hit the market and annihilate us
old guys.

------
brlewis
Has anybody here compared different JavaScript techniques for drag and drop?
What works best?

------
supercrack
i'm 15 and i want to become the geatest hacker ever for those who read this
e-mail me at surescore@hotmail.com thanks

ps.can you give me some programs

------
robmnl
give jquery a try:

<http://jquery.com>

Most fun javascript library ever.

~~~
domnit
Learning a library is not the way I would recommend learning a language. At 12
years old, javascripter has no time constraint to build a product fast.

javascripter, learn about Javascript's language features. Learn about nested
function and function passing. Learn about object-oriented Javascript and
prototypes. Learn the difference between Javascript the language, and DOM, the
thing within the language you use to add functionality to web pages. If you
find that you are repeating things, write your own library.

Is this the first programming language you are learning? If so, it will give
you a leg up when you learn a more conventional language like C or Java,
because it will give your mind flexibility. If you already know a programming
language, understand that different programming languages have different ideas
about how programs can or should be expressed. (That's why there are so many
languages.) It will sometimes be helpful to see how something in a new
language is similar to a language you already know, but other times you have
to just say to yourself, this is different, and I have to think a new way.

~~~
jeresig
I don't believe this, at all. A JavaScript library abstracts away frustrating
details that aren't related to the JavaScript language: like insane browser
bugs.

Instead choosing a good library can give you free range to explore the
advanced programming concepts in JavaScript, instead. jQuery, for example, is
highly functional. It makes heavy use of lambdas and closures - even
encouraging newbie programmers to use them.

If you want to get better at programming, through programming JavaScript, then
a library is the only way that you'll be able to keep your sanity and make
that a reality.

------
brooksbp
Am I the only one who suspects spam?

~~~
dfranke
I think so. Why do you suspect that?

~~~
brooksbp
His alias is "Javascripter"... he wants to be the "best in the world"... he's
12 years old... just the overall wording taunts me with a hint of spam.

I don't think a 12 yr old would have that enthusiasm for pure javascript..
would definitely ask about HTML (if he knows html he knows how to find out
about javascript?)...

what 12 year old knows about YC.news?

Seriously... I'm calling this one out... spam.

~~~
dfranke
Well, I assume you really mean "troll" rather than "spam", and given the
earnest and constructive answers he's gotten so far, I'd say that if he's a
troll he's the least successful one ever :-).

~~~
wheels
When I was 14 (1995), I'd been doing shoddy programming for a couple years and
read an article in Newsweek about genetic algorithms and somewhat naïvely
decided to look up the guy interviewed (on compuserve) and drop him a mail
(David E. Goldberg). He went to the trouble to not only answer me, but run off
a huge packet of copies of articles and snail-mailed them to me. That
seriously changed my life. That's when I learned what computer science really
was. Answering questions like this is important, in my opinion, even if you
get duped once in a while.

Whoa, just found it again: <http://www.newsweek.com/id/103827/output/print>

------
lyime
Build a flash game in javascript.

------
edw519
A little dated, but the site I originally learned Javascript:

[http://www.jalix.org/ressources/internet/dhtml/_dynduo/dyndu...](http://www.jalix.org/ressources/internet/dhtml/_dynduo/dynduo/)

Have fun.

------
albertcardona
My very first language ever was javascript. I completed Thau's javascript
tutorial and the advanced version (both at webmonkey.com), and from there I
got a really nice start (without knowing it).

If you combine a simple introduction like that with plenty of exploration with
Firebug, and have a strong motivation -like making a kick-ass webpage for
yourself-, you are on your way,

