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.
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.
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
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>).
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.
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.* 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?
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