Friday, April 29, 2011

Too much flexibility in programming language, good or bad?

PHP is a very flexible programming language, and javascript is worse. I use the word 'worse' and i think that presents my point regarding language flexibility.

Too much flexibility usually means you can achieve same goal through variant ways. My point of view, that can only bring confusion. I guess that is one reason why software engineering stress so much on convention like naming convention and coding convention.


var person = {name:'henry', gender:'m'};


The code define a variable, person. Obviously, here person is an object. So we can access its name property through:

 person.name


Well, and you probably know that we can get the same result by calling

person['name'].


For me, that brings nothing but confusion. Let's see another example. The code below works very well:

function func() {
     return {name:'henry'};
}
//you will see Object { name="henry" } in console
console.log(func());


This also works as well:

//there is no semicolon!!!!
function func() {
     return {name:'henry'}
}
//you will see Object { name="henry" } in console
console.log(func())


See the difference? The second code snippet doesn't have semicolon! Javascript will add semicolons for you!
But check this code:
function func() {
     return 
     {
           name:'henry'
     }
}
//you will see undefined
console.log(func())



What do you expect from the above code? You are wrong if you think you still get an object. Actually, you will get undefined! Thanks to the javascript semicolon insertion mechanism, the code is actually like this:
function func() {
     return ;
     {
           name:'henry'
     }
}
//you will see undefined
console.log(func());


So, i hope you see my point. I don't like too much language flexibility because it helps and even encourages to create error-prone, inconsistent, and confusing code.

Friday, April 22, 2011

The best free software to convert pdf to mobi

Mobipocket creator ( http://www.mobipocket.com/en/DownloadSoft/default.asp?Language=EN ) is the best software i've seen so far that can convert a pdf file to mobi in very good quality. My opinion, it is much better than calibre ( http://calibre-ebook.com/ ), another ebook format conversion software.

Kindle fans know that kindle supports pdf poorly. I personally feel kindle supports .mobi as good as its own .azw. At least i haven't found any difference between them. They both bring me same comfortable reading experience.

Tuesday, April 12, 2011

start to learn extjs

i have to say i'm not very enjoying it. Maybe because it is not my comfort zone, i haven't get used to it yet. But i do like its philosophy - OPOA(One Page, One Application)