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

Help Understanding Why We Need So Many Languages

From watching a few video tutorials on PHP, they essentially have the same tools used in Javascript(for loops, functions, objects, etc...). This is one of the things I'm baffled about since I've started programming is the myriad of different languages out there. Why does it make sense to program in PHP if you can handle the same tasks in Javascript? This goes for a lot of different languages. Can someone please elucidate why we need thousands of languages that do the same thing ?

1 Answer

Hi Brian,

You might apply the same question to lots of things - why so many models of cars, or blog software, or computer hardware. :)

The short answer basically boils down to a couple of things: evolution, preference, and specialization. Computer languages have evolved over time, from assembly and machine languages to more general and human-readable (higher level) languages. Just as there are multiple programming languages, there are also multiple paradigms/styles for programming - imperative, object-oriented, functional, etc.

Some are better at some things than others. Ruby and Python are typically marketed as 'easy for beginners to learn', but Ruby (via Rails) has historically been used much more for web-related programming than Python. Python seems to be more often used in data science, statistics, or where you need heavy number-crunching. So certainly, you can do the 'same things' in them (or any Turing-complete language) but you don't necessarily want to. AAA game titles are generally programmed in C/C++ because it's fast - Ruby and Python (or PHP or JS) can't compete in terms of speed of processing.

In regards to PHP and JavaScript in particular, PHP is a server-side language. JS is client (browser) side. Meaning, the scripts for each were only able to be run either on the server or in the browser, but not both. In recent years Node.js has become a big deal because it allows developers to use JavaScript on both the client and server side.

There's no real simple answer here - people learn new things and use it to improve older things or create new ones; you like red and I like blue. There's a good discussion on StackOverflow, and many other places online.

Best, Cena