6 ms·
You should start with Haskell and teach her monads. Just kidding :) If your intent is to have her get the hang of programming, javascript probably isn't the b
by tkahn6 16y ago
You should start with Haskell and teach her monads.
Just kidding :)
If your intent is to have her get the hang of programming, javascript probably isn't the best language. There's a lot of overhead involved in running a simple program such as
Enter your name:
> Alice
Hi, Alice!
Enter your age:
> 20
Alice, your age minus 10 is 10!
As I'm sure you know, javascript is used to manipulate the DOM and process data entered by the user in forms. Any sane person will tell you to just use jQuery -- plain javascript requires a lot of boiler-plate non-business-logic code to replicate the above example. At that point you're just learning jQuery, which is useful knowledge, but very domain specific.
I started with BASIC but obviously today I would recommend Python. Python has a REPL like javascript with Chrome or Firefox with Firebug, but unlike javascript you can easily write up some code and run it in the command line. A really important benefit of Python is that the interpreter will give you good debugging information (not properly indented, variable not initialized) whereas IMO javascript doesn't have such great error messages.
That said, if you still wish to have her learn javascript, http://www.w3schools.com/js/default.asp http://www.w3schools.com/js/default.asp is probably the best site. It's where I learned.
- jey 16y agoI really sympathize with your points, but I feel like line-based text entry based programming is not something today's kids can relate to at all. For them web programming is much more relatable and accessible. Their "hello world" is in HTML, and their first programs should be in JavaScript. You don't want the kid to face the horrors of the browser DOM APIs directly, so using jQuery or the like makes a lot of sense. But overall this will hold the kid's interest a lot more than text line-input based programming, since she's probably never seen a text-based program before and can't relate to it at all. That said, if the OP's neice is willing to "put up with" text-based programming, Python is a great environment.
- axod 16y ago>> "Any sane person will tell you to just use jQuery -- plain javascript requires a lot of boiler-plate non-business-logic code to replicate the above example" BS. Also I'd suggest a book is far better than anything like w3schools. There's a ton of good js books which go through examples and tutorials. "Javascript the definitive guide" is extremely good. First step though is to get used to the js console within browsers, and play around. For example, load up google, open the js console, and start messing... document.body.style.background="green"; etc
- Twisol 16y agoIn my opinion the browser console is better for debugging than for learning. You have to know the basics of Javascript to be able to begin "messing" anyways, so it's not really the right "first step". A w3schools-style editable example would be a lot better, especially because you can integrate explanations and guidance into the page.
- tkahn6 16y agoWhat exactly are you calling BS on?
- axod 16y agoThe line I quoted. Maybe I'm just insane. But adding a pointless layer of abstraction to manipulating the DOM is.... pointless.
- tkahn6 16y agoThe second part of that line was referring to javascript in general as compared to other languages. And I think you are insane :) I've never met a single developer (besides you apparently) who prefers the tedium of raw javascript DOM manipulation to jQuery's abstracted methodology. I'll take var i = $('.someclass:first').next().val() over the equivalent raw javascript any day of the week.
- axod 16y agoThere's a lot of us about ;) That syntax you quote is not something I like, and isn't something that will run fast on browsers either. $('<code>') is quite ugly. Any typos inside that string won't be caught. Also I don't find chaining to improve code readability. Dealing with the DOM directly means you can optimize properly. For example, say you want to get an input elements value, in js you'd do: theInputElement.value Since you probably created or referenced the input element from js earlier and saved a ref to it...
- 16y ago
- haliax 16y agoI too started with Basic, and learnt Python and so on, but I feel like she likes the visual aspect of it and the link to HTML which she "knows" already
- tkahn6 16y agoIf she learned HTML on her own volition, then yeah I think you should go with javascript to add interactivity to her creations. If you get the feeling she's interested in the computational aspect of it, definitely show her python. Another approach would be to code up a simple interactive python script and let her run it. It could be a number guessing game (she tries to guess a randomly generated number, it tells you if your guess is low or high and she has a certain number of tries). Or it could be a mad lib game (she enters a noun, verb, adjective, etc. and it spits back a funny story/sentence). It depends on the kind of kid she is. You could help her code up a version of her own and go from there.