Re:Modern Javascript: Everything you missed over the last 10...
by zozbot234 on Saturday May 15, 2021 @02:28PM
(#27167648)
> Being able to do SSR and sharing validation logic are two huge and obvious reasons. Ever try to exactly duplicate validation rules between the browser and PHP? What about when they use weird regexp rules?
PHP is adding support for FFI to any C ABI-compatible language, and you can run the exact same code in the browser via emscripten or a WASM polyfill. As a bonus, emscripten/WASM compiled code will also be more efficient in the browser than plain JavaScript or Typescript.
Re:Modern Javascript: Everything you missed over the last 10...
by chrisbroadfoot on Saturday May 15, 2021 @05:03PM
(#27168991)
> As a bonus, emscripten/WASM compiled code will also be more efficient in the browser than plain JavaScript or Typescript.
Small gains compared to the cost of implementing. 10-20%. Now you're asking your full-stack developers to know PHP, JS, C, and WASM.
Re:Modern Javascript: Everything you missed over the last 10...
by bastawhiz on Saturday May 15, 2021 @07:24PM
(#27169856)
It seems silly to add a third language to your stack just so you can share code between the other two languages.
Re:Modern Javascript: Everything you missed over the last 10...
by gls2ro on Saturday May 15, 2021 @02:05PM
(#27167466)
Here is my perspective: There are plenty of reasons to use the same language on FE and BE but for me the main problem is the JS standard library.
Let me give you one example:
Lets say you want to validate if a string is a valid URL. What is a good way to do this in JS?
Just for reference in Ruby for example I can do:
URI.parse(input).kind_of?(URI::HTTP)
No gems or any other engines needed.
Do you have any evidence for this? Because there's plenty of reasons why you'd share the same code in the browser and the server. Being able to do SSR and sharing validation logic are two huge and obvious reasons. Ever try to exactly duplicate validation rules between the browser and PHP? What about when they use weird regexp rules?
I have a site builder codebase that renders previews instantly as you make changes, then uses the same code on the server to render the HTML and CSS for visitors. That would be otherwise be outright impossible to do without writing the same code again in another language.