Sign in to follow this  
Nanook

lua vs v8

Recommended Posts

Nanook    537

I'm been working on a engine for about 3 years, but had a break from it for some months now. Diving back into it now and I'm going to embed some scripting language for it. I thought I had decided on JavaScript with V8, but now I'm thinking maybe I want to use Lua instead. I'm having trouble making up my mind.

 

I'm intrested to hear from people using either of them and why you chose the one you did. Does someone know of some engines that uses either of them that I can look at some examples on how it used?

 

 

Share this post


Link to post
Share on other sites
Ravyne    14300

Lua is used more widely for scripting, so there's a lot of knowlege and third-party systems for making integration easier. For myself I'd actually prefer javascript (ecmascript, actually) -- there's nothing wrong with Lua though, I just feel that ecmascript is a more useful skillset all-around. Unfortunately the knowlege and tooling for integrating v8 isn't really there, so you're on your own for the most part. To its benefit, ecmascript is also easy for people with a background in flash or front-end web development to 'transition' to, which could be a way to differentiate your engine from all the rest.

Share this post


Link to post
Share on other sites
skwee    337

I'm interested in the same topic and made some research.

First of all, v8 is faster than pure Lua but slower than LuaJIT. I know that both Lua and LuaJIT successfully implemented in different engines and games. I haven't heard of a decent engine\game that implements v8 though.

 

Lua is a very cute language, I had some experience with it. Its widely used in games, so there should be a lot support for it.

JavaScript on the other side is getting very popular now because of web developers who uses it, node.js. So consider this if you are planning to find people who have experience in JavaScript. However there are no documented experience of using v8 as a game scripting language, so consider this as well.

 

my 2 cents

Share this post


Link to post
Share on other sites
Nanook    537

I've been googling a bit the last days too. I like the syntax better for js than lua. That might be because I use abit of js at work though? :p Performance shouldn't be that cruisal for a scripting language so I don't think I will base my decission on that.

 

I found this link:

http://www.moddb.com/games/rogue-reborn/news/rogue-reborn-googles-v8-and-implementation

Share this post


Link to post
Share on other sites
rpiller    839

Lua is very easy to implement and to bind to other languages. I'm guessing that's a large reason as to why it's mainly used in AAA games. It's also a small footprint which I've heard Javascript engines are not compared to Lua.

Edited by rpiller

Share this post


Link to post
Share on other sites
Nanook    537

Does it make sense to use stuff like node.js in the scripts to write a server all in js? I've never used node.js before so not sure how it would work, but a friend of mine said that could work? 

Share this post


Link to post
Share on other sites
skwee    337

Nanook,

Node.js is just a software platform written in C, C++ and JavaScript. The core of node.js is written in C and C++ with bindings to JavaScript. And yes, it is possible to create a web server entirely with node.js. I'm not going to say you should do that before I'll know what your needs are.

 

As for scripting, I wanted to create scripting engine with JavaScript, simply because I love JavaScript, but I assume its easier and more common to use Lua because it was already tested and proved to work. And I agree with previous comments, Lua is very lightweight.

Share this post


Link to post
Share on other sites
Nanook    537

Yes lightweight and speed is a pro for luajit, but for script code that shouldn't be run too often anyways the performance shouldn't be a problem should it?

 

How much more memory does V8 actually use? Does it really matter on todays hardware, even on mobile?

Share this post


Link to post
Share on other sites
BitMaster    8651
One important issue with V8 might be that you cannot use it on iPhone/iPad because you are not at all allowed to generate executable code there at runtime. Qt had to implement their own (non-JIT) JavaScript implementation to transfer Qt 5.x over to those platforms. They also got a few other advantages out of a custom implementation (like retaining QML type information that was lost when stepping into V8) but depending on your cross-platform needs, V8 might be a no-go.

Share this post


Link to post
Share on other sites
Promit    13246

One important issue with V8 might be that you cannot use it on iPhone/iPad because you are not at all allowed to generate executable code there at runtime. Qt had to implement their own (non-JIT) JavaScript implementation to transfer Qt 5.x over to those platforms. They also got a few other advantages out of a custom implementation (like retaining QML type information that was lost when stepping into V8) but depending on your cross-platform needs, V8 might be a no-go.

iOS 7 exposes a JS engine of its own, though.

http://blog.bignerdranch.com/3784-javascriptcore-and-ios-7/

Share this post


Link to post
Share on other sites
DejaimeNeto    4221

Well, it is weird to compare fully interpreted Lua with Compiled JS.

 

I like my scripting languages to remain as loose as possible, so I avoid compilation.

It makes all tests easier, requires less set-up steps before running them, allows me to change scripts during runtime, are easier to debug depending on the compiler.

I only compile the scripts (using Lua's own compiler) when I want to send the built project somewhere, without source code. But I don't think that brings any considerable performance gain, in this case.

 

Also, the different syntax is a pro on my account. I often got myself writing C++ code on my script editor when I was using C-like syntax scripting. Different syntax makes it easier to differentiate both, so I don't end up overengineering my scripts nor neglecting my low level code.

 

I have a personal rule, if my script performance is affecting my game, I'm doing something wrong.

 

So, between these two, I would not really care that much. They are both easy to learn if you don't have experience.

Performance differences shouldn't really be groundbreaking or anything.

Go with the one you are most comfortable with!

I would personally pick Lua without hesitation.

Edited by dejaime

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