Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I used PHP in my university days, 20 years ago, and went on to build a few websites with it that I still run today e.g. https://caption.me

It was a fantastic student language - the docs were great, the code was simple and imperative, there was loads of prior art online. It was empowering to tweak code and see immediate results in the browser.

These days I prefer the strictness and ecosystem of Scala on the back-end, and the developer-friendliness of ReactJS on the front-end. And I think the separation of concerns (model-view-controller) is helpful.

So I am gradually migrating caption.me PHP code to Scala/ReactJS. A migration like this can be done piece by piece. After implementing the back-end for a feature in Scala, I write the ReactJS component, then alter the PHP code to render the ReactJS component tag in place of the former PHP implementation, then use some simple javascript plumbing for the React DOM binding.

I have a Grafana chart that shows the number of lines of PHP code remaining, so I can track my progress over time. It's quite satisfying.



If you are the sole developer working on migrating the project and you want to have the frontend in React.js why not use Node.js/TypeScript instead of Scala for the backend? This would save you from context switching between two languages and consequently increase the development speed.

Also why the rewrite? If it works (in PHP) it works. Perhaps instead you could maybe add some frontend JS for better caption UI/UX?

Does everything have to be done in React nowadays, as opposed to plain static HTML? (Speaking as a React/Node dev myself)


I tried Node.js on the backend but it didn't have the expressiveness and ecosystem of Scala.

I run a few simple Node and Python apps behind the scenes of caption.me, but for the core code, I want the power of Scala, its functional style, rich type system, monadic composition, immutability-by-default, avoidance of nulls etc. As well as great libraries like http4s, Doobie etc, Scala also gives me access to the entire Java ecosystem.

The PHP->Scala/ReactJS rewrite is partly a learning and experimentation project for me. I use Scala in my day job, and when I make technical/architectural decisions, I benefit a lot from the stuff I've learnt in my side projects, particularly on the front end side.

PHP has had its day in the sun (as shown in the job market trends on https://www.itjobswatch.co.uk/jobs/uk/php.do ), so I think it's more valuable to get exposure to modern languages as I still have a few years of professional coding ahead of me :-)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: