Archive for May, 2008

PHP functions in Javascript

Thursday, May 29th, 2008

I came across a cute project which implements PHP functions in Javascript (128 functions and counting). If you are one of those PHP developers that feel out of the water in Javascript, this is for you.

Plenty of useful shortcuts there regardless, especially the date functions (which is a major drag in javascript). Check it out.

PHP syntax mixings

Wednesday, May 28th, 2008

There has been some discussion on the PHP internals list on adding a short syntax array seen in other languages. The short syntax array defines an array directly with the array operator brackets:

  1.  
  2. $array = array(1,4,array(5,9),array(3,'name')); // Old way
  3. $array = [1,4,[5,9],[3,'name']]; // Shorter syntax
  4.  

The shorter syntax is both more readable and more welcoming to programmers coming from other languages. I read about this on Brian Moon's blog, and among one of the comments I read an interesting thought:

Yes, would be a nice addition. Though I’d rather the anonymous object syntax came too, would be much more useful, with callbacks etc.
visit({ function accept() { … } });

I think the commentator was actually referring to anonymous functions (which are objects in Javascript). If PHP implemented anonymous functions (and maybe closures?) it would become very powerful (callbacks anyone?), sort of like Javascript with real class based OO. Food for thought.

The Advancing PHP Developer Part 3: Refactoring

Tuesday, May 27th, 2008

Refactoring

3. Refactoring

Code refactoring is a programming technique that involves rewriting code in a way that improves its readability or simplifies its structure without changing its results. Thus refactoring is mainly about improving code maintainability. Code smells is a term coined by Kent Beck, and refers to certain attributes of written code that suggest it should be refactored. (more...)

Not A Number Is A Number

Monday, May 26th, 2008

Not a numberI recently came across an interesting page called 'Types' in the documentation of my favorite Javascript library, jQuery. It is a brief summary of Javascript language properties, and a very good read that reveals many little known quirks that this untraditional language offers.

One thing in particular caught my attention - the type of the NaN (Not A Number) language value, is surprisingly enough, a number. Try it, write a simple script alerting the typeof of NaN:

var isNumber = NaN;
alert(typeof(isNumber)); // Alerts 'number'

Just another thing to keep you on your toes when working with Javascript ;-)

You Are Only As Good As The People You Work With

Monday, May 26th, 2008

business developmentAs I've mentioned previously, I work freelance developing web projects in addition to acting as CTO at my start-up Octabox. Freelancing as a web developer is pretty profitable business nowadays, however it is too hands-on and technical to my liking.
I Usually 'settle' for the technical role as it is good income, but I try to develop my consultant persona as to hopefully provide mostly web business consultancy services as time goes on. It is a much more rewarding process for me, and I feel like I have much more to give at a higher level having acquired extensive experience and feel for the web entrepreneurship process. (more...)