munificent / game-programming-patterns

Source repo for the book
http://gameprogrammingpatterns.com/
Other
4.02k stars 495 forks source link

Other programming languages #268

Open leissler opened 9 years ago

leissler commented 9 years ago

Hi,

fantastic book and great examples from the gaming domain. I'm currently professor teaching in germany in the area of game development and plan to incorporate some of the examples into teaching for students to get a feeling for how certain problems should be tackled.

As all examples are C++, I'd be wondering if you plan to make them available in other programming languages too? C# comes to mind (with Unity3D being a strong backer) or Java, Lua, or even JavaScript.

I agree that the C++ examples are quite generic, but I think when having explicit memory management and destructors out of the way, they could look even more clear.

Any thoughts on this?

All the best Martin

AlexKalopsia commented 9 years ago

I started reading the book really excited, and as soon as I got to the first Command chapter, I felt very intimidated by the code. I have no C++ experience, but I usually easily follow code. I found the last part (where you write in JavaScript) so much clearer that I wonder what's the real benefit of going with C++. C++ programmers will not have any difficulty reading C# / Js, but this is not true the other way around :)

In any case, great job, I'll try to follow as much as I can

leissler commented 9 years ago

There is a part of the book using JavaScript? I'm surprised as I've seen only C++ Can you tell me where you found this? Bob, any chance you could comment on this topic?

AlexKalopsia commented 9 years ago

it's a very short passage at the end of the chapter Command.

leissler commented 9 years ago

Ah yes, thanks. Now I spotted it. ITs really just for explaining how much easier this could work in a modern language with first-class functions and closures. The stuff Bob wrote there on C++ being clumsy for such a job, however, is true for several patterns and would be a valid and strong argument to create a JavaScript or C# Version of the book. But it seems that not too many people are interested in this.... including Bob ;)

munificent commented 9 years ago

Sorry for the long delay! I've been busy working on the print version of the book, so I haven't checked GitHub in a while.

I have considered having examples in other languages. In most cases, they would be fine and likely be shorter and easier to read for a lot of people. Some patterns, like Object Pool and Data Locality, are hard to translate to a higher-level language. You really need precise control over memory layout, especially for the latter.

But one option would to just not translate all of the code to other languages, just ones where it makes sense. If I was looking for more things to do on this book, this would be pretty high on the list. But, right now, I'm trying to focus on finishing it, not un-finishing it, so I'm afraid I'm not going to make any major changes. I've been working on this for five years. I've worked on it every single day (except for one!) for 473 consecutive days. I still have to finish off the eBook versions, and then get that and the print version out where people can get to them.

After that, I need a break!

I'll leave this open because it's a good idea, but it will likely be a good while before I consider getting around to this. I hope you understand. :)

Nearoo commented 8 years ago

...I'm just going to leave this here in case you consider updating the examples with other languages. There's a repository with an amazing amount of programming patterns and examples in Python: https://github.com/faif/python-patterns . You might want to check it out if you're searching for Python equivalents for patterns described in the book.