Sign in to follow this  
AcidZombie24

I dont know what script language to use

Recommended Posts

I dont know what script language to use or if i should bother? I do cross platform code. All my code works on linux, mac and windows along with some consoles (such as DS). Most of the time i only need stl containers and some template. I use a c++ libs frequently, I tend to like power. VB6 stressed me because i couldnt do what i wanted to do. So... What scripting language should i use? how easy is it to call my c++ functions? do i have access to template classes or template anything? I would at the very least need function overloading and default func params such as long func(long param1, long var2, type varWithDefault=defaultNumber, string anotehrType="i should still be able to overload this func with the first param as a float or whatever type i like") { ... }

Share this post


Link to post
Share on other sites
Another vote for python here. Boost::Python makes it pretty easy to interface with your c++ code.
To answer the question, python doesn't support function overloading (AFAIK), but default parameters are fine.

Share this post


Link to post
Share on other sites
In the kinds of languages that tend to be used as "scripting" languages, concepts like templates and default arguments aren't that important. For example, with lua:

-- this function returns a number
--
function func(param1, var2, varWithDefault, anotehrType)

varWithDefault = varWithDefault or 42
anotehrType = anotehrType or "default values"

local result = 0

if type(param1) == "number" then
-- do whatever
elseif type(param1) == "string" then

end

-- do whatever

return result
end



Now there are some downsides. You will need to explicitly check the types sometimes, which can be a pain. But the benefits more than outweigh the costs I find. Anonymous closures are awesome [smile].

Share this post


Link to post
Share on other sites
edit: I just reread your question, as far as I know Lua doesn't do defualt param, but u can optionally not pass parameters, they will be nil when the function is called, u can check for that and give them defualt params.

Lua can do OOP just fine there are several good examples in the Lua wiki,

http://lua-users.org/wiki/

I use this :

http://lua-users.org/wiki/SimpleLuaClasses

It does what I want, but I noticed that u can't call a base call impl from a super class function directly, you'll have to modify the impl to keep the base class metatable around for that. It's a minor modification but worth it, that's how C++ does it too.

As rip-off mentioned though, it doesn't do explicit type checking, due to Lua dynamic nature, you'll have to build in some mechanisim for that yourself.

Good Luck!

-ddn

Share this post


Link to post
Share on other sites
Python is strongly and dynamically typed. Each object has 1 strict type, and attempting to convert between them without the proper mechanisms will raise an exception. However each variable name can be bound to an object of any type. In typical use you would only bind a name to 1 type, sometimes 2 (with the 2nd being the 'None' type) but it doesn't enforce this.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this