Making Libraries Consumable for Non-C++ Developers - Aaron R Robinson - CppCon 2021

Learn how to make libraries consumable for non-C++ developers by designing libraries with assumptions in mind, using handles, and communicating clearly, and explore the role of interop in facilitating data sharing between languages.

Key takeaways
  • Interop is the process of making a library accessible from multiple languages, and it’s important because it allows different systems to communicate with each other.
  • Libraries should be designed to be consumable by non-C++ developers, and this requires understanding the assumptions made in the library and communicating them clearly.
  • One approach is to create a neutral language that can be consumed by multiple languages, such as C++ or C#.
  • Another approach is to use a source generator to create code that can be used by multiple languages.
  • Interop can be facilitated through the use of handles, which provide a level of indirection that makes it easier to access and manipulate data.
  • Marshalling is another term for interop, and it refers to the process of converting data from one format to another.
  • Calling conventions, such as std call or cdecl, are important for interop because they determine how data is passed between languages.
  • The garbage collector can play a role in interop, as it can help to manage memory and ensure that data is not lost or corrupted.
  • To make a library more consumable, it’s important to understand the assumptions made by the library and communicate them clearly to consumers.
  • 使用一个中立的语言,可以让多语言之间共享数据。
  • Handles provide a level of indirection that makes it easier to access and manipulate data.
  • Marshalling is converting data from one format to another.
  • Calling conventions are important for interop because they determine how data is passed between languages.
  • Garbage collector can help to manage memory and ensure that data is not lost or corrupted.
  • To make a library more consumable, it’s important to understand the assumptions made by the library and communicate them clearly to consumers.
  • The process boundary in interop experience is important because it determines how data is passed between languages.
  • The JVM,.NET, and Python are all examples of languages that can be used for interop.
  • SWIG is a tool that can be used to generate code for interop.
  • Go has a unique approach to interop, where C code can be written in comments in a Go file.