Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Announcing C++Script

10 views
Skip to first unread message

Calum Grant

unread,
Nov 10, 2008, 8:17:26 AM11/10/08
to
The first public release of C++Script is available. This is version
0.9.0, which is a beta version.

Web page: http://calumgrant.net/cppscript

About C++Script:
C++Script adds dynamic types to C++. This creates a scripting language
with full backwards compatibility with C++, and provides C++ programmers
with the following functionality:

- Dynamic types
- Memory safety and garbage collection
- Dispatch-based object orientation
- Closures, binding and functors
- Thread safety, futures and message queues
- A front-end to “run” C++ source code
- A foreach macro to iterate collections
- Serialization and “pickling”
- No in-depth knowledge of C++ required.

The main benefit of this approach is that the language is fully
compatible with C++ which reduces the learning curve, allows C++Script
to be used in C++ projects, allows performance-critical parts to be
written in C or C++, and provides the full set of C++ libraries.

Please have a go, and let me know what you think.

Calum

--
Calum Grant - http://calumgrant.net

Aaron Gray

unread,
Nov 13, 2008, 5:12:51 PM11/13/08
to
"Calum Grant" <n...@hotmail.com> wrote in message
news:gf9c92$pk2$1...@aioe.org...

Hi Calum,

Interesting direction.

I have had a very brief look at your documentation but I have yet to look at
the source.

Do you have something akin to JavaScript's associative arrays or Smalltalk
or Pythons slots ?

Aaron

Christopher Diggins

unread,
Nov 13, 2008, 10:36:26 PM11/13/08
to

Hi Calum,

Great job! I'm really interested in contributing to the language. Is
there any chance you might consider releasing it under a more
permissive open-source license? Otherwise I am not sure how much I'd
be able to offer.

Christopher Diggins
http://dobbscodetalk.com/index.php?blogger=cdiggins

Calum Grant

unread,
Nov 14, 2008, 7:38:43 AM11/14/08
to

I think the answer to both those questions is "yes".

C++Script has a map() function which creates an associative array. e.g.

var x = map();
x["fish"] = "Henry";
x[12] = list(3.14)(true)(L"")(x["fish"])(x);

I'm not too clued up on slots, but is it just a closure? You can
dissociate methods from objects to create closures. You can use the
closure as a signal handler, and add it as a member of another object as
follows:

form1["ok_button"]["on_click"] = bl["validate_submit"];

where "validate_submit" is a method on bl.

This might seem normal for scripting languages but it is pretty far-out
for C++.

Calum Grant

unread,
Nov 14, 2008, 10:12:39 AM11/14/08
to

Thanks! I'd be very excited about others contributing. I'll think
about the license, maybe LGPL would be better. We should also consider
hosting this on SourceForge or Google Code if a lot of people want to
contribute.

There's two main ways to contribute. The simplest is to write a
separate library. If the library provides something really essential
like a regex, then it can be folded into the core library. If the
library is something more niche, then I'll be very happy to host it or
link to it from the main page. I need to think about how the front-end
deals with additional libraries (a -l flag springs to mind).

The other way to contribute is if you want to mess with the internals,
such as rewrite the memory manager, optimise or alter existing
behaviour. That's great too, but I'm tinkering on those parts.

I'm currently working on a Python connector (for seamless C++/Python
integration), though there are lots of useful libraries such as
networking, XML, database, ORM, HTTP, web apps, dynamic linkage, GUI
that would be great to contribute. A lot of these libraries would be
wrappers, and my vision is that the C++Script version would add value
(otherwise why do it?) by making the interface simpler or more intuitive.

Being only a week old there isn't a user base yet but I'll spam/announce
on c.l.c++ shortly, and maybe write some articles.

Cheers, Calum

Aaron Gray

unread,
Nov 14, 2008, 1:04:05 PM11/14/08
to
"Calum Grant" <n...@hotmail.com> wrote in message
news:gfjrgq$qd5$1...@aioe.org...

Interesting.

Okay, had a brief look at code but wound up by things like :-

libcppscript/script/var_variant.hpp contains 'class variant' not 'class
var_variant'

sometimes you use "*_impl.*" on filenames sometime you do not.

Its just these things make things hard to find your way around code when
first looking at it.


To be straight to the point, I thnk version 0.9.0 is too late, this is
something like a 0.0.9 really, its a prototype. It needs alot of work and
normalization doing to make it really usable and stable code wise, otherwise
I dont think it is going anywhere and will be marginalized.

Okay to thurther be straight I am only really interested in the techniques
in view of using them for implementing an actual dynamic language in C++
simular to Tamarin (ECMAScript 4) and to use it for interfacing between the
two, for implementation and extension modules.

I think you need some better or more comprehensive examples and tests too.

Anyway good work, a good beginning. Will probably write more no doubt once I
have had an actual play with it once I get time.

Tanks,

Aaron


Charlie Gordon

unread,
Nov 14, 2008, 7:44:45 PM11/14/08
to
"Calum Grant" <n...@hotmail.com> a écrit dans le message de news:
gf9c92$pk2$1...@aioe.org...

Hello Calum,

Very interesting simplification of C++, but not quite a scripting language:
most people associate 'scripting' with dynamic evaluation (through
interpretation or dynamic compilation), not merely dynamic typing ;-). Very
useful nonetheless to show how much crud can be removed from the language,
and how readable it then becomes.

I cannot compile the product under Linux Debian lenny with gcc 4.3.2: I get
fatal errors about missing prototypes that can be easily fixed, but this one
escapes me:
proxy.cpp:71: error: ISO C++ forbids declaration of 'auto_ptr' with no type

Under Cygwin, with gcc 3.4.4, cppscript compiles and checks OK.

Also, you should include a licence file in the source distribution.

Congratulations.

--
Chqrlie.


Calum Grant

unread,
Nov 16, 2008, 8:11:50 AM11/16/08
to

The "cppscript" program is designed to "run" C++. The only difference
is where the compiler exists I guess. The "cppscript" front-end is not
big or clever, but just designed to help users as much as possible.

I too am confused about whether this is a new language, or just a
library for an existing language.

> I cannot compile the product under Linux Debian lenny with gcc 4.3.2: I get
> fatal errors about missing prototypes that can be easily fixed, but this one
> escapes me:
> proxy.cpp:71: error: ISO C++ forbids declaration of 'auto_ptr' with no type

I've updated the library to fix this platform. Check
http://calumgrant.net/cppscript to get the latest version, let me know
of any problems.

( std::auto_ptr is in <memory> )

> Under Cygwin, with gcc 3.4.4, cppscript compiles and checks OK.

> Also, you should include a licence file in the source distribution.

It's in the file called COPYING. I've relaxed the license to LGPL.

Thanks, Calum

Calum Grant

unread,
Nov 16, 2008, 8:31:49 AM11/16/08
to

I've released version 0.9.1 under the LGPL.

I don't feel happy making it freer than that at the moment. Actually
the FSF recommend using GPL for libraries, as they discuss here:
http://www.gnu.org/licenses/why-not-lgpl.html

Hope that helps, Calum

Calum Grant

unread,
Nov 16, 2008, 9:02:29 AM11/16/08
to

var_variant is defined in var_variant.hpp. I'm guilty of putting more
than one definition in a header file, but that's actually fairly normal.

> sometimes you use "*_impl.*" on filenames sometime you do not.

Similarly, the class var_impl is declared in var_impl.hpp, and
implemented in var_impl.cpp. The pimpl idiom is well known.

The only other _impl is inline_impl.hpp, which contains inline functions
which couldn't be defined in their classes because of include order.

> Its just these things make things hard to find your way around code when
> first looking at it.

I'd be quite surprised if you can meaningfully reverse engineer the
design given that it's not described anywhere. The manual is for users,
not implementors.

The source code is very poorly annotated - I should look at fixing that.

To be honest most users would never look at the source code (why should
they?)

> To be straight to the point, I thnk version 0.9.0 is too late, this is
> something like a 0.0.9 really, its a prototype. It needs alot of work and
> normalization doing to make it really usable and stable code wise, otherwise
> I dont think it is going anywhere and will be marginalized.

I disagree on this point. I don't want to add any more features or
change the design for 1.0.

The work that needs doing is perhaps cosmetic. I could restructure the
files a bit, tidy up the manual a little, jazz up the website, give some
larger examples, do a bit of tuning, annotate the source code better.
None of these tasks are fundamental.

To me, a 1.x version means that the code can be used in stable products,
and commercially. I wouldn't call the current release 1.0, not because
I know of any outstanding bugs, but just because I want to flush out any
problems (e.g. build problems on certain platforms). A gestation
period is definitely needed to gain confidence in a product, and I don't
see a version 1.0 before year-end.

I've got good confidence in the quality because of the unit test
coverage, but at what point can you flick a switch and say that this is
now "ready"?

You might want version 1.0 to include database, GUI, XML, DOM, HTTP,
sockets, object-relational mapping, regexes and the kitchen sink. I'm
not sure I'll ever get to 1.0 if that's the case. I'm happy to defer
this functionality until after 1.0, and put it into additional
libraries. Remember you've still got all the C++ libraries at your
disposal.

> Okay to thurther be straight I am only really interested in the techniques
> in view of using them for implementing an actual dynamic language in C++
> simular to Tamarin (ECMAScript 4) and to use it for interfacing between the
> two, for implementation and extension modules.

Right, so you're not interested in using C++Script, you're just
interested in how it works.

This is a good article (not on C++Script):
http://www.ddj.com/cpp/184402027?pgno=1

What would probably make your life easier is a description of the
implentation, and a better annotation of the internals. This won't help
users of course, who are the main target audience.

> I think you need some better or more comprehensive examples and tests too.

The test suite is 4456 lines long, for a code base of 10124 lines. The
test suite is distributed with the source code under the tests/
subdirectory. I'm happy with the current unit test coverage.

There's 458 lines of examples (in source files you can actually run).
That's not a huge amount I agree. I should look to increase that.

> Anyway good work, a good beginning. Will probably write more no doubt once I
> have had an actual play with it once I get time.

Thanks for the candid feedback, I really appreciate it.

Calum

Christopher Diggins

unread,
Nov 29, 2008, 4:01:55 PM11/29/08
to
> > Hi Calum,
>
> > Great job! I'm really interested in contributing to the language. Is
> > there any chance you might consider releasing it under a more
> > permissive open-source license? Otherwise I am not sure how much I'd
> > be able to offer.
>
> I've released version 0.9.1 under the LGPL.
>
> I don't feel happy making it freer than that at the moment.  Actually
> the FSF recommend using GPL for libraries, as they discuss here:http://www.gnu.org/licenses/why-not-lgpl.html

Thank you very much, Calum.
I have some opinions of the FSF and the GPL which can't be posted
without starting a flame war. :-)
Anyway, thanks for making it LGPL.

Prepare for a potential onslaught of visitors. I have posted about C+
+Script on my blog at:
http://dobbscodetalk.com/index.php?show=Embedding-a-Scripting-Language-in-C%2B%2B.html

Some random suggestions:
- change the name officially to CppScript. No one will ever find C+
+Script (or is it C++ Script?) in Google.
- break up the manual into multiple pages.
- prettify the manual (use a CSS)
- post more CppScript samples in the examples
- write a CppScript validator (is file X valid CppScript)
- move your project to Google code hosting http://code.google.com/hosting/
- formalize the language: what are the precise syntax and semantics.
- I would like operator, overloaded for lists. e.g. var mylist = nil,
1, 2, 3;
- I would like all collections to inherently support ".indexes()",
which returns a range. This would allow me to write foreach (i,
xs.indexes()) and simplify many algorithms.
- I want to know precisely what subset of C++ makes up CppScript.
Obviously anyone can mix and match, but having a formal distinction
between the two, would be nice, because if I was to write a CppScript
interpreter/compiler/translator, I would know what features to
support.
- I would like to see a module system or namespaces as an official
part of the CppScript language. I have a few ideas on maybe how to do
this.
- Consider providing a formalized numerical system (like Scheme's
numerical tower).

Some questions:
- Do you know who is using this project yet?
- What are the plans for this project?
- How can I help?

Cheers,
Christopher

Christopher Diggins

unread,
Nov 29, 2008, 4:05:49 PM11/29/08
to
> > Hello Calum,
>
> > Very interesting simplification of C++, but not quite a scripting language:
> > most people associate 'scripting' with dynamic evaluation (through
> > interpretation or dynamic compilation), not merely dynamic typing ;-).  

Write an interpreter, with a read/eval/print loop and voila it becomes
a dynamic langauge. If only I didn't have a day job. Anyone want to
pay me to do it?

> Very
> > useful nonetheless to show how much crud can be removed from the language,
> > and how readable it then becomes.
>
> The "cppscript" program is designed to "run" C++.  The only difference
> is where the compiler exists I guess.  The "cppscript" front-end is not
> big or clever, but just designed to help users as much as possible.
>
> I too am confused about whether this is a new language, or just a
> library for an existing language.

It just requires some formalization of the syntax and semantics, and
it would become a new language.
I think this is a very worthwhile thing to do.

Ch

Christopher Diggins

unread,
Nov 29, 2008, 8:50:17 PM11/29/08
to
> Prepare for a potential onslaught of visitors. I have posted about C+
> +Script on my blog at:http://dobbscodetalk.com/index.php?show=Embedding-a-Scripting-Languag...

Link was broken:

http://dobbscodetalk.com/index.php?option=com_myblog&show=Embedding-a-Scripting-Language-in-CPlusPlus.html&Itemid=29

- Christopher

Christopher Diggins

unread,
Nov 29, 2008, 11:05:25 PM11/29/08
to

I'm flattered!
Can't remember whether that version or the one at
http://www.codeproject.com/KB/cpp/dynamic_typing.aspx
is more up to date.

Cheers,
Christopher Diggins

Calum Grant

unread,
Dec 3, 2008, 5:07:37 PM12/3/08
to
Aaron Gray wrote:
> "Calum Grant" <n...@hotmail.com> wrote in message
> news:gf9c92$pk2$1...@aioe.org...
>> The first public release of C++Script is available. This is version
>> 0.9.0, which is a beta version.
>>

<snip>

> Hi Calum,
>
> Interesting direction.
>
> I have had a very brief look at your documentation but I have yet to look at
> the source.
>

I've got the code documented in Doxygen, and you can browse the
implementation here:

http://www.calumgrant.net/cppscript/html/index.html

This should help a lot,
Calum

Calum Grant

unread,
Dec 4, 2008, 6:11:53 PM12/4/08
to
Christopher Diggins wrote:
>>> Hi Calum,
>>> Great job! I'm really interested in contributing to the language. Is
>>> there any chance you might consider releasing it under a more
>>> permissive open-source license? Otherwise I am not sure how much I'd
>>> be able to offer.
>> I've released version 0.9.1 under the LGPL.
>>
>> I don't feel happy making it freer than that at the moment. Actually
>> the FSF recommend using GPL for libraries, as they discuss here:http://www.gnu.org/licenses/why-not-lgpl.html
>
> Thank you very much, Calum.
> I have some opinions of the FSF and the GPL which can't be posted
> without starting a flame war. :-)
> Anyway, thanks for making it LGPL.
>
> Prepare for a potential onslaught of visitors. I have posted about C+
> +Script on my blog at:
> http://dobbscodetalk.com/index.php?show=Embedding-a-Scripting-Language-in-C%2B%2B.html
>
> Some random suggestions:
> - change the name officially to CppScript. No one will ever find C+
> +Script (or is it C++ Script?) in Google.

A quick Google search reveals it's now at position #4 for "C++Script".
So it might be okay.

> - break up the manual into multiple pages.
> - prettify the manual (use a CSS)
> - post more CppScript samples in the examples

Good ideas. I'll get that done before version 1.0.

> - write a CppScript validator (is file X valid CppScript)

That should be okay, and will come directly from the grammar.

> - move your project to Google code hosting http://code.google.com/hosting/

Great idea. I've moved the repository and hosting to
http://cppscript.googlecode.com and am in the process of setting up a wiki.

> - formalize the language: what are the precise syntax and semantics.

The syntax should be relatively straightforward, but I'm neither willing
nor qualified to write out formal semantics. A spec might be more
appropriate, but I can flesh out the reference section.

> - I would like operator, overloaded for lists. e.g. var mylist = nil,
> 1, 2, 3;

I'll look into that. The current notation is array(null)(1)(2)(3).
Unfortunately the C++ comma operator associates left which isn't quite
what you want.

> - I would like all collections to inherently support ".indexes()",
> which returns a range. This would allow me to write foreach (i,
> xs.indexes()) and simplify many algorithms.

Actually, the var::keys() method does this already.

> - I want to know precisely what subset of C++ makes up CppScript.
> Obviously anyone can mix and match, but having a formal distinction
> between the two, would be nice, because if I was to write a CppScript
> interpreter/compiler/translator, I would know what features to
> support.

There's no official spec - I suspect that a grammar would go a long way.

> - I would like to see a module system or namespaces as an official
> part of the CppScript language. I have a few ideas on maybe how to do
> this.

I'm thinking about this. C++ has its own approach to libraries already.
I'm not sure if I want to expose users to C++ namespaces.

> - Consider providing a formalized numerical system (like Scheme's
> numerical tower).

It kind of has this already. There's a method called comparison_index()
which returns the index, starting with cmp_null=0, cmp_false, cmp_true,
cmp_char, cmp_wchar, cmp_int, cmp_double, cmp_string, cmp_wstring,
cmp_array ...

In a sense, each category subsumes the previous one. Users see this in
the sense that there can sometimes be implicit conversion between the
types, but types can convert "up" as well as "down".

> Some questions:
> - Do you know who is using this project yet?

Not yet. It's still early days.

> - What are the plans for this project?

In the short term, iron out little issues and tidy things up. In the
longer term I want to write (or get other people to contribute, hint
hint) functionality that is particularly suited to dynamic programming.

I'm still at heart a C++ programmer, so my aim is to enrich C++ with
dynamic programming, by using dynamic programming where it's
appropriate, and static typing where that's appropriate.

> - How can I help?

I've written up an implementers' guide which includes a task list of
both short term and long term ideas:

http://www.calumgrant.net/cppscript/C++Script%20Implementors%20Guide.html

I'll move this to a wiki shortly.

Thanks a lot, Calum

Calum Grant

unread,
Dec 5, 2008, 8:37:50 AM12/5/08
to
Christopher Diggins wrote:
> - I would like operator, overloaded for lists. e.g. var mylist = nil,
> 1, 2, 3;

I've decided against this functionality because there would be too many
problems with the existing C++ "," operator. For example you'd need
brackets around the list in your example above, and more importantly
you'd have to ensure that the first item in the list was a "var" type.
(Unless you intend that "nil" is a special list constructor, but that
would look slightly odd).

The problem is that most people would expect

var v = (1,2,3,4);

to produce a list, whereas in C++ this would actually just give the
number 4.

0 new messages