4 ms·
Some background. I actually wrote a semi-popular book on PHP (published by a major publisher) and have contributed to the core project. And I have spoken at man
by throwaway2016a 9y ago
Some background. I actually wrote a semi-popular book on PHP (published by a major publisher) and have contributed to the core project. And I have spoken at many PHP conferences. Perhaps tellingly, PHP is rarely my first choice anymore. Which I think it a great language (contrary to many opinions) I just find other languages a better choice.
Today my language usage looks like this:
- Web services / APIs: Node.js [1]
- Front-ends that require easily modifiable templates and quick command line scripts: PHP [2]
- When I need speed and low latency for a network connected app: Go [3]
- When I need speed on an app that requires no network: C
[1] The promise chain asynchronous nature of Node.js makes it great for web services in my opinion. And the ability to easily have global variables that persist across connections for things like caching and pooling is a huge plus over PHP.
[2] PHP is very good at spitting out HTML and making web service requests, the performance is acceptable in most cases, and it is really easy for most people to edit, even people without a CS background. Likewise, for quick command like scripts PHP is unbeatable in my opinion. The tools it provides out of the box means most common command line tasks can be done 100% with the standard library. No package manager required. Though if you need to add packages PHP is pretty good about that now. Incidentally the fact the standard lib does so much is also one of PHP weaknesses. The standard library is a mess of inconsistently named functions and classes that grew organically over 20 years.
[3] I've saturated my loopback network interface on a non-trivial app on my Macbook Pro using Go. PHP and node don't even come remotely close.
- chj 9y agoin latest nodejs there is no a single place to catch exceptions in promise chain, which is very inconvenient.
- maktouch 9y agoCould you explain this? We use node everyday and I don't understand what you mean.
- Xeoncross 9y agoNot sure what you are talking about: Promise.resolve().then(() => Promise.resolve().then(() => {throw new Error('Problem')})).catch((e) => console.log(e.message));
- always_good 9y agoThat doesn't make sense. That's one of the purposes of promises. The only escape hatch is to throw asynchronously which you just don't do.
- leetbulb 9y agoI have many large applications running on NodeJS 9.3.0 that rely on exceptions in promises for both control flow and error logging...no issues here.
- Xeoncross 9y agoI think this represents a lot of developers, except some replace PHP with Ruby or Python.