8 ms·
PHP, Python and Ruby all feel to me like last-generation languages. IMO we should be building new frameworks on modern languages that support concurrency & stat
by cageface 6y ago
PHP, Python and Ruby all feel to me like last-generation languages. IMO we should be building new frameworks on modern languages that support concurrency & static typing. The most promising new stack I've seen is Kotlin's KTOR framework. Thanks to the expressiveness of Kotlin it's not really any more verbose than something like PHP or Ruby but it's far more powerful and robust.
- pojntfx 6y agoNah. The JVM must go; we have Docker and the universal platform are Linux ELF binaries so the entire "bytecode" concept makes sense for the compiler (i.e. LLVM), but no longer at runtime. It's just bloat.
- cageface 6y agoKotlin native might eventually make the JVM superfluous but for now there are a lot of benefits to being on the JVM including great performance, a huge ecosystem of Java libraries, and very battle hardened monitoring and debugging tools.
- hocuspocus 6y ago> Kotlin native might eventually make the JVM superfluous That is probably never going to happen. GraalVM native images are a more realistic approach in this space, and even that is not trivial in most cases.
- lmm 6y agoThe JVM does what Docker does for far less overhead and is easier to understand and upgrade.
- erik_seaberg 6y agoBytecode is simple enough to alter at load time. This gives you aspect-oriented programming and instrumentation of everything that statically linked binaries have never offered. And I don't think anything compares to the JVM's GC throughout yet; why roll your own if it's slow?
- nelsonic 6y agoAgree that PHP, Python and Ruby Web Frameworks lack modern features. Have you tried Elixir + Phoenix?
- cageface 6y agoElixir and Phoenix look very appealing but I'm very firmly in the strong static typing camp.
- Ndymium 6y agoJust a note, Elixir doesn't have static typing like you mentioned, but it does have fairly strong typing.
- holler 6y agowhat modern features does python 3 lack compared to phoenix/elixir?
- Ndymium 6y agoConsidering the GP commenter started with an emphasis on concurrency, Elixir's concurrency features (thanks to the Erlang VM) are totally different than what Python can offer, namely isolated processes (scheduled in the VM so like green threads) where you can write blocking or CPU intensive code without worrying about blocking the other processes and where GC is per-process. With Python you (AFAIK) run into the GIL when threading or you fork OS processes that are heavyweight so you can't do that for every request or you'll fall down. Or you have to write async code which can still only saturate one core. Not saying Elixir is the answer to everything but that's where it differs in the concurrency sector. It doesn't have static typing though, which is a requirement for some.
- simion314 6y agoWhat do you mean by concurrency here? JS like async or Java/C# like threads? And why would concurrency help in problems where PHP is involved, in the problems I solve with PHP I don't think I ever needed async. For unning more things in parallel like processing 1000 RSS feeds you can spawn 10 scripts that run in parallel and if one crashes the others still continue to work(I had experienced crashes with some RSS XML files crashing the built-in XML parser).
- solraph 6y agoNot the parent, but it would be nice to have separate thread for things like logging and firing events into a queue.
- simion314 6y agoJust curious what problem are you trying to solve, I never had the need for different threads to communicate in PHP, most of the time in my work a user makes a request, and a PHp scripts does something like update the database or does some searching/working and returns a result.
- nsomaru 6y agoWhat if that request was a document upload and your system is calling out some external api or processing for long enough such that you’d rather return now and update later when the job finishes. Maybe through Ajax or a redirect. The shenanigans that WP plugin devs go through to get around the lack of a queue is ridiculous (chunk the file and keep reloading the page until we’ve processed all the chunks or have an Ajax endpoint that processes a chunk at a time...) and the when I asked a marketing friend of mine who works with Wordpress he said that redis is an “advanced requirement” and I should keep things simple. In Django land I’ve always set up queues even just to send emails because it keeps things snappy.
- simion314 6y agoFor that kind of problem we create a database table. then you schedule there your work tasks and background scripts will fetch jobs from the database and run them. This also works great if the third party is busy or fails, the background jobs are set to attempt a few times before giving up. What solution would you prefer for this kind of jobs? launching a new thread directly? or have a worker project always running and send to it the job directly?
- solraph 6y agoAlas, I feel the same way. After much thought this weekend, I concluded that it was time to move on from PHP. I decided against the any other scripted language (Ruby, Python), as it felt like more of the same. Requirements were strict typing, functional programming support, built-in concurrency, decent library support, and real support for both native and Javascript. It pretty much came down to Kotlin or Rust. I really want to like Rust more, but the library support, and the jobs in my area just aren't there (yet?). Picking up Kotlin feels like coming home.
- 72deluxe 6y agoWhy not C++ in this area? The more I use PHP the more I appreciate C++'s type system.
- solraph 6y agoNo garbage collection, doesn't compile to Javascript[0] and everything on Android is moving to Kotlin anyway. Just to be clear, my reasons stated above is why I'm moving to Kotlin. I make no claim that other people should or would want the same things. I've realised that I like languages with explicit strict typing, and that allow for a greater level of expressiveness at the cost of a higher intrinsic complexity and the comprehension that requires. [0] https://kotlinlang.org/docs/reference/js-overview.html https://kotlinlang.org/docs/reference/js-overview.html
- jfkebwjsbx 6y agoWhat do you mean by "real support for both native and Javascript"?
- solraph 6y agoCompile to Javascript, and compile to native binaries supported by the core language team.
- cageface 6y agoKotlin is really a fantastic language even without IntelliJ but with IntelliJ it makes these older languages feel archaic. Once you've had this level of explicit typing & null checking, code navigation, and refactoring that really works its very hard to go back. Kotlin also feels like a pretty safe bet since both Google & Jetbrains are backing it.
- perttir 6y agoPhp supports (somewhat) strictly defined types. You can defined what types/interfaces methods needs to return, what types/interfaces variables must have, what types/interfaces the method arguments needs to have. It also supports class inheritance, abstract classes, interface classes, class traits, etc.
- solraph 6y agoIt does, and using PHP in strict mode, in combination with tools like phpstan is what led me to looking for a language that is even better in that regard. If PHP hadn't made advances in it's type system with the 7.x series, I probably would not have stuck with it this long. However, while PHP the language supports strict typing, it does it at run time (inherently a limitation of scripted languages, I know), rather than compile time.
- stephenr 6y agoOne of the main benefits of PHP for web serving, is the "shared nothing" architecture. By operating as a non-threaded application, entire categories of bugs and security holes are avoided. Are there situations where threads could genuinely help? Sure, there is always an exception to any rule, but for the vast majority of projects where PHP is used, I don't believe threading would achieve much in terms of performance gains.
- ragnese 6y agoYeah, but if you're worried about bugs and security holes, I'm not sure PHP can possibly help more than it hurts. E.g., type juggling: https://www.netsparker.com/blog/web-security/php-type-juggling-vulnerabilities/ https://www.netsparker.com/blog/web-security/php-type-juggli...
- stephenr 6y agoThere are very few places where PHP cannot do strict comparisons. The first example in that article even highlights that `in_array` has a `$strict` parameter. I'd bet a months salary it's easier to teach developers to use strict comparisons (either through arguments to be passed, or strict operators to be used) than it is to teach developers how to avoid thread-safety bugs.
- ragnese 6y agoYeah, you're probably right about that. Though, it might take longer to train them to spot every place where they could/should be using some stricter version of the defaults. That's the problem with opt-in safety. On the other hand, there are languages that make thread-safety bugs much less likely. Some day those ecosystems will catch up to the languages that have been around "forever" and we'll get our cake and eat it, too.
- stephenr 6y agoThere really aren't that many places to remember, and there is copious amounts of developer tooling available to identify, and in some cases even fix the issues automatically. I don't recall ever seeing any kind of dev tooling that can just automatically fix thread safety issues.
- chown 6y agoI'm there with you about Kotlin. I started with PHP last "last generation" and was pretty bored with it. Kotlin was a breath of fresh air. Also, if you like some similar to Laravel/Symfony for Kotlin, give Alpas a try: https://alpas.dev/ https://alpas.dev/