4 ms·
What is the PHP equivalent of writing your front end and back end in the same language so you can share libraries and data and not have to switch gears between
by DonHopkins 4y ago
What is the PHP equivalent of writing your front end and back end in the same language so you can share libraries and data and not have to switch gears between two different languages each time you look up or down the stack?
There is a HUGE advantage to using the same language in the browser and on the server, and PHP isn't ever going to displace JavaScript in the browser. So JavaScript it is. That ship sailed a LONG time ago.
- archerx 4y agoI like switching gears, I truly don’t find it an advantage using the language for both. Have separate languages makes the distinction between backend world and front end world very clear. Also the backend code is mostly data manipulation and the front end code is mostly rendering so there is very little overlap in similar functions for both. The separation helps keep things tidy in my brain. I much prefer not having to write JavaScript everywhere, not every problem is a nail and not every solution requires a hammer.
- ihatepython 4y ago> What is the PHP equivalent of writing your front end and back end in the same language so you can share libraries and data and not have to switch gears between two different languages each time you look up or down the stack? You can simply compile your PHP code to wasm with emscripten, and then run it in the browser. Pretty straightforward. No more switching gears.
- ThatPlayer 4y agoI believe you'll need to compile the PHP runtime itself with emscripten, since LLVM won't take PHP code, but PHP compiled to wasm will!
- pjmlp 4y agoAs long time Java, .NET and C++ developer, this is oversold, beyond some form validation there is hardly any value sharing code. And in what concerns validation, it can be automated on most frameworks, which has to be done on server side anyway due to security concerns.
- toyg 4y agoThe value is really not in sharing code, but rather sharing developers. Instead of having to assemble and keep happy a diverse group of specialized professionals, you can just hire and fire a bunch of cheap JS folks, who are easily replaceable.
- pjmlp 4y agoOffshoring already takes care of the cheap developers part. When people get what is peanuts in local currency of the owner company, whatever they are using doesn't matter and most sweet shops are experts in everything. I can also tell that at the level I work on, salaries are the same regardless of FE, BE, DevOps, ...., specially because no one has a single role.
- DonHopkins 4y agotoyg makes a good point about sharing developers, but also sharing code is important, especially for efficient server side rendering, with view code that runs on both the server and the browser. The point is it takes fewer people (or even the same person) to write less code (instead of writing everything twice, then trying to keep them in sync forever). There's a fascinating deep discussion about SveltKit and other frameworks here: Reacting To Web Hot Takes from Rich Harris - SVELTE STUFF https://www.youtube.com/watch?v=JGuUY7dZhWs https://www.youtube.com/watch?v=JGuUY7dZhWs
- pjmlp 4y agoJava and .NET have been doing efficient server side rendering for several decades now.
- paulryanrogers 4y agoLiveWire?