Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » Bazaar » Squirrel - the programming language
Squirrel - the programming language [message #34472] Fri, 25 November 2011 00:31 Go to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Homepage:
http://squirrel-lang.org

License:
MIT

Version:
3.0.7 (stable)

Description:
Squirrel is a high level imperative, object-oriented programming language, designed to be a light-weight scripting language that fits in the size, memory bandwidth, and real-time requirements of applications like games.
Although Squirrel offers a wide range of features like dynamic typing, delegation, higher order functions, generators, tail recursion, exception handling, automatic memory management, both compiler and virtual machine fit together in about 6k lines of C++ code.

Documentation:
Squirrel 3.0 reference manual
Squirrel 3.0 Standard Libraries manual

In the attachments you could find Squirrel source code, samples, converted to U++ packages and documentation.

To note:
There were minor changes for include files for original sources to adapt for U++ package structure.
The "squirrel.h" file includes "config.h" file with double precision define (SQUSEDOUBLE) by default.

Edit: Updated to 3.0.7 version.

[Updated on: Wed, 14 January 2015 18:53]

Report message to a moderator

Sqrat - Squirrel C++ Binding Utility [message #34473 is a reply to message #34472] Fri, 25 November 2011 00:33 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
Homepage:
http://scrat.sourceforge.net

License:
zlib/libpng

Version:
0.9.1

Description:
Sqrat is a C++ library for Squirrel that facilitates exposing classes and other native functionality to Squirrel scripts. It is similar to SqPlus, both in functionality and syntax, but seeks to address several issues present in other binding libraries.

Sqrat models the underlying Squirrel API a little more closely than most other binding utilities, and this fact gives it a lot of power in exchange for a couple of minor quirks in the syntax. Code is straightforward and easy to read, however, and can easily be ported to from existing bindings.

Beginning in Sqrat 0.8, several utilitiy libraries are also included to extend the squirrel language itself with useful libraries and functionalities.

Sqrat has been tested against Squirrel 2.1.1 through 2.2.3 and 3.0 to 3.0.4. Other versions may work fine, but the author makes no promises!

Documentation:
Binding Library
Module Import Library
Threading Library
Doxygen generated documentation for 0.9 version

In the attachments you could find Sqrat source code, sq sample, converted to U++ packages.

To note:
There were minor changes for include files for original sources to adapt for U++ package structure and disabling some of MSC warning about comments inside of function arguments.

Edit: Updated to 0.9.1 version.

[Updated on: Wed, 14 January 2015 18:55]

Report message to a moderator

Re: Squirrel - the programming language [message #34474 is a reply to message #34472] Fri, 25 November 2011 00:35 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
As for AngelScript, I made sample application based on Mirek's "little experiment" example.

With following results:
1 / (1 - x * y + x - y) = -0.01851851852
fn->Execute() = -0.01851851852
sum = 5190404.858
sum = 5190404.858
sum = 5190404.858
sum = 5190404.858
TIMING Squirrel (fully interpreted): 197.00 ms - 197.00 ms (197.00 ms / 1 ), min: 197.00 ms, max: 197.00 ms, nesting: 1 - 1
TIMING Direct         : 13.00 ms - 13.00 ms (13.00 ms / 1 ), min: 13.00 ms, max: 13.00 ms, nesting: 1 - 1
TIMING Compiled       : 57.00 ms - 57.00 ms (57.00 ms / 1 ), min: 57.00 ms, max: 57.00 ms, nesting: 1 - 1
TIMING Interpreted    : 770.00 ms - 770.00 ms (770.00 ms / 1 ), min: 770.00 ms, max: 770.00 ms, nesting: 1 - 1

Edit: Updated to Squirrel 3.0.7 version. The results from previous versions.

[Updated on: Wed, 14 January 2015 19:00]

Report message to a moderator

Re: Squirrel - the programming language [message #34477 is a reply to message #34474] Fri, 25 November 2011 07:43 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1264
Registered: September 2007
Senior Contributor
Hi Sender Ghost,

thank you for posting the packages Smile

BTW, a question.... I still don't understand the timing with RTIMING macro... could you explain a bit more the results ?

For example, what are the 197 ms for fully interpreted and the 770 ms for interpreted ?

Max
Re: Squirrel - the programming language [message #34478 is a reply to message #34477] Fri, 25 November 2011 07:58 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
mdelfede wrote on Fri, 25 November 2011 07:43


BTW, a question.... I still don't understand the timing with RTIMING macro... could you explain a bit more the results ?

For example, what are the 197 ms for fully interpreted and the 770 ms for interpreted ?


Hello, Massimo.

RTIMING is profiling macro for source code scopes. In this case for:
	{
		RTIMING("Interpreted");
		double sum = 0;
		// ...
		RDUMP(sum);
	}
	// ...
	{
		RTIMING("Squirrel (fully interpreted)
		using namespace Sqrat;

		double sum = 0;
		// ...
		RDUMP(sum);
	}

RTIMING writes results to application *.log file, even in Release mode. TIMING for Debug.
Re: Sqrat - Squirrel C++ Binding Utility [message #34479 is a reply to message #34473] Fri, 25 November 2011 08:10 Go to previous messageGo to next message
unodgs is currently offline  unodgs
Messages: 1356
Registered: November 2005
Location: Poland
Senior Contributor

That binding utility looks interesting. I think I'll give squirrel a try Smile
Re: Squirrel - the programming language [message #34480 is a reply to message #34478] Fri, 25 November 2011 08:42 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1264
Registered: September 2007
Senior Contributor
Sender Ghost wrote on Fri, 25 November 2011 07:58

mdelfede wrote on Fri, 25 November 2011 07:43


BTW, a question.... I still don't understand the timing with RTIMING macro... could you explain a bit more the results ?

For example, what are the 197 ms for fully interpreted and the 770 ms for interpreted ?


Hello, Massimo.

RTIMING is profiling macro for source code scopes. In this case for:
	{
		RTIMING("Interpreted");
		double sum = 0;
		// ...
		RDUMP(sum);
	}
	// ...
	{
		RTIMING("Squirrel (fully interpreted)
		using namespace Sqrat;

		double sum = 0;
		// ...
		RDUMP(sum);
	}

RTIMING writes results to application *.log file, even in Release mode. TIMING for Debug.


The time given is just the time spent inside block ? Because I see than that Squirrel fully interpreted is quite faster than interpreted case.....
BTW, looking into your example, it seems to me that the squirrel time is the whole of compiling+running the script (why running ?) and evaluating the function; it would be more interesting to take evaluation part of pre-compiled script separate.

I mean, usually script compiling is done once and the important stuff is execution speed.

@Unodgs : I like squirrel because it's simple, powerful and it forces you to declare variables, even if untyped.... I hate javascript because of this lack which makes very easy to introduce hidden bugs just because of mispelled vars.

Max
Re: Squirrel - the programming language [message #34481 is a reply to message #34480] Fri, 25 November 2011 08:55 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
mdelfede wrote on Fri, 25 November 2011 08:42

BTW, looking into your example, it seems to me that the squirrel time is the whole of compiling+running the script (why running ?) and evaluating the function; it would be more interesting to take evaluation part of pre-compiled script separate.

Because without running, it will not find Squirrel function to get interpreted result.
Results for pre-compiled code:
1 / (1 - x * y + x - y) = -0.01851851852
fn->Execute() = -0.01851851852
sum = 5190404.858
sum = 5190404.858
sum = 5190404.858
sum = 5190404.858
TIMING Squirrel (fully interpreted): 195.00 ms - 195.00 ms (195.00 ms / 1 ), min: 195.00 ms, max: 195.00 ms, nesting: 1 - 1
TIMING Direct         : 13.00 ms - 13.00 ms (13.00 ms / 1 ), min: 13.00 ms, max: 13.00 ms, nesting: 1 - 1
TIMING Compiled       : 58.00 ms - 58.00 ms (58.00 ms / 1 ), min: 58.00 ms, max: 58.00 ms, nesting: 1 - 1
TIMING Interpreted    : 759.00 ms - 759.00 ms (759.00 ms / 1 ), min: 759.00 ms, max: 759.00 ms, nesting: 1 - 1
Results by sections:
Toggle Spoiler


1 / (1 - x * y + x - y) = -0.01851851852
fn->Execute() = -0.01851851852
sum = 5190404.858
sum = 5190404.858
sum = 5190404.858
sum = 5190404.858
TIMING Squirrel (fully interpreted): 222.00 ms - 222.00 ms (222.00 ms / 1 ), min: 222.00 ms, max: 222.00 ms, nesting: 1 - 1
TIMING Squirrel (running and getting function):  0.00 ns -  0.00 ns ( 0.00 ns / 1 ), min:  0.00 ns, max:  0.00 ns, nesting: 1 - 1
TIMING Squirrel (compiling):  0.00 ns -  0.00 ns ( 0.00 ns / 1 ), min:  0.00 ns, max:  0.00 ns, nesting: 1 - 1
TIMING Direct         : 14.00 ms - 14.00 ms (14.00 ms / 1 ), min: 14.00 ms, max: 14.00 ms, nesting: 1 - 1
TIMING Compiled       : 59.00 ms - 59.00 ms (59.00 ms / 1 ), min: 59.00 ms, max: 59.00 ms, nesting: 1 - 1
TIMING Interpreted    : 848.00 ms - 848.00 ms (848.00 ms / 1 ), min: 848.00 ms, max: 848.00 ms, nesting: 1 - 1

Edit: Updated to Squirrel 3.0.7 version. The results from previous versions.

[Updated on: Wed, 14 January 2015 19:03]

Report message to a moderator

Re: Squirrel - the programming language [message #34482 is a reply to message #34481] Fri, 25 November 2011 09:21 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1264
Registered: September 2007
Senior Contributor
Uhmmm... it seems that the compiling time is around zero... weird.
Anyways, it shows that running a pre-compiled script don't bring advantages, at least for such simple scripts.

BTW, it looks slower than Angelscript, but by far easier to use.

Max
Re: Squirrel - the programming language [message #34483 is a reply to message #34482] Fri, 25 November 2011 09:35 Go to previous messageGo to next message
Sender Ghost is currently offline  Sender Ghost
Messages: 301
Registered: November 2008
Senior Member
mdelfede wrote on Fri, 25 November 2011 09:21


but by far easier to use.


Not quite true.
The AngelScript syntax is near with C++. It is possible to create wrapper functions to get AngelScript functions and use assert(r >= 0); for result checks. What I did is just complete code. This is because I added Sqrat binding library. Using Squirrel stacks directly will show different picture.

They are just different.

[Updated on: Fri, 25 November 2011 11:02]

Report message to a moderator

Re: Squirrel - the programming language [message #34484 is a reply to message #34483] Fri, 25 November 2011 09:48 Go to previous messageGo to next message
mdelfede is currently offline  mdelfede
Messages: 1264
Registered: September 2007
Senior Contributor
Yep, of course, I meant squirrel + sqrat, not squirrel alone.

Max
Re: Squirrel - the programming language [message #34489 is a reply to message #34480] Fri, 25 November 2011 14:24 Go to previous message
unodgs is currently offline  unodgs
Messages: 1356
Registered: November 2005
Location: Poland
Senior Contributor

mdelfede wrote on Fri, 25 November 2011 02:42


@Unodgs : I like squirrel because it's simple, powerful and it forces you to declare variables, even if untyped.... I hate javascript because of this lack which makes very easy to introduce hidden bugs just because of mispelled vars.


I tried this binding utility and I must say I didn't expect it to be so easy.
struct Test {
    void SayHello() {
        Cout() << "Hello\n";
    }
};

.. bindings ...

RootTable(vm).Bind("Test", Class<Test>(vm)
    .Func("SayHello", &Test::SayHello)
);
	
Test globTest;	
RootTable(vm).SetInstance("globTest", &globTest);


.. and the script ..

local test = Test();
test.SayHello();
globTest.SayHello();

This is just awesome! As for JS - I'm not a huge fan either (I don't like broken == operator and few other weird things) but if it comes to declaring variables you can use var everywhere and new strict mode. That should help.

@SenderGhost: Thank you for sharing Squirrel language - I didn't know this one.

[Updated on: Fri, 25 November 2011 14:26]

Report message to a moderator

Previous Topic: XMLMenu - User configurable menu system - completed
Next Topic: SysInfo package
Goto Forum:
  


Current Time: Thu Jun 04 06:36:14 CEST 2020

Total time taken to generate the page: 0.00866 seconds