Live data from Hacker News

Why I switched from Ruby back to C++

chrismdp.github.com

71–80 of 100 posts

Re: Why I switched from Ruby back to C++

#71

This post should be titled, "Why I fucked up by choosing Ruby to write a game." - Or "What the fuck was I thinking" I love Ruby, I spend a lot of time writing it. I also write kids games for iOS. I would never consider Ruby(in it's current state) a good language to write a game in. Anyone who would has clearly; never written a game before; or never used Ruby for anything serious before. I agree with the other posters…

This post is mean, and has no place on Hacker News. It's fine to say there's no reason to ever use Ruby for a game, but it seems like the main purpose of your post is just to call into question the OP's intelligence and experience.

It is mean. That's nothing wrong with trying new thing even if most people are saying it's the wrong choice. And there's no shame in failing in the process. People will say, I told you so. But you never know until you have tried it, and you would learn a lot in the process. And sometime you might just have a break-thru.

Re: Why I switched from Ruby back to C++

#72
post #38

Earlier quoted context omitted.

For what it's worth, I help to organize a fairly active Ruby group, and I am certain that, if not zero, nearly zero of us would make this proclamation. In fact -- and I mean not to attack you, but just to illustrate how incredulous I am -- I tried to think of a reason there might be for you to fabricate or exaggerate that story. I don't really think you did, but my mind went there.

Didn't make it up. No reason to do so, although I suspect if I spent some time on HN I could find some posts about Ruby perf that don't jive with reality. But I will say this, do you think this guy made up his post about using Ruby to try to write this game? If you don't think it fabricated, do you think he's alone? I do think there is a fundamental problem, especially with respect to perf, that a lot of people have…

> But I will say this, do you think this guy made up his post about using Ruby to try to write this game? If you don't think it fabricated, do you think he's alone?

I neither think his story is fabricated, nor do I think he's alone. (I didn't say I really thought your story was fabricated, either.)

> While I appreciate that none in your Ruby group would think this, I'd also ask why do they believe this?

I don't know that we would all choose C++, were we building a game, but the performance of Ruby is frequently a topic of discussion. We are lucky enough to have several members that have significant experience working with/around Ruby performance, and they share their knowledge. In other words, were you to choose one of us at random, we would more likely be able to tell you why Ruby is not a good idea, as opposed to why C++ is.

Re: Why I switched from Ruby back to C++

#73
post #48

Earlier quoted context omitted.

This post is mean, and has no place on Hacker News. It's fine to say there's no reason to ever use Ruby for a game, but it seems like the main purpose of your post is just to call into question the OP's intelligence and experience.

I thought he was just calling into question the link-baity title. The title is designed to be controversial as people don't like their favourite programming language to be slandered, thus they will be obliged to read the article so that they can defend their baby. Using link bait as a title is contrary to HN guidelines, so if anything, it is the article that does not belong on HN, not the grandparent comment.

Fair enough: perhaps I should have been more specific about the context and thought of a better title.

Re: Why I switched from Ruby back to C++

#74

This post should be titled, "Why I fucked up by choosing Ruby to write a game." - Or "What the fuck was I thinking" I love Ruby, I spend a lot of time writing it. I also write kids games for iOS. I would never consider Ruby(in it's current state) a good language to write a game in. Anyone who would has clearly; never written a game before; or never used Ruby for anything serious before. I agree with the other posters…

While what you say may be 100% true you might be shocked by the number of Ruby and Python devs I talk to who tell me that Ruby can do anything that C++ does if you're even a half-decent Ruby or Python dev. I've literally asked people, "What about something like Gran Turismo 7?" And I've literally been in rooms where every dev there (none game devs, all web devs) basically said if they were writing it in Ruby it could…

It's not because it would not be wise to write a Gran Turismo 7 in an interpreted language such as ruby or python that writing any game with such language wouldn't work. Not all games have such specific requirements as Gran Turismo 7 where huge teams want to extract the most power out of some very specific piece of hardware.

Nowadays it gets easier and easier to use interpreted language as the hardware gets more and more things delegated. For some games, it may be better to do everything in C/C++, some others C/C++ with some interpreted language on top for some parts, and some others whatever language you prefer.

Given higher level language usually help you write code faster, I would definitely give up some performance (which is not really visible usually) in exchange for some efficiency. Even for some 3d game. But then again, not everyone is writing the next Gran Turismo :)

Although I can't speak of ruby or its vm since I never used it, but have used python + OpenGL or pygame quite a few times.

In his case not only performance suffered too much from ruby but writing code in ruby didn't make him more efficient. So ruby didn't bring enough value.

Re: Why I switched from Ruby back to C++

#75

Earlier quoted context omitted.

Heh :) I'll take the bait :) I've written lots of Ruby for things that are serious (large websites with lots of traffic), and I've worked as part of a team that built on commercially available games in C++ that sold lots of copies. Ruby has come along enormously recently, especially with 1.9.3 and the other flavours that are out there now. I thought it might be worth trying it and advancing the state of the possible.…

The title of your self-submitted post is misleading. The bait post you're referring to stated the obvious, albeit in highly charged language. It's one thing to choose the wrong language for a project. But having done that, please don't submit a post that suggests expert knowledge or deep experience in Ruby. For what it's worth, I use both Ruby and C++. I would probably have gone with Qt if I wanted to build such a ga…

Reasonable comments - thanks for the HN feedback. It's not for me to say if I'm an expert in Ruby or not, but I don't think attempting something to push some boundaries is mutually incompatible with experience or knowledge. If I'd succeeded, it would have been awesome for Ruby (far and away my favourite language).

Re: Why I switched from Ruby back to C++

#76
post #50

Earlier quoted context omitted.

I suppose it does: but it's the honest truth. I have two months of ruby code that's rusting now, and it was quite a difficult post to write.

A more honest title would by "Why C++ is better than Ruby for game development".

Fair enough: thanks.

Re: Why I switched from Ruby back to C++

#77
post #34

Earlier quoted context omitted.

I suppose it does: but it's the honest truth. I have two months of ruby code that's rusting now, and it was quite a difficult post to write.

That was not the point of my comment. It was a realization of how it came across (aka how I got here). My main point, however, and this in reply to your post (that I have no doubt it was honest and on the back of some tough thinking) was that you simply started using the wrong tool for the job and then, realizing this, found a more appropriate tool. Nothing wrong with that, but your post came across as "Ruby sucks so…

That's a shame: I didn't mean to come across like that. I love Ruby: it's far and away my favourite language. Anyone reading the rest of my blog can see that very quickly.

And I'm not sure Ruby will be the wrong tool forever: there just isn't a way through some of the environment and implementation issues (yet).

Re: Why I switched from Ruby back to C++

#78
I think the author's problem is not choice of language, but rather choice of architecture. He notes that he was passing a lot of float objects between Ruby and C, eating up valuable garbage collection time. The problem here is not the bridging of Ruby to C, but rather the wrong choice of data structure and design. Ruby should pass high level requests to the (C-based) rendering backend; instead of passing "push a vertex at (1,2,3)", the requests should be like "draw a spaceship at (1,2,3) flying forward with velocity vector (1,1,0)". The means you're going to be writing the core of your game in C, but things like AI and level design will all be handled in Ruby. (I think pretty much every commercial game works like this.)

Another thought is to treat simulation and drawing as separate concerns. Every 1/60th of a second, interrupt the simulation and draw the current state to the screen. This means that you can do things that take more than one frame to calculate without reducing the framerate. (Does Ruby have a good coroutine library?)

Rewriting your entire game because your design is bad is silly. Switching to C++ just makes your mistakes less obvious. (And now you'll be debugging memory leaks and segfaults instead of slow frames. If only there was One Perfect Tool...)

Re: Why I switched from Ruby back to C++

#79

I don't why this needs to be an either/or proposition. Write your program in Ruby. Where it needs speed, write the pertinent bits in C++. I've done this before with Ruby and C. Two great tastes that go great together!

I looked at this, but the stop the world GC would still kill the frame rate from time to time sadly. Also there's a large amount of inefficiency in the object translation layer between the two languages.

Re: Why I switched from Ruby back to C++

#80
post #22

Earlier quoted context omitted.

I always got a "stay on the golden path and away from ObjC++" vibe from ObjC++, kind of like trying to ask Rails to do database stuff without using ActiveRecord in 2008. You can easily write C++ code without having to bridge ObjC's object system to C++'s object-and-generics system: provide a simple C API to your C++ libraries. But the other thing is, one reason to do ObjC at all is to avoid all the heartache that com…

Obj-C++ is working well for me so far and the STL is much better than Obj-C's awkward and slow collection classes for anything that needs to run fast or that requires significant algorithmic complexity.

One of the nice things about going back from Ruby to a C language is, it's hard to think of anything you could do in the C language that would be as non-performant as Ruby. As slow as ObjC's collections are, they're faster than Ruby's.
Post reply on HN