Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HELP] sol2 Users - Feedback Appreciated!! #189

Open
ThePhD opened this issue Aug 22, 2016 · 53 comments
Open

[HELP] sol2 Users - Feedback Appreciated!! #189

ThePhD opened this issue Aug 22, 2016 · 53 comments

Comments

@ThePhD
Copy link
Owner

@ThePhD ThePhD commented Aug 22, 2016

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. 👍

@ThePhD ThePhD added this to the Documentation milestone Aug 22, 2016
@ThePhD ThePhD self-assigned this Aug 22, 2016
@Nava2
Copy link
Contributor

@Nava2 Nava2 commented Aug 22, 2016

  • 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.

@Grant1219
Copy link

@Grant1219 Grant1219 commented Aug 22, 2016

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.

@devxkh
Copy link
Contributor

@devxkh devxkh commented Aug 22, 2016

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! :)

@jeychenne
Copy link

@jeychenne jeychenne commented Aug 22, 2016

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...

@jnbrq
Copy link

@jnbrq jnbrq commented Aug 23, 2016

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. 😄
  • 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.

@Murloc992
Copy link

@Murloc992 Murloc992 commented Aug 28, 2016

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. :)

@OrfeasZ
Copy link
Contributor

@OrfeasZ OrfeasZ commented Aug 28, 2016

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).

@wtfbbqhax
Copy link
Contributor

@wtfbbqhax wtfbbqhax commented Aug 29, 2016

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!

@henriquegemignani
Copy link

@henriquegemignani henriquegemignani commented Sep 28, 2016

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!

@eliasdaler
Copy link
Contributor

@eliasdaler eliasdaler commented Sep 28, 2016

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.

@shohnwal
Copy link

@shohnwal shohnwal commented Sep 30, 2016

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.

@kavika13
Copy link

@kavika13 kavika13 commented Oct 15, 2016

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.

@billw2012
Copy link

@billw2012 billw2012 commented Oct 29, 2016

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).

@adriweb
Copy link

@adriweb adriweb commented Nov 17, 2016

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!

@Strasser-Pablo
Copy link

@Strasser-Pablo Strasser-Pablo commented Nov 25, 2016

-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.

@shultays
Copy link

@shultays shultays commented Jan 9, 2017

  • 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.
@ThePhD
Copy link
Owner Author

@ThePhD ThePhD commented Jan 9, 2017

@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...

@shultays
Copy link

@shultays shultays commented Jan 9, 2017

@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.

@carloscm
Copy link
Contributor

@carloscm carloscm commented May 3, 2017

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!

@bditt
Copy link

@bditt bditt commented May 15, 2017

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: bditt#0327
I really like this but I find it kinda confusing. Thanks for producing this. <3

@IamTheCarl
Copy link

@IamTheCarl IamTheCarl commented May 19, 2017

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.

@mrgreywater
Copy link
Contributor

@mrgreywater mrgreywater commented Jul 5, 2017

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 #189 (comment)
  • 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!

@adriweb
Copy link

@adriweb adriweb commented Jul 5, 2017

@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.

@ThePhD
Copy link
Owner Author

@ThePhD ThePhD commented Jul 7, 2017

@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).
@denesb
Copy link

@denesb denesb commented Dec 21, 2017

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. :)

@bditt
Copy link

@bditt bditt commented Jan 5, 2018

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.
@RussellHaley
Copy link

@RussellHaley RussellHaley commented Feb 20, 2018

How did you find out / hear about sol2?

You had mentioned it on the lua-l list. I found your presentation on the LuaWorkshop and "just had to have it".

What're you using it for?

The lua C API really turns me off. I started using Lua to make my life in C easier, not harder. Having to manage a stack is the opposite of what I wanted. I have been really depressed about that for a while now.

What Lua library did you use before you found sol2?

I've tried some of the .Net lua wrappers. Very leaky and not great. I could see building a .Net package off of sol2 as being a far better option.

What do you like about sol2?

Still new. I got it to compile into my qt sample app in 26 minutes! (And I promise you my C++ skills are not going to impress anyone). I've been trying to learn "pure lua" and was very hesitant to walk away from that (even though I don't like the C API). You're presentation is the first thing to convince me there is a better way.

What do you dislike about sol2?

TBD

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'm avoiding the C API like the plague. I keep piking up PIL and putting it back down... lol

Is the documentation or examples helpful?

TBD. The 2016 workshop presentation was excellent.

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

Thank you thank you thank you thank you thank you thank you thank you thank you!

@ThePhD ThePhD changed the title HELP - sol2 Users [HELP] sol2 Users Feb 23, 2018
@CaptainHorse
Copy link

@CaptainHorse CaptainHorse commented Mar 6, 2018

  • How did you find out / hear about sol2?
    Google-Fu!

  • What're you using it for?
    Scripting for engine

  • What Lua library did you use before you found sol2?
    Nothing, Sol 2 was my first

  • What do you like about sol2?
    Everything

  • What do you dislike about sol2?
    Nothing yet

  • Is the documentation or examples helpful?
    Definitely!

  • Anything else about the library you feel like adding or pointing out?
    Amazingly fast bug response, commit message and change comment made me laugh.

@RussellHaley
Copy link

@RussellHaley RussellHaley commented Mar 10, 2018

Hi,
The speed and deftness with which you respond to open tickets is amazing, but your proclivity to close issues after your response feels like it cuts conversations short. It may be worth while setting up a means for users to communicate and share? Cheers, and thanks for you hard work.

@ThePhD
Copy link
Owner Author

@ThePhD ThePhD commented Mar 10, 2018

@RussellHaley https://gitter.im/chat-sol2/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

It's no mailing list and it's actually not the BEST of all the electron-based chat apps, but... it gets the job done! I do apologize for quickly closing issues: I don't quite use them as good as other people do, or for their intended purpose. I'm sorry if it feels like I'm cutting things short: but I'm more than happy to keep replying in closed issues if things don't quite pan out fully.

@RussellHaley
Copy link

@RussellHaley RussellHaley commented Mar 10, 2018

And you have gone to great lengths accommodating me in closed issues, for which I am grateful. Gitter will be fine for my purposes. See you soon. 👍

@NullCascade
Copy link
Contributor

@NullCascade NullCascade commented Mar 18, 2018

How did you find out / hear about sol2?

I think the first place I heard of it was from http://lua-users.org/wiki/BindingCodeToLua

What're you using it for?

The Morrowind Script Extender will be using it (on top of LuaJIT) for its expanded scripting language in its next version. I am binding reverse engineered structures and exposing native functions to get away from the hell that is Morrowind's normal scripting VM.

What Lua library did you use before you found sol2?

I've not used any other Lua library before sol2, other briefly testing a few others. Professionally I've used Lua while working at Corona Labs.

What do you like about sol2?

Everything is dead simple. Manipulating the stack is fun the first time, but I'd rather just get up and go.

What do you dislike about sol2?

Having to learn the "sol2" way to do things can be annoying, but the docs have helped. So far the only issue I've had is binding (non-std) arrays. That isn't always viable, because I don't get to control the underlying structures viably.

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?

They are, but they aren't always complete. For example, I couldn't find documentation for state.create_table(narr, nrec); easily and had to just go off of variable names/tests.

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

I'm sure I'll find something eventually, and will use the chat room/issues here to bring it up.

@JoshKlint
Copy link

@JoshKlint JoshKlint commented Mar 28, 2018

How did you find out / hear about sol2?

Googled for the terms "lua", "shared_ptr".

What're you using it for?

Evaluating for use in Leadwerks Game Engine 5

What Lua library did you use before you found sol2?

tolua++

What do you like about sol2?

Support for shared pointers, very flexible and lets me tune the API to deliver the Lua user experience I want, have not yet found something I could not do with it. Speed is also a big benefit. The ease with which you can expose a new function or class is awesome.

What do you dislike about sol2?

No support for default arguments, necessity to hand-write entire binding code, and shared_ptr support is a bit wonky in places. However, this can be alleviated with a custom header parser once I figure out how everything works.

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)

Harder than tolua++ but the increased flexibility is worth it.

Is the documentation or examples helpful?

Yes, but a lot of it is over my head.

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

Not done evaluating it but do far it looks like the best Lua binding library I have ever used.

@noresources
Copy link

@noresources noresources commented May 22, 2018

I am not currently using sol2 but looking for a good lua binder for an existing game engine / system daemon

What're you using it for?

running lua scripts to interact with C++ code instead of writing pure C++ plugins

What Lua library did you use before you found sol2?

In a previous project, a completely home made solution. Something which I definitely don't want to reproduce in the new project.

What do you like about sol2?

Seems straight forward, powerful and does not require a lot of code to do something. Everything I need.

What do you dislike about sol2?

The very high compiler requirements of sol2. When I started to monitor this project, it requires C++11 and it was already a negative point to me. Now I am unable to compile tests on most of platform I am using and I see that sol3 will require even newer compiler. I consider compile time performance as the least significant problem, especially if it's at the expense of other concerns like portability.

@ka0s420
Copy link

@ka0s420 ka0s420 commented Jul 24, 2018

How did you find out / hear about sol2?
Can't remember exactly, it was in the comments of a blog post tutorial for lua bind possibly. The author of the article had replied to someone saying sol2 is better, forget luabind (lol).

What're you using it for?
It's part of a bundle of super cool libraries I'm using in my game engine project. Its a simplish, 2d tiled based engine. I'm using Sol2, Cereal, Dear Imgui and SFML - to think I used to be afraid of libraries, yours and the others on this list have changed that outlook somewhat ;)

What Lua library did you use before you found sol2?
I've tried a few things, not all lua based. I've used pybind 11, luabind, chaiscript and others that I can't remember. I was actually at the point of giving up on the idea of embedding a scripting language, and that's when i found sol2. Those other were either too complicated,, or slow or as in chaiscript had very little documentation.

What do you like about sol2?

Seems pretty easy to use, very little boiler plate, good documentation, reassuringly prompt and professional developer behind it who seems passionate about the library, single header and fast!

What do you dislike about sol2?

There are still certain things about it that are a bit mystical or over my head, but I've only been using it a week now. Like someone else mentioned, a forum or something would be good for users to help each other. I see that you responded to a similar comment earlier, about a gitter, but still, I wouldn't have known about it without having read that comment. Whenever I'm googling to try and work out sol related stuff, it's usually the docs or github that come up in the search, I haven't seen any community results pop up. And I didn't notice it advertised anywhere on the docs, though that could be my own lack of attention.

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)

very much easier. See my comment above about lack of boiler plate and such. It mostly just feels like Im accessing a lot of really flexible std::map data that's partially heterogeneous.

Is the documentation or examples helpful?

Yes, the docs are helpful. They're miles ahead of a lot of documentation out there. Some of it is a little unclear though. Like, at the moment, I'm trying to figure out how to return a tuple to lua to access in lua, but the docs about returning data to lua only show it being accessed inside of c++. I might try and find this gitter and ask about it on there.

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

Colour me subjective, but it's just damn sexy ;) It feels native and like it's oriented with the user in mind. Its also always nice to have an idea of who's behind a library, and I very much enjoyed the videos on youtube of your talks etc.

@ThePhD ThePhD changed the title [HELP] sol2 Users [HELP] sol2 Users - Feedback Appreciated!! Jan 14, 2019
@xzores
Copy link

@xzores xzores commented Apr 3, 2019

  • How did you find out / hear about sol2?:
    one of your talks

  • What're you using it for?
    game engine

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

  • What do you like about sol2?
    the simplicity

  • What do you dislike about sol2?
    lacking some documentation on the different type, like if I just want to know what an sol::object it does
    and what all its member functions do

  • 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 plain c API and this is much better

Is the documentation or examples helpful?
yes, I would personally like to see some more example on differed lua_states and communication
between them

Anything else about the library you feel like adding or pointing out?
it is great!

@kdudnyk
Copy link

@kdudnyk kdudnyk commented Jun 5, 2019

How did you find out / hear about sol2

Saw your talk on cppcon :-)

What're you using it for?

Game engine, code-parsing and automatic lua binding

What Lua library did you use before you found sol2?

LuaBridge, SWIG

What do you like about sol2?

Simplicity and speed

What do you dislike about sol2?

Sometimes it is a little bit annoying to write the boilerplate code, but i know that without reflection there is not that much you can do :(

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)

Much better

Is the documentation or examples helpful?

For Sure!

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

While meta-classes or reflection is on the way - I'd like to suggest implementing some binding generator. It shall be relatively easy to use libclang + python to wrap the least complex libraries.
( I've took a liberty of making a really basic and simple PoC at https://github.com/kdudnyk/LuaSol3Generator )

@TheAifam5
Copy link
Contributor

@TheAifam5 TheAifam5 commented Jun 6, 2019

@kdudnyk You can use RTTR, then iterate all reflections and bind to sol ;)

@playmer
Copy link

@playmer playmer commented Jun 6, 2019

@TheAifam5 have you done this (RTTR -> Sol)? I'm curious about seeing a sample of something like that. Sorry if it's a bother!

@TheAifam5
Copy link
Contributor

@TheAifam5 TheAifam5 commented Jun 6, 2019

@playmer kinda.... writing something else for now. Can’t find a good IDE 😂 I will report back to you when I’m done writing a profile manager for VSCode :D

@kdudnyk
Copy link

@kdudnyk kdudnyk commented Jun 6, 2019

@TheAifam5
I am not sure how RTTR will help if i'd like to bind an external library with sol2.
As far as i understand i would still need to write a lot of boiler plate - just to get started ( or there is already something automagic available ?)
Instead by using an code-generator i can automatically generate sol bindings ( just by a blink of an eye ) and include generated library into my project.

I've already create a very limited script, so you can find an example at https://github.com/kdudnyk/LuaSol3Generator/tree/master/example/Box2D
All files that are "Bind_*" - are generated, - and just by that - i am able to run an "hello world" sample of box2d in lua - without writing a single line of wrapping

@ThePhD sorry for spamming here - i am just curious whatever you have any plans to automate boiler plate generation ? If yes - i would be glad to help

@ThePhD
Copy link
Owner Author

@ThePhD ThePhD commented Jun 6, 2019

@kdudnyk I have no plans on writing external binding generators. In most cases people already have a generator in mind (e.g., UnrealHeaderTool) and have custom logic (e.g., this these things should be properties, these things shouldn't be, and so on so forth...).

If I write one, I have to support everyone's use case. If you write one... well, you only have to support you, your syntax, your coding guidelines / styles, and what you want.

In short: reward / effort ratio is waaaaaaaaay less than even 0.1 here. With C++ reflection I'll only have to write this once, and everyone else can go nuts.

@fwjavox
Copy link

@fwjavox fwjavox commented Sep 26, 2019

How did you find out / hear about sol2?

Googled for LUA / C++ integration

What're you using it for?

Scripting in user role management system (some sort of hybrid RBAC/ABAC)

What Lua library did you use before you found sol2?

Plain LUA C API

What do you like about sol2?

It uses modern C++ features so you need just a few lines of code to solve complex problems.
It also helps to avoid lots of duplicate code that is neede when using the LUA C API directly.

What do you dislike about sol2?

RAM usage while compiling is immense. I have 32GB installed and have to compile with make -j1 because I run out of memory otherwise. We have complex objects with many fields.
I did read the FAQ about this but it didn't help too much.

Is the documentation or examples helpful?

Yes! Both are very good.

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

On this page it says:
This is due to C++11 and C++14 not having very good facilities for handling template parameters and variadic template parameters. There are a few things in cutting-edge C++17 and C++Next that sol can use

Is there any ETA on when the transition will happen? This could possibly help a lot with the compile time and RAM usage isses.

@nefethael
Copy link

@nefethael nefethael commented Oct 3, 2019

How did you find out / hear about sol2?

Google search for C++14 Lua wrapper

What're you using it for?

Make a flexible microservice with C++ framework backend

What Lua library did you use before you found sol2?

None

What do you like about sol2?

It's great integration with new C++ features (lambda, ...)

What do you dislike about sol2?

None

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?

Great documentation & examples

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

Can't use last version as it needs C++17

@RealmRPGer
Copy link

@RealmRPGer RealmRPGer commented Mar 27, 2020

  • How did you find out / hear about sol2?

I did a specific search for lua c++ wrappers and happened upon it. (A few years earlier I had done a similar search but failed to find sol2 at that time)

  • What're you using it for?

We originally started using sol2 for the scripting side of our menu system. I had wanted a scripting language that could easily bind c++ classes, but the language we were using before finding sol2 wound up being far too slow and was causing slowdowns after just 30+ menu items.

Since then, we're also using sol2 as a game object scripting system. Lua's coroutine support allows for scripting things in a task-like manner -- self:WalkToThing() self:PickupThing() can be turned into a coroutine that iterates one step every frame. (C++'s coroutine implementation unfortunately falls short). We'd previously been using lua for just this purpose, but it was plain lua and I begrudged the lack of support for binding c++ classes.

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

We used vanilla Lua.

  • What do you like about sol2?

As previously mentioned, the ability to directly bind c++ classes and functions is much appreciated. It's also nice that we can send over various object types to lua functions without having to cast -- it requires a little bit of work and c++ templating to get working properly, but is nice once flowing correctly.

  • What do you dislike about sol2?

Right now sol2 takes a hefty chunk of time to compile object bindings. We're mapping most of our classes to sol2, so there is admittedly a lot of them, but it still feels like it takes a comparitively long amount of time considering the comparitively few bindings (18 usertypes with a total of ~100 bindings = 20-30 second compile time).

  • 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)

Certainly far easier than vanilla lua. I'd say it's also easier to use than the scripting language we used before sol2, which was a language specifically built for c++ bindings, haha.

It is fairly helpful, though I do find myself running into numerous cases not explicitly mentioned in the documentation.

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

I've had difficulty with calling unnamed/sol::function functions with state_views. I'm not sure if this is possible or I'm just doing it wrong, but the documentation doesn't have this use case.

@ThePhD
Copy link
Owner Author

@ThePhD ThePhD commented Mar 31, 2020

@RealmRPGer If you can elaborate on the "unnamed/sol::function functions with state_views" in a new issue, I'd be happy to figure out what to do to help!

@McKillroy
Copy link

@McKillroy McKillroy commented Apr 1, 2020

How did you find out / hear about sol2?
- General web research on Lua bindings
What're you using it for?
- Building a distributed gameserver as a hobby project. Lua is for gamelogic scripting.
What Lua library did you use before you found sol2?
- None
What do you like about sol2?
- Fast, easy to use, well supported, modern C++
What do you dislike about sol2?
- Nothing yet. Keep up the good work!
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)
- Doesn't apply.
Is the documentation or examples helpful?
- Absolutely ! Good job on that.
Anything else about the library you feel like adding or pointing out?
- Just keep improving it and fixing issues. I want this to be rock-solid.

@thinlizzy
Copy link

@thinlizzy thinlizzy commented Apr 5, 2020

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?

From a friend while looking for Lua libraries in the Internet.

  • What're you using it for?

Storing logic and configuration for C++ home made games and some applications.

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

Manual Lua stack manipulation and it was painful as hell.

  • What do you like about sol2?

It automates all my interop with Lua. Very easy to use!

  • What do you dislike about sol2?

Build times and especially linking times are painful. Tried with MSVC and MinGW. LTO in mingw helped a bit, but it's buggy in the newer versions.

  • 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)

So much easier.

Yes! Most examples cover what I need.

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

My two main issues are:

  1. how to reduce the building times?
  2. need a guide or some resources on how to use your library in the correct way. Sometimes I feel like I am abusing its features because some Lua scripts I have take almost 3 seconds to load

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

Thanks to YOU for making this for us :)))))))

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

@atom0s
Copy link
Contributor

@atom0s atom0s commented Dec 23, 2020

I've been using sol for a few months now and feel more comfortable being able to answer the questions requested now.

How did you find out / hear about sol2?

Was recommended by a friend and had seen it used in some other projects before.

What're you using it for?

I create injected hooks/mods for various games that expand the game client beyond it's normal capabilities in various forms. From API layers that expose game information to modders, to allowing full-on rendering modifications/additions.

What Lua library did you use before you found sol2?

Luabind; more specifically the deboostified version because I hate Boost.

What do you like about sol2?

I like sol's API and layout. It's fairly easy to jump into and recreate what I've done already in my past projects. I'm currently working on a full rewrite of a project that is moving from Luabind to sol and so far, it's been fairly straight forward/easy to port from one binding to another.

What do you dislike about sol2?

These are probably less of an impact to others and more specific to me but:

  • I dislike that sol pollutes the registry table heavily rather than bundling things into its own cleaner tables.
  • I dislike how sol names some things that get registered to the registry.
  • I dislike the compile times and file output sizes due to having a very large number of usertype bindings.
  • I dislike some of the API layout that allows for multiple ways to do 1 thing, but those ways all have various impact on file size and performance with not much information/docs regarding the differences. (ie. there's a dozen different ways to pull a table/value in a table, each with their own performance impacts.)(ie. Binding a usertype via new_usertype fully creates massive compile times and inflates the file size due to how it expands the Args... in the tuples, where as using .set() and .set_function() instead help reduce the size and heap problems during compiling.)

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)

At first harder, Luabind has pretty solid straight-forward documentation and since it was a fairly popular library before sol existed, it's got a lot of examples floating around as well. I used the plain C API for a while before that as well, which is ideal for the best performance, but the tradeoff for the ease of binding and such is worth it.

Is the documentation or examples helpful?

Yes. While sol does have a lot of docs and examples, it feels a bit scattered and unorganized for some topics. Some topics also feel heavily under-documented such as coroutines and dealing with sol's namings for certain things related to Lua threads. But for the most part it's not too bad to find what you're looking for.

There's some more recent changes to the code that aren't documented for yet though which can be a tad annoying when looking for information about things such as the configuration changes that were done recently. A lot of the SOL_ defines and configurable options are not documented.

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

Just would like to see the compile times and file sizes get some optimization in the future. I understand the reason for them though with sol heavily using std::tuple and such. It's just a bit sad to see how many bloated calls are added to the output to deal with all the argument expansions and such. A large usertype can lead to calls with 60+ arguments, then additional sub-calls for each of those arguments to prepare the stack/etc. This leads to a single usertype generating well over 200 function calls to register itself in the disassembly.

A more up to date documentation regarding best-practices for various aspects of the library would be nice to see as well. As I mentioned above, the API is open-ended allowing multiple ways to accomplish the same task. Some more in depth information on which is the best for say speed, file size, etc. would help.

Some more specific types such as sol::main_ prefixed things could be better addressed and up front as they can be heavily useful for situations where coroutines are used a lot and passing around callbacks between them.

I have loved the time I've spent with sol so far, and want to again thank you for what you've done and still do for the Lua community. Libraries like this are such a huge asset to making the use of Lua suck less and help speed up development and testing. After the time I've spent with sol testing it out, I'm definitely sold on sticking with it over Luabind so far. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet