Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

As the title says, I'm a student that will be starting my second year of C++ very soon. I've discovered Ruby, however. While I've heard much buzz about the language before, I've disregarded it because I always thought it wasn't something that would be useful.

However, I've found a number of FANTASTIC tutorials on ruby and am interested in learning it (probably because it seems so straightforward).

  1. Would playing around with ruby be a good or bad idea? I understand that there's not such thing as bad knowledge, but I'm afraid that Ruby will only confuse me when dealing with C++.

  2. How different from C++ is it? I've read it's based on C in some way.

  3. I've read some posts on here that Ruby and C++ can hold hands once in a while. How flexible is this relationship? Is it rarely that this would work?

  4. How useful is Ruby in the real world? I'm not specifically asking about jobs- I'm more interested in what sort of applications may come from this language. Any specific examples worth looking at?

share|improve this question

migrated from stackoverflow.com Jan 16 '11 at 5:17

This question came from our site for professional and enthusiast programmers.

6 Answers 6

  1. Learning a completely different programming language is always worth it, as it forces you to think differently and expands your understanding of programming. Yes, it might confuse you if you're a beginner learning another language. But that will make you understand the difference all the better. In addition, Ruby and C++ are sufficiently different for you not to confuse their syntax.

  2. Ruby isn't based on C, it's written in C. Ruby is quite different from C: it's interpreted, has duck-typing, allows meta-programming, and all sorts of programming styles (functional, object-oriented, etc.)

  3. Ruby is very useful as "glue". Any time you need to write something really quickly to automate a task, Ruby will help you out. Of course, many other languages can do that too (Python, Perl, etc.). Ruby will be much more practical for these tasks than C++. Ruby gained a lot of its fame from Ruby on Rails. You can find many open source application written in rails for you to study (e.g. http://www.webresourcesdepot.com/23-amazing-and-open-source-ruby-on-rails-applications/). Of course, Ruby can also be used to write desktop applications. On a side note, JRuby can be used to work with Java-based projects.

Ruby (or a similar language) is great to learn in addition to C++ as it will put your programming experience in a whole different light. You'll understand the trade-offs between development speed and execution speed much better. Also, writing functional programs and meta-programming will open a whole new universe to you.

But once again, if you're really a novice, learning another language at the same time might confuse you somewhat at the beginning. But if you pull through, it will definitely be worth it.

share|improve this answer
1  
Thanks! =] I'd vote up, but not enough rep apparently (weird requirement). I'll wait for a few other answers as to whether or not it's a good idea... So far I'm itching to dive in, though. –  Von32 Jan 15 '11 at 4:21
1  
+1 - That is what being a student is all about... learning. Back in the day, my university had you learn FORTRAN, Pascal, VAX Assembly, 6068 Assembly, COBOL, Ada, Lisp, and C et al. Flash forward 20 years and in your professional life you learn C#, PL/SQL, SQL, Ruby (RoR), PHP, Perl, and more. Eventually you retain what pays the bills and forget more about some languages than others will ever know. –  tawman Jan 15 '11 at 4:35
    
+1 - I must have learned 10-20 different languages before settling on the one I wanted to gain expertise is: c++. –  Crazy Eddie Jan 15 '11 at 4:36
    
+1 - Just do it. It will "free" your head! –  Achim Jan 16 '11 at 14:00

It depends. Do you want to learn Ruby? It doesn't sound like you have a specific application in mind, but if it sounds like fun and you have the time, then why not? As a student of programming you will be asked to learn many languages; after the first couple you'll find that picking them up becomes second nature.

I don't think it will help much, nor will it hurt. The main danger is that once you know Ruby, C++ will start to feel like a pain in the rear. (Full disclosure, I'm not a fan of C++ and I avoid it when I can.)

Syntactically, it bears some influence from C (which is the same for most languages conceived after the advent of C), but there's a lot of things that just don't resemble either C or C++ that much, such as blocks and iterators. In fact, off the top of my head, I can think of only one concept that Ruby borrows from C++, and that's operator overloading (which it does not use nearly as extensively as C++ does).

I've found Ruby to be a very useful language. You can write just about anything in it so long as you don't need the performance of a compiled language. You can do OpenGL graphics. You can write GUI apps on a number of platforms. You can interface with databases and write web pages (there's this thing called Ruby on Rails, you may have heard of it :). Those are just a couple examples.

I'll end with a caution. It's been my experience that, if you don't have a specific project in mind to use Ruby on, you'll have a hard time sticking with it and retaining what you learn. So, at least figure out something that you want to write in Ruby before you take the plunge.

share|improve this answer
    
Thanks! I'd love to start with some project, but I don't know what ruby can handle. I realize that a lot is theoretically possible, but I'm not sure what's practical. Any suggestions or examples? –  Von32 Jan 15 '11 at 4:24
    
As an example, my most recent Ruby project was a neural network machine learner. Before that I did a web app in Ruby on Rails. And before THAT I did a peer-to-peer chat client and server. You really can write nearly anything in Ruby. –  Ryan Ballantyne Jan 15 '11 at 4:30
    
Oh..! May I ask for where I could get info on p2p chat clients? I have two great ideas that I'd like to create down the road, but they're kind of difficult. Something like a chat client relates a lot, though..! –  Von32 Jan 15 '11 at 7:00

Ruby and C (or C++) can work together very tightly. There is a Ruby extension called RubyInline that allows you to write straight C or C++ and bundle it into a ruby class. It's trivial to install--as are most Ruby gems--but I have found it somewhat tricky to use. It is useful if you need to leverage the speed of C/C++.

C++ and Ruby share some features. Both support imperative and object oriented programming styles. Both have some metaprogramming capacity, although I think it shows that Ruby was designed from the ground up to support metaprogramming. Ruby is a lot more flexible.

One thing about Ruby is that it tricks you into doing things without really realizing that you're doing them. For example, I've noticed that I'm using aspect oriented programming techniques without really planning to, simply because that's a convenient way to use Ruby. Ditto reflexion. What I like about this is that in Ruby, I can ease into some of the ideas you learn about in a Programming Language Concepts course. The functional/aspect-oriented/reflective/metaprogramming features are there, but you can use them a bit at a time. Ruby is nice to you.

It's possible that this will actually help you learn C++. The features of C++ that give it more expressive power, like templates, might make more sense if you work with similar concepts in a more forgiving language.

share|improve this answer
  1. Learning Ruby will help you. It won't necessarily help you learn C++ faster but it will make you a better developer. The more languages you learn the more you will realize when language is not important and the better equipped you will be to choose a language which is a good fit for the problem you are trying to solve. You will probably spend some time typing semicolons in your Ruby and forgetting them in your C++, you will survive this.

  2. Ruby has some semantic similarities to C++, more so than say objective-C or lisp, but is it a significantly different language which will allow you to express behavior is significantly different ways.

  3. At least in my current market demand for Ruby programmers greatly exceeds supply. That won't necessarily be relevant to you by the time you enter the job market but I think it is a good indicator that Ruby is both relevant and valuable. Ruby has proven to be an excellent tool as a rapid development language which can still produce scalable and reliable applications. This makes it valuable for any environment where developer hours, and therefore developer efficiency, is a significant cost. Rails is certainly worth taking a look at if you are picking up Ruby. There are a number of good tutorials and resources available, the framework provides excellent guidance on how you should structure a web application, and you get visible results very quickly as you build a web interface. Additionally you will find a huge collection of open source Ruby Gems(libraries) available which provide implementations for common tasks and can serve as an introduction to different aspects of the language and framework.

  4. I'm not really sure what "hold hands" means to you. There are certainly many Ruby tools which use natively compiled extensions for hardware access, performance, or to provide access in Ruby to existing libraries.

share|improve this answer

I have to disagree with the crowd.

Ruby has a vastly different philosophy than C++. Many things that are commonly done in Ruby are either impossible or very bad practice in C-based languages. Trying to learn Ruby from a background that includes C++, Java, Perl, PhP, and C# with ASP.NET, I often find myself banging my head against the wall asking "but WHY?!" -- it's taking me considerably longer to get the "Ruby paradigm" right in my head, particularly when you throw in Rails and Cucumber and the other side technologies that inevitably get pushed into the learning queue when you start delving into actually making Ruby applications.

So I would say switching back and forth between paradigms can be confusing, especially when you're just learning both at once.

share|improve this answer

Learning Ruby will be a good thing for you. Since you are already asking this on Stack overflow, I wouldn't be worried that it gets you confused. Ruby and C++ are two good languages to learn.

Ruby is mostly used for web apps (see Ruby on Rails). A lot of big websites you use are using Ruby.

C++ has been (and is still probably?) the most used language in the world and it is great to learn to get the concepts. After C++ you can probably get any language. See this site about C++.

Good luck with coding!

share|improve this answer
    
I'd say that C is probably the most used, as it predated C++ by many years. –  the Tin Man Jan 15 '11 at 5:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.