Author Topic: Virtual Machine VS Procedural Interpreter  (Read 18655 times)

RoguelikeGCS

  • Newcomer
  • Posts: 16
  • Karma: +0/-0
    • View Profile
    • Roguelike GCS
Virtual Machine VS Procedural Interpreter
« on: June 11, 2010, 11:58:10 AM »
Eventually I'm going to start writing the scripting language for my RL. The dilemma I'm faced with is whether to commission someone to develop a proper VM to execute low level byte code generated by my parser/compiler, or to develop a perl style interpreter myself.

The main issue seems to be with speed and efficiency; it's hardly rocket science to write an interpreter to execute through a data structure created by a parser. but even with optimisations, I can't imagine this approach producing a very fast scripting language.

The VM would be a complex engineering feat - something I would not likely be able to achieve myself (but it would offer irresistible performance).

Etinarg

  • Rogueliker
  • ***
  • Posts: 424
  • Karma: +1/-1
  • Idea archivist and game tinkerer.
    • View Profile
    • Gedankenweber Blog (German)
Re: Virtual Machine VS Procedural Interpreter
« Reply #1 on: June 11, 2010, 12:07:21 PM »
Why not use an already available scripting language like Lua?

purestrain

  • Rogueliker
  • ***
  • Posts: 172
  • Karma: +0/-0
    • View Profile
Re: Virtual Machine VS Procedural Interpreter
« Reply #2 on: June 11, 2010, 01:21:48 PM »
Because he can write a scripting language !

Etinarg

  • Rogueliker
  • ***
  • Posts: 424
  • Karma: +1/-1
  • Idea archivist and game tinkerer.
    • View Profile
    • Gedankenweber Blog (German)
Re: Virtual Machine VS Procedural Interpreter
« Reply #3 on: June 11, 2010, 01:31:40 PM »
I like this metaphor:
http://en.wikipedia.org/wiki/Standing_on_the_shoulders_of_giants

It works for software development, too. I picture the giants as libraries, algorithms and knowledge that former software developers and engineers created, and we can use these to lift us up, and empower us.
« Last Edit: June 11, 2010, 01:34:00 PM by Hajo »

stu

  • Rogueliker
  • ***
  • Posts: 138
  • Karma: +0/-0
  • Moop!
    • View Profile
    • Stu's Rusty Bucket
Re: Virtual Machine VS Procedural Interpreter
« Reply #4 on: June 11, 2010, 09:39:17 PM »
Its a REALLY bad idea to write your own if you lack the knowledge and experience. there have been a few threads on this here before. There are lots embeddedable scripting langs around, choose one.
--/\-[ Stu ]-/\--

guest509

  • Guest
Re: Virtual Machine VS Procedural Interpreter
« Reply #5 on: June 16, 2010, 09:18:51 AM »
Its a REALLY bad idea to write your own if you lack the knowledge and experience. there have been a few threads on this here before. There are lots embeddedable scripting langs around, choose one.

  Well...there are two paths here.
  Dream big! [and maybe fail]
  Or do as Stu says....

  I once had a track coach that told me the exact opposite of what they tell you in High School. He told me to NOT reach for the stars. He told me to do what I could do. Find success. Success breeds success and you'll live a happy life. If you do something that you are not that great at. If you reach too far. If you swim against the steam instead of going with the flow, you will find barrier after barrier and failure. If you set yourself up to fail you will not be happy.

  Maybe too deep...I use gamemaker [hangs head in shame.]


Etinarg

  • Rogueliker
  • ***
  • Posts: 424
  • Karma: +1/-1
  • Idea archivist and game tinkerer.
    • View Profile
    • Gedankenweber Blog (German)
Re: Virtual Machine VS Procedural Interpreter
« Reply #6 on: June 16, 2010, 02:25:27 PM »
Maybe too deep...I use gamemaker [hangs head in shame.]

Uh? Don't listen to those who say using tools is bad. There are quite good games made with Gamemaker, and Gamemaker users seem to produce games quickly. One can argue if there are better tools, but seeing what people do with Gamemaker I think it is a pretty sound choice for game creation - at least for a certain type of games.

Most tools are specialized in a way, and I wouldn't call a tool bad, just because it only performs well for certain tasks and not so good for others. If you want to do something, and the tool helps you, it's good.


guest509

  • Guest
Re: Virtual Machine VS Procedural Interpreter
« Reply #7 on: June 17, 2010, 01:10:35 AM »
  Heck yeah Hojo. Tools are good. I mean, I can USE Pascal and C++ to a level good enough to write a roguelike, but man I don't have the time anymore. I'm an attorney with no aspirations of being a programmer. So Gamemaker and GML are my creative outlet.

  It should be noted that Spelunky was written in Gamemaker.
 

RoguelikeGCS

  • Newcomer
  • Posts: 16
  • Karma: +0/-0
    • View Profile
    • Roguelike GCS
Re: Virtual Machine VS Procedural Interpreter
« Reply #8 on: June 17, 2010, 04:12:45 AM »
Why not use an already available scripting language like Lua?

For the sake of clarity, let me tell you that this scripting language is not for my own use during development of the RL engine, but for use by clients of the GCS. Therefore LUA will need to support adding callable functions in the following manner:

Let say for example, that the client wants to get a reference to an inventory so he can iterate through the items there; he would need some code like the following:

Code: [Select]
begin()
{
rInv = GetInventory(GetAutoPassedVars(0));

for (i = GetFirstItem(rInv); i; i = GetNextItem(rInv))
{
a = GetItemProp(i, 0);

DestroyItem(rInv, i);
}
}

the begin() function would be specified by the client, and called in the respective creature once upon entering an area, or starting the game.

Having looked at the LUA website, i must say, not only does it look highly complex with very strange python esque code, but it seems that getting it work for my needs (providing it can even do what i want it to) would be too much hassle. I think I'll roll my own. Good luck convincing me otherwise :)
« Last Edit: June 17, 2010, 04:17:46 AM by RoguelikeGCS »

Etinarg

  • Rogueliker
  • ***
  • Posts: 424
  • Karma: +1/-1
  • Idea archivist and game tinkerer.
    • View Profile
    • Gedankenweber Blog (German)
Re: Virtual Machine VS Procedural Interpreter
« Reply #9 on: June 17, 2010, 10:09:45 AM »
Good luck convincing me otherwise :)

I won't. I like to do things my ways too, so I can understand you and your decisions very well. Sometimes, after a while, one finds out that the advice was good, sometimes one finds that ones own idea was better. Only time can tell.

Have fun whipping up your own scripting language, and tell us how it goes and how people like it :)
« Last Edit: June 17, 2010, 10:17:13 AM by Hajo »

stu

  • Rogueliker
  • ***
  • Posts: 138
  • Karma: +0/-0
  • Moop!
    • View Profile
    • Stu's Rusty Bucket
Re: Virtual Machine VS Procedural Interpreter
« Reply #10 on: June 18, 2010, 01:39:26 AM »
Having looked at the LUA website, i must say, not only does it look highly complex with very strange python esque code, but it seems that getting it work for my needs (providing it can even do what i want it to) would be too much hassle. I think I'll roll my own. Good luck convincing me otherwise :)

Hey its your game so its up to you, honestly everything you have said about lua in the above paragraph is totally wrong.

I'd code your example like;

Code: [Select]
function Begin()
local rInv
local key, value

rInv = GetInventory()
for key,item in pairs(rInv) do
if item.MyPropertyFlamingSwordVsTrolls == true do
FlamingTrollSnot()
end

DestroyItem(key)
end
end

I'd be interested in seeing the specifics of your scripting language + vm, its design and implementation (I'm a hobby language/compiler/vm junkie).
--/\-[ Stu ]-/\--

EdR

  • Newcomer
  • Posts: 19
  • Karma: +0/-0
    • View Profile
    • Email
Re: Virtual Machine VS Procedural Interpreter
« Reply #11 on: June 18, 2010, 08:16:39 AM »
Just a couple cents here:

Lua does do everything you need--I can say this confidently without even knowing the bullet-points of what you need, because I'd bet everything I own that it's not something somebody else has already made Lua do--and it is far simpler than rolling your own. Lua is a well-understood, well-accepted language that is actually used in the real world with some large-scale adoption. It's used in areas from standalone applications to scripting for 3D engines (my colleagues on Sharplike wrote a slick 3D engine with Lua as the primary scripting system). I am not the biggest fan in the world of its syntax, but it is really, really good.

As for Lua itself, one of Sharplike's other devs (and one of the guys behind that 3D engine) had this to say: "Lua = VM. Fastest embeddable scripting language according to the computer language shootout. And lowest memory overhead. And easy to use. And rock solid."

If you don't want to use Lua, there are a ton of other options. You've got a Python interpreter in Boost::Python. You can self-host Mono and give users their choice of CLR language for scripting (and get a JIT compiler and runtime out of the deal--I don't know anyone who can write a VM/compiler for a roguelike engine that will come anywhere close to the perf that you'd get out of Mono--and Lua/Python are faster than that, albeit less featureful). There are good options for pretty much any use case out there. (Sharplike's code runs on .NET, so we get IronPython and IronRuby for free. Gotta love it!)



No disrespect intended, but it has almost certainly been done and done better, and you have all that code out there you can leverage. There are only a very few people in the world with the computer science background and the technical proficiency to develop a sane, effective programming language with a well-performing runtime. I am reasonably sure that none of them, myself very much included, are making roguelikes. Rolling your own off-the-cuff in a project you want other people to actually use is likely unwise. (Not that I'd really mind if you did--I like people doing things that make my own code look better. ;) Just some friendly advice, because I don't like seeing people shoot themselves in the foot.)
« Last Edit: June 18, 2010, 02:10:17 PM by EdR »

ido

  • Rogueliker
  • ***
  • Posts: 618
  • Karma: +0/-0
    • View Profile
    • Tame Tick
Re: Virtual Machine VS Procedural Interpreter
« Reply #12 on: June 22, 2010, 01:17:36 PM »
it look highly complex with very strange python esque code

I find it odd that you would:
1. Find lua to be similar to python.
2. Consider that a bad thing.

It seems to be a lot more ruby or (superficially) pascal inspired to me than python inspired.

It is at any rate a much smaller and simpler language than any of these.
« Last Edit: June 22, 2010, 01:19:56 PM by ido »

ido

  • Rogueliker
  • ***
  • Posts: 618
  • Karma: +0/-0
    • View Profile
    • Tame Tick
Re: Virtual Machine VS Procedural Interpreter
« Reply #13 on: June 22, 2010, 01:18:15 PM »
[double post, ignore this message.]

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Virtual Machine VS Procedural Interpreter
« Reply #14 on: June 24, 2010, 05:22:38 AM »
What is the deal with scripting? I've never thought scripting a good solution to like anything.