Page 1 of 1

Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 2:06 am
by Levio91
Why does c++ need a compiler, and html doesnt? does ruby need a compiler, if not then what did I even download?

Link to what I thought was a ruby compiler. http://www.ruby-lang.org/en/downloads/

a confused person.

Re: Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 7:39 am
by ismetteren
Im am not an expert, and a can give you the fully correct explanation.

But basicly; when you compile a c++ file, the compiler makes it into an executeable .exe file, wich your computer can run. HTML dosent have to be translated into anything else for your browser to read it.

I am not sure if ruby gets compiled...
(i dont know if the thing you linked to is a compiler. It might be a libary(a set of basic funtions))

Re: Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 8:13 am
by Moosader
ismetteren wrote:Im am not an expert, and a can give you the fully correct explanation.

But basicly; when you compile a c++ file, the compiler makes it into an executeable .exe file, wich your computer can run.
Also note that this is required because Windows, Mac, and Linux all read different file types when they run, so they would have to be compiled specially for each.

A compiler takes your code and essentially converts it into Assembler code. The machine doesn't understand C++, but it understands Assembler and Machine Language.

Some languages are scripting languages and, instead of a compile, they have an interpreter. An Interpreter will not generally compile or mess with the code beforehand, it just starts at the starting place, reads each line, and executes it as it comes up. If something's wrong, THEN it complains. Visual Basic, Python, and Lua are scripting languages.
No idea about Ruby.

Re: Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 8:17 am
by exor674
Ruby is a scripting language too.

Technically, you could think of a browser as the "compiler" for HTML, if you use the term compiler loosely.

Re: Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 8:19 am
by Falco Girgis
Ruby is interpreted, not compiled. It's a scripting language just like Perl, Lua, Python, etc.

HTML is "interpreted" by your browser.

Re: Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 3:48 pm
by Andy K.
I've only ever used Ruby in scripts, and then had a language or program use the scripts, but never complied it to an executable. Although, I am pretty sure it can/has be done. I'd have to research more, Ruby is not one of my go to scripts.

Re: Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 3:51 pm
by Falco Girgis
Ruby, Perl, Lua, and those kinds of scriping languages can be "compiled" into executables in a sense. It's not the same as compiling a C/++ program. You are basically packaging your script with its executable interpreter into a single executable file. Your script is still being interpreted. It's not magically becoming a compilable language.

Re: Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 3:54 pm
by Andy K.
GyroVorbis wrote:Ruby, Perl, Lua, and those kinds of scriping languages can be "compiled" into executables in a sense. It's not the same as compiling a C/++ program. You are basically packaging your script with its executable interpreter into a single executable file. Your script is still being interpreted. It's not magically becoming a compilable language.
yeah that's kinda what I meant, sorry I wasn't more clearer :lol:

Re: Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 6:37 pm
by avansc

Re: Why does c++ need a compiler? Does ruby use a compiler?

Posted: Tue Dec 02, 2008 7:29 pm
by mllarson
A scripting language is interpreted by another program. In other words, it is "looked at" by a program to see what tasks are supposed to be done. This type of language is slower than compiled. A compiled language is one that is looked at by a compiler program, and then translated into the machine's native instruction set. Certain scripting languages like PHP have a compiler to make it faster to run. Basically scripts are used to make anything that you'd want to run on any type of computer. Compiled programs, however, only work on the CPU type they were compiled for. Hope that helped more than it confused.

-Matt