Disclaimer
- It's not our intention to criticize other languages – other people could do a much, much better job at this than we can :)
- We are only exposing our experiences, it does not mean there are other valid or better approach than ours
- We work for a company, but opinions expressed here are ours and are not influenced by or represent our employer
- Insults are welcome (but will be ignored :)
What does “living” with it means?
- The team inherited a legacy code base and it’s not cost effective to migrate away from it
- The language or stack is a requirement of the project owner
- The team has not time or resources to train and master new languages/technologies
Why do people
choose PHP?
Developers
- PHP has a deep pool of PHP developers
- This make companies feel "secure"
Good tools available
- Frameworks…
- Dependency Managers like Composer
- Editors, IDEs, etc…
- Documentation tools like phpDocumentor2, Doxygen, etc…
Documentation is good
- Lots of official documentation
- Lots of unofficial documentation based on the mostly widespread availability of the PHP stack
(PHP is used for more than 75% of internet websites)
The Stack
- LAMP is the most popular web development stack in the world (robust, reliable, scalable)
- If LAMP is not enough, then you have LHNMPR (Linux, HAProxy, nginx, MySQL, PHP, Redis)
But what about all the bad
reputation PHP has?
PHP has often been dismissed
- As hacky
- Unusable
- Badly designed language
PHP has often been dismissed
Maturity
- Evolving at a truly rapid pace in the past few year
- It’s inheriting modern features from other languages
- Recent advances like built-in OpCache and VM like HHVM take the language further
Performance
- It’s a fast and robust language
- With the added benefits of projects like HHVM, Phalcon, PHP performance is excellent in the land of dynamic languages
Language Evolution
Typing is coming:
- Regular PHP (ex. arrayof RFC)
- HHVM’s Hack
Pragmatism
- PHP will grant you the ability to go from idea, to prototype, to production in days, with your current development team
But using language X
does not make you professional
Absolutely any language has downsides
- Search for “____ the bad parts”
- Each language has it’s “community” of haters
- If you focus only on the bad stuff, you’ll never experience the good
Let's stop focusing on how bad
language X is, and let’s start
looking for alternatives
The limitations have not stopped
Wikipedia, Facebook, Etsy
and hundreds of other companies
are successful using PHP
Know the limitations, do your best
and keep building and shipping
Command line apps
- That’s not to say it isn’t possible, there are good approaches (ex. Symfony Console)
- But it simply isn’t intended for that
- There are better alternatives (Python, Golang, etc…)
Long running applications
- Increased memory usage due to poor garbage collection
- Bad performance
- You should handle supervision yourself
Soft Real Time applications
- Mainly Request/Reponse paradigm
- Definitely not the tool for the job
Computationally intensive applications
- If you are dealing with a lot of math, heavy calculations, etc… again, there are better options
- Scala, the newcomer Dart, Golang, will perform much better at this task
A good programmer can work with any
language. PHP isn’t the reason for
bad programming, bad programmers
are the reason of that.
Regardless of what language you use,
good programming is a skill that will
not magically happen just because you
use Ruby, Python, Javascript, etc.
Implementing features with
Redis and Lua
Redis
- Multi purpouse in-memory database
- Data structure server
Features we can build with Redis
- Rankings / Leaderboards
- Counting Stuff
- Live cache
- Real-time analysis
- Rate limiter
Lua and Redis
- Redis supports Lua scripting from version 2.6
- Lua is a great fit for Redis, they have similar philosophies
When to use Lua
- Redis supports Lua scripting from version 2.6
- Lua is a great fit for Redis, they have similar philosophies
Lua
- Group operations so they are executed together
- Execute operations that depend on the results of previous operations
- Atomic executions
Microservices
an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API
-- Martin Fowler
from monolythic to microservices
microservices: the good parts
- decoupling
- best tool for the job
- deployment independence
- incremental migration
- easier to scale out
microservices: the bad parts
- ecosystem complexity
- latency
- bandwidth
- net splits: consistency vs availability
- [micro]service discovery
- log aggregation
Distributed systems
collection of independent computers that appears to its users as a single coherent system