Archive

Archive for the ‘Web Technology’ Category

Type Looseness

November 16th, 2009

The whole idea behind type loose languages is so that variables would be easier to use in comparison and other operations. You don’t have to declare how you intend to use variables. You just use them and they just work. Sounds great, right?

In fact it makes it much more difficult to use them. Type loose languages like PHP can be a nightmare in the evaluation of complex expressions because one not only has to look at what is apparent on the code at face value, one must also consider the complicated parsing rules when different types are banged up against each other. In type strict languages, we usually get a compile error when incompatible types are compared or misused, thus, allowing us to avoid embarrassing end-product behavior. In the type loose, interpreted PHP world, we get a runtime error (or somebody — not necessarily  the coder during debugging — gets a runtime error) — maybe or maybe not, when operations are made on incompatible types. Mature programming languages, do not allow such problems to happen in runtime — or at least do everything they can to minimize such runtime problems.

It’s the difference between building a house of straw and a skyscraper of concrete and steel. Sure, you could build a huge building with bales of straw and it would be functional living or work space until the moisture problems and other problems set in.  Then what happens if someone runs a truck into it? Or sets it on fire?

Have a gander at the PHP comparison operator page. Back in the old days we thought it was hard enough remembering the difference between = and == in C. Now there is a === and the way things are evaluated are TYPE BASED although there are loose restrictions on which types can go on which side.  NOW not only do you have to understand what the type of the variable is, you have to understand when PHP is going to decide to convert your string into an integer or when it will convert it into some other type like a boolean.

Another problem with languages like Javascript and PHP is that they keep running even if serious runtime problems occur, often without even so much as a warning or any other kind of message to anyone anywhere. This is not a big deal with a high school or undergrad programming project where maybe you are trying to get the n-factorial or do your first shopping cart — but is it a good idea to build ANY business on top of that? Yet there are thousands…(maybe millions).

They say always use ‘===’ when comparing strings in PHP. I would say the best practice would be like the practice in C — use strcmp()  and remember that 0  means TRUE if your question is “are these 2 strings the same?” (otherwise we get the mathematical difference of the ASCII characters between them.. For C this is a descendant of the assembler comparator, where the differences between the character values are subtracted from each other. 0 means they subtracted each other out exactly, meaning they are the same string of characters. I dunno where PHP thinks it’s going with that.

Or all hail the String.equals(string) comparison function in Java — where “true” means the strings are the same. With the “easier” type loose languages, you can be guessing and permuting code for hours, chasing down a bug.

In short, only coders who truly understand the consequences of type looseness should program in type loose languages. But type loose languages are ostensibly made to help people who don’t understand programming too well. It helps them alright — it helps them make mistakes that they can’t find.

kaht Web Technology

To Frame or not to Frame

July 29th, 2009

The broad stroke for web sites these days is to not use frames for the sake of holy search engine optimization. This can result in reduced functionality and, contrary to what the SEO heads say, increased maintenance.

Why? Frames are great. We’ve been writing web apps since 1994 and frames were the answer to prayers of simplifying interface code and server load.

What some code pups today may do in their innocence is re-route the functionality of frames through ajax by using divs that load themselves. This can actually increase server overhead (every new connection to the server causes it to instantiate a gazillion objects) and ajax content is not typically SEO friendly anyway.  Just because you can get a control to load its stuff asynchronoulsy doesn’t mean you’ve sped anything up or made any actual improvements.  But it does mean you’ve made your interface more optimizable and you have more control over what your interface can do.  In fact, before AJAX became a religion it was possible to do this in the earliest versions of Netscape and other browsers.

The guide? AVOID frames on NON-VALIDATED content — that is — for content you want the whole world to know about. But for applications development where things get serious and your users are logged in as  distinct individuals — use frames if you need them. There’s no law against them yet. They are there because they are useful.

kaht Web Technology

St. Ignucious Decries the Cloud

June 1st, 2009

I am a big fan of free software and what the FSF is trying to do.  But the legendary founder of the FSF, Richard Stallman’s recent remarks on cloud computing should be addressed, specifically since we work with cloud computing here at Huytech.

Clearly it is a risk VS benefits issue. We believe that the benefits of cloud computing, when it comes to business applications far outweigh the risks that he mentions.  It is not true that we have always been able to do what cloud systems do today. We have never had the level of access and convenience we have today. We have never had the sheer power of massive pipes and servers hosted in secure facilities at the price we get today.  We have never had the versatility of scaling resources on command or on demand. The only way to have this kind of power in the past was to host your own secure, Tier 4 facility with millions of dollars of equipment and staff.

Much of cloud computing is accessible today in terms of pricing because of software that the FSF has brought into production.  Packages like Apache or Linux and PHP all have components that would not have reached their level of sophistication and reliability without the help of the FSF community and GNU licensing.

True — products like Google Docs and Gmail are not “free software” in the same sense that Open Office is free software. And products like Amazon’s EC2 and S3 could all of a sudden meet a spike in pricing at the whim of the company that runs it. But there are others who provide similar services who will keep the prices in check. Although many of these products are not free, the equivalent “Free Software” configuration on hardware with equivalent performance and reliability specifications would cost much, much more to own and maintain.

So Dr. Stallman, with all due respect, we disagree that the cloud is the wrong direction. You helped bring it to us and although it may cost some freedoms, the sacrifice is not without its rewards in considerable benefits for businesses and individuals.

kaht Emerging Tech, Web Technology