Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

General Discussion

Scott Moore
Scott Moore
4,050 Points

JavaScript vs PHP

So I just started watching lessons of PHP. Reading some other forums there's lots of arguments of which one you should use. JS if I am reading correctly is more client side. PHP more server side.

I'm just wondering from some of you all who have experience. Why would you use both? Am I mistaken in understanding they both accomplish the same thing with the exception of one is client and one is server?

Also reading, some people turn off javascript in their web browsers. So going forward, Would it be more beneficial to learn JS or PHP. I also read JS is slow compared to PHP.

As a new person learning, And not quite sure where these two will fit into my mix. What would you recommend learning first? There's also Ruby. So what would you recommend the new person to learn first?

Thanks

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Scott,

I think using the word more is distracting and won't help in explaining the languages, so here we go.

JavaScript JavaScript is purely a front end only language so what does that mean? Essentially you use JavaScript for DOM manipulation, local data storage, animating elements using math, making AJAX calls to a sever and lots more. If you're starting a career learning other languages such as HTML and CSS then this is where you should start.

A more detailed explanation about JavaScript

PHP PHP is purely a back end language meaning it only interacts with the user when a script is executed on the server, you would use PHP if you need to interact with a local database server, authenticating users for forms, making calls to third party APIs such as Twitter, Facebook and lots more. Like Ruby you only need to learn PHP once you feel you need something that browsers can't do such as connecting to a MySQL database.

A more detailed explanation about PHP

Again if you're learning HTML and CSS JavaScript would be more beneficial as PHP can't interact with front end code at all.

If you try the tutorials here for both, you should begin to see how they are used differently. I wondered the same thing initially, but as i delved into each the server and client environments became clear :)