QUOTE(cobaltchloride @ Feb 27 2005, 03:00 AM)
No. Ruby is much easier than c or c++. Let me know how u fare in learning it.
Is Ruby much easier to learn than C/C++?
Well, that depends on how much you already know about those languages. I use Ruby from time to time, but I can't see it replacing my heavy usage of C/C++ programming. It's good for scripting, and can sometimes outperform PERL. The only downfall I guess, is that it wasn't around sooner.
Now I haven't actually encountered any means of compiling it into binary, I just use .rb files filled with scripting commands to perform simple tasks and execute it as if it were a binary file. This method is considered an interpretted language, which is basically scripting but Ruby does claim to be an OOP language and can be compiled I assume.
Just with those commands listed above, you can run Ruby when it's installed by console just by typing ruby, you then do:
CODE
1.upto(10) {|x| puts x}
^D
Should probably explain this code:
The above sets the first number to start from, in this case number 1.upto(10) suggests that it starts at 1 and goes upto 10, we assign it with x, when then print x out with puts in C++ terms:
CODE
for(int x = 1; x <= 10; x++)
cout << x << endl;
Remember ^D = Ctrl+D and will perform the typed commands and exit when finished.
So the second code will be displayed:
CODE
puts "abcdef".reverse
^D
How we do this in C++, well to make it easier, we'll use the algorithm header file to include the reverse function, but remember there are other ways, and quite possibly more efficient than this method:
CODE
#include <algorithm>
#include <iostream>
using namespace std;
int main(void)
{
char szString[] = "abcdef";
reverse(szString, szString + strlen(szString));
cout << szString << endl;
return 0;
}
Cheers,
MC
Reply