0

A problem is what Ruby does at run time. It is an interpreted language as compared to C, which is a compiled language. How feasible would it be? Ruby is getting faster every year, but how? What is being done? Are the methods we use a lot (each, map, etc.) being written in C, speeding up everything? Is the long-term goal to let Ruby be as fast as C by being C? What are the biggest problems when trying to convert what is written in Ruby to C, then getting it run? Or, does this question not make any sense? If so, why?

sawa
  • 165,429
  • 45
  • 277
  • 381
David
  • 7,028
  • 10
  • 48
  • 95

1 Answers1

5

Ruby gives you a lot more functionality than C. For example, one of the downsides of programming in C is that the programmer has to do the memory management. This requires time, self disipline, and skill. Lack of any of those results in bugs and security holes. But it produces fast runtimes because it is tailored to a specific case rather than a general one.

With Ruby you can concentrate on the application, rather than the mechanics. It does the memory management for you, and this means (generally) fewer bugs and more secure code. But there is no free lunch - you pay for that with increased runtime.

C is a static language - decisions on types and operation have to be taken at compile time. Ruby is a dynamic language, where decisions can be deferred until runtime, which leads to a more flexible and reactive language. Comparing C and Ruby is like comparing apples and oranges.

Sure, you can do all that in C, Ruby is written in C as you point out, but it is a lot of work and you had better be a damn good programmer.

cdarke
  • 42,728
  • 8
  • 80
  • 84
  • I see. Is it correct to say that Ruby does the memory management for you, but it does it very generally. It makes sure it plugs all the holes, including the ones that you wouldn't even run into. This is in contrast to C, where memory management is handled completely by you, so you wouldn't waste time on areas and holes that you know your code won't fall into, so the memory management is tailor-made to your code. Ruby is much more general, which takes time, whereas C streamlines because it doesn't have to waste time on the extras. Yeah? No? – David Jun 13 '13 at 07:03
  • @David: absolutely. In practice it is not so much "areas that you know your code won't fall into", more "areas that you *think* your code won't fall into". Ruby covers all the bases, with C its up to you. Also remember that this is only one difference I used as an example. I didn't mention huge areas of functionality that would be a pig to code in C, like Object Orientation. – cdarke Jun 13 '13 at 07:35