game programming language capabilites

Started by
11 comments, last by Stroppy Katamari 10 years, 7 months ago

what capabilities would one want in a high level programming language designed just for writing games?

high level as as in keywords / opcodes like BeginScene, and DrawIndexedPrimitive.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

Good support for composition, probably. Beyond that, I'd have to give it more thought.

[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

No single language can handle all the challenges in games well. For rendering and math you want to be close to the hardware, something without a stop the world garbage collector, etc.. But for game logic it's entirely different, you want a high level language that ideally has higher order and first class functions, suitable for writing dsl's, etc..

Instead of looking for the one true language, go learn 5-6 different languages so you can pick the best tool for the job, instead of forcing the tool you know to do a job it's not designed for (not that you are doing that, it's just a general statement).

Chris

When I try to imagine a language written exclusively for writing games --- and I have to try really hard for that --- I come up with a language that has absolutely nothing to do with rendering or animating or user interfaces or audio or anything else.

A language written just for writing games is going to be a scripting language within an existing game engine. It would control other systems through a mix of metadata such as animation graphs, something along the lines of an event and response driven language, or possibly a functional language that manipulates a block of game data.

The closest I can come to imagining such a language would be a redacted form of Lua, but even that doesn't fit the question.


As snacktime points out above, good games are built up with many different languages and tools. An engine might use two, three or four languages by itself, and one or two more for scripting systems that do all the fun gameplay stuff.

well it seems i have come upon the opportunity to create my own game programming language.

i have three language projects going on at the moment.

one is a macro processor / code generator that uses a syntax designed to minimize keystrokes to generate c++ code.

the second is a virtual machine run time module with high level opcodes like beginscene

the third is another VM rtm, with p-code compiler and its own proprietary syntax and instruction set., used for copy protection schemes, and is not germane to this discussion.

so i'm not looking for a single [existing] language that can handle all the challenges in games well, i'm not looking for the one true [existing] language...

i guess i'm... thinking of making one.

i took formal languages and systems and all all that stuff. so i could actually go the metal with a full blown compiler if i wanted to. but i don't really think that's necessary, it would be a LOT of work, and i'd be caught in a never ending cycle of keeping up with the jones as far as features / capabilites vs other languages. Much better to take something like MS C++ 2012 and work from there.

I've been looking into game engines vs libraries, code design difficulties experienced in games, and ways to speed up typing in code.

The short story is that it looks like libraries are more flexible than engines, many code design issues appear to be related to specific types of use of specific syntax in specific languages, and a macro processor / code generator inserted upstream of the compiler in the build pipeline will create faster running code than a VM implementing the same syntax, and will be much faster to implement than a full blown machine code generating compiler (especially for me, since i've already written two of them! <g>).

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

what capabilities would one want in a high level programming language designed just for writing games?

high level as as in keywords / opcodes like BeginScene, and DrawIndexedPrimitive.


The most important thinks I can imagine I'd like to have in an game oriented language would be iterator like features and continuation passing style mechanisms to make it easier to write game logic and event driven code.

What I mean by this is:

I want to write code like:
(and I'm imagining here)


   def changeHealth(amount)
      change Player.Health to Player.Health + amount
      over 2sec
      continueWith
         if (Player.Health < 0)
            deathAnimation  
            chagngeState Game.DeatScreen
         else
            flashHealthBarAnimation
    ...
    def countDown()
       for i in 3..0 over 3sec step 1sec
          coudownAnimation(i)
I hope I've made my idea sufficiently clear.

P.S. Any similarities to Python syntax are pure coincidence tongue.png

* composition

* For rendering and math you want to be close to the hardware

* something without a stop the world garbage collector

* higher order and first class functions, suitable for writing dsl's, etc

* It would control other systems through a mix of metadata such as animation graphs, something along the lines of an event and response driven language, or possibly a functional language that manipulates a block of game data.

anything else?

pretend there were no limits - a wish list. what would you want?

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php


def changeHealth(amount)
change Player.Health to Player.Health + amount
over 2sec
continueWith
if (Player.Health < 0)
deathAnimation
chagngeState Game.DeatScreen
else
flashHealthBarAnimation

that would be something like a DeltaThen command.

command name: delta then

purpose: delta a value over time, then execute a block of code.

keyword: dt, DeltaThen, deltathen, delta then, dthen, etc - pick one. i'm shooting for low keystrokes ad mnemonic, so perhaps dt unless that's already taken (i have list of 160 or so, so far). or maybe dthen. short but mnemonic.

syntax:


dthen value delta time
// code block code goes here
.                                         // a period means "end code block"

this would be what you'd type in the CScript scripting language (the macro processor / code generator language)

my plan is to make it so CScript can generate code to work with various libraries. so there would be a library that implemented event processing, such as incrementing a variable by an amount each time its called, and one that called a function after a timer expired. Then the code gen would generate the calls to add the event handler to the list of active events, and start the time delayed function call, and generate the code for the function called when the timer expires.

you can freely mix, C, C++ and CScript syntax together. so you could say:

dthen player.health amount time
// your c++ code  goes here
.

and it would turn it all into c++ code for you.

come to think of it, it would probably be better as two functions, delta var over time, and call function on timer.

sounds like a basic need for a library for time triggered function calls, ie: it calls functions repeatedly at some constant time interval, or calls them once after some period of time. attach a timer to a function pointer with a little controlling code and you've got it. functions with parameters may be an issue, but may be unnecessary.

so you have your "event system library" hooked into your game loop with a single call. when its called, it checks its active events. an event could just be a time delta, a function call, and how many iterations. its start time is saved when an event is added to the list of active events. if current time >= start time + time delta, it calls the function. it does this for "iteration" number of times, then deactivates.

so that would lead to CScript syntax like:

addevent time iterations
// your code goes here
.

or in your case, perhaps something like:

// setup two events: add amount to player health over 2 seconds,
// and check for player dead after 2.1 seconds (100 milliseconds later to give the first event a chance to complete).
 
addevent 1000  2                          // addevent, 1000 millisecs per iteration, 2 iterations
player.health+=amount/2
.                                                    // end code block
addevent 2100 1                          // addevent 2100 millisecs per iteration, 1 iteration
if (Player.Health < 0)
deathAnimation
chagngeState Game.DeatScreen
else
flashHealthBarAnimation
.                                                           // end code block
 

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

A short personal wishlist of mine would include stuff like:

Functional purity as default, enforced by compiler
Mutation-using code allowed inside pure functions as long as it only operates on local data (and so does not cause an actual loss of purity)
Can annotate an individual pure function call at call site to enforce the arguments must be const and the whole thing must therefore be eliminated at compile time
Strong typing, strong type inference so you rarely have to spell out the types
Deep/transitive const
Generic code written with the same syntax as other code
Generic containers and algorithms connected with ranges, iterators
Designed to allow fast and automatic incremental compilation and re-linking on the fly while in development mode, without having to add any crud in the code to make it happen

The D language already manages quite a bit of those, and also allows getting close to hardware so you don't need a separate language for that.

Tim Sweeney's old opinion touches on many of the same things:
http://www.st.cs.uni-saarland.de/edu/seminare/2005/advanced-fp/docs/sweeny.pdf


higher order and first class functions, suitable for writing dsl's,

dsl's: distributed systems logic? as in distributed systems programming?

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement