lundi 20 juillet 2015

Is it me, or Laravel Lumen is actually pure sham?

When I heard about that new Lumen framework, I said "Great, they decided to do something about the poor performance of Laravel".

Lumen advertize itself (frontpage) as "The stunningly fast micro-framework by Laravel." or "a framework dedicated to micro-services". 
Yeah, you got it, the proper buzzword.

Then I saw some reddit post arguing that indeed it is faster than all others (ie Slim).
Then I went over this article from the author himself 
http://taylorotwell.com/how-lumen-is-benchmarked/
(I will not get into the discussion on how wrong is this environment setup for benchmarks).

So since I know from my personal benchmarks that there is a huge gap between Laravel & Slim2 (Slim being 9x faster), since I noticed that Slim3 is slower than Slim2, I decided to setup a fresh machine to see by myself.

Quickly, my conclusion: it is pure sham, Slim3 is 2 times faster than Lumen.

  1. Lumen --> Requests per second: 212.89 [#/sec] (mean)
  2. Slim3 --> Requests per second: 526.94 [#/sec] (mean)

Notes :
- command used: ab -k -t 10 -c 10 url
- "composer dump-autoload -o"  executed as stated in the link above


Why do I think it is intellectual sham?
Remove the buzzword and you end up with yet another framework that by its existence aknowledges the poor raw performance of laravel. 

However, when you look deeper it is far better than Laravel because a simple hello controller will only load 52 files (while laravel is 127).
So it equals Silex - And still it is bloatware.
A true microframework loads below 20 files,the lowest I seen is 6 files.
Why is it important? we all know the loaded files number has prime impact on performance.

This is not a microframework (158k SLOC!)

Conclusion v2
Why creating a new brand? Why not just calling this the new Laravel version N+1, a complete rewrite, that tackles its pathetic performance? 


Conclusion v3
They advertize about performance: it is pure sham. 
To me It is just like creating a problem (overengineering a simple thing) and then being proud of yourself because you finally been able to solve it ;-)



mardi 26 août 2014

Laravel facades...misuse the term, they are proxies, ok?

The problem with the advent of Laravel and its popularity, is that it teaches wrong ideas to a huge amount of people.

Laravel facades are not facades. They definetely misuse the term.
What Laravel calls facade is just an opaque PHP magic method wrapper.
Said differently they're static proxies to service locators.

A proxy should be called a proxy, it is a pattern used elsewhere like in Java (RMI), Corba, etc.
You should also read about "dynamic proxy".

How are they different?
A facade hides something that takes a complex, multi-step operation, and simplifies it. So the interface (=public methods) is different: it is simplified, and 1 method call replaces several calls to one or many objects.

A proxy on the other hand has the exact same interface (meaning same list of public methods) of 1 proxied object, and usually add a feature (in example like logging method calls or usage of a network call).
(for some it could be confused with Decorator).

Learning programming "design patterns" is quite difficult, and this kind of framework is a danger from ths perspective.
So please take 2 minutes to learn the real facade design pattern: design_patterns/facade or here proxy-pattern.

I am glad some people know design patterns (@pmjones):  I could not resist to add my word to this discussion: about laravel facade.
Finally as I said there, maybe it is PHP magic methods are just plain evil for OO design.



lundi 18 août 2014

PHP 5.3.29 came out, and it is EOL - End of Life

14 Aug 2014: The PHP development team announces the release of PHP 5.3.29. This release marks the end of life of the PHP 5.3 series. 

The thing is: why putting it EOL now, when it is the most widely used version worldwide?
Yes, PHP version 5.3 is since march 2013 the most used version, just ahead of 5.2 (google it to verify).
See this link about php version 5.3.

In example WordPress.org collects stats about WordPress installs, you can see it at http://wordpress.org/about/stats/
Versions 5.2 & 5.3 represents almost 80% of the live PHP websites!

The authors of PHP will not force them to switch, because the installed PHP will live with the installed Linux.
Even for security reasons, they will not force them to do it (even if security is the main driver, not the new features: who eagerly need traits?).

Putting it EOL means no more security fix.
it is weird decision, because it ends up in reinforcing the feeling that PHP is insecure.

I am quite sure not to be the only one to think it is just another bad decision.

acronym of the day: YAGNI

This is an important principle, as important as it is easy to understand. It stands for "You aren't gonna need it".

Quoting Wikipedia (YAGNI at wikipedia):
You aren't gonna need it" is a principle of extreme programming (XP) that states a programmer should not add functionality until deemed necessary.
I link this principle to The MicroPHP Manifesto: where it states "I want less code, not more" and "I need to justify every piece of code I add to a project".

Now, if we look at the current trend of the web frameworks, & in peculiar PHP framework, every programmer should always ask to himself:

  • Do I really need DI (dependency injection?)
  • Do I really need ORM?
  • Do I really need Unitary tests (compared to functional tests) for my web app?
I cand easily answer to most of them: No.

About dependency injection

First: what for?

Validation: Without dependency injection, writing tests would be a nightmare or impossible.
You can then create a Mock that has a predefined behaviour and explicitly test the logic of a software component (a mock is a fake avatar of other component that is user by the tested component).

What is it?
Genrally speaking, dependency injection end up in accepting in the object constructor every external dependency instead of creating them itself in this constructor.


Dependency injection always comes with an "IOC container" (Inversion of control),  and an IoC container provides two things:
  • dynamic binding
  • a dynamic language (usually an incredibly crappy one, built on top of XML or in newer versions on top of annotations)
Then you need a "Service Locator", a sort of object instances directory.
Those usage & patterns direclty come from Java & the J2EE platform.

My  statement of the day

With a scripting language, so PHP here, it is totally USELESS & goes directly into the YAGNI principle.

Dynamic binding is already part of a dynamic language and the dynamic language is already a dynamic language. Therefore, an IoC container simply doesn't make sense: the language is already an IoC container if you prefer.

Secondly, the whole thing is not really helpfull in the PHP context, since PHP destroys everything at every page load.
One of the main features of IOC containers is that you can automatically "wire" your modules together "at runtime". In dynamic languages you can do this fairly easily without any fancy reflection-based logic. 
Those principle existed for platfoms that keeps objects persistant in memory (or disk) across the time. First they failed (to scale), and second this is exactly what we don't want for PHP. 
Again it is a Java thing that has been wrongly ported to PHP.



vendredi 15 août 2014

Best PHP Frameworks 2014

I am fed up of that kind of post, [21-best-php-frameworks-2014], that you got when searching words like "top 10 php frameworks 2014".
They keep on repeating the same content, rewriting each other, and these are such poor quality advices because in fact they have no clue.

I don't want articles showing "what people say", rather I generally prefer facts over opinions. So please give me numbers of comparison criterias.

Why it matters?
Because, yes, PHP is still the language of choice of the web - roughly 80% of the web (source: Server side language)
But IMHO it is not going in the right direction (I'll keep my opinion about that for a future post).

So here I will not provide you with a list the the 42 Frameworks that are supposed to matter. There are 2 categories of framework currently: The heavy one (or bloated if you prefer) and the microframeworks.

Now for the heavy frameworks that are worth learning:
  • Laravel: version 3 is far better than 4, noone knows it. I am talking about PHP 5.3 compatibility, and raw performance (6 times faster!)
  • Cake PHP: here to stay
  • Fuel PHP : compromised by the team, as they want a complete rewrite (the 2.x baseline) even though it is very good already (the 1.7 baseline)
Forget about Symfony, which is a nightmare. It's codebase is twice that of Wordpress, and you still have no app!
CodeIgniter? Abandonned by their author
Zend Farmework: welcome to bloatware, PHP that want to look like Java
Yii: very good, a bit too "verbose"
Phalcon: I am not confident about the framework and its capability for debugging and testing.
Kohana: it has inspired most of the moderns frameworks, a bit too old & overengineered right now.

Microframeworks that are worth learning:
  • Fat Free (F3): stable, mature, straight to the point (answering HTTP requests), and the fastest of the list
  • Slim Framework: good, I am worried about the direction they chose (usage of pimple & symfony components)
  • PHPixie: quite good
Forget about SILEX, it is not a Microframework. Saying it is really is a complete intellectual sham.

I will post a deeper analysis on those frameworks, with techninal facts, so that one could judge by himself.


jeudi 14 août 2014

We always think the Web is permanent

if you look for this page, titled "A new direction for web applications (link) ", which is a good article that I had in my Evernote, you will find that there are many backlinks to it, but the source disapeared, because the nodejistu account has been deleted.

​The solution in that kind of situation:
- Google cache obviously - but not for very old content
- Better: the wayback machine ​Internet Archive: Wayback Machine

(​Found it at web archive :-) ​A new direction for web applications)



​Finally of course you should always use tools like Evernote.​


mercredi 13 août 2014

The Web is Us

Welcome to my discussion on current web trends.

I am sharing here my expertise and interests about web technologies - and my toughts about it.

A tought I had the other day: The Web is us - The Techies

If you always ask "why would I do that?" before following any trend, then we have something in common.