Or so it would seem!
I was tempted to make this a blog post about ‘games I’ve been playing’. Then I looked at my last ten posts and decided against that. Instead I’m going to talk about something a bit more technical.
Starting in June of last year I took up a position that was a new thing for me – client-side web development. Up to that point I had mostly been doing backend stuff – writing backend services, maintenance scripts, that sort of thing. The last time I had done any client-side work was all the way back in 1999, when I was designing websites for school clubs and the like.
So it was a return to something I had done and enjoyed before, but at the same time it was mostly new because 15-year old me used frames and tables liberally and had no idea how DIV tags or CSS worked. Not to mention my main use of Javascript was looking up stuff online and copy-pasting it into my HTML without really trying to figure out how it worked.
So how did 27-year old me take this on? Well, with some trepidation and a lot of help from Stack Overflow. Not to mention looking at other people’s code, and talking to the actual client experts on my team.
And it’s been fun! Well, sort of.
The one thing you learn immediately is that there is a whole new set of problems you need to grapple with. The two biggest ones are:
- Browser differences
This is mostly down to IE-related issues, although I’ve seen some weirdness in my code because of Chrome and Firefox as well. Because the Web pretty much grew as organically as it did, and because MS took over the browser market back in the 90s and then spent the better part of a decade sitting on its ass doing nothing with Internet Explorer, a lot of JS and CSS has to be written with old versions of IE in mind. My sense of it is that IE9 is sort of better in this regard and IE10 closes the gap even more, but there are still lots of people out there running IE7 and 8 for whom special code needs to be written to handle stuff like..calculating offsets of page elements (and probably other things, but that’s the first thing that sprung to mind).Granted, there are now frameworks in place to help deal with this kind of problem (yay for jQuery) but I’m not always able to use them for various reasons. As such, it’s a challenge, but it’s also something I’ve found interesting to dig into (and make notes on, to save myself some time spent investigating in the future). Thank goodness for Quirksmode.
- Javascript limitations and quirks
Javascript is yet another thing that seems to have more or less grown organically, yet it’s surprising how primitive it feels compared to other scripting languages I’ve used in the past. It doesn’t really have proper objects (although it has something called prototypes that you can twist to sort of use in the same way), it’s single-threaded (so no real background/asynchronous tasks unless you’re using HTML5 features) and because of the nature of interaction with web pages, a lot of your code ends up being event-driven.In fact, it only just recently occurred to me how absurd it is having a language that’s explicitly single-threaded (implying synchronicity) and yet has an event-handling model (implying the exact opposite) This realisation mostly came about because I was trying to write some code that needed to wait for something to happen, and was trying to see if there was some way to block Javascript execution without locking up the browser. As it turns out, there isn’t.
I haven’t done a whole lot of UI programming which is probably why this feels a little odd to me, but even then I kind of know that you generally want to have a separate thread for UI vs actual program logic to prevent your program from becoming unresponsive while other stuff is going on. The Javascript implementations I’ve seen in all browsers don’t seem to do this, for what I’m sure are completely valid reasons, but which I do end up ramming my face into a lot of the time.
Still, I’m having fun, for now. I have dipped into the jQuery/HTML5 pool a little bit and want to see what else I can do there, although right now my work projects don’t seem to be taking me in that direction. Perhaps it’s time for a side project of some sort…
is there some low-level generic type code you can use for those?
Assuming you mean Javascript’s limitations? Not really, although there are more sophisticated languages that will compile to Javascript (see Typescript for a recent example).