2021-03-19
1468
#js libraries#php
Kenneth Ekandem
37731
Mar 19, 2021 ⋅ 5 min read

Getting started with JavaScript for PHP developers

Kenneth Ekandem Software engineer with four years' experience in PHP and JavaScript. Currently working as a backend developer for Codekago Interactive.

Recent posts:

Vue logo over a brown background.

A guide to two-way binding in Vue

Learn how to implement one-way and two-way data binding in Vue.js, using v-model and advanced techniques like defineModel for better apps.

David Omotayo
Nov 22, 2024 ⋅ 10 min read
TypeScript logo over a pink and white background.

Drizzle vs. Prisma: Which ORM is best for your project?

Compare Prisma and Drizzle ORMs to learn their differences, strengths, and weaknesses for data access and migrations.

Temitope Oyedele
Nov 21, 2024 ⋅ 10 min read
Practical Implementation Of The Rule Of Least Power For Developers

Practical implementation of the Rule of Least Power for developers

It’s easy for devs to default to JavaScript to fix every problem. Let’s use the RoLP to find simpler alternatives with HTML and CSS.

Timonwa Akintokun
Nov 21, 2024 ⋅ 8 min read
Rust logo over black marble background.

Handling memory leaks in Rust

Learn how to manage memory leaks in Rust, avoid unsafe behavior, and use tools like weak references to ensure efficient programs.

Ukeje Goodness
Nov 20, 2024 ⋅ 4 min read
View all posts

6 Replies to "Getting started with JavaScript for PHP developers"

  1. Migrating from php to JavaScript. One of the best frameworks to go for is Expresswebjs which enables you to build structured, secured and scalable application.

  2. Laravel livewire or Laravel+inertia.js is the way to go for me, but 9/10 times Livewire wins. Most of the points you pointed out can easily be challenged when you need third party functionality such as import/export csv,authentication, charting, oauth, pdf generation. All of this is easily done with Laravel, but not so easily with a JS backend solution, i’ve done projects in both sides, im glad i found Livewire, i drastically reduced js code in my aplications and whenever i need it, alpine.js does the rest of the job. If i work with inertia.js, Laravel still helps tremendously because i dont have to write any api like in a classical api project, Laravel is the workhorse providing the data, handling authentication… etc, then vue.js is for the front end receiving data from Laravel as props. But still working with Livewire handles all of this with less code and dont have to go through some annoying stuff that vue.js has. The only time where i would only use a pure JS solution will be if the app is a chat app, a prodict builder with a rich UI which changes on every click and event or a social media app like facebook, which is the reason why they created React, because that solves their problem.

  3. You highlight all the benefits, but none of the downsides of JavaScript. Types is going to be the big pain point, as you will likely learn the hard way.

    Typescript doesn’t solve this except at the static level. When your application exchanges data with the external world, by which I mean anything external to the code you wrote, you’re at risk, as there is zero type-checking in function calls, in data exchanges via web requests, or anywhere else.

    The results range from, best case, your script crashes, which is often hard to debug, because the wrong type can travel through many function calls and Promises etc. before causing an error – to, worst case, your program executes, but does something entirely else than intended, making the problem not only difficult to debug, but difficult to detect in the first place.

    And maybe you think you’ll get around all that with tests, but reality is, nobody manually tests every internal function in a codebase. Are you going to cover every function with unit tests to see how it responds when you pass it every conceivable wrong type? Of course not, your test suite would end up being 90% noise. Are you going to add type-assertions to every argument in every function? Even if you do, authors of third party code you depend on did not.

    Even if you test everything like crazy, and fight like hell to keep unsafe code out of your dependencies (completely unrealistic), at some point, you would most likely have to concede why some of us insist either on static guarantees, which Typescript does not provide, or run-time guarantees, which JavaScript does not provide.

    PHP’s type system isn’t great, but at least it has type-checking in function calls. It now has type-checked properties as well.

    This simple fact keeps me firmly on the side of PHP, if the choice is between the two.

    For all the fun and cool stuff that JavaScript does, and for all the ugly in PHP, I’m not even tempted.

    But good luck with that. I hope you find what you’re looking for. But I’m pretty sure you’ll find something else as well.

  4. Thank you for your feedback, I just discovered Livewire. The thing about Laravel applications that are built for large-scale use is that you find out there still in one way or the other rely on JavaScript. My point is, why not just build an application with one language handling both the client and server-side?

  5. java script is not secure. Any one can see de code with little or no difficult. Use resources of the computer which PHP does not. 45% of web servers use php.

Leave a Reply