Search This Blog

4/25/2011

Why did you choose PHP?

PHP for life

Well, I was thinking about: why do I use PHP? I met the language after I have learned a little of Perl, and as soon I saw it I loved it. In few time, I was noting that it is more fantastic then I though. It did "magic" for programmers. I select some features:

  • Consistency;
  • Variable variables;
  • Variable functions;
  • "eval" function to run dinamic code;
  • Magic methods and some interfaces to overload core language actions;
  • Easy casting from data types.

The "consistency" I have refered is the predictability I have while programming. JavaScript, for example, often works diferent in each browser. PHP has a few points that differs from architeture to architeture.

Variables, attributes, functions and methods accessed by variables is a interesting feature from this language. The capability to instantiate an object from a value kept into a variable is very useful to create a good framework. Although, I think it is a dangerous feature in the high layer of applications(from security reasons to code legibility).

The "eval" function is in the same situation. It offers the possibility to execute a PHP code kept into a string variable. It is very dangerous, but it can ofer useful benefits to performance or lines of code.

The magic methods and interfaces that allow overload native features (i.e. Iterator or ArrayAccess) are very useful to create generic classes. In one hand, it prejudices legibility/documentation, in other, it helps the low layer of application, where anyone need to put their hands.

Well, the ability to work/cast with diferent types is very good, especially to work in Web applications, that always receive string and always generate string (HTML). I have hardship to understand why to use a strongly typed language in a web application.

In fact, there are many other interesting features, but it is hardo to put in a post like that. Some desires I have about the language are:

  • Allow class and functions deallocate;
  • Operator overload;
  • Unicode suport (they are working on it);
  • etc.

No comments:

Post a Comment