Live data from Hacker News

Game Programming Patterns – Bytecode

gameprogrammingpatterns.com

31–40 of 73 posts

Re: Game Programming Patterns – Bytecode

#31

http://c2.com/cgi/wiki?GreenspunsTenthRuleOfProgramming "Any sufficiently complicated C or Fortran program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of CommonLisp"

Are there any good real-world examples for this?

The browser.

Re: Game Programming Patterns – Bytecode

#32
post #15
post #8

Earlier quoted context omitted.

I used to work as a programmer in a game company shipping on consoles+PC. The first time we embedded a scripting language in our engine to be used by the level designer's they surprised the whole team with their new found 'toy'. This was great and lessened the burden on programmers. Fast forward to first milestone (everyone crunching) and the milestone was delayed ... The level designers (not being programmers) had i…

I get the feeling that "crunching" is to blame for the bugs a lot more than the engine's newly-integrated scripting language.

I didn't imply the scripting engine was to blame. It's unchecked use and the lack of tools for debugging it were mostly to blame ... of course crunching amplified all these problems

Re: Game Programming Patterns – Bytecode

#33
post #22

Earlier quoted context omitted.

I am beyond very confident that the solution set containing embedding Python, JavaScript, AngelScript, and Lua covers just about everything in the problem set a game programmer reading that book is going to encounter. And if it doesn't, it's not going to be improved by rolling your own.

Hi, I wrote that chapter. I also wrote the AI system for Hatsworth. There is absolutely no way we would have embedded Lua on a DS! What we did do was write a tiny little bytecode VM as described in the chapter. The level editor I wrote[1] let designers author behavior using a little UI. It then compiled that to bytecode. It worked like a charm if I may say so. Unlike a full-featured language VM, we didn't have to dea…

As we say in Quebec: 'Din Dents...'

Re: Game Programming Patterns – Bytecode

#34
post #4

In what situation would "just embed python/lua/js/etc." not be the appropriate solution to this problem?

You saw them a lot in old games (the kind likely to be written in assembly), because not even C, let alone a general-purpose scripting language, was acceptable for performance reasons for quite some time, yet there has always been a need for greater abstraction and expressive power. Look at any Japanese RPG of the 80s and 90s, for instance, and there's probably a simple bytecode VM (or state machine, if you prefer) f…

> Even in 2014, I'm sure there are plenty of people out there still using Pentium 4s and Windows XP.

Don't forget low-end mobile devices.

Re: Game Programming Patterns – Bytecode

#35
post #22

Earlier quoted context omitted.

I am beyond very confident that the solution set containing embedding Python, JavaScript, AngelScript, and Lua covers just about everything in the problem set a game programmer reading that book is going to encounter. And if it doesn't, it's not going to be improved by rolling your own.

Hi, I wrote that chapter. I also wrote the AI system for Hatsworth. There is absolutely no way we would have embedded Lua on a DS! What we did do was write a tiny little bytecode VM as described in the chapter. The level editor I wrote[1] let designers author behavior using a little UI. It then compiled that to bytecode. It worked like a charm if I may say so. Unlike a full-featured language VM, we didn't have to dea…

That's really interesting, thank you for mentioning that. That's totally in my "just about", for sure--but this isn't 2008 (even the 3DS has 128MB of RAM) and this doesn't exactly strike me as the sort of book that somebody who already has a console devkit is going to be reading. "A bytecode interpreter" seems to me to be something that that guy (i.e., you) is going to have sussed out entirely, whereas somebody who actually needs a book like this is in just about every case going to be getting off in the weeds building something instead of going off the rack.

(That said, no-GC AngelScript uses under a megabyte of RAM on ARM; before I switched to libgdx and decided that I could do without supporting the Galaxy Nexus I'd spent a lot of time examining it. It certainly might be tight on the DS, but on any modern system, I think you're probably cool.)

Re: Game Programming Patterns – Bytecode

#36

Earlier quoted context omitted.

You saw them a lot in old games (the kind likely to be written in assembly), because not even C, let alone a general-purpose scripting language, was acceptable for performance reasons for quite some time, yet there has always been a need for greater abstraction and expressive power. Look at any Japanese RPG of the 80s and 90s, for instance, and there's probably a simple bytecode VM (or state machine, if you prefer) f…

> Even in 2014, I'm sure there are plenty of people out there still using Pentium 4s and Windows XP. Don't forget low-end mobile devices.

Eh, angry birds runs on Lua. Your point was?

Re: Game Programming Patterns – Bytecode

#37

Earlier quoted context omitted.

You saw them a lot in old games (the kind likely to be written in assembly), because not even C, let alone a general-purpose scripting language, was acceptable for performance reasons for quite some time, yet there has always been a need for greater abstraction and expressive power. Look at any Japanese RPG of the 80s and 90s, for instance, and there's probably a simple bytecode VM (or state machine, if you prefer) f…

> Even in 2014, I'm sure there are plenty of people out there still using Pentium 4s and Windows XP. Don't forget low-end mobile devices.

Low-end mobile devices these days have 80+MB of RAM available to an application and the downsampled assets that I assume you're using on them 'cause you're a pro leave you with a pretty large chunk of RAM to work with.

I sorta doubt there are many games targeting these devices (and, more particularly, the people who still use these devices in 2014) in the first place, but even fewer which are pushing their headroom so hard that, if they decide they need what amounts to a scripting language, they can't fit one in off-the-rack.

Re: Game Programming Patterns – Bytecode

#38
post #4

In what situation would "just embed python/lua/js/etc." not be the appropriate solution to this problem?

You saw them a lot in old games (the kind likely to be written in assembly), because not even C, let alone a general-purpose scripting language, was acceptable for performance reasons for quite some time, yet there has always been a need for greater abstraction and expressive power. Look at any Japanese RPG of the 80s and 90s, for instance, and there's probably a simple bytecode VM (or state machine, if you prefer) f…

"At the same time, I think you could extract 99% of the performance benefits of the bytecode approach if your language had a well-defined heapless, stackless "tasklet/microthread" subset that centered around mutating existing objects"

Oh hey, I think you just described asm.js

Re: Game Programming Patterns – Bytecode

#39
post #36

Earlier quoted context omitted.

> Even in 2014, I'm sure there are plenty of people out there still using Pentium 4s and Windows XP. Don't forget low-end mobile devices.

Eh, angry birds runs on Lua. Your point was?

I think the point is you don't generally need something with the extreme power and flexibility of lua to simulate comments like yours. A simple bytecode with 5 or 6 instructions should do. And it'll be performant enough to run on a casio calculator watch at full speed!

Re: Game Programming Patterns – Bytecode

#40
post #36

Earlier quoted context omitted.

> Even in 2014, I'm sure there are plenty of people out there still using Pentium 4s and Windows XP. Don't forget low-end mobile devices.

Eh, angry birds runs on Lua. Your point was?

Angry Birds is not a terribly involved or demanding game, and the hard part, 2D physics simulation, is handled in C by the Box2D library anyway. It requires no real-time control, you just aim the bird and watch the reaction. You could half or quarter the framerate and add enormous interframe jitter and the game would play exactly the same. If you tried to do the same thing with an demanding twitch action game, it would quickly become unplayable.
Post reply on HN