How is Ruby? JRuby?

Started by
8 comments, last by WilleRoberts 13 years, 4 months ago
So first, a brief on my background and what I want to do. I am a freshman undergraduate (planning on a CS-minor) just finishing up my first CS-programming class (C++) and I now want to go actually make something. I have an idea for a sort of "game shell" which I am to be something which will allow someone to create a game without having to program hardly anything (mostly changing numbers in a file which stores no code, just numbers and names). It will be focused on a trading simulation, but the way I have it planned out, I think it could have the flexibility to do more. The mechanics I plan on are based on printing out a "menu" to the terminal, and taking inputs for commands, and reprinting it, which right now is the only way I'd know how to do it. The key with this project is that I want it to be expandable as my knowledge increases without having to redo everything over again.

Originally I was planning on doing this in C++ because that's what I've learned in school. However, as we're ending the semester and going into data structures, we're having these projects where we have to deal with leaking memory. This is not what I want to spend my time working on when doing my project.

So, I figure I can choose a new, "easier" language, and in addition throw a new skill on a resume (as well as talk about the whole project in general). I went and did some research and came to find that Ruby is known to be very easy. I was curious about JRuby as well because I hope eventually someone else might find what I come up with interesting too and might want to create something from it, so the flexibility of allowing Java would be good.

Anyway, the key features I'm looking for are:

-Simple syntax
-Garbage collects for me (I just don't get data structures)
-Modular
-Not dreadfully slow

Are Ruby/JRuby good choices? Are there other good choices I should be sure to check out?

Beyond this, I would like to know if there's a way I can create a GUI for it using this language? Next semester I will take an Operations Research class in which we'll learn Visual Basic, so if there's no way to make a GUI would I be able to integrate VB into is somehow.

Thanks guys!
Advertisement
Something you should know about Ruby is that it has no specification, it is based on a reference implementation. At a more advanced level I found it to be very confusing and when I found out that there is no specification I basically gave up.
Do you mean that you don't declare something as an "int" or something like that in Ruby the way you do in C++?

How problematic does this become?
Quote:Original post by WilleRoberts
Do you mean that you don't declare something as an "int" or something like that in Ruby the way you do in C++?

How problematic does this become?

No, read what a specification is. Basically there is no document that tells you what a piece of code is meant to do.

EDIT: Just found out that a draft exist. (Last update 11/27/2009)
Ruby is a robust, full language. It has many libraries that ease development, and with RubyGems, you have even more! It's easy to pick up, with many tutorials, an easy syntax, and clear object-orientated ideals.

I cannot say anything about JRuby, however.

Quote:Original post by WilleRoberts
Do you mean that you don't declare something as an "int" or something like that in Ruby the way you do in C++?

How problematic does this become?


You do not have to. And not problematic at all. It's just different coming from a statically typed language. Think about the function (c-based pseudo code):

AddTwo(a, b) { return a + b }

Using a dynamic typing system, such as ruby, a and b only have to have a + operator. This includes integers, floats, doubles, and many other math objects. Using a static typing system, such as C++ or Java, you would have to define a form of the function for each type. Wikipedia actually has a good article on typing.
http://en.wikipedia.org/wiki/Type_system
Quote:Original post by dragonhawk360
Ruby is a robust, full language. It has many libraries that ease development, and with RubyGems, you have even more! It's easy to pick up, with many tutorials, an easy syntax, and clear object-orientated ideals.

I cannot say anything about JRuby, however.

JRuby is basically Ruby running on JVM meaning you get to use all the libraries available to Java.
Quote:Original post by dragonhawk360

AddTwo(a, b) { return a + b }

Using a dynamic typing system, such as ruby, a and b only have to have a + operator. This includes integers, floats, doubles, and many other math objects. Using a static typing system, such as C++ or Java, you would have to define a form of the function for each type.
This isn't strictly true.

What dynamic typing allows you to do is:
a = 17;a = "Hello World"print a[0];a = [3.14, 7, 0, "Hello World", [1,2,3]];print a[3]print a[4][3]a = new HttpServerprint a;a = a + "Hello World"

Some of these may fail during runtime, or they may be even monkeypatched.

With statically typed systems, once a variable is declared, its type is also defined. An a will be an int during its entire existence.

The equivalent can be obtained in statically typed languages by only working with some generic base type. In Java, it would be Object. But such approximations are clumsy and cumbersome.


Dynamic typing, lazy evaluation and similar techniques also expose some interesting properties. Consider:
function f() {  return f();}
What is the type of result? (this is not necessarily infinite recursion). Is it even a type? And if it's not, then what is it?
I wanted to come back and ask again about my choice of language? Is Ruby a good choice? Should I look at any others?
You can try C# or F#. C# has syntax very similar to C++, but you don't need to worry about memory management (ex; leaking memory). F# is a functional language which has syntax similar to OCaml (and some features similar to Ruby).

Both are languages can be used with XNA 4.0 (Game Dev API) and both take care of memory management so you don't have to.

Beginner in Game Development?  Read here. And read here.

 

This topic is closed to new replies.

Advertisement