Jump to content


C++ like script language


34 replies to this topic

#1 nopcoder

    New Member

  • Members
  • Pip
  • 8 posts

Posted 30 January 2007 - 02:33 AM

I have decided to go “Data-Driven”-design with my project and use a script language for game code. I’ve looked at Lua, Python, Ruby, AngelScript and UnrealScript (seems great, shame it’s not free). Except for the annoying lack of inheritance, AngelScript seems good.

I’m mainly looking for a C++/Java syntax-like (strongly-typed and object-oriented) language that binds well with C++, suggestions are appreciated.

Thank you.

#2 eddie

    Senior Member

  • Members
  • PipPipPipPip
  • 751 posts

Posted 30 January 2007 - 03:34 AM

Any reason why Lua doesn't cut it?

#3 monjardin

    Senior Member

  • Members
  • PipPipPipPip
  • 1033 posts

Posted 30 January 2007 - 08:17 AM

Lua isn't strongly-typed and some people don't grok it's object-oriented capabilities. Both completely bogus points in my humble opinion. Of course, I just finished writing a another quick application in Lua and found it as enjoyable as ever. ;)
monjardin's JwN Meter (1,2,3,4,5,6):
|----|----|----|----|----|----|----|----|----|----|
*

#4 dave_

    Senior Member

  • Members
  • PipPipPipPip
  • 584 posts

Posted 30 January 2007 - 12:44 PM

Tcl works fine for game scripts too.

Why bother having a "strongly-typed and object-oriented" as your scripting language when you've already got a one in C++.

I'd recommend using DLL instead of scripts if that [c++] is what you want, and allow the ability to reload your code.

#5 nopcoder

    New Member

  • Members
  • Pip
  • 8 posts

Posted 30 January 2007 - 03:27 PM

eddie said:

Any reason why Lua doesn't cut it?

As monjardin mentioned not strongly-typed (which I seek) and it has some annoying quirks (no explicit variable declaration, index from 1?). Other than that it seems like a fast, light and mature language.

dave_ said:

Why bother having a "strongly-typed and object-oriented" as your scripting language when you've already got a one in C++.

I'd recommend using DLL instead of scripts if that [c++] is what you want, and allow the ability to reload your code.

DLLs are not cross-platform and require compilation (which I want to avoid).

#6 jkleinecke

    New Member

  • Members
  • PipPip
  • 27 posts

Posted 30 January 2007 - 03:54 PM

Squirrel is a decent language, although it isn't strongly typed. It's basically a flavor of lua with some c++ features. The binding is pretty easy using SqPlus and I've heard jkBind is pretty good too.

#7 Kenneth Gorking

    Senior Member

  • Members
  • PipPipPipPip
  • 939 posts

Posted 30 January 2007 - 04:00 PM

You could always write your own :) : http://www.peroxide.dk/tuts_scr.shtml
"Stupid bug! You go squish now!!" - Homer Simpson

#8 Christian Weis

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 30 January 2007 - 05:14 PM

Writing your own scripting language isn't that hard. I got a prototype of the compiler and interpreter of my object-oriented (UnrealScript like) language ready within 2 months.

You may try out by yourself.

cu,
chris

#9 GameEngine_Designer

    Valued Member

  • Members
  • PipPipPip
  • 100 posts

Posted 30 January 2007 - 11:28 PM

Torque Scripting is very powerful, also look up DM Language for Byond.

#10 eddie

    Senior Member

  • Members
  • PipPipPipPip
  • 751 posts

Posted 31 January 2007 - 12:33 AM

monjardin said:

Lua isn't strongly-typed and some people don't grok it's object-oriented capabilities. Both completely bogus points in my humble opinion. Of course, I just finished writing a another quick application in Lua and found it as enjoyable as ever. ;)

Ah. I don't think he mentioned strongly-typed/OO before he edited it again, hence my question.

Too bad - Lua's a great language. And strongly-typed is really over-rated in a scripting language: IMHO.

#11 Christian Weis

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 31 January 2007 - 10:09 AM

eddie said:

And strongly-typed is really over-rated in a scripting language: IMHO.
You miss the point that strongly typed languages help the programmer to catch some errors at compiletime instead of runtime and therefore reducing the cost of runtime-debugging. The sooner you find errors the better.

cu,
chris

#12 dave_

    Senior Member

  • Members
  • PipPipPipPip
  • 584 posts

Posted 31 January 2007 - 10:19 AM

There is an answer to that: Test driven development

#13 Christian Weis

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 31 January 2007 - 10:41 AM

dave_ said:

There is an answer to that: Test driven development
Well, there're many other strategies that are far better than that. Strongly typeness is one of it.

cu,
Chris

#14 dave_

    Senior Member

  • Members
  • PipPipPipPip
  • 584 posts

Posted 31 January 2007 - 11:02 AM

That's not really the current consensus. In fact I'd go as far to say that is nonesense. For an fairly complex system you end up having to break the typing anyway! (using things like RTTI, reflection or similar)

Test driven development can be applied to both strong and weak typed, but with it, it doesn't matter if you've got strong or weak typing. If you write your tests properly you wont get stupid runtime errors.

Dynamic languages are gaining quite a bit of momentum at the moment.




I've just thought that you might not actually realise what weak typing actually is. Its not a complete absence of typing. It just allows implicit conversions more easily. It is actually possible for a weakly typed language to be type safe.

http://en.wikipedia....iki/Weak_typing

#15 Christian Weis

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 31 January 2007 - 11:29 AM

There's a lot misunderstanding about strong vs weak vs loose typeness. C++ is not a strong typed language nor is java. But many people here (see the posts above) think that they are. I believe that what many people really mean is typed vs untyped. So I take their definition for not confusing them.

And as for test driven develeopment you need to write lots of test cases that do not enshure, that everyone uses your classes and methods as they're meant to be. Those tests show only that all those stuff is working in the context of your test environment not necessarily in the context of the final complex software product.

cu,
chris

#16 dave_

    Senior Member

  • Members
  • PipPipPipPip
  • 584 posts

Posted 31 January 2007 - 11:38 AM

How does that argue in favour of strong typing?
You might be against TDD but you haven't argued for strong typing.

#17 Christian Weis

    New Member

  • Members
  • PipPip
  • 11 posts

Posted 31 January 2007 - 12:03 PM

I thought that the benefits of strong typeing are well known!

- no implicit conversions that may result in behaviour not intended by the programmer.
- classes/methods have to be used as they are meant to be. If a function expecteds an integer you are forced to use that type. You're forced to use an explicit conversion otherwise that visualizes what's truly going on.
- In a truly strong-typed language you're also forced to declare the range of a type and *useness* of a variable. This way nobody can accidentally pass a 'null' reference when it's not allowed. Or pass wrong array sizes, etc. This makes software overall more safe and reduces debugging costs a lot.
- You can't lie by hacking around with address-operators and unsafe c-conversions making code less readable and errorprone.
- Software inspections are easier und much more powerfull what in turn safes you more time and money.

ok I'm now going to eat something. Back in a while...

cu,
chris

#18 eddie

    Senior Member

  • Members
  • PipPipPipPip
  • 751 posts

Posted 31 January 2007 - 03:55 PM

Christian Weis said:

You miss the point that strongly typed languages help the programmer to catch some errors at compiletime instead of runtime and therefore reducing the cost of runtime-debugging. The sooner you find errors the better.

cu,
chris

I never said I didn't understand the benefits of a strongly typed language -- simply that it's over-rated in a scripting language.

First let me start off explaining the way I work with scripts -- I generally use runtime *as* compile-time. I love being able to reload scripts at runtime, and use that as valuable debugging time to make sure that everything's positioned correctly, or flowing in the right way, etc. I mention this not because it's super relative to the debate, but simply because it's how I use scripting, and therefore the difference between compile time and runtime is much smaller -- although it doesn't argue for/against strong/weak/dynamic typing, it does impact the way I work.

As for my point about strongly-typed being over-rated: I can appreciate how that thought might scare someone who's used to a strongly-typed system: "Why wait until the failure reaches further down your code, rather than at the spot where a compiler can catch it?". And I agree in part - it's nicer to have your errors sooner rather than later. But to be honest, it doesn't buy you much. It can make you feel comfortable that the type is indeed what you want it to be, but after all my years in working with languages like Lua, Python, JavaScript -- I've never found myself wanting that in those languages.

Perhaps it's because, like _dave alluded to, I find unit tests a much more important part of checking my code than strong-typing ever will be in those languages. I'd much rather catch those errors in a domain semantic way -- a way that has much more meaning to you as a programmer -- rather than a very elementary compiler semantic one.

But that's just been my experience.

#19 Elvis Enmanuel

    New Member

  • Members
  • Pip
  • 1 posts

Posted 31 January 2007 - 04:50 PM

AngelScript or c-script

ains.

#20 dave_

    Senior Member

  • Members
  • PipPipPipPip
  • 584 posts

Posted 31 January 2007 - 11:15 PM

eddie said:

Perhaps it's because, like _dave alluded to, I find unit tests a much more important part of checking my code than strong-typing ever will be in those languages. I'd much rather catch those errors in a domain semantic way -- a way that has much more meaning to you as a programmer -- rather than a very elementary compiler semantic one.
:yes: :worthy: :yes:

Christian Weis said:

I thought that the benefits of strong typeing are well known!
They are well known, but they're not generally thought of as useful for a scripting language. Most useful scripting languages lean towards the weaker side of things to enable rapid prototyping.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users