This is the P2PU Archive. If you want the current site, go to www.p2pu.org!
You haven't posted any discussions yet.
Just curious, as I'm new to Ruby in general, but what is the difference between JRuby and the standard Ruby interpreter? I know the primary difference is that JRuby runs inside the Java Virtual Machinem while standard Ruby is written in C. I'm just wondering whether there's a specific difference that made it required for the course over the standard Ruby distribution.
You're absolutely right as far as the primary differences.
1. jRuby has the ability to import and call Java code from Ruby. Otherwise (ex. pure ruby program), the code is identical.
You run into problems with implementation, however:
1. jRuby must run java-compiled gems. Although the majority of gems are both in C and Java, you may run into availability issues or lagging versions. Rails originally had this problem.
2. Setting up Java server-side. A lot of consumer server providers have ruby set up out of the box.
For the purposes of this class, it's my understanding that we're deploying apps to Heroku, which doesn't currently support jRuby. Otherwise, it's up to you based on your specific project needs.
Good question!
So, is it safe to say that JRuby is mainly for Java programmers moving to Ruby?
If we're not currently working with any Java programs, and we're learning Ruby now as noobs, is there any merit to run JRuby?
I have a follow up question. (Though may not be that related...)
MacRuby? Is that also like JRuby? Running Ruby instead of Objective-C?
In this course, we'll learn Ruby and RoR, which will allow us to build web apps. How much of that knowledge can we apply to writing other programs? Like for Macs or iOS?
Apologies for answering your questions out of order, but I think it will make more sense this way:
When you write a program, that source code is not readable by your computer. It must be compiled into a lower-level machine code to be executed.
Why do one over the other? When you run Ruby code, you don't have to wait for the code to compile or recompile the code every time you make a change to the program. However, all the code has to be translated through the interpreter, and thus interpreted code is slower than compiled code.
The main differences with Ruby MRI (the default, or C Ruby), jRuby, or MacRuby is the language in which the interpreter is written.
To answer your question:
Yes, MacRuby is Ruby on Obj-C, just like jRuby is Ruby on Java.
As far as reasons to use the others: jRuby's main advantage is the ability to run Java code. With the 1.9 release of Ruby 1.9, jRuby is generally slower than cRuby (a.k.a Ruby). Unless you're running Java code or your hardware/server is set up for Java, there really isn't any advantage to running jRuby.
Programming for web apps is much different than programming for desktop or mobile. There's a much different set of constraints; generally you start to have to worry about low-level problems (hardware limitations, screen size/resolution, etc.)
Programming languages are like any other language. You can express the same idea in any language, but the way it is expressed is different. Mac/iOS is written in Objective-C, which is very different from Ruby. Every programming language has specific syntax and paradigms that may be incompatible. However, programming theory is transferable - learning algorithms, logic, loops, etc., can be implemented in any language. Additionally, you'll be more familiar with the look and feel of code.
Thanks for your detailed response to the OP. I wanted to add a couple of points to your excellent reply.
Before Ruby 1.9 was release JRuby was supposed to be faster than MRI for deploying Rails. The release of JRuby 1.6 may make that true again.
Most of this shouldn't matter for the purposes of this class. I think the eyu VM image and vagrant have everything nicely standardized so you won't need to sweat such details.
The first point is definitely good to keep in mind! If you are ever wanting to use Ruby and/or Rails with a business that's solidly a Java shop, know that you can run JRuby through a traditional Java application server.
More info about this via the warbler gem homepage.
I think you misunderstand: JRuby is Java implementation of Ruby. What this means is that JRuby is a runtime/compiler that runs your Ruby code. But JRuby itself is coded in Java.
There are some Java links; primarily, that there are ways to call Ruby code from Java or vice versa, but it isn't a special version of Ruby for Java programmers or anything.
One merit to running JRuby is that it runs on multiple types of operating systems; I may be wrong about this, but it seems that JRuby is the best choice for people on Windows.
MacRuby is like JRuby, but instead of being coded in Java, MacRuby runs on Objective-C. Again, the language you program in is not different; It's the same Ruby. But the programs that run or compile your code are made using Objective-C rather than C or Java.
As for your last question, learning any programming language will teach you about writing programs in another language, especially if you've never programmed before. Learning Ruby will help you start to think about how programs are structured, and many of the constructs (like conditionals, looping, methods, classes, etc) are common among many languages; conditionals, for example, are pretty much required for any language to be useful at all.
Learning Rails in particular isn't quite as directly helpful, but is still useful. Rails is an MVC framework (Model-View-Control). MVC is a pattern of organizing a program that is very common in making web applications, although it is also used elsewhere.
The biggest thing you'll get from learning Rails is learning how to use a library to create an application. Whenever you make a program elsewhere, you will probably have to learn some other framework or library to help you create your program quickly and effectively. Learning Rails will give you experience in learning how something someone else made can help you program.