Confessions of a Javascript Master

Sat, January 5, 2008
Filed under: Coding, Geekyness, Humor, Rants, Work

… well “master” is pushing it a bit, but makes for a flashy title. I was going to post about my creepy stalker(s). Alas, none showed up. Couple that with the fact that a certain Snark member decided not to sue herself for libel(nu LULZ) this is what you get: way too much free time and boredom.

[edit] Rewritten to make it clearer… hopefully -_-; [/edit]

There are some things I instantly take a dislike to: Java1, for example. As with all instant dislikes, no good reason was to be found. I was annoyed at having to use Notepad to edit code files, which meant no color coding and no automatic indentations. Add to that using command prompt to debug. What do you get? One great mess and an extremely pissed of Vera.

Javascript and I, started out on friendly terms. My first encounter with it was during my n00b days. I decided that my invaluable (Dreamweaver-generated) coding must be worth a fortune, and thus warranted the disabling of right clicking. Sure, there was the little matter of yours truly being highly annoyed when it happened to her, but who counted that?

Around the same time, thanks to a mad frenzy of installing anything and everything, my computer went on strike. Regardless of how illegal or not my demands commands were, it never failed to prohibit their execution. It ended up rebelling so much, that only Opera could placate its Internet connection. Being a self-respecting browser, Opera had Javascript disabled, thus the no-right clicking script didn’t work. My initial reaction was, of course, that Opera must be faulty. Shouldn’t it cater to MY dodgy coding?! Suffice to say, I ended up hating both Opera and Javascript2.

Fast forward 3 years, during which I was most happy to rage against anyone using Javascript; especially as it made my job as a reviewer a pain. Which reminds me, instead of having:

<script type="text/javascript">
function doSomething(name)
{
alert(name+": I'm doing something!");
}
....
</script>

in the head section, be kind and save everything (sans the script tags) inside a .js file and link to it in the head section. It will not only save your reviewer a headache, but it will also lower your pages’ overall loading time.

<script language="javascript" type="text/javascript" src="my_javascript_functions.js" />

In the end, I got hired as a web application developer. Despite being relatively happy with my knowledge (of HTML and CSS), my employer made it quite clear that I would also have to learn Javascript. Nodding vehemently, I quietly resolved to avoid it and demonstrate that anything can be done using CSS. After all, what client needs colored scrollbars, no right-clicking scripts, or TickTackToe?

For about 4 months I could easily weasel myself around show/hide options, by using ASP.NET, or convincing my boss that the client would not notice the lack of colored scrollbars… Until, I had to create a dynamic graph. As said graph only had a decorative purpose, I was not allowed to use server-side coding to generate it, and thus I was forced to use Javascript. Being a client-side scripting language, there was no need for the web server to interpret it, and thus the execution time was lowered.

Despite my initial misgivings, it wasn’t quite so bad. I remembered all kinds of “fun” algorithms I had learned in high school, most especially the one which inserted an integer number into an ordered array.

Step 1: Locate the position to insert the number (11 in this example)

Find the position

Step 2: make way for the new element, by shifting those larger than it, to the right.

Moving elements

Step 3: inserting the element in its proper place.

After moving elements

For those of you, who are used to modern programming languages, like Visual Basic, the above could have been done in two lines:

orderedArray.Items.Add(insertItem);
orderedArray.Sort();

So what if PHP makes it easier? Mastering Javascript proves (to me, at least) that all those 8 years of learning to program were not useless.

In conclusion: I still don’t like Javascript much, but it brought back fond memories of figuring things out by oneself. Though Rachael would probably put more emphasis on its harmful influence over my psyche XD
____________________
1 NO, not Javascript.
2 I’ve since made up with Opera, though it still comes second to Firefox.

12 Comments

  1. Rachael on Sat, January 5, 2008 at 12:25 am

    Yes! It made you very crazy indeed. XD
    I’m still not going to sue myself.

    Vera: you’re taking all the fun out of my e-life… *cue dramatic sigh*

     
  2. Rilla on Sat, January 5, 2008 at 3:13 am

    I did not understand half of that. And now I just love PHP more. :P

    Vera: how about now? :hehe:

     
  3. Chien Yee on Sat, January 5, 2008 at 5:19 pm

    I agree with Rilla :) I’m clueless with Javascript, and to me PHP is easier to handle :)

    Vera: because PHP has a library with a lot of inbuilt functions which you can use without any changes. Javascript is much more of a challenge.

     
  4. Tracy on Sat, January 5, 2008 at 7:04 pm

    Ok ….. what the hell are you talking about :teeth: :P

    Vera: I hate it when this happens :cry: Hopefully it’s clearer now.

     
  5. Aisling on Sun, January 6, 2008 at 3:00 am

    I read that, but I have no idea what it said. :fist: Still, I hope maybe I learned something by osmosis. :D

    Vera: um… still not? I removed all coding references now…

     
  6. Veve on Sun, January 6, 2008 at 4:19 am

    Heh, I was just racking my head for a way to do it in one line. I’m sure there’s a class or predefined object that keeps the elements sorted and inserts it into the correct position without you having to explicit sort it again. Alas, nothing comes to mind.

    P.S. I love Java.

    Vera: C# FTW!!! :dance:

     
  7. Veve on Sun, January 6, 2008 at 3:02 pm

    I think we’ll be picking up C# this semester so I’ll withhold my judgment until then =)

    Vera: fair enough. But 1)msdn beats forums 2)Visual Studio beats Netbeans oh and C# version 3 sounds awesome. I’ve yet to use it, as it only comes out this year, but our company assured us that it will acquire the new version of Visual Studio. :yay:

     
  8. Tracy on Tue, January 8, 2008 at 7:02 am

    I was just messing with you - according to your post at Snark (better blogger) ;)

    I need to learn a language, I really do. Maybe PHP - some day.

     
  9. tiara on Wed, January 9, 2008 at 7:03 am

    wow your not the only one who dosn’t like javascript i don’t too. lol i need to read this tutorial, btw i like your layout.

    Vera: eh… I edited it in the meantime to a … non-tutorial :P

     
  10. Raina on Sat, January 12, 2008 at 9:31 pm

    I can’t really comment on Javascript :P
    I do like the chess pieces in your layout, though! Do you play chess?

    Vera: ironically enough no, I just find them elegant (chess pieces in general) XD

     
  11. Brenda on Mon, January 14, 2008 at 2:52 pm

    JAVAAA! My second favourite language after PHP. :P

    Arrays still make my confused sometimes though.

    Vera: pfft! Can’t compete with C#! :P

     
  12. Brenda on Mon, January 14, 2008 at 2:53 pm

    Oops. I meant *me. Typo there. :(

     

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.