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
Dona Hertel
9,459 PointsIs this VM needed if I'm using Linux? I'm not sure what I'm gaining from doing this.
I'm do the rails development track. I have a Linux laptop with rails sucessfully installed on it. So I'm not sure why I need to install rails on a VM on my laptop (the video isn't clear what the purpose of the VM is for). Is it possible to just build the app straight on my laptop?
3 Answers
Maciej Czuchnowski
36,441 PointsIf you're comfortable with installing and switching between different versions of Ruby and Rails (RVM), you have Git and other necessary tools working for you, you don't need the virtual machine. They provide virtual machines for each course, because when you do the given course using different versions of Rails (example: trying to do the Treebook application using Rails 4.1) and some other gems, you might encounter some problems (some small, some huge and frustrating) along the way or your output may be different from what you see in the videos. Depends on your immunity to frustration and your linux tinkering skills ;).
Maciej Sitko
16,164 PointsVM is a shortcut for Virual Machine and it is a way of executing code for high level languages such as Ruby, Python, and for instance Java.
High level languages are characterized by the fact that they are much slower in execution than the low level ones (such as C), that is manly due to the fact that, example, by VM they are compiled to bytecode, instead of binary code.The advantage of that is they are easier to use, and more understandable (overally, that kind of a language is more human readable).
In other words, the high level way of doing things is a bit longer to be executed, and the chucks of information are bigger, harder to be processed, need to have fictional virtual machine, to use something machine doesn't use. Because, unlike binary code, bytes don't directly go to the CPU's Arithmetic Logic Unit that crunches these numbers. The kind of a binary code that low-languages use, on the other hand, is compiled by compilers, there is no dynamic way of doing things, you write the code, and need to use compiler; no interpreter or virtual machine allows you to do that on the runtime, dynamically. This is why C is a static programming language, it is not run on runtime by virtual machine.
The way Virtual Machine works, for instance, is:
---> SOURCE CODE ---> BYTE CODE ---> VIRTUAL MACHINE
Moreover, The difference between Virtual Machine and Interpreter is that Interpreter executed/interprets the code one line at the time from the source. It is opposite to continous work done by Virtual Machines, that reduces the initial interpretation lag. In short, VM is a fictual machine that runs the programming language environment on runtime to compile byte code, using instructions by method known as just-in-time, also called as dynamic translation. It is designed to combine interpretation with premature code execution, which is called ahead of time compilation.
So, explaining the above arrow example of how VM works; Source code is compiled ahead of time to the bytecode, and then undergoes just-in-time compilation to the code readable by machine (virtual machine code). On the runtime, only a specific, small portion of a progoram is executed this way, this reduces performance lag, compared to running a program all over again, line-by-line execution of Interpreter.
VM aims to improve performance of a given language, when compared to an ordinary Interpretation.
Hope that it helped.
Dona Hertel
9,459 PointsI'm pretty comfortable in figuring things out on my own and I have Rails version 4.1.5 installed. So I'll go ahead and just do without the virtual machine (I know what one is).
Maciej Czuchnowski
36,441 PointsGood. Rails 4.1.5 is fine for Todo application and its related courses. For Simple Rails Application (treebook) you need Rails 3.2 or else you will have bad times :). That's the only major thing to remember.