From owner-freebsd-questions@FreeBSD.ORG Mon Jan 19 00:11:48 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E593C106566B for ; Mon, 19 Jan 2009 00:11:48 +0000 (UTC) (envelope-from linda.messerschmidt@gmail.com) Received: from rv-out-0506.google.com (rv-out-0506.google.com [209.85.198.239]) by mx1.freebsd.org (Postfix) with ESMTP id BB9688FC16 for ; Mon, 19 Jan 2009 00:11:48 +0000 (UTC) (envelope-from linda.messerschmidt@gmail.com) Received: by rv-out-0506.google.com with SMTP id b25so2501602rvf.43 for ; Sun, 18 Jan 2009 16:11:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=jJ2PT5Idp6rAzYhzeYSTSpsEnf0Z4xjd3+U72IMlXns=; b=AnT8H1HcuDZU1SOVMzE+MA49guHc1SEIlS/ZlMoLGq8Rtrc1k2WuQ5EllwZsralDWb Wqqp+yfExDjMMaUVHYve+SlUqLyvRTIppwHydnkdwNmLOy+NHME4wWQklpjlUuXNweka NIQYzSnoOKN6v0zCGVJhhGCMmrqHU/i8/xjL0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=uw7MtgfY08oLto87Gl/NTKLW8t8jCqVUDyZ81OA6QxGZaxKfW/xBI2PabgO4PBg8s6 x7hGwg2ipsK+67zLSUCDRWfZhWYkE8XaG4bxjG0kYhjp3Sbt6AP22uxhYHYB+0PxBPf1 aWwhDIgAEdsVE7MNo386ngpKtu14a5Ssd5UkQ= MIME-Version: 1.0 Received: by 10.140.187.10 with SMTP id k10mr40726rvf.264.1232322119503; Sun, 18 Jan 2009 15:41:59 -0800 (PST) Date: Sun, 18 Jan 2009 18:41:59 -0500 Message-ID: <237c27100901181541n412f66c3v24ebae43b9efc313@mail.gmail.com> From: Linda Messerschmidt To: freebsd-questions Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Embedded scripting language advice sought X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jan 2009 00:11:49 -0000 For a project I'm working on, I need to find an scripting language, and I have a long wishlist: - able to be "easily" embedded in a C++ application - "real" object-oriented with inheritance (preferably multiple inheritance) - able to implement object methods in C++ where needed - "sandbox" operation (e.g. ability to suppress any file I/O & system libraries, but keep math and string libraries) - thread-safe, or, at least able to have multiple coexisting execution contexts in one running process - relatively user-friendly syntax (i.e. (not (lisp (based)))) - has to build and embed on FreeBSD This is a mathematical model, and the goal is to write certain high-performance parts in C++, but to provide the user a command-line style interface where they can "explore" interactively, examine/tweak data values, etc, and then override certain behavior by subclassing from the C++ base classes using the scripting language to see how it affects the next model iteration. One thread is handling the model calculations, and one handles the user's exploration, with appropriate synchronization when changes are made. (We are doing this already, but since the code is C++, only the data can be edited while it's running and inspection is limited to our hacky pseudo-language.) The obvious choice for this was Lua; it hits a lot of the marks, but not all of them and not all well. I got as far as creating a Lua "object" in C++ that exposes some core functionality, which is great, but when it comes to inheritance, and especially multiple inheritance, Lua's object model wasn't thrilling me. Also, it uses setjmp for error handling, which I'm worried will mess around with C++ exceptions; they are already fragile enough in threaded applications. I do like Lua, but I'd really rather find an embedded scripting language designed from the start to support OO, if one exists. Are there other alternatives I should look at? Lua is to C as ______ is to C++? I tried to give Guile a look but a quick poll of the users vetoed the syntax. Lua is clearly ahead in the user-friendly department. I also wondered if Python would be a good choice, but I'm just not sure about how well it handles having new code generated more or less on the fly in the middle of a running application. I somewhat suspect that if it were done in Python, it would end up being a Python app with C++ add-ins, rather than a C++ app with an embedded scripting language. That isn't a deal-breaker, of course, as long as it works; results matter. That's not exactly "lightweight" though, and I'm not sure if (or how) Python sandboxes. One last "wouldn't it be nice" wish... If the user creates something they particularly like on the fly, compositing up an object a piece at a time on the command line, it would be just grand if the scripting language were able to reproduce a class definition for that arbitrary object that could be saved or tweaked for later reference and reuse. If not, we'll just have to abstract the editing process enough to keep one ourselves, which would probably be a bit user-unfriendly but hardly the end of the world. But with a wishlist this long and exotic, I'm afraid the question here is not whether something can do it all, but how disappointed I'm going to be. :-( I'm grateful for any language suggestions or feedback. Is Lua as close as we can get? Python? Other?! Thanks! -LM