• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

how is lua mixed with c++ (1 Viewer)

younyokel

Newcomer
Joined
Jan 8, 2020
Messages
16
Reaction score
19
Age
20
Location
Kazakhstan
Website
stackoverflow.com
Hello and welcome to this forum! I truly hope you'll like it here.

Lua is a high-level programming language which, firmly speaking, means almost imperceptible lower performance (comparing to medium and low level programming languages) and fast, human-readable coding.

Lua is written in C. C++ though incorporates a large part of C. But still thence converting Lua into the C++ world would seem rather difficult, but Lua does provide abilities to do this.
 

stetre

Member
Rank: II
Joined
Jan 8, 2020
Messages
103
Reaction score
58
Location
Italy
Website
github.com
Hi, and welcome.

Lua is implemented as a C library, and provides a C API that allows you to either extend it with C code and/or embed it in C code.
To "extend it" means writing some functionalities in C and then call them from Lua, while to "embed it" means writing some code
in Lua and then executing it from within a C application.

Since Lua and the C API are written in a very clean ANSI C, this means that you can also extend it with C++ code and/or embed it
into C++ applications.
 

dinsdale247

Moderator
Staff member
Community Patron
Creator of WinLua
Joined
Nov 17, 2020
Messages
93
Reaction score
34
Location
Victoria BC
Website
winlua.net
While the above is all true, there are also binding libraries available between Lua and C++. The one I think is best called Sol 3 - https://github.com/ThePhD/sol2. Sol 3 (GitHub repo hasn't been renamed) is a "header only" binging that allows you to work natively in C++ against the Lua interpreter. It's *very* slick and is almost as fast as writing against the Lua C API. There is a copy included with all my WinLua installers as well. See my signature.

Cheers,
d
 

dinsdale247

Moderator
Staff member
Community Patron
Creator of WinLua
Joined
Nov 17, 2020
Messages
93
Reaction score
34
Location
Victoria BC
Website
winlua.net
 
Top