Node.js or PHP?

Hi, I’m really newcomer at the backend world, and I’ve reading that the most used technologies are Node.js and PHP, what do I would learn at first and why?

You’re going to need JS for the frontend anyway, so Node makes the most sense and is the least to learn. You can also take advantage of pre-rendering and universal JS.

1 Like

Personal opinion is that PHP I think is easy to learn due to the great docs. However yes Node.JS would be good because you can’t go wrong with learning JS in any form.

2 Likes

I’d say go with Node JS. @mrlagmer does have a point in that PHP can be easy. But that actually depends on the person. This community is a great example. There are so many people struggling to learn just the basics of PHP while the knowledged will ask questions that are more advanced. It’s not that people don’t ask questions. Asking questions is a good thing. But when you start to notice that you have multiple people asking the same basic questions, you’ll start to see that PHP is actually harder for beginners than any other language. So your best choice is to go with Node JS.

1 Like

PHP is actually harder for beginners than any other language

I completely agree with this. It also teaches a lot of bad habits and teaches developers to think strangely about how a web app works in contrast to everything else out there. I always suggest to learn PHP if you need it for some reason, but if you don’t, then don’t worry about it. If you can learn to program you can pick up PHP quickly.

1 Like

It would help if we knew the desired front end result and your experience with front ends.

PHP has been on the go for a very long time and the biggest problem is because it allows sloppy code.

Here is an excellent YouTube video that highlights beginner’s problems and details solutions which take advantage of the latest features:

2 Likes

PHP has been on the go for a very long time and the biggest problem is because it allows sloppy code.

A lot of languages allow sloppy code. I’d say most do. Plus… this is a comparison of JS and PHP after all.

My comments were more geared towards the way PHP is ran, configured, and the way applications are designed. These things are unique to PHP and make it hard for people to transition.

2 Likes

Well, as with most questions in IT, the answer is: it depends

  • What do you want use it for?
    PHP and Javascript both have strengths and weaknesses. Some problems are better solved with NodeJS, while others are better solved with PHP. There is no best tool for anything.

  • Do you know anyone that knows either PHP or NodeJS well?
    Nothing beats a 1 on 1 with someone who knows their stuff and can explain concepts to you in person. Sure, forums and stack overflow work, but not as well as 1 on 1 interaction. So if you know anyone that knows either of those languages that would favourable over the other language as you have someone who could help you.

  • Do you have any idea where you want to host yet?
    Most hosts out there offer PHP by default, NodeJS not so much.

  • How well do you deal with change?
    The PHP ecosystem isn’t moving quite as fast as the Javascript one, where the seem to a have a Shiny New Thing™ each week1 and burn everything that happened last week to the ground. If you don’t like change PHP might be more your thing.

1 Ok, I’m exaggerating, but the speed with which new things appear and are discarded again is mind blowing. How can you ever obtain stability if you never converge to anything?

6 Likes

My experience building frontend is simple, I made some basic web sites, but nothing too proffesional, I would like to build sofisticared web applications using databases and auth system, cruds, etc.

1 Like

Thanks a lot for your answers guys, I really appreciate it, due to your advices I choose node.js to start learning backend. Thanks a lot!

3 Likes

That’s great news.

As per the rest of the discussion, I agree with all the comments that have already been said. However, speaking on terms of beginning to learn a language, I don’t think PHP is suitable as far as I’ve seen for beginners. Beginners seem to fail to understand simple basic concepts of anything. Shoving PHP in front of them just makes it worse. We all have seen this time and time again. PHP should be tailored for more advanced users, not beginners. By its nature, beginners will always write really bad code. If we take PHP out of this, maybe then we’ll see if PHP is truly allowing bad coding habits or if it’s the person’s fault. As of right now, I have seen all over the internet people bashing on PHP for this matter. No one seems to understand that people write bad code if they are taught bad code. You see 2/3rds of the pie tailored to using sites like w3schools and other tutorial sites that teach beginners how to code badly. The other 1/3rd of the pie, you see people who actually want to learn something instead of copying and pasting or doing guess work with PHP.

I know that we all love PHP including myself. But there’s also parts we hate about PHP and this is mine. So coming to a conclusion, I don’t think it’s appropriate to learn PHP until the beginner gets a main grasp of the basic fundamentals of programming. If the beginner just jumps to writing PHP, they aren’t going to listen to no one like the many of times we have seen on here. Until we stop feeding the bad habits, it will continue until PHP is rejected by all community as “a bad language”. It already is labeled as such in some circumstances.

I don’t know that you can blame PHP for people choosing to follow bad coding practices. HTML is very simple to learn correctly, yet we frequently see people here producing unsemantic and/or invalid code. And not just newbies, but folk who’ve been doing this for years and should know better. Even with the easy help of the W3Validator available, there are those who prefer to press on with broken code and hope, somehow, it will work.

Sloppy coding is down to an attitude, rather than a language, IMHO.

3 Likes

That’s like saying people who learn soccer aren’t learning it correctly, so we’d better teach them how to play basketball instead.

How about learning people how to code PHP properly by showing them proper code, pointing them to good resources, etc, instead of dismissing PHP outright?

5 Likes

Yes, I see both your points. However it’s been already done before. A great example is the recent thread I created. I gave perfect examples of how to properly write good code. Have you guys seen it being used any where on the forum? It’s not to say there aren’t any resources available. There are very good resources out there, but beginners are super stubborn. I already know that it’s not the language’s fault. But there are so many people saying that it is. So there’s a battle between people saying that it’s the language’s fault and people saying that it’s the person’s fault. It’s just so hard to prove that it’s the person’s fault because people are so stubborn to learn the right way.

1 Like

That’s rather a sweeping statement. Some beginners may be stubborn, but in my experience, it tends to be the folk who think they know what they’re doing who are the worst in that respect. Generalisations like that are not helpful, and we don’t want to start pre-judging folk based on their level, or lack, of expertise.

3 Likes

It feels like we’re getting a bit off-topic here, but anyways …

I think besides newbies not knowing any better, a lot has to do with whether someone is a pragmatist (it “works”), or a professional (“best practice”).

In terms of Node vs. PHP (or similar decisions) a lot depends on personal preference and experience. eg. if I “know” PHP, have had good success with it, but would need to learn Node, I would tend to go with PHP.

What would be preferable is that I know both and base my decision on which is the better tool for the task at hand.

4 Likes

My provider might host NodeJS but is not advertising it. I have been using PHP since 1999 and it is my mainstay. Yes, I wrote some horrible code in those days, and I just rewrote a contact form from scratch because I can now do real-time things with JS, AJAX, PHP, and of course HTML.

Would I change to NodeJS? Not likely. I can do everything I want with JS, AJAX, PHP, and HTML. Bootstrap and jQuery are useful also.

Isn’t it a given that fundamentals of programming are needed for learning anything? My first crack at programming was in 1973 (yeah, I’m ancient) using Fortran.
The principles then are pretty much the same as now.

3 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.