Javascript – my experience

Recently I’ve been working on a project that is Javascript based. I’ve never done Javascript before, but I know PHP pretty well, so how hard could it be? It’s just another language designed for building web pages, right?

Yeah, my own casual arrogance here just bit me in the ass big time.

Javascript is to PHP what C++ is to Basic. Javascript carries within it several paradigms that you just have to get your head around.

There are some that are relatively easy, and now I know about them, I do actually miss them when I go back to C++ or Objective C – Promises are a case in point.

Promises are where you can ask Javascript to do a bunch of functions, one after the other, and feed the results of one into another. It’s really useful for doing back and forth with a webserver, for example. Normally I have block code indented to do it, and the XCode debugger fails in those situations. With Promises, I don’t have to worry.

I’ve had to get my head around the concept of local Javascript and server side javascript. I had no idea that javascript websites physically download javascript code to the client in the background. That was a stunner.

But all that being said, because of what Javascript is – basically a thin access layer to data structures, with some logic thrown on top – writing JS can be a monumentally frustrating experience.

The fact is, JS is abstract. Very abstract. You can call functions using variable names. All data structures are, effectively JSON objects (which makes sense, since JSON actually stands for Javascript Object Notation). You don’t serialise anything, and being able to see inside data structures can be…problematic, to say the least.

The entire language is something that it’s extremely difficult to work out, just from looking at code; you have to already know the language to understand what is going on, because it’s all so abstract. It’s almost as impenetrable as Perl.

How it integrates into HTML is another of those things that either you know or you don’t – it’s nigh on impossible to work out why anything is done the way it is just from looking at samples.

Javascript strikes me as being an extremely powerful language, but it has a cost of entry that is far far greater than those of traditional languages, even for an experienced programmer. It’s equal “Oh, that’s cool!” with “What the HELL is going on here??” moments.

I suspect more familiarity will help. Either way, it’s been a learning experience…

This entry was posted in Game Development, Web Dev. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>