Ewww, You Use PHP? (2010)
blog.mailchimp.com
blog.mailchimp.com
As a language, PHP definitely has some warts. But, it's come a long way, and it keeps getting better all the time.
Personally, I don't think it deserves all the hate it gets. Some criticism is warranted, but definitely not all of it. I think a lot of it stems from the fact that the language is so easy to learn and lets you do things your own way, which (at least in the early days) led to a lot of newbies writing insecure code. See: register_globals (since removed).
That all said, I love PHP. It's simple, yet powerful. It grows with you, and most importantly, it gets the job done.
I have yet to see a good example where this was worth even considering. Model validation seems to be the only real use case and there are so many potential non-JS based clients that you'll likely need a more general solution for that problem anyway. And even for JS based clients, usually the big pain is the UI logic for showing users the errors and helping them correct it, stuff you won't use on the server side.
I'm interested, what do you mean? Can you give an example?
As far as I can tell, whatever you serve to the client is also available server-side. You render it there, send it down the pipe as static HTML and hydrate it client-side seamlessly.
Except for specific cases where client's local storage has a significant amount of data, of course, but that seems more like the exception than the norm.
> you'd have logic that sends JSON and checks that, and on the server side you'd need logic that checks the POST request and checks that
Sending != receiving. That's not duplicate code, it's just different functionality.
> (and there'd be subtle differences in the variable format between the JSON & regular HTML POST data)
I don't see why.
> and then maybe the way the UI element would be displayed in JS vs in the server-side HTML is also different.
Why would you do that? Inconsistent UI is bad. I'd expect the same UI whether I got the page via URL or via AJAX.
What JS code sharing gives you is the same server-side and client-side rendering. E.g. you can send fully rendered HTML or just JSON depending on the Accept header, saving on data and full-page refreshes but still having SEO (and not having to wait for client-side to render).
You can also share the same model in both environments (like having the same Book class, which you'd have to code twice in JS and whatever server-side language you use).
[1] https://medium.com/@firasd/quick-start-tutorial-universal-re...
None of these are huge issues to solve with a separate language on the server. But for our projects it's been a time saver.
Easy to use documentation. "Batteries included" standard library that specifically caters to web dev. Shared-nothing architecture. No separate compilation step. Easy deployment via source code. Ability to use PHP files as configs and templates. In more recent times, autoloaders and APC cache.
As far the language goes, I also like their approach to dynamic invocations via __call. Very simple and powerful.
Saying "<PHP's syntax> is atrocious" has always been spurious (or simply mischaracterized as "I like X better"). Compared to what? C or Erlang or Haskell? It's really damaging to credibility to start with flamebaiting.
See http://www.phpsadness.com/, specifically Inconsistency and Cruft.
Hey, I like PHP too. And inelegant syntax is not the end of the world.
There is a reason that paradigm exists, other than to make development frustrating. How do you avoid thread exhaustion in PHP if you synchronously block on a line that could take a really long time to complete? (Making a request to an external HTTP service, for example)
If it's a pure API (no HTML templating involved) I would use Go today. I personally find nodejs async programming obnoxious. Go isn't perfect (the type system is extremely limited, though It can be cheesed through reflection) but you have access to powerful concurrent constructs without having to write callbacks, promises and all that bullshit. Async programming is fine when it comes to GUI programming (it makes sense to write click event handlers). Having to perform an HTTP request in the backend asynchronously does not. Gimme threads,queues and pools and let me think synchronously.
Now if your backend is about serving some HTML files and forms, keep using PHP,there is very little reason to rewrite it in another language, that's where PHP shines.
Expounded on that in this bit that HN picked up a while back: http://www.brightball.com/articles/no-such-thing-as-real-pro...
Java's not a terrible option. But it's rarely the best option, especially for Right Now, though it may become the best option later when enough competing concerns have cropped up.
Example: http://spring.io/guides/gs/accessing-data-rest/.
Here you don't even have to write code for controllers or db connections for basic CRUD HATEOAS REST service. Spring takes care of it. The model still needs getters and setters, but you can avoid this with Lombok
Java development today is different.
Spring Boot may be a bit nicer than the most out of the way method I used years ago (now at https://github.com/stoicflame/enunciate/wiki) which did use Spring for some things, but it's really still far away from what dynamic languages and their ecosystems offer.
It's far better to do background tasks with its parallel capability.
The bigger concern is nodejs app server holds states between requests unlike PHP and as such when you define a static property on a class, it's held between all subsequent requests not giving you a clean state.
I'm trying to get used to nodejs for frontend as well but you should delegate db logics down to database triggers, so you don't have to duplicate logics between different languages if you have multiple or change language later on. Same goes for keeping config files in ini format or other language agnostic format.
Sounds like a tempting option amirite
You only add '*' and 'yield' (or 'await' and 'async') and write like any synchronous code once you wrap it under co module and such.
async/await is for ES7. TypeScript already has an implemention though.
Or... could be a sign that the community is maturing :)
A lot of talented developers are looking for remote jobs.
As a decent dev with a decent CV, it would make complete economic sense for me to work for a company remotely.
* Scalar type declarations
* Return type declarations
* null coalescing operator (the real MVP)
* spaceship operator
* introduced Throwable, big improvement to error handling
* removed PHP4 style constructors
* removed the old mysql extension
Most modern PHP codebases should be able to upgrade from PHP5.6 to PHP7 seamlessly
I'm glad someone appreciates it that much! Since helping introduce it, I haven't found as much use for it as I expected.
It's not so much about the count though, but the beauty of it:
$id = trim($options[$longCamelCaseID]['abcdefg'] ?? "");
A real godsend