Jump to content
  • Advertisement
Sign in to follow this  

Creating a Scripting Language

This topic is 3618 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I know C++ and basicly I want to learn to create my own scripting language. Not programming language, but a physics oriented scripting language. Can any of you direct me to further resources? The language should be interpreted, not compiled, although I presume compilation would increase it's time.

Share this post


Link to post
Share on other sites
Advertisement
Scripting Langauages and Mod Development

There's some good info there, but if you want to make a simple interpreter just figure out what kinda syntax you want to use like, ASM, BASIC, C, etc. and make a function that will tokenize the string for each line then interpret those tokens and execute each line separately. I personally like the BASIC approach because everything is pretty much contained to one line. You can make an interpreter quite fast this way as well.

Make sure you have a Program Counter, PC to keep track of what line you're executing as well.

Then you'll just need some cool functions like:

Move, Teleport, Print, etc. things like that along with some things that are specific to physics.

Share this post


Link to post
Share on other sites
Well, sadly I cannot use a BASIC type of language beacause it would need to be Object Oriented. The nature of the engine works on OO paradigm. Plus, the scripting language should be powerfull enough to allow the user to implement physics rules to the engine. Like planck constants and other stuff (I only program the physics part, not understand it :p). I would require something more complex like C++ that would pe OO.

Share this post


Link to post
Share on other sites
Why not use an existing language like Python or Lua? Writing bindings is fairly easy for either of these two languages.

Creating an object-oriented scripting language from scratch, on the other hand, is no small task.

Share this post


Link to post
Share on other sites
Is there any particular reason why you don't use an existing scripting language or physics API? Also, implementing physics through scripting seems a bit weird; typically, the physics system is constant throughout your application and also one of the most computationally demanding systems, which makes it sensible to code in a compiled language.

Share this post


Link to post
Share on other sites
Using anything but python would be somewhat foolish here. It's an except language in academic, and notably physics community, and offers full interoperability with C and C++.

Quote:
Also, implementing physics through scripting seems a bit weird;


That's not physics as in collision detection, but physics as in "We are physicist and need a language to run our simulations in".

Scripting languages are a very prefered choice in such environments, since scientists scorn anything related to coding, as its considered a menial task. They also believe that good coding practices, memory overruns, functions and code organization have no place in serious science. Most of them are convinced that anything beyond Fortran is just an attempt of commercial companies enforcing their own agenda on them.

Yes, it's a difficult world for CS-oriented people.

Share this post


Link to post
Share on other sites
Quote:
Original post by Hnefi
Is there any particular reason why you don't use an existing scripting language or physics API? Also, implementing physics through scripting seems a bit weird; typically, the physics system is constant throughout your application and also one of the most computationally demanding systems, which makes it sensible to code in a compiled language.


Yes there is, the system im developing and desinging would not impose any restriction to the user in regards to anything. And especially physics. There would be some base constants like gravity, celestial movement like keppler's laws, day/night cycles, but they would not be set. If the user wanted 3 wind sources and 0.5 G's gravity as well and a 3 day in real time day/night cycle then he should be able to do it. I take the World of Warcraft approach in which I store all models and objects on the server. However the rules of the game are created by the user, parsed by the system and stored on his account on the server without causing any trouble to other "worlds". That's why I need a versatile scripting language.

And Antheus is right, the system could, would and should be used as a simulation tool :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Antheus
Using anything but python would be somewhat foolish here. It's an except language in academic, and notably physics community, and offers full interoperability with C and C++.

Quote:
Also, implementing physics through scripting seems a bit weird;


That's not physics as in collision detection, but physics as in "We are physicist and need a language to run our simulations in".

Scripting languages are a very prefered choice in such environments, since scientists scorn anything related to coding, as its considered a menial task. They also believe that good coding practices, memory overruns, functions and code organization have no place in serious science. Most of them are convinced that anything beyond Fortran is just an attempt of commercial companies enforcing their own agenda on them.

Yes, it's a difficult world for CS-oriented people.


True, it will be a physics engine mainly developed for simulations. But that would not stop me to cut on some CPU intensive stuff and license it for games. The freedom to use it would be awsome.

Share this post


Link to post
Share on other sites
Well, if you're set on it, I suppose there's no reason to dissuade you. Assuming you have a graduate level understanding of mechanical physics and the appropriate math, designing a language appropraite for physics should be a relatively straightforward, though quite large, task. Expect to work on it for a significant amount of time (months or years).

I suggest you begin by studying current implementations of scripting languages. Model your language after an existing one; decide on what features your language should have (static vs dynamic types, OO vs procedural vs functional etc) and look how others implement them.

You may also want to look for literature on parsing techniques. Parsing is a central part of any interpreter or compiler, so you may want to start by getting a grip on that to better determine what you can and can not do in regards to syntax.

Share this post


Link to post
Share on other sites
I looked at Python and it looks pretty darn well. Question is if it would fit over my paradigm. But I guess I would try to implement a small wrapper for Python and see how it works, I played with it and it looks pretty easy to use from a user perspective, and yet pretty powerfull.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!