Moving away from PHP

Abhi Beckert

Ars Tribunus Angusticlavius
8,981
I’ve been a PHP developer for 20 years and a fair chunk of that time has been spent as project lead for a system that has now outgrown PHP.

Specifically I’m looking for a language that:

1. Runs reliably behind Apache and CentOS - we are a small business with important customers who operate 24/7/365 and our servers are a critical component of their employees doing their job.

2. Able to handle huge data sets (hundreds of millions of database rows, terabytes of files).

3. Is easy for our system administrators to learn and troubleshoot (we’ve outsourced that to a third party company - I don’t want a language that would force me take on part of their work).

PHP’s lack of threading and memory management are my main complaints.
 

ShuggyCoUk

Ars Legatus Legionis
10,388
Subscriptor++
I agree. If you want extremely wide support go there. Note that if you go c# go fully dotnetcore from the start, you should consider the net framework stuff to be essentially ossified long term support no new features, so a proor fit for starting a new project.

If you need to process significant amounts of data there is tooling in both lanaguges for that, note that in Java there will be idioms (which frankly don't look much like idiomatic java otherwise) you need to apply to play nice with that, which are more or less unnecessary in the c# world.

There's less support for the sorts of sizable frameworks that actually apply in this space (dealing with huge datasets) for the dotnet world though (e.g. spark). I would experiment with the non web aspects of both in that space before deciding which you go for, you might find that some significant effort can be offloaded to that, where as it's easy to do web based front ends in either.
 
Java or C#, leaning heavily towards Java if you really want to stick with an open source hosting stack. Both are widely used and proven in some very big and very critical environments, and are pretty standard stuff these days from an admin and support perspective.
Yep. I have limited experience with C# personally, but it's similar enough to Java. I've heard tons of amazing stuff about C#. Java itself can be open source and will run on an open source stack, but it looks like Oracle is trying to pull an Oracle, and put it all behind a paywall, so that's something to be wary about. C# has Mono, if you want to run it on a Linux based stack or whatever. I don't know if that's enterprise grade (again, my lack of experience with C# is showing), but it is an official Microsoft-sponsored project, so that must mean something. :) I'm my particular job market, there are way more Microsoft admins and developers than there are Java developers, you should consider that in your decision making criteria.


I'm sure you have your datastore already figured out, but I've had great success with PostgreSQL and huge data sets. It's very performant, even with hundreds of millions of records. It also has some nice performance bonuses that other RDBMSs don't have. For example, VARCHARs add no performance hit over CHARs, and the character limit is just a convenience feature for validating data input: there's no difference in performance between VARCHAR(255) and simply VARCHAR.
 

dodexahedron

Ars Praefectus
3,368
Subscriptor++
Er...
DotNet Core is entirely open source.
Mono isn't necessary, any more, with DotNet Core.

On Linux, you can write your application in C#, on a Microsoft toolchain, and use MS SQL Server.
For free.
With internal production use rights.
Within limits, of course, on the database side.
But if you write the code well, it won't matter what backend you use.
 

alxx

Ars Praefectus
5,142
Subscriptor++
If you are looking at Java I would go for kotlin, instead
kotlin has the advantage of being interoperable with java in the jvm.
https://blog.jetbrains.com/kotlin/2018/10/kotlin-1-3/

Has great tools/ide, can compile for jvm, js or native, all the java libraries as well as kotlin libraries.
More concise than java. Very good support on linux

https://kotlinlang.org/
https://medium.com/@hinchman_amanda/kot ... 719aa9c172

Another advantage is there are plenty of developers using and learning it since Google added it as an official language for android development. There is also plenty of use server side
https://kotlinlang.org/docs/reference/s ... rview.html
https://www.infoq.com/articles/intro-ko ... developers

Why would you use Oracle java/jdk? Always openjdk https://openjdk.java.net/ or even Amazon's version of openjdk corretto
https://aws.amazon.com/corretto/


Other options (not already mentioned in the thread) are Python3, Rust, Go and Nodejs

Python3
https://www.python.org/
Tons of libraries, easy to learn.
https://www.whizlabs.com/blog/python-and-big-data/

Rust is another one to look at.
https://www.rust-lang.org/
Seen a few teams switch from Java to Rust especially for large product catalogs/catalog search
https://medium.com/paritytech/why-rust-846fd3320d3f


Go
https://golang.org/
Lot of Go getting used for large projects.
Docker, kubernetes
https://www.slideshare.net/jpetazzo/doc ... cker-in-go

Nodejs
https://nodejs.org/en/
https://medium.com/the-node-js-collecti ... 66a78fa088
https://medium.com/the-node-js-collecti ... 95e9747b70
https://medium.com/the-node-js-collecti ... 053b94ab8e
https://medium.com/the-node-js-collecti ... 2b4cacb17d


What languages do you and your sysadmins already know?

What data format/s do you use?
Do the databases you use have interfaces for the languages you are considering?

What sort of api's do you have?
Are you planning to migrate them to restful if they aren't already?

Depending on the language you pick(and on your existing systems), you may/will possibly need to re-architect
as forcing other languages to work the same way as php can cause plenty of fun!
 

PatrickPhelan

Seniorius Lurkius
22
Subscriptor
PHP’s lack of threading and memory management are my main complaints.

I've also been thinking about this for one of my clients and had some thoughts on it, leading to this js demo http://c.dev.roswellstudios.com/threadx.html and this php/redis example task queue https://github.com/patrickroswellstudio ... -php-redis

A task queue in front of a pool of workers might address these complaints. Each php worker is still a single thread, but a web request or command line can generate multiple tasks, each handled by a separate, simultaneous worker. The workers can also generate new tasks. The php task queue is easier to integrate into your existing php (move some php code to a worker, replaced with a new task call), but also easier to integrate other languages into the php (the worker can be anything that can talk to the queue), so you don't have to rewrite the entire app in one go.

Streaming and unbuffered loads like $pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false); will help keep memory under control, and the workers can have limited lifetimes with PM2 or Supervisor, though I don't think PHP leaks as much memory as it used to.
 

cninroh

Seniorius Lurkius
28
Subscriptor++
I think it’s almost impossible nowadays to recommend a language in this setting before considering frameworks it offers catering for specific needs. It would be perfect, therefore, if you could provide a bit more insight in the type of business you do.

I personally would really recommend Ruby, but primarily due to abilities and use case of Rails framework. As someone who also comes from PHP background of almost 10 years, I find it to be easy to learn and incredibly capable, well supported replacement.

I often find that with solutions coming from Java, you are still stuck writing a lot of core components from zero, while many frameworks in languages like Ruby, Python and Node, offer these core functionalities (for instance fully fledged catching for web apps, complex database connectors with intelligent model management, hierarchical routing system integrated with HMVC patterns etc.) via package managers and bootstrapped solutions built in core. The documentation is also excellent, which is one of the most important considerations for me personally when making a framework choice.

If your business is more “scientific” than purely “web” Python becomes more interesting due to the libraries it has available. It also is more of a glue of a language, because if you use something like “numpy” you essentially offload heavy duty math to dataframes executed in C, which works incredibly fast, while some of their other plugins rely on Ruby or other language implementations, and work as interface rather than implementation.

As I said before, very reliant on what exactly you would like to build.

A lot of design paradigms can already be fixed in PHP if you choose to migrate some bottleneck functionality to something like AWS Lambda microservices. Frameworks such as Serverless.com can then permit you to use several languages at once to build state machines offering huge performance and scalability gains for many popular use cases!
 

CanSpice

Ars Tribunus Angusticlavius
7,147
I think it’s almost impossible nowadays to recommend a language in this setting before considering frameworks it offers catering for specific needs. It would be perfect, therefore, if you could provide a bit more insight in the type of business you do.

I personally would really recommend Ruby, but primarily due to abilities and use case of Rails framework. As someone who also comes from PHP background of almost 10 years, I find it to be easy to learn and incredibly capable, well supported replacement.

I often find that with solutions coming from Java, you are still stuck writing a lot of core components from zero, while many frameworks in languages like Ruby, Python and Node, offer these core functionalities (for instance fully fledged catching for web apps, complex database connectors with intelligent model management, hierarchical routing system integrated with HMVC patterns etc.) via package managers and bootstrapped solutions built in core. The documentation is also excellent, which is one of the most important considerations for me personally when making a framework choice.

Before dismissing Java you should look at the Spring Boot framework, which does everything you list with a minimum of boilerplate that Java's known for.
 

cninroh

Seniorius Lurkius
28
Subscriptor++
I think it’s almost impossible nowadays to recommend a language in this setting before considering frameworks it offers catering for specific needs. It would be perfect, therefore, if you could provide a bit more insight in the type of business you do.

I personally would really recommend Ruby, but primarily due to abilities and use case of Rails framework. As someone who also comes from PHP background of almost 10 years, I find it to be easy to learn and incredibly capable, well supported replacement.

I often find that with solutions coming from Java, you are still stuck writing a lot of core components from zero, while many frameworks in languages like Ruby, Python and Node, offer these core functionalities (for instance fully fledged catching for web apps, complex database connectors with intelligent model management, hierarchical routing system integrated with HMVC patterns etc.) via package managers and bootstrapped solutions built in core. The documentation is also excellent, which is one of the most important considerations for me personally when making a framework choice.

Before dismissing Java you should look at the Spring Boot framework, which does everything you list with a minimum of boilerplate that Java's known for.

I think you are completely missing my point about Java, even incl. Spring Boot framework. A simple Hello World, that would instead return Hello, #Username! in Spring takes an incredible amount of imports, and lines of code to produce (https://spring.io/guides/gs/rest-service/), while equivalent functionality in Rails would take only a few lines of code, and no other fuss at all. It's not that Java does not provide this functionality "somewhere", but in terms of ease of use, and ability to quickly and with a few lines of code to do a lot is something that Java is still not strong with. That by no means implies its incapable, but as far as modern frameworks go, some of its claims are pretty 'dry'.
 

CanSpice

Ars Tribunus Angusticlavius
7,147
I think it’s almost impossible nowadays to recommend a language in this setting before considering frameworks it offers catering for specific needs. It would be perfect, therefore, if you could provide a bit more insight in the type of business you do.

I personally would really recommend Ruby, but primarily due to abilities and use case of Rails framework. As someone who also comes from PHP background of almost 10 years, I find it to be easy to learn and incredibly capable, well supported replacement.

I often find that with solutions coming from Java, you are still stuck writing a lot of core components from zero, while many frameworks in languages like Ruby, Python and Node, offer these core functionalities (for instance fully fledged catching for web apps, complex database connectors with intelligent model management, hierarchical routing system integrated with HMVC patterns etc.) via package managers and bootstrapped solutions built in core. The documentation is also excellent, which is one of the most important considerations for me personally when making a framework choice.

Before dismissing Java you should look at the Spring Boot framework, which does everything you list with a minimum of boilerplate that Java's known for.

I think you are completely missing my point about Java, even incl. Spring Boot framework. A simple Hello World, that would instead return Hello, #Username! in Spring takes an incredible amount of imports, and lines of code to produce (https://spring.io/guides/gs/rest-service/), while equivalent functionality in Rails would take only a few lines of code, and no other fuss at all. It's not that Java does not provide this functionality "somewhere", but in terms of ease of use, and ability to quickly and with a few lines of code to do a lot is something that Java is still not strong with. That by no means implies its incapable, but as far as modern frameworks go, some of its claims are pretty 'dry'.

Uh, I made a Hello World Spring Boot REST service in five minutes a couple of months ago. You just go to start.spring.io and pick the dependencies you want to add, like 'Spring Web Starter' or 'Spring Reactive Web' and you're pretty much good to go. It's almost as quick as doing 'dotnet new webapp', say.
 

Pont

Ars Legatus Legionis
26,160
Subscriptor
I think you are completely missing my point about Java, even incl. Spring Boot framework. A simple Hello World, that would instead return Hello, #Username! in Spring takes an incredible amount of imports, and lines of code to produce (https://spring.io/guides/gs/rest-service/), while equivalent functionality in Rails would take only a few lines of code, and no other fuss at all. It's not that Java does not provide this functionality "somewhere", but in terms of ease of use, and ability to quickly and with a few lines of code to do a lot is something that Java is still not strong with. That by no means implies its incapable, but as far as modern frameworks go, some of its claims are pretty 'dry'.

If you're replacing a "big, ugly codebase", then the "overhead" of a proper framework in a strongly-typed language is minimal in comparison to the actual code.

I detest Java-the-language, myself, but there's always Kotlin. And .NET Core is truly cross-platform, these days.