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

Development Tools

Use javascript or Ruby?

As I am in the process of learning both javascript and Ruby, they both do a lot of the same things. When developing a website, how do I decide which to use? Or a combination of both?

4 Answers

Michael Hulet
Michael Hulet
47,912 Points

If the purpose is for web development, JavaScript is likely a must. It's the only language that can be used to write programs that run in a user's browser. If you like Ruby as a language, you should totally go for that, too! On the backend, it's totally up to you what you're stack's like, so you can write just about whatever you want there

Thanks for the great advice, Eric! I am pretty far down the road with Ruby on Rails and am planning and starting to create a couple of websites using ROR and JavaScript on the front end. A few years ago I tried to learn C#/.NET on my own but wasn't too successful. I have had a hard time getting my head around object oriented programming and all the ways methods can be used and then creating your own methods etc., and then stringing them all together, but I am starting to get the hang of it with practice. Plus all the different languages have slightly different preferences for syntax, and convention, and keeping them straight is also taking a little practice.

I think with Microsoft's influence, C#/.NET will always have some level of popularity, that is why I tried to learn it first. Now that I have access to this wonderful Treehouse training system, I think I can learn just about any of these technologies.

Thanks, again!

Thanks, Michael. Yes, that was what I was thinking. It seems better to do as much as possible on the client side.

Bruno Brito
Bruno Brito
3,652 Points

I love reading about the future of this industry and when it comes to Backend a lot of people out there seem to think JavaScript is not only viable right now but very likely the top choice in the near future. Nonetheless, I plan to learn python for that purpose also, just in case.

Andrew, Your question can only be answered with opinions, but there are some important points to make:

Ruby is a server-side language, meaning any logic you write in Ruby can only be run at the server, almost always as a pre-process to the server returning an HTML page to your site visitor's web browser. This logic is often to do something like interact with data in a database. Ruby is only one of many server-side languages, and they all can be used to accomplish the same server-side processing tasks: PHP, Python, C#, Java, etc. Relatively recently, JavaScript became a server-side language with the advent of Node.JS. Right now, server-side JavaScript is a trendy topic and some feel it is the "future" of programming. However, you can use any of the above-mentioned languages for server-side tasks, and many-many-many (most) of the biggest websites in the world use something that is NOT JavaScript as their server-side language.

However, JavaScript is ALSO a client-side language, which means it can run at your site visitor's web browser without requiring a page load or re-load. It is also really the ONLY language that you can trust to work on all browsers, because all browsers support JavaScript without any add-ons or explicit permissions. You use JavaScript in this client-side context, usually, for simpler reasons: you want to add interactivity or animation to the elements of a webpage. You can also use client-side JavaScript to do "heavier" tasks like send or retrieve data, through AJAX or APIs.

So with that all said, to answer your question about which language to use, you decide which to use based on whether your site needs server-side processing, or client-side processing. If you need to make a navigation menu open and close when a visitor clicks on a hamburger icon, that's client-side JavaScript. If you need to submit a form on an e-commerce website and save the visitor's purchase info in a database, you'd use Ruby or any other server-side language for that. You also might need to use a database language like MySQL or PostgreSQL if your site uses a database.

It really just depends what your website needs to do. Does that help?

That does help a lot, Eric. Thanks! My thoughts on the subject line up with everything you said, but since I am new and looking to work in the industry, I was looking for a little confirmation from people who have more experience than I do. I like doing both the front and back end, and it makes since to me that JavaScript is almost essential on the client-side, and another technology is more appropriate for the server-side, at least how things are currently. Things change very quickly. I started doing programming over 40 years ago, and the idea of object oriented programing hadn't even germinated yet. Yet a lot of things remain the same. It is just as important today to write clear and concise code and do everything as efficient as possible.

Andrew, Cool! Welcome back to programming. If you want my opinion on language trends: I'd say the 2 hippest languages to learn these days are front-end JavaScript and maybe back-end Python. Ruby (and its most popular framework, Ruby on Rails) is starting to wane in popularity while JS (with Node/Express, etc.) and Python (with Django) are picking up steam, at least in "coolness." I also feel like C#/.NET (MVC) is kind of cool again, plus (at least in my city) it's very in demand. I honestly feel like Java is very in-demand still, too, just not in startup-land. PHP is not "cool," even though lots of people (including me) still use it constantly with Laravel, WordPress, etc. I think a PHP dev's salary is lower on average, though.

One thing I think is undeniable: the popularity of front-end Javascript frameworks like Angular, React, etc. is really taking off, and likely going to dominate front-end development for a while. You only really need to know a little about Node/Express to get into those. So if you prefer front-end, I'd say learn Angular or React. If you prefer back-end, I'd say learn a little Node and then maybe try out Python's Django framework so you can start working with MVC (model-view-controller) architecture, which is actually maybe one of the biggest trends to heed nowadays. You'll likely be encouraged to use an MVC framework instead of writing anything "raw," regardless of which language you're writing in.