>Or alternatively how Badoo could have saved $1.9M by coding in a compiled language.
Assuming you don't include the cost of converting their 3 million lines of code to a new language and the cost of learning a new language. Of cause they did need to "port" from PHP5 to PHP7, but I feel that it's cheaper than going to a completely different language.
You're not wrong, but the $1M saving is much cheaper bought than the $1.9M. PHP is a weird language though, it's easy to get started with, pretty efficient at this point, and yet somehow people use it to write ugly and sluggish code. I haven't written PHP in a long time, so this may have changed, but it almost like the language is missing ways of structuring the code in a sane way.
This isn't really true anymore. Namespaces, as ugly as they are visually, plus autoloading plus a package manager that handles it for you allows quick structuring of a project. This can be configured to fit whatever conventions you prefer but the community has put out there a set of good conventions in the form of PSR docs so you can get started quickly.
The whole mixing of HTML with PHP with SQL is bad form and is widely discouraged. In fact, this code is often seen with usage of mysql_ functions plus manual escaping and interpolation. This is discouraged to the point where that library has been removed.
I'm no evangelist, I prefer other languages, but with these "good parts" so to speak, the language is usable and supportive of good structure. We have had these improvements relatively late in the game but they do appear to come thick and fast nowadays.
There are many warts in the language. Sometimes I'm angered when very good ideas for progress are shot down via committee. There has, however, been improvement since PHP 4.
I don't think you should have been down voted for this question. It discourages asking to learn.
What I meant was mixing them together in the same piece of code. The other comments explain why: its doing too much, its difficult to maintain and reason about so its harder to find bugs, especially serious ones, and difficult to fix them.
separation of concerns and DRY would be the two main reasons I'd put forward.
Anything involving manipulating your data / business logic should not be embedded in a template.
PHP in your html should really be for display/rendering (i.e. looping over a list of Employee records), it should not be fetching those records itself (either by Employee::fetchAll() or especially mysql_query("SELECT * from employee") )
Research "model view controller" and separation of concerns.
It is very hard to maintain or even reason about a file or make a change or secure exploitable edge cases when the application has html, css, javascript, php, and calls to the database in the same place.
> Assuming you don't include the cost of converting their 3 million lines of code to a new language and the cost of learning a new language. Of cause they did need to "port" from PHP5 to PHP7, but I feel that it's cheaper than going to a completely different language.
No I am not. I am talking about 1.0 decision. Obviously 10 years down the road with 3 million lines of code you have to compare conversion cost.
Assuming you don't include the cost of converting their 3 million lines of code to a new language and the cost of learning a new language. Of cause they did need to "port" from PHP5 to PHP7, but I feel that it's cheaper than going to a completely different language.
You're not wrong, but the $1M saving is much cheaper bought than the $1.9M. PHP is a weird language though, it's easy to get started with, pretty efficient at this point, and yet somehow people use it to write ugly and sluggish code. I haven't written PHP in a long time, so this may have changed, but it almost like the language is missing ways of structuring the code in a sane way.