sol2 icon indicating copy to clipboard operation
sol2 copied to clipboard

[HELP] sol2 Users - Feedback Appreciated!!

Open ThePhD opened this issue 7 years ago • 56 comments

Hello, users of sol2! This issue was made so that I could get a better idea of what you all use for Lua and how much you like / dislike sol2 compared to what you used to use (if anything) and sol2 now. If anyone could just reply to this issue with their thoughts, perhaps answer some of the questions below (or go on a tangent, really anything), I'd appreciate it. I'm going to be writing a paper about sol2 and the Lua landscape, so I'd like to get to know what my users use sol2 for:

  • How did you find out / hear about sol2?
  • What're you using it for?
  • What Lua library did you use before you found sol2?
  • What do you like about sol2?
  • What do you dislike about sol2?
  • Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)
  • Is the documentation or examples helpful?
  • Anything else about the library you feel like adding or pointing out?

Thanks for much for reading and considering, and double thanks if you do reply!

If you don't have a github, nag me on twitter with @thephantomderp or just shoot me an e-mail or something. :+1:

ThePhD avatar Aug 22 '16 17:08 ThePhD

  • How did you find out / hear about sol2?

Was investigating sol originally, but found there to be bugs which were fixed in a sol2 developer branch.

  • What Lua library did you use before you found sol2?

Did not use any extensively, however, I was investigating sol and luacppinterface.

  • What do you like about sol2?

Syntax is much cleaner than other libraries.

  • What do you dislike about sol2?

Take the following with a grain of salt, as these are negatives, but I also understand why they exist.

  • Compile times: When creating even simple structures, the compiler takes a world of time to figure out loading
  • Error messages: The current error messages when a compiler error is made are opaque and often are not an indication of the user error because they propagate so deeply before surfacing.
  • Build tool: As a multi-platform developer, it would be helpful to have the project building with a classical build tool like cmake for integration purposes
  • Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

N/A

  • Is the documentation or (examples)[https://github.com/ThePhD/sol2/tree/develop/examples] helpful?

The documentation has become excellent and you're great at improving it when brought to your attention.

  • Anything else about the library you feel like adding or pointing out?

Keep up the activity, it's great to see. What would be helpful is having a means of "asking for help." Github issues don't seem like the place for that and there's a lot of people asking questions. Additionally, there has been a significant amount of "unprofessional" contact within the issues pages and it's off putting for enterprise types to see it.

Nava2 avatar Aug 22 '16 17:08 Nava2

How did you find out / hear about sol2?

While searching around I found this page: http://lua-users.org/wiki/BindingCodeToLua That eventually brought me to sol2, although I tried others as well.

What Lua library did you use before you found sol2?

I used Luabind many years ago. It worked alright at the time.

What do you like about sol2?

Header only library, and even single header if you want. This makes it so much easier to integrate with an existing codebase. Very clean syntax. I'm really impressed how little I have to type to get things hooked up between C++ and Lua.

What do you dislike about sol2?

I haven't had a ton of time to use it yet, but so far I am pleased with how the code works.

Is it easier or harder from the last Lua library you used?

Definitely easier and less verbose.

Is the documentation or examples helpful?

The docs are a bit messy, but the information is all there and accessible.

If I had to suggest something it would be to provide more complex/practical examples. Most of the examples use simple types like integers, floats, strings. Showing how to properly pass/return usertype classes between C++ and Lua would be cool.

Anything else about the library you feel like adding or pointing out?

Overall I think this is the best Lua binding for C++ right now. I am using it for some server side logic for an online game at the moment (I think games are a pretty common use case for Lua scripting). When I get more time I'd like to read through more of the Sol code to understand how things work under the hood as I think it would be a good way to learn more about C++14 features.

Grant1219 avatar Aug 22 '16 19:08 Grant1219

How did you find out / hear about sol2?

  • per random from this post: post

What're you using it for?

  • my little sparetime project: FrankE

What Lua library did you use before you found sol2?

  • selene

What do you like about sol2?

  • fastest in the land
  • lua, luajit support
  • your energy you put into this wrapper
  • fast/good support from you
  • very active

What do you dislike about sol2?

  • currently i'm just scratching the surface, so i'm happy till now

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

  • registering objects in selene was a bit easier for me. But thanks to your help and doc, i got it to work

Is the documentation or examples helpful?

  • Yes. but as every doc, it could be better, clearer and having more examples. But it's already very good for an open source project documentation.

Anything else about the library you feel like adding or pointing out?

Keep it up! don't abandon it, even if you're full with work or family! :)

devxkh avatar Aug 22 '16 21:08 devxkh

How did you find out / hear about sol2?

I googled "C++ lua binding" and sol2 was one of the first few links.

What're you using it for?

I'm using it in an academic project. The program is a wxWidgets-based tool for natural language processing. Lua is used for plugins, and part of the high-level logic is also written in it.

What Lua library did you use before you found sol2?

I did some prototyping using the plain C API, with my own wrappers. Let's just say it wasn't fun...

What do you like about sol2?

It's very well written, header-only, there's a nice "getting started" tutorial, and most importantly it is super easy to bind C++ and Lua. Wrapping a class only takes a few minutes. It plays nice with shared_ptr.

What do you dislike about sol2?

Although the tutorial is very nice, I think the documentation itself could be improved. For example, adding your own types is not very clear, at least to me. It took me a fair amount of guess work, and I had to search in sol's source code to get it to work when I added my own Unicode String class (which was essential for me as std::string is a prank).

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

Far easier. In fact sol2 is the very reason why I decided to stick with Lua as a scripting language.

Anything else about the library you feel like adding or pointing out?

It's a really great library, keep up the good work! If you do publish a paper about sol2, please put the reference somewhere on the website so that I can cite it...

jeychenne avatar Aug 22 '16 21:08 jeychenne

How did you find out / hear about sol2?

I was looking for a good way to bind my C++ APIs to Lua. Then, I googled for C++ bindings and found Sol2.

What're you using it for?

I am using it for my application based on wxWidgets which can simulate a simple robot in a 2D space, to demonstrate some algorithms on common jobs -such as maze solving, pathfinding, etc. I use Lua and Sol2 to pass algorithms to be tested, and draw using wxWidgets.

What Lua library did you use before you found sol2?

I was using Selene before Sol2. I abandoned it after experiencing very simple bugs, and learning about its speed.

What do you like about sol2?

  • Very easy to bind.
  • ThePhD working on it actively, and s/he's very responsive to issues.
  • It's header-only.
  • It surprises me when I think the library is incapable of doing something, but it does it successfully. :smile:
  • It provides a lot of code examples in tests, documentation.
  • It's documented.

What do you dislike about sol2?

  • The way we navigate the documentation is not very good. It would be better if we had a contents page, listing every title, including the subtitles in a tree form.
  • Some parts of the documentation aren't clear. You may add more examples.
  • It's a huge library using template magic. And, template magic is somehow write-only for even small libraries. And with such a hugeness, it's really hard to comprehend the internals of the library, unless you're the author. If you document its internals, the techniques you use, then it would be great, and other users can also help the development more actively. (Of course, one may read the source code, but its hugeness makes it very hard without such documentation.)

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

I used both the C API and Selene. Of course, Sol2 is much easier to use than C API and it has same easiness level as Selene. (But I must confess that the plain C API is more fun but dangerous.)

Is the documentation or examples helpful?

They are both definitely helpful. But as I stated before, they can be improved.

Anything else about the library you feel like adding or pointing out?

It's just a great library. Thank you.

jnbrq avatar Aug 23 '16 12:08 jnbrq

How did you find out / hear about sol2?

Was just looking through GitHub for a better library than I had that didn't choke on Union-heavy user types

What're you using it for?

A small VR game, just want to test some code easier than just doing some recompiling

What Lua library did you use before you found sol2?

Selene

What do you like about sol2?

It's amazing and not stale so far, very responsive dev.

What do you dislike about sol2?

Nothing at all

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

It's pretty much the same in the difficulty department

Is the documentation or examples helpful?

Yes, it's very nice

Anything else about the library you feel like adding or pointing out?

I will do it if the need arises.

Thank you. :)

Murloc992 avatar Aug 28 '16 15:08 Murloc992

How did you find out / hear about sol2?

I don't exactly remember. I think I was looking for an alternative to luabind, as it was causing several issues for me, when I came across sol2.

What're you using it for?

I'm using sol2 for making data classes and functionality of a game engine available to lua land for a few mods I'm working on, in order to allow users to more easily modify the game via lua.

What Lua library did you use before you found sol2?

I was using luabind (some custom fork, not the latest official one).

What do you like about sol2?

I like that it's pretty straight forward, that it supports the vast amount of features my project requires, and that it's actively developed. Even things that were not supported were very quickly introduced by you.

What do you dislike about sol2?

I will have to agree with @Nava2 here. Compile times can be very long and generated code can also be very large. I understand that this is a trade-off of using template metaprogramming, which generates mostly static code in order to avoid performing operations during runtime, but especially for me, where I have projects with over 3000 generated bindings, it gets pretty insane (10GB+ RAM usage to link, about an hour to compile on 12 threads, 150MB+ output binary (with some optimizations on)). I believe there are some things that are inherently too complex for no reason in sol2's codebase, and can be possibly improved upon by simplifying them.

Secondly, the codebase itself is rather hard to follow for someone that hasn't been actively involved in the project's development from the beginning. During my attempt to implement member inheritance for #157 I was often lost trying to figure out what something does, and the lack of internal documentation in most places doesn't help either. This is more of a minor complaint, but I think that it could be an important step towards getting more people to actively contribute to this project.

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

I would say it's pretty similar to how luabind worked. Some things are definitely easier, while some things were slightly confusing when transitioning. Thankfully, the documentation (and yourself) were very helpful when it came to that.

Is the documentation or examples helpful?

The documentation has improved by orders of magnitude in the past few months. I believe it is now more accessible and more straight forward for people without immediate knowledge of lua or other binding libraries.

Anything else about the library you feel like adding or pointing out?

After my recent shenanigans with #157 I came across a possibly interesting observation, especially after looking at the benchmarks you posted. I think you should evaluate sol2 performance when accessing bound usertypes with a huge number of members that are dynamically indexed (ie. using find_call()), as it might produce different results than expected. I would do so myself, but unfortunately I can't get the lua-bench project to work correctly for me, and it was a massive pain to get it somehow working to evaluate the performance of my fork (which was apparently identical to yours btw).

OrfeasZ avatar Aug 28 '16 21:08 OrfeasZ

How did you find out / hear about sol2?

I found sol2 recommended in an issue report from jeremyong/Selene project.

What're you using it for?

  • Tremulous is an ioQuake3 Mod created by Darklegion Development but has since been discontinued. Using ThePhD/sol2 I would like to replace the standard in-game quake console with a full featured Lua REPL.
  • Lua support for my extended catalog of C libraries most of which are related to InfoSec.

What Lua library did you use before you found sol2?

Plain C API

What do you like about sol2?

Best documentation I've seen probably ever- Nearly everything has an example, what doesn't shows up as an issue here. Sometimes those issues turn out to be missing/broken functionality, but the pace at which they are fixed is worth a 🏆.

What do you dislike about sol2?

C++14- Figuring out how to add this to the ioquake3 build system (a massive hand crafted Makefile) and continuing to cross compile all the binaries via Travis is tough 😭.

  • update* i finally got my builds all working, it involves more docker than i would have though but works for me.

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

It is easier to use than the Plain C API. It is has better documentation and examples then the plain C API. It is better 👍

Is the documentation or examples helpful?

Yes, thanks!

Anything else about the library you feel like adding or pointing out?

Great Job!

wtfbbqhax avatar Aug 29 '16 01:08 wtfbbqhax

How did you find out / hear about sol2?

Recomendation from a friend.

What're you using it for?

Most recent use, I wanted to integrate bump.lua into my C++ game. It's not going to be definitive, so I wanted to do something quick.

What Lua library did you use before you found sol2?

Mostly C API directly, sometimes some self-made C++ wrappers, and something else made by my aforementioned friend.

What do you like about sol2?

Treating lua objects as they were C++ objects. Also, header only!

What do you dislike about sol2?

N/A, didn't use too much.

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

Easier.

Is the documentation or examples helpful?

Yes, but somehow I walked in circles for a long before being able to write this:

auto file = file_manager()->OpenFile("bump.lua");
L.require_script("bump", file->GetContents());
L.script("world = bump.newWorld(8)");
collision_body_ = L.create_table_with("name", "Player");
L["world"]["add"](L["world"], collision_body_, position_.x, position_.y, width_, height_);

Not really sure why...

Anything else about the library you feel like adding or pointing out? I'll definitely continue using!

henriquegemignani avatar Sep 28 '16 03:09 henriquegemignani

How did you find out / hear about sol2?

Google + some people on twitter (especially Jason Turner :D) recommended it to me.

What're you using it for?

I'm using it for my game called Re:creation

What Lua library did you use before you found sol2?

LuaBridge

What do you like about sol2?

Almost everything. Its interface, capabilities, speed. It has everything I need from the Lua/C++ binding.

What do you dislike about sol2?

  • Compile times. Those are being reduced by recent releases, but I feel like there's still some work that needs to be done about that. :)
  • Some random bugs breaking my game from time to time .Thankfully they're fixed very fast and I understand that maintaining such a huge project is very hard. And it's mostly stable and bugless in most things.
  • Safety being turned off by default. While I undestand that it's important for speed, there should be some important subset of errors which are thrown by the default. Getting a total crash instead of exception is frustrating at times, because you have no indication of what went wrong. And sometimes it's just some simple Lua error, like trying to call a nil value. sol::function vs sol::protected_function is still a not that obvious in my opinion. I guess most people expect functions to have some basic protection being turned on by default and have it turned off in some sol::quick_function or something like that.

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

It's much easier! Binding classes/functions, iterating over tables, creating new tables, handling state, etc. - everything is much easier and neater.

Is the documentation or examples helpful?

Yes, they're pretty great, though maybe some of them should be less abstract. And there are some common things people may need to do being left from documentation (e.g. returning table from script and getting it in C++). But I understand that there's work being done in that direction and I'll be happy to help with this once I have more free time on my hands.

Anything else about the library you feel like adding or pointing out?

Nah! Just keep doing great job @ThePhD, your Lua/C++ binding is the best one in most categories and I hope it gets more users, recognition and praise.

eliasdaler avatar Sep 28 '16 08:09 eliasdaler

How did you find out / hear about sol2?

I googled for methods how to combine C++ and Lua, found that plain C Lua was not compelling and searched for Lua wrappers and decided to take a look at Selene. However for some reason working with it didn't feel comfortable so i looked further and discoverered Sol (Sol1), which was great. After looking for updates i found out that you already released Sol2.

What're you using it for?

My team recently started working on a Ragnarok Online remake/singleplayer spinoff with the UE4 engine and i'll be using Sol2/LuaJit for moddable features like monster databases, item databases, npc scripts, quest scripts, etc.

I will also use it for any other future gaming project or even non-gaming project i'll do where scripting and modding would be useful. Sol2 made C++/Lua interaction really fun for me!

What Lua library did you use before you found sol2?

Selene, Sol1

What do you like about sol2?

I absolutely love -the comfortable syntax, -the many different syntax methods how to access tables -the amount of features it has (class bindings, method bindings, tuple returns) -Sol2 being header only -the speed, of course. Also, i really like how compatible it is with differnt Lua versions and LuaJit. Really great!

What do you dislike about sol2?

Currently my biggest problem is that it's not inherently compatible with Unreal 4 because UE4 only uses C++11 and has macro conflicts with Sol2 (as mentioned in one of my issue tickets) but i can't really blame Sol2 for that.

Other than that, maybe the usage of protected_function is a bit verbose, because you need to first assign a lua function to it, then an error handler needs to be defined, then you have to call it to get an auto object back, then you have to check if it's valid or not and then finally you can use it. I'm not sure if the return value usageit can be shortened, but an optimal usage when creating the function, would probably be something if we could initialize a protected function with two parameters : the first one being the lua function to call and the second being the error handler to call incase something goes wrong.

Currently it works like this:

sol::protected_function problematicwoof = lua["woof"];
problematicwoof.error_handler = lua["got_problems"];

which could be shortened to this: sol::protected_function functionname(<luafunction_to_call>, <lua_error_handler_function>);, or in practical values used by the documentation sol::protected_function problematicwoof (lua["woof"], lua["got_problems"]);, which would reduce the required lines for a protected function from 2 to 1 and we wouldn't have to manually assign the problematicwoof.error_handler with a separate line, much more comfortable and easier to read.

Heck, this could be taken even further by giving sol::state a option for a default error_handler lua function and then every protected function with only one parameter would use the default-ed error_handler:

sol::state lua;
lua.open_file( "somefile_that_contains_error_handler.lua" );
lua.default_error_handler = lua["got_problems"];
sol::protected_function problematicwoof (lua["woof"]); //<<< calls lua.default_error_handler if it fails

But other than that nitpicky stuff i'm very, very happy with Sol2. ^___^

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

I used Selene before Sol2 and for me, absolutely and definitely yes, Sol2 is much more comfortable and easier to use!

Is the documentation or examples helpful?

Absolutely! In the beginning it was a bit sparse but now it's really useful. I haven't read through all of it yet, though, but for the things i needed so far it's sufficient.

Anything else about the library you feel like adding or pointing out?

I like the dedication that is put in this library and the continuous development.

shohnwal avatar Sep 30 '16 05:09 shohnwal

How did you find out / hear about sol2?

Coworker at Wolfire Games told me about Sol2 when I was picking a scripting engine for my personal project.

What're you using it for?

Doing a ground-up C++ rebuild of the game engine for https://github.com/kavika13/jumpmanzero - using Lua as the scripting language.

What Lua library did you use before you found sol2?

None of them.

What do you like about sol2?

I'm a big fan of the transparent smart pointer support. I was skeptical, and expecting missed cases, but so far it's worked out well!

There is a lot that looks really promising (and already plenty useful). The syntax and API seem good. The continual attention to performance benchmarking and semantic differences between LUA/C++. The consideration for breaking/non-breaking changes.

The direct, suitably brief, not "RTFM", and non-defensive communication on issues is really great. This is a great example of how to talk to your user base 👍

I love the very human tagging on issues :)

The quick and dirty tutorial and graduating detail pages on C++ support is probably the thing that sold me hardest. Seeing a demo of a usertype front-and-center was the most important thing to me - I was expecting to have to read through those docs more fully before knowing whether I liked that interface or not.

What do you dislike about sol2?

I don't dislike anything, really, but I will describe some of my challenges so far.

The C++ STL container support isn't well documented yet, or if it is, I haven't found it. I've only found closed issues on the topic, and it looks like it is somewhat in flux. I'm trying to draft up an issue to discuss this further, though it's hard to tell the current state of the project and future plans on this topics.

I want to see a roadmap of things you think will need more work going forward. Even if there aren't any explicit milestones on that roadmap, this would still show where you are most interested in feedback, and where people are going to start hitting the fringes of the library.

This probably isn't something you can do much about (I think it might be Lua's problem?), but I am not liking the error messages I'm seeing when doing bone-headed noobish things like accidentally typing some_instance.some_method(xyz) instead of some_instance:some_method(xyz). I see the error thrown from Sol2 code, so maybe there's something that can be done about it. I wouldn't be surprised if it couldn't be solved, though, due to Lua's ability to pass fewer-than-declared parameters to functions...

From the docs (without having a solid grasp on Lua's user type support), I can't tell how far down the chain of user types I have to define things, and what happens down the line if I don't explicitly declare some types I expose as members. I also can't tell what happens if I choose to define only a few members of a user type, and then pass an instance back and forth between Lua and C++. Does it slice? Does Lua just expose an interface to the underlying C++ memory so I don't need to worry about it? What about cases where I return a struct instance (not a pointer to heap), don't explicilty define that user type, and pass that instance to C++ functions/methods/assignment to members?

A clearer and more open support forum might be a good thing. Irc? Slack? ;)

or go on a tangent, really anything

More on the choice of Lua + Sol2 than on Sol2 itself -

I haven't embedded Lua before. I used Lua in World of Warcraft a while back, and knew how it worked since I read most of the language spec back then. Lua looks like it is still the de-facto "standard" for game scripting, it's tiny, and generally pleasant enough to work in.

Squirrel and Angel Script were the other options I considered, and both look interesting. For my first game script embedding project, I wanted to use something that I would spend as little time as possible banging my head on. Application layer boundaries have been the source of ~90% of my google searches in the past 10 years, so I wanted to make sure I was going to find answers.

Sol2 still seems to be quite the work in progress (in the best way). It looks like you're paying plenty of attention to it, and it looks like it is already capable of doing what I need it to do.

kavika13 avatar Oct 15 '16 23:10 kavika13

How did you find out / hear about sol2?

http://lua-users.org/wiki/BindingCodeToLua I think I went through a couple of other C++ bindings quite rapidly before I got to this one (luacppinterface and luawrapper I think). They had limitations this one does not.

What're you using it for?

I little android/pc game engine I am working on. I'm driving UI, game state, and entity logic with lua. Had very little troubles getting consistent behaviour on both (and you fixed every one I had quickly).

What Lua library did you use before you found sol2?

luacppinterface and luawrapper if I recall correctly, but only enough to know they didn't cover all my use cases.

What do you like about sol2?

The support, the extensive features, how well complex things like overloading, properties and special functions are simplified.

What do you dislike about sol2?

How it doesn't exist in a vacuum and I might one day have to use lua api without it.

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

Probably the same for the features from the others that I remember and actually used. I'll put it this way: I haven't so far seen a feature in sol2 that I think could be easier to use.

Is the documentation or examples helpful?

Helpful enough.

Anything else about the library you feel like adding or pointing out?

It's pretty awesome. I guess one thing that makes me slightly uneasy is how complex the library is, and that one day I might have to fix a bug in it myself. I don't think it would be impossible but I haven't seen any docs for how the library itself works (I haven't really looked though, as it hasn't been necessary, and that should indicate how slight my unease is).

billw2012 avatar Oct 29 '16 21:10 billw2012

How did you find out / hear about sol2?

Googling around for a C++ Lua binding lib

What're you using it for?

Adding Lua bindings for a TI calculator emulator, so that (hopefully) both the emu core and GUI can be scripted :)

What Lua library did you use before you found sol2?

None (in other things, I've used the plain Lua C API though)

What do you like about sol2?

Very easy to use, and the performance is quite awesome

What do you dislike about sol2?

Well that's probably at least partially my fault for not learning all the new tricks in the book, but I've had a bit of a hard time sometimes understanding the fancy C++14 things going on in the code :)

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

N/A

Is the documentation or examples helpful?

Yep, definitely (especially the examples)

Anything else about the library you feel like adding or pointing out?

Keep up the good work, it really is a great lib!

adriweb avatar Nov 17 '16 12:11 adriweb

-How did you find out / hear about sol2? Googling for lua to c++ binding. -What're you using it for? Use torch from c++. Creating a bridge between lua code and c++ code. -What Lua library did you use before you found sol2? None. -What do you like about sol2? Easy to use. -What do you dislike about sol2? Strange compile time error for nested different type table like lua["a"][1]["b"][2] may not work if not casting to sol::table at each step. Need to create the table first a create table if needed would be nice. -Is the documentation or examples helpful? Yes but it miss sometimes an example of use. -Anything else about the library you feel like adding or pointing out? It would be interessting to have a function or class that create a main loop accepting the same argument than a lua interpreter which will allow to easely extend lua functionality without need to write c++ code to read a script and only write code to extend the types.

Strasser-Pablo avatar Nov 25 '16 15:11 Strasser-Pablo

  • How did you find out / hear about sol2? I think I googled "lua C++ wrappers" and found about sol
  • What're you using it for? I am using it for scripting part of my game
  • What Lua library did you use before you found sol2? I tried it going without any wrapper and it was a big head ache. thanks sol!
  • What do you like about sol2? It is pretty easy to use.
  • What do you dislike about sol2? Sometimes I get lua run time errors without explanations. Compile errors are impossible, but that is kinda expected when it comes to templates.
  • Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this) I tried to use plain C api before, it is definitely easier.
  • Is the documentation or examples helpful? Examples are very useful, honestly I didn't need to check documentation at all, everything I tried to was available with examples.
  • Anything else about the library you feel like adding or pointing out? Would it be possible to add any kind of performance analyzer? How much time I am consuming on lua methods, sol overhead or passing data between C++ and lua would be great.

shultays avatar Jan 09 '17 14:01 shultays

@shultays The most I can do for you is give you sol2's benchmarks compared to other libraries (available in the benchmarks section of the docs). After that, any performance analysis is something you'll have to insert around your code and the like...

ThePhD avatar Jan 09 '17 14:01 ThePhD

@ThePhD That is alright. Mostly I use visual studio performance analyzer tool but it does not work on lua of course. in future I will add remotery to my project and add ability to call it on lua.

anyway, great work! thanks for sol2.

shultays avatar Jan 09 '17 15:01 shultays

How did you find out / hear about sol2?

I decided to move from s7 Scheme + my own C++ reflection layer to LuaJIT+l2l + my own reflection layer. I first researched C++ wrappers for Lua before rolling my own, and I discovered sol (mostly by googling), which allows me to avoid writing a large part of the reflection layer (I still use my code to inspect C++ headers and generate the usertype mapping calls).

What're you using it for?

Wrapping the core C++ classes in a videogame to make them available to Lua code.

What Lua library did you use before you found sol2?

None, this is my first Lua project.

What do you like about sol2?

Super natural and easy to use, it just feels right.

What do you dislike about sol2?

std::[unordered_]set had no way to perform a lookup from the Lua side (other than iterating), and I saw in #196 it wasn't desired to have table-like access for lookups, so I added a :find to the container metatable. I've submitted a pull request.

I also have some very particular legacy requirements in the source I'm porting so I had to hack the metatables sol generates for my C++ classes (basically my old scripting system allowed any C++ instance to be extended on the fly with new scripting-side properties, so my __newindex and __index must lookup a Lua-side table for each instance for possible new fields, then pass control to the sol code). This is not a dislike, more like a resignation on my part, that I will have to follow closely the evolving internals of sol if I want upgrades.

Is the documentation or examples helpful?

They are!

Anything else about the library you feel like adding or pointing out?

I'm probably obsessing too much about performance (I'm still porting, so not doing perf work for now), but I've seen class methods and attributes are indexed by string, like map<string, ...>. I was dreaming on having a Lua-side table for this, to take advantage of the string interning, then instead of passing a string to C++, pass an integer ordinal, for a constant lookup into a vector. I may hack on this in the future if I'm not buried under a landslide of work.

Thank you for sol, it's top notch work!

carloscm avatar May 03 '17 21:05 carloscm

How did you find out / hear about sol2? Was looking for Lua Wrapper in C++ on GitHub. What're you using it for? As a VM frame work. What Lua library did you use before you found sol2? Just lua 5.1.5 vanilla for the Lua C API. What do you like about sol2? I was actually able to get it to work. Tried LuWra first but couldn't get it to work. What do you dislike about sol2? It's a little hard for me to understand. Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this) I found the plain C API easier but very limited compared to this. Is the documentation or examples helpful? Not really. They didn't show me what I needed to know. Anything else about the library you feel like adding or pointing out? Can you make some examples on how to use C API in this. I'm having a hard time figuring that out.

If you wouldn't mind, it would be great if you can add me on discord. My discord: <Aspect>bditt#0327 I really like this but I find it kinda confusing. Thanks for producing this. <3

bditt avatar May 15 '17 16:05 bditt

How did you find out / hear about sol2? I honestly don't know. I had been looking for a C++/Lua integration library, but do not remember across Sol. Then one day I was cleaning up my tabs and found one opened to Sol. There was no history to the tab, so I'm guessing I did the "Open in new tab" thing and forgot about it.

What're you using it for? I've been working on a video game. It requires some really heavy optimization, so I've been writing my own engine in C++. The Unreal engine might be able to suit my needs, but meh.

What Lua library did you use before you found sol2? I tried out LuaBind, but that thing is a serious pain in the butt to compile. Boost is a great idea, and I use it, but I personally feel like they really over complicated that project. I've also used LuaJ. Your library is easier to use than that one.

What do you like about sol2? Being a header only library, it's super easy to cross compile, which is something I do. It's also very intuitive and has excellent documentation. I mean really, your documentation is worthy of an A+.

What do you dislike about sol2? I've had some trouble getting it to play nicely with the Boost filesystem library. Even with sol::resolve, it just can't figure out which overloaded function I'm trying to get from the path class. I honestly don't know if it's an issue with sol, boost, or if I'm just doing it wrong. It works right with other classes, so I think it's one of the APIs causing the issue.

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this) I've used the C API before, and I've also used LuaJ, but this one has proven to be the easiest one to use.

Is the documentation or examples helpful? This is some of the best documentation I've had the pleasure of reading.

Anything else about the library you feel like adding or pointing out? It's very useful to be able to define classes in C++ and make them available in Lua, but it would also be very helpful to have the power to define classes in Lua that are derived from a C++ class. For example, I would like to define base GUI elements in the C++ side and then let Lua extend them to make custom GUI elements. I'm okay if we have to extend a bunch of functions/add a bunch of stuff to the class intended to be extended to make this work, but only if we have to. I'm actually contemplating contributing to this project to add a feature like that.

IamTheCarl avatar May 19 '17 22:05 IamTheCarl

How did you find out / hear about sol2? What Lua library did you use before you found sol2?

  • using google to find an up-to-date alternative to luabind

What do you like about sol2?

  • performance
  • easy to include in the project
  • up-to-date c++
  • that it exists and is maintained ;)

What do you dislike about sol2?

  • documentation is lacking in some areas.
  • some features are missing, or just not possible right now (see below)

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

  • about the same

Is the documentation or examples helpful?

  • it's helpful, sadly the documentation and examples only cover the obvious stuff, more complicated features are not mentioned no examples e.g. not every sol::metafunction like sol::metafunction::pairs...

Anything else about the library you feel like adding or pointing out?

  • ~~for usertypes, why is the constructor called 'new', and not just sol::meta_function::call. e.g instead of local instance = usertype.new() -> local instance = usertype()~~ edit: see https://github.com/ThePhD/sol2/issues/189#issuecomment-313220848
  • what's the difference between
sol::object <-> sol::reference
sol::stack_object <-> sol::stack_reference <-> sol::stack_proxy

and when do I use which?

  • why is it called sol::object::as<T>() vs sol::reference::get<T>(), while both seem to do similar things, they are named differently - why?
  • difference between the script loading functions seems confusing and is not documented sufficiently
sol::state::do_file <-> sol::state::script_file <-> sol::state::load_file
sol::state::do_string <-> sol::state::script <-> sol::state::load
  • how would I load a compiled lua script, but not if it's plaintext (or the other way around)? how do I check the script I want to load for syntax errors without actually executing it (this probably just needs some documentation, I guess it's possible with sol::state::load_buffer)?
  • get_type seems to be missing when iterating over sol::variadic_args, which requires a conversion to sol::reference
    lua.set_function("print", [](sol::variadic_args va) {
        for (auto v : va) {
            // why is there no v.get_type() ?
            sol::reference r = v;
            if (r.get_type() == sol::type::string) {
                ...
            }
        }
        ...
    };
  • dynamic amount of return values: Let's say i wanted to write the function table.unpack with sol and c++, which takes a table, and returns all of it's values. Currently this doesn't seem possible, as you can only return a fixed amount of args with sol.
  • is there any way to get sol to convert any type to a string while bypassing type checking (without manually pushing the value to the stack and using lua_tostring and then doing the codecvt stuff)?
    lua.set_function("mytostring", [](sol::object const& o) {
        return o.as<const char*>();
    });
    mytostring("asd") -- works
    mytostring(1) -- error, expects string

That being said: I really appreciate all the effort you put into this library. Keep it up!

mrgreywater avatar Jul 05 '17 20:07 mrgreywater

@mrgreywater I've had the same "issue" about the .new(), you can customize that with sol::call_constructor, see the messages below in the comments I've linked.

adriweb avatar Jul 05 '17 20:07 adriweb

@mrgreywater Thanks for your interest in sol2. I'll try my best to answer your question, and also redirect to new issues I'll open up in case our framework doesn't cover something.

  • The difference between stack_reference and reference is mentioned in the documentation here. It is meant for a person working directly with the stack. It's obviously not immediately mentioned because it's really not important to anyone who isn't trying to use sol2 directly with the C-API and it's stack or at a "low level".
  • as<T> used to perform type-checking by default, no matter what you did. It was changed around a bit, and now it does not (you're supposed to do obj.is<T>(), then obj.as<T>() if you want to force checking). It is also what people were used to doing (is + as is common conversion language idiom). get was poorly named for the proxy-types (the result of lua["b"] and the result of dereferencing iterators for variadic_args). and should have been is and as, all along.... but, well. There's thousands of lines of code now that rely on the API as-is (HAHA, GET IT??), and oh god would I be an idiot to start forcing changes now...
  • I don't have documentation for complicated use cases because at that point I expect someone to have read Lua's manual and connect the dots. For example, pairs is a metamethod only viable in Lua 5.2/5.3 and it allows you to override the default pairs() behavior. It's exceedingly advanced and at that point either I'd basically copy-paste the Lua manual and sprinkle on some sol2-isms or expect someone to read the manual and get cozy with exactly what they're trying to mess with (because you'd need to understand the Lua stack and what you're messing with at this point to start destroying things at that level anyways). I am also not super-human: this is a solo-maintained, solo-man job as it has been for the past few years, and most people had trouble with the basics (which is why it receives the biggest face-lifts and aggregations for the docs). The people who wanted advanced things are often thrifty enough to recognize Lua terms and know what to follow to get it done. Still, pull requests and help with the docs is definitely appreciated and welcome (otherwise, you're sort of subjected to my pace of recognizing problems in the docs and fixing them, which sometimes is lightning fast and other times is absolutely lacking).
  • The string-enforcement is a deliberate choice: SOL_CHECK_ARGUMENTS does not budge and there's no backdoor methodology I've placed in the API. Your options are to turn off safety (SOL_CHECK_ARGUMENTS -> don't define it) and manually sol::protect what you want to protect, or to do a get_type and manually convert when you detect the argument is not a string. The reason it's like this is because of overloading: I have to strict-type-check, otherwise overloads between functions that take, e.g. 1 string versus 1 integer become BROKEN.
  • You're right that there's no built-in way to return multiple arguments. You can jerryrig a customization point. But that's hacky and dumb and you're right that I should have something that could return 1 or 3 or 20 arguments depending on a runtime decision, like whether its a nice day outside or not.
  • I'll add get_type to the proxy, thanks for catching that oversight. I'll also consider adding is and as and get_type to every proxy, too (though I don't think I can remove get, which will effectively mean there's 2 functions doing the same thing... OH WELL. The price of my sins as a bad API designer).

ThePhD avatar Jul 07 '17 00:07 ThePhD

Okay, I'm one week into this drug so I think it's time to give some feedback.

How did you find out / hear about sol2?

http://lua-users.org/wiki/BindingCodeToLua (totally should be at the top of that list!)

What're you using it for?

Adding a scripting API to my long-time sparetime project OpenMPT.

What Lua library did you use before you found sol2?

The idea of adding scripting to that application came up in about 2010, at which time I was still trying to roll my own abstractions from the Lua C API. Then later I decided to use Squirrel (with the Sqrat wrapper) instead, and now I'm back to Lua after considering that it just has the better (more alive) ecosystem (like this wrapper). We only recently dropped support for compilers older than VS2015, and now I have one more reason to be glad about that change.

What do you like about sol2?

  • Ease of use
  • Usage feels similar to the standard library
  • Use of operators to avoid explicit function calling where necessary, which makes the code a lot shorter
  • Header-only
  • Can't say anything about the performance right now since I'm not doing anything that would require it yet.

What do you dislike about sol2?

  • Compilation times. :D My API is still really small (less than 100 functions/properties in maybe a dozen usertypes or so) but it's already taking a considerable amount of time to compile the wrapper source file.

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

Definitely easier than the C API, and if the comparison is allowed, also easier than the Squirrel bindings I've tried.

Is the documentation or examples helpful?

Mostly yes, and when there's something that's missing, I've already seen that you will add it basically at light-speed. ;)

Anything else about the library you feel like adding or pointing out?

Thanks for the continued maintenance!

sagamusix avatar Jul 07 '17 17:07 sagamusix

@mrgreywater I've pushed some new stuff that adds some ease-of-use for some of your concerns (except for the string handling). You can see it in the new docs:

http://sol2.readthedocs.io/en/latest/api/as_returns.html http://sol2.readthedocs.io/en/latest/api/variadic_results.html

That should help you get very far. For the string thing, see the advice here: https://github.com/ThePhD/sol2/issues/442

Good luck!

ThePhD avatar Jul 09 '17 18:07 ThePhD

How did you find out / hear about sol2? Found here: http://lua-users.org/wiki/BindingCodeToLua What're you using it for? New scripting API for TES3MP What Lua library did you use before you found sol2? LuaBridge What do you like about sol2? Ease of use. C++11 and C++14 support. What do you dislike about sol2? Payment for head-only (Compilation time) Is the documentation or examples helpful? Helps a lot Anything else about the library you feel like adding or pointing out? Would be nice if you add terra compatible layer

Koncord avatar Aug 31 '17 05:08 Koncord

@Koncord What's a "terra compatible layer", exactly? Where you can make sol2 speak to all of Terra...?

ThePhD avatar Sep 01 '17 12:09 ThePhD

How did you find out / hear about sol2?

Don't remember exactly, some blog post, possibly eliasdaler's

What're you using it for?

A hobby game project.

What Lua library did you use before you found sol2?

None

What do you like about sol2?

It is really convenient to use.

What do you dislike about sol2?

Nothing comes to mind.

Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)

N/A

Is the documentation or examples helpful?

Yes, the documentation is first-class and the examples are useful as well. So far I found everything I was looking for.

Anything else about the library you feel like adding or pointing out?

I love how it exploits modern C++ meta programming to generate the binding code. Feels like knowing how the Lua C API works is a prerequisite. Not that this is a problem, after all this is a Lua bindings project. Maybe add a note about that and a link to the relevant chapters of the Lua book. :)

denesb avatar Dec 21 '17 13:12 denesb

Questions:

  1. How did you find out / hear about sol2?
  2. What're you using it for?
  3. What Lua library did you use before you found sol2?
  4. What do you like about sol2?
  5. What do you dislike about sol2?
  6. Is it easier or harder from the last Lua library you used? (If you did use a library or the plain C API before this)
  7. Is the documentation or examples helpful?
  8. Anything else about the library you feel like adding or pointing out?

Answers:

  1. Searching Github for a lua wrapper.
  2. I use it as a reference guide by studying the code and try to make my own version that will work with my functions.
  3. I only used the vanilla Lua 5.1 library before learning of Sol2.
  4. I like how easy it is to use Sol2 along with it being open source.
  5. That I can't get it to actually be compatible with my project but that's only because the problem is on my side. Not Sol2. Besides that, nothing. @ThePhD, fixes any problems that arises pretty fast if he is able to.
  6. It makes it easier because it makes ideas seem more possible because the functions from Sol2 gives you ideas.
  7. Yes, they are helpful but could be a little more in-depth.
  8. The library is pretty great in general and I just wish I use it in a few of my projects. Glad I use it.

bditt avatar Jan 05 '18 18:01 bditt