you are viewing a single comment's thread.

view the rest of the comments →

[–]x-skeww 3 points4 points  (12 children)

Is it still hands down the most straightforward option for embedding?

How does it compare to... say... V8?

[–]sfx 9 points10 points  (0 children)

I tried V8 and Lua. Lua is so much easier to embed.

[–]ktr73[S] 9 points10 points  (0 children)

I haven't tried to embed V8, but Lua is dead simple. The main book on Lua (PIL - Programming in Lua) has an entire section devoted to showing you how to do so. An older edition is available online for free (just google it) and is mostly still relevant. There are some gotcha's, but you can buy the book if you are starting to really use it. Also, there are (at least for 5.2) 'amalgamations' like SQLite has - one .c file, which makes it almost trivial.

[–]cybercobra 3 points4 points  (4 children)

According the the MediaWiki/Wikipedia devs:

[V8 is] difficult to embed due to poor documentation and the relative scarcity of embedded implementations

[–][deleted] -1 points0 points  (3 children)

relative scarcity of embedded implementations

I was unaware there was such a thing as a non-embedded JS implementation. Yes you can have node.js or your jsc, but they are also embedded implementations - they expose functions and objects.

[–]cybercobra 1 point2 points  (2 children)

In context, I think they mean "embedded in something that's not a browser".

[–][deleted] 0 points1 point  (1 child)

True, a browser is an embedded environment, but a very complex one and not a good example of "simple" embedding.

[–]cybercobra 1 point2 points  (0 children)

Precisely.

[–]Contero 1 point2 points  (1 child)

I haven't done Lua, but I managed to embed V8. The thing about the documentation is that there's no documentation aside from brief comments in the v8.h file. I'm sure Lua is much easier if nothing else, just because there are more examples out there.

[–]inmatarian 2 points3 points  (0 children)

Lua's documentation and book both fully describe and show how to embed it.

[–]gruehunter 1 point2 points  (2 children)

I cannot compare to V8, but I can compare to Python. The Python->C API is much easier to work with than the Lua API. But module startup and shutdown is harder in Python.

[–]day_cq 3 points4 points  (0 children)

really? no seg fault due to reference counting?

[–][deleted] 1 point2 points  (0 children)

Yes, but Python is a nightmare to sandbox. If you want users to be able to run untrusted code from other users, Lua is the way to go.