The Montoya Herald, a weblog about Blueprint, jQuery, design, music and life, publishing on the web since September 2005. Written by Christian Montoya: developer, designer and entrepreneur.

The Montoya Herald — ChristianMontoya.com

Search

Buy My DVD!

Like What I Do?

My Amazon.com Wish List

On this domain

Elsewhere

Hatin' on Javascript

Posted on November 5, 2006.

(Or, "Teaching Web Design, part 7.5")

Last year, when I was a student in the Intro to Web Programming course at Cornell, there was a smidgen of Javascript in the course plan. The course is a sort of "feeder" course designed to serve the dual purpose of introducing students to Information Science and giving them a basic introduction to web programming, so it's no surprise that a tiny introduction would be present. Still, this doesn't excuse the fact that spending a few hours on Javascript with students (some of which have never done any programming before their crash course with PHP) is a bad idea.

If you guessed that this little "intro" to Javascript involved no more than image rollovers, you would have been right. That's all it was. Students learned how to do the following:

<img src="something.jpg" 
onmouseover="OBTRUSIVE JAVASCRIPT HERE" 
onmouseout="MORE OBTRUSIVE JAVASCRIPT HERE" />

Enlightening, huh? So now I'm a TA for the course, and the topic of Javascript in the course plan came up again. It was pretty quickly assumed that another smidgen of Javascript would be introduced (whatever that would actually be), and I had to gather up my confidence and say something along the lines of,

"It is my opinion that we should not introduce Javascript to these students at all. There isn't enough time to teach them how to use Javascript correctly, and there are more useful things we can teach them related to CSS and PHP. I think Javascript should be avoided altogether."

Dean had some words to that effect as well, if he doesn't mind me mentioning that.

I think my stance on teaching Javascript to beginners in an "intro" course requires little explanation; there just isn't enough time to teach them all about the DOM or get into progressive enhancement. As for silly tricks like image rollovers, we all know there are other ways to do those.

In thinking about this, however, I realize that my aversion to Javascript goes quite far beyond this. There's a lot I have to say about the proliferation of Javascript on the web today, and I think it's all worth sharing, considering how popular Javascript has become in the web industry.

For one thing, Javascript has to be the worst language I've ever seen. Variable names have no clear delimiters, there are very few rules on how code should be written, and there is too much outdated code mixed in with proper DOM-scripting, to name a few problems. I'm sure my readers can think of more. When it comes to syntax, Javascript just makes me sick, and I can't think of another language that has that effect on me.

For another thing, Javascript is heavy on system resources. While static pages present very little in terms of required processor power to the end user, Javascript does not, especially when you have Javascript that runs continuously. Even worse, there isn't much one can do to optimize Javascript other than what can be done at the source-code level, and very few people know how to do that.

More importantly, I believe that the majority of websites have no need for Javascript. There are a lot of reasons why sites use it, but I'm convinced that many of those reasons are not valid. You can throw out all uses which simply achieve "cool tricks," emulate CSS that browsers ought to support, or do things that shouldn't be done with Javascript at all, for starters. You can also throw out things that can be done server-side, like form validation, since the server-side solutions, while not as slick as the Javascript solutions, are usually much safer. You can also throw out all the Javascript that is unobtrusive, since technically, if you can remove the Javascript and still have the site function properly, then you never actually needed it to begin with. In the end, all you are left with are Javascript-dependent interfaces (i.e. GMail), and cross-site scripting (i.e. Google Adsense). I'm sure I'm leaving a lot of uses out, but I'm just trying to make a point: teaching students Javascript, which may provide them with useful skills, will probably not provide them with necessary skills. Food for thought.

This isn't to say that students shouldn't learn Javascript at all; I would love to teach a full course on Javascript, covering everything from DOM-scripting and progressive enhancement to AJAX and OOP, with a bit on frameworks for good measure. That's just me and my wishful thinking (I doubt such a thing would ever be possible at Cornell). The truth is that I do love Javascript, and I use it, even in some cases where the justification is questionable. I just want students to get a proper introduction to it, and I don't want them learning outdated obtrusive practices, ever. That's why I'm happy to say that we won't be touching Javascript at all this semester, and instead we'll be introducing the students to some very useful PHP functions (i.e. mail) which they can use in their work. It's cool to have this kind of input into the way the course is structured, and it's all because we have a professor who is very open and willing to listen to us, even if we are "just" students. Thanks to that, I won't have to see worthless Javascript image rollovers for a second time. What a relief.

Get a trackback link

5 Trackbacks/Pingbacks

  1. Pingback: Max Design - standards based web design, development and training » Some links for light reading (15/11/06) on November 14, 2006
  2. Pingback: Learnal » Blog Archive » Links for light reading (with notes) on November 14, 2006
  3. Pingback: Paul Armstrong Designs » Blog Archive » I Hate/Love Javascript on November 14, 2006
  4. Pingback: live and let learn » Should learners be learning intro to Javascript? on November 14, 2006
  5. Pingback: Hatin’ on Javascript | Christian Montoya on November 15, 2006

16 Comments

  1. M on November 6, 2006

    "You can also throw out things that can be done server-side, like form validation, since the server-side solutions, while not as slick as the Javascript solutions, are usually much safer."

    Actually, client-side form validation is very useful, increases the site's usability and decreases frustration. Why would i want to wait for the server to process my form's information and tell me what's wrong when i can see the errors just when they happen?

    And regarding safety: any decent web developer would know that he still needs to use server-side validation even if client-side validation is present, so it shouldn't be a big issue. :)

  2. Christian Montoya on November 6, 2006

    M, I'm not saying the JS isn't good, just that it isn't really necessary. I'm just making a case for avoiding JS in an intro course.

  3. Paul Armstrong on November 13, 2006

    when teaching that mail() function, you might want to make sure to run through necessary security measures: http://www.securephpwiki.com/index.php/Email_Injection

  4. Christian Montoya on November 13, 2006

    That's very true, thanks for reminding me.

  5. Nate K on November 14, 2006

    I would agree with what you have to say…for the most part. I think that in some cases it helps an interface (and it can still work without JS). For those that REQUIRE JS, thats where it can be a little frustrating.

    However, as already noted before - if ou are going to set JS aside for PHP, be sure to teach them how to program PHP properly. There are SO MANY hack programmers out there because they weren't taught how to do it right (or they find a tutorial that is outdated). PHP mail() is actually a very broad topic. Dealing with headers, how e-mail clients handle the email, sending multipart emails, adding attachments, adding images inline with the e-mail itself, and the obvious security as listed above. Teaching an outdated, or improper, approach to this would be no better than teaching them inline JS.

    So, while I think teaching PHP would be more valuable - make sure you take the same care and caution with PHP as you would JavaScript.

  6. Prisca on November 14, 2006

    hi ;) I agree ;) I run a webdesign course myself and have to say that the buzz around all the fancy little JS tricks is not very healthy for the beginners to webdesign. I find that it can become quite a distraction from the focus on good design and standard compliant websites.

    Especially on an intro course to webdesign - I agree that there are far more important and essential concepts to focus on. I stick with delivering handcoding with CSS and try to add some intro to php when my class is ready. This will hopefully give them a good working knowledge of effective webdesign, rather than tempting them into a superficial approach to creating sites which might then horribly fail due to their inexperience or poor understanding.

  7. Christian Montoya on November 14, 2006

    Thanks Nate, you are absolutely right.

    Prisca: Yes, especially considering their final projects involve making real websites for real clients, that's exactly what I'm looking out for!

  8. Nathan de Vries on November 14, 2006

    I agree - don't teach Javascript. It's clear that you really don't understand it, so it should most certainly not be taught by yourself anyway.

    All the points you've attempted to make are extremely opinionated. It's clear that you don't understand functional programming languages (I guess that's why you sway towards PHP). It's also clear that you don't understand the usability benefits of Javascript (why use Javascript when you can do everything with CSS or server-side?). This article just seems like one massive pile of FUD, for want of a better word:

    "Variable names have no clear delimiters"

    Please explain?

    "…there are very few rules on how code should be written"

    You're a teacher. Teach.

    "…there is too much outdated code mixed in with proper DOM-scripting"

    This makes no sense. There's crap code written in every language on the planet. Therefore, all languages are crap? Please.

    "When it comes to syntax, Javascript just makes me sick"

    That's unfortunate. See my previous point about functional programming languages and PHP. Uh-oh spaghetti code!

    "Javascript is heavy on system resources"

    Sometimes. An example of "heavy" Javascript is your "Live Comment Preview" feature. Using "onkeyup" to update your preview pane is absurd (there's a reason I'm writing this comment in TextMate). Again, don't teach Javascript.

    "There isn’t much one can do to optimize Javascript other than what can be done at the source-code level"

    In a similar vein, you can't change your stylesheet without changing your stylesheet. I'd never thought of it that way, but yeah, you're right.

    "You can also throw out things that can be done server-side, like form validation"

    See the first comment made by Mashhoor. Your dismissal of it was inadequate. When someone points out that your argument doesn't make sense, it's not a great idea to respond by saying that you're trying to make a point. His point is that your point makes no sense. Got it?

    "…if you can remove the Javascript and still have the site function properly, then you never actually needed it to begin with"

    Like CSS? Anything that's an enhancement can be removed. No enhancements to the raw content are necessary?

    "The truth is that I do love Javascript"

    No you don't.

    "That’s why I’m happy to say that we won’t be touching Javascript at all this semester, and instead we’ll be introducing the students to some very useful PHP functions"

    Good luck. You'll need it.

  9. Christian Montoya on November 14, 2006

    Nathan: Ordinarily, I would respond to your comment immediately, but I have an exam to study for, so I'll give you a quick response now and a detailed one tomorrow. The quick:

    • You are wrong on all counts (and it shows I have to explain myself more, since I assumed too much knowledge of readers).
    • My points are not opinionated, and in a strict view of the concepts I'm discussing, are actually quite factual.
    • There's a pretty good chance I know a lot more about computer science than you assume, and I REALLY DO NOT APPRECIATE YOU ATTACKING MY KNOWLEDGE, but there's no need to get personal, honestly.
    • I am teaching a beginner course that has the purpose of introducing students to web design. If you really think there is enough time to give a proper introduction to Javascript, you are wrong. Besides, we haven't given enough on PHP, CSS, or XHTML to even consider moving on to anything else.
    • I am a student instructor, so don't talk to me like a professor. I do not have decision making power and I only teach one of three sessions in the week.
    • I do love Javascript, and I want to see it taught correctly. I could teach it correctly, if I could make an entire course for it in the curriculum. I do not appreciate people calling me a liar by directly contradicting something I say in my own posts.
    • The "Live Comment Preview" is not mine, it's a plugin I installed.
    • Mashoor got my point, you did not.
    • Quotes can be made with <blockquotes>
    • I don't believe in luck.

    OK, I really have to study now, but do expect a complete response tomorrow.

  10. Dave on November 14, 2006

    Wow, your mouth just opens and all this drivel comes pouring out. Javascript is the worst language you've ever seen, the syntax makes you sick, but you love it. Variable names have no clear delimiters, whatever that means. You go on to suggest that students in an introductory course to Web Programming should learn PHP which is the number one source of web vulnerabilities and constantly on the Sans list for newly discovered vulnerabilities.

    Personally I can only express strong relief that I'm not taking the Web Programming course at Cornell. Given that javascript is one of the core components of AJAX I would be very disappointed if it wasn't covered in an introductory web programming course. Just because the example sucked doesn't mean the topic itself isn't worth exploring, i.e. use a different example of which there are countless good ones available simply by using "view source" in your browser.

    I have spent 15 years writing commercial software in a variety of languages and javascript is probably the most underrated language I have used. It is also perhaps one of the most misused and misunderstood. I can't imagine why the syntax of the language makes you sick, it is syntactically similar to c, c++, java, c#, etc (actually VB makes me sick but that's a different story).

    I also think you will find that in an increasingly Web 2.0 world, users will tire very rapidly of your server-side form validation round trips. Frankly I'm disappointed the link to your post ever showed up in my inbox and I can't believe I'm spending time responding.

  11. Nathan de Vries on November 14, 2006

    You are wrong on all counts

    You will notice that rather than posting the comment "You are wrong", I quoted each part of your entry that I thought was wrong. You should do the same if you have a point to make.

    My points are not opinionated, and…are actually quite factual

    See above. Your comments about the speed of Javascript, poor quality of code, syntax & its general necessity were not fact: they were opinion. This is irrefutable. It's even more obvious when you talk about your "aversion to Javascript".

    There’s a pretty good chance I know a lot more about computer science than you assume

    I never assumed anything about your knowledge beyond this topic. We are talking about web development with Javascript, and I have commented in light of that fact.

    If you really think there is enough time to give a proper introduction to Javascript, you are wrong.

    My opinion is that you should teach XHTML & CSS. If there's time, teach Javascript. Keep the course client side so there's a clear distinction. The reason I posted wasn't that I disagreed with you that Javascript shouldn't be taught. It was that you're spreading FUD about something you don't understand. You've taken that as a personal attack, but it's not. There's a whole bunch of things that I would never teach or write about, purely because I don't know enough about them.

    Besides, we haven’t given enough on PHP, CSS, or XHTML to even consider moving on to anything else.

    I would argue that if you have time to teach PHP, you're better off skipping it and teaching Javascript.

    I do not have decision making power…

    Then don't attempt to make this decision.

    I do not appreciate people calling me a liar by directly contradicting something I say in my own posts.

    I'm not really calling you a liar. What I meant by my comment is that you can't begin an article by saying Javascript just makes me sick, and I can’t think of another language that has that effect on me., and then going on to state that you love it. Surely you agree?

    The “Live Comment Preview” is not mine, it’s a plugin I installed.

    Use your knowledge of Javascript to change it. It sucks.

    Mashoor got my point, you did not.

    I must have missed Mashoor's follow up comment in which he agreed with you after pointing out that you were incorrect. My bad.

    Quotes can be made with BLOCKQUOTEs

    Thankyou, I've done that now.

    …do expect a complete response tomorrow.

    I look forward to it.

  12. Paul Armstrong on November 15, 2006

    I wasn't going to get involved, but I'm wondering why "Nathan de Vries" and "Dave" didn't include a site in which us other readers could use to check THEIR credentials.

    Seriously people. It's not cool to just run to someone's blog and start attacking them instead of using some constructive criticism.

  13. Dave on November 15, 2006

    Actually Paul I don't have a personal website, I develop and maintain an online banking website and I won't post a link to that site because these comments are my own. We use javascript extensively both client- and server-side and we work hard to ensure our pages look good, load fast, work in all modern browsers, and validate against the W3 standards. I came here via a link in a web dev mailing list I subscribe to that I normally consider a useful resource.

    Ignorant and innacurate comments such as Christian's just annoy me, particularly when he appears to be in a position to influence the content of an introductory web development course. First impressions count.

    Nathan's posts were both far superior to mine and if I had read them prior to posting I wouldn't have bothered. I can only suggest you go back and read them and think about who is responding to the issues and who is behaving like a petulant child.

  14. Christian Montoya on November 15, 2006

    Goodness people, wait until I have a chance to respond okay?

    Paul: I can handle commenters like Nathan and Dave, but thanks very much for the support.

    Dave: Keep up the personal attacks and I will close this thread and end any further discussion of the topic.

    Nathan and Dave: If you don't like the WSG "Links for Light Reading," unsubscribe from the mailing list. It's a shame that I am being attacked by fellow members of a list where I am one of the major contributors. Just please keep in mind that Russ Weakley added the link to his list because he felt it was a good resource; it was his decision, not mine. If you have a problem with this article, maybe you should take it up to the WSG mailing list and see what Russ has to say.

    But please, and I'm asking nicely: no more bickering until I have a chance to post a serious response. My exam is in 20 minutes. I'll have a response up by tonight.

  15. Nathan de Vries on November 15, 2006

    Again, this isn't a personal attack - being vocal about an issue leaves you open to the chance that people will agree and disagree with what you're saying. I wholeheartedly believe that the reasons you have provided for steering your proffesor away from the teaching of Javascript were inadequate and/or unfounded.

    I look forward to hearing your reasons for believing otherwise.

    Good luck with your exam.

  16. Christian Montoya on November 15, 2006

    Well, here you go: Hatin' on Javascript, revisited. And with that, comments here are closed. Further comments should go to the link I just provided.

Sorry, comments for this entry are closed at this time.