Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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