Posts

Showing posts with the label javascript

Web application framework popularity over time

I thought I'd do a quick comparison of web frameworks to see how popularity is trending nowadays per google trends. I realized this is has some serious drawbacks, but as a person who has been in the j2ee space for years, I find the trend very interesting. The trend is clear, if you're an ace J2EE super guru, you are about in the same position as a yii developer. While you're experience might be transferrable, the days of java containers ruling the universe appear to be numbered. To do some other interesting comparisions, let's look at java specifically. This roughly supports my observation that Struts is dying off, spring is holding stead, and gwt...while making a big splash a few years ago seems to be tapering off. These numbers are a little deceptive because back in 2005 a lot of the "up and coming" frameworks, languages, and tools didn't even exist. So let's take a look at just the upstarts. I've included rails because it's...

javascript sleep method

For newcomers to javascript, it might come as a surprise that there is no sleep method. Worse yet, if you search the internet, you'll find all manner of really... really bad ways to simulate this. One of my favorite "rotten tomatoes" is something like this: alert('start'); var date = new Date(); var curDate = null; do { curDate = new Date(); } while(curDate-date Note, I borrowed this horrible example from stack overflow . If you're lucky, that example will not completely crash your browser. A much better solution is something like this: alert('start'); setTimeout(function() {alert('finish')},5000); The obvious problem is that if you truly want to simply pause for 5 seconds in the middle of a really long method, the anonymous function is not going to help you out very much.. unless you do something like this alert('start'); //lots of code var a = 'foo'; setTimeout(function(){ alert(a); ...

Object Oriented Javascript

Suppose we need to create a counter that starts at zero, increments to 4 and then restarts at 0 (A "you can't count to five" counter). There many ways to do this, but a straightforward way someone might do this in javascript would be: var global_count = 0; function increment() { global_count ++; if (global_count > 4) { global_count = 0; } } This is pretty common for beginners and works until your systems start to get complicated and your global_count gets clobbered or multiple people need to have counters. For multiple counters, one might start with a naming convention and add variables like "global_count2, global_count3" and et cetera. This doesn't solve the problem of the variables getting clobbered in other parts of your system and it likely makes it worse because now there are more permutations to mix up and accidentally change the value of. As an example of what I'm talking about var global_count = 0; function increme...

The Road to Enterprise Cloud Computing

I'm at a company that has a number of fairly high traffic web sites. Essentially, there is a holding company that does the "IT Stuff" and there are a number of brands that we support. Problem is, all these brands want the same sort of stuff, but just slightly differently. For example, they all want a store locater, they all want to search for things by categories and attributes, they all want a movie player, new/blog service... Historically, we'd get the request for a "rewrite" of a brand site. We'd spin up a project, start copy/pasting code from other sites and assemble a fresh new application from the pieces of the old ones. This is good, we're at least reusing some things instead of simply recoding everything from scratch.... but, it's also bad. Why? Because we're creating independent copies of code that does the exact same thing (see copy/paste coding ). Our previous solution to this problem was to not really update anything after...