CppCon 2017: Andreas Weis “Howling at the Moon: Lua for C++ Programmers”

preview_player
Показать описание


C++ is a great tool for solving complex problems in a thorough way. But every once in a while, the desire for a simpler language emerges. For those parts of our code where performance is of secondary concern, but the ability to perform rapid iterations over the code is paramount, a scripting language might be a tempting choice. But integrating a second language besides C++ and managing the interaction between the two is also scary.

Lua is a lightweight, dynamic language that was designed to be used as an embedded language within existing applications. It is easy to learn, has very reasonable runtime performance, and a memory footprint small enough that it is usable even on embedded systems. Furthermore, it is almost trivial to integrate with C++.

This talk will give a brief introduction to the Lua scripting language, highlighting specifically how it can complement C++'s language features to enrich a developer's toolbox. In the second part of the talk, we will look at Lua's C API and give suggestions how to integrate it with a modern C++17 codebase. In particular we will focus on how to interface with the dynamic language Lua without compromising the benefits of C++'s strong type system.

Andreas Weis: BMW AG

Andreas Weis has been writing C++ code in many different domains, from real-time graphics, to distributed applications, to embedded systems. As a library writer by nature, he enjoys writing portable code and exposing complex functionalities through simple, richly-typed interfaces. Both of which C++ allows him to do extensively. Andreas is also one of the co-organizers of the Munich C++ User Group, which allows him to share this passion with others on a regular basis. He currently works for BMW, where he tries to make cars smarter than humans.


*-----*
*-----*
Рекомендации по теме
Комментарии
Автор

Wow they mentioned Sol2, I'm currently using it, best binding I've ever used. It has decent documentation, pretty cool examples, great dude who's maintaining it and oh, it's written in a modern cpp!

outsiderst
Автор

MUC++ had four talks (Andreas, Klaus, Lukas and some newb) at CppCon'17, now that's something that makes me proud of my town.

tobiasfuchs
Автор

Wooow this is so good. Compact and to the point! Ideal for C++ devs.

radoslawbiernacki
Автор

this talk is well made! why? 'cz:
* the slides are made by latex/beamer like similar software (not some dumb powerpoint)
* the aspect ratio is smaller than 16:9
* as it has to leave enough space in side to put the speaker inset

this above last point becomes a huge issue otherwise

yash
Автор

14:17 operator overloading?
14:27 metatable (table with special fields' custom def) and attaching normal table to a particular metatable

yash
Автор

imagine this guy, realize that lisp has only lists and is the only complex data structure to interpret lisp on lisp...

eliseulucenabarros
Автор

13:49 > _"don't want to pass it explicitly, ... colon syntax"_

wish java wrapper object method implementors were this aware of situations.

yash
Автор

What's the game at 1:50 in the top left corner?

BitPuffin
Автор

"I don't know about any language that can manage with just one complex data structure" What about JavaScript and it's dynamic Object? Heck it's basically the same thing. It's a key, value pair with potentially "magic" functions associated with it. Great talk overall tho :-)

tomasruzicka
Автор

Two problems with Lua: Speed is bad when you go OO with a Lua class hierarchy and the stack API is in fact terrible if you do something serious in the C routine which is not a simple take parameter - return argument. And another thing might be a problem: The garbage collector was improved in 5.3 but it is still terrible (neither ruby nor python is better) when you have large memory sets.

llothar
Автор

Another performance killer. If you use a custom type, they want you to put a type identificator into the global hash table so during parameter checking you have another hash calculation and lookup operation, instead of storing a pointer to a type descriptor and doing it in one instruction. Add the inefficency of the stack and you wonder where the Lua is fast myth comes from. Not from skilled C++ programmers. And i have no idea why simple implementation should be a point of interest for any user (it's only for the implementors). This is the main reason why still all script languages technically suck, except Javascript which sucks on the language design.

llothar