狠狠撸

狠狠撸Share a Scribd company logo
C/C++  与  Lua  的混合编程
为什么需要使用多于一种语言? 性能与扩展性互重 不同的层面需要不同的语言描述需求
为什么是  C ? 为底层开发人员最熟悉 大部分操作系统层面和通用库均提供  C API 性能可以得到保证 C++  亦可,但不推荐
为什么是  Lua ? 容易嵌入 轻量 语言特性补充了  C  的不足 还有其它的选择 Python Javascript 自定义语言
获得的好处 隔离底层,让系统更健壮 降低开发成本 应付多变的需求 热更新系统 数据描述更方便 能做到单一语言难以做到的
易出现的问题 多语言构建的系统更为复杂 层次划分不清,职责混乱 把  Lua  当成  C/C++  来用 定义不恰当的  DSL
嵌入还是扩展,这是一个问题 选择 1:  以  C  语言为主体,将  Lua  嵌入 选择 2:  以标准  Lua  解释器为主体,编写  C  扩展
Lua  作为数据描述语言 配置管理 处理结构化数据 XML (LuaExpat/LOM)
为  Lua  编写  C/C++  模块 luabind (boost.python?) tolua? lua native C API
面向对象 C++  层的对象粒度 userdata/lightuserdata/handle ? 对象生命期管理问题 lua metatable  带来的动态性 C/Lua  交互的性能
调试 lua debug  库 阅读  lua source code debug API IDE
系统性能优化 重写内存分配器 保持  C  层次的简洁 理解  Lua  ,它是一门独立语言 LuaJIT LuaCOM
参考资料 http://www.lua.org lua mailling list 书 Programming In Lua (Pil) Lua  手册 Lua Programming Gems http://blog.codingnow.com
谢谢

More Related Content

More from xlight (20)

What does it take to make google work at scale
What does it take to make google work at scale What does it take to make google work at scale
What does it take to make google work at scale
xlight
?
淘宝无线电子商务数据报告
淘宝无线电子商务数据报告淘宝无线电子商务数据报告
淘宝无线电子商务数据报告
xlight
?
New zealand bloom filter
New zealand bloom filterNew zealand bloom filter
New zealand bloom filter
xlight
?
Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0
xlight
?
Oracle ha
Oracle haOracle ha
Oracle ha
xlight
?
Oracle 高可用概述
Oracle 高可用概述Oracle 高可用概述
Oracle 高可用概述
xlight
?
Stats partitioned table
Stats partitioned tableStats partitioned table
Stats partitioned table
xlight
?
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
xlight
?
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed SystemsGoogle: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
xlight
?
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed SystemsGoogle: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
xlight
?
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile ServiceHigh Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
xlight
?
PgSQL vs MySQL
PgSQL vs MySQLPgSQL vs MySQL
PgSQL vs MySQL
xlight
?
SpeedGeeks
SpeedGeeksSpeedGeeks
SpeedGeeks
xlight
?
GOOGLE: Designs, Lessons and Advice from Building Large Distributed Systems
GOOGLE: Designs, Lessons and Advice from Building Large   Distributed Systems GOOGLE: Designs, Lessons and Advice from Building Large   Distributed Systems
GOOGLE: Designs, Lessons and Advice from Building Large Distributed Systems
xlight
?
UDT
UDTUDT
UDT
xlight
?
sector-sphere
sector-spheresector-sphere
sector-sphere
xlight
?
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
xlight
?
Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004
xlight
?
Make Your web Work
Make Your web WorkMake Your web Work
Make Your web Work
xlight
?
Capacity Management from Flickr
Capacity Management from FlickrCapacity Management from Flickr
Capacity Management from Flickr
xlight
?
What does it take to make google work at scale
What does it take to make google work at scale What does it take to make google work at scale
What does it take to make google work at scale
xlight
?
淘宝无线电子商务数据报告
淘宝无线电子商务数据报告淘宝无线电子商务数据报告
淘宝无线电子商务数据报告
xlight
?
New zealand bloom filter
New zealand bloom filterNew zealand bloom filter
New zealand bloom filter
xlight
?
Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0Product manager-chrissyuan v1.0
Product manager-chrissyuan v1.0
xlight
?
Oracle ha
Oracle haOracle ha
Oracle ha
xlight
?
Oracle 高可用概述
Oracle 高可用概述Oracle 高可用概述
Oracle 高可用概述
xlight
?
Stats partitioned table
Stats partitioned tableStats partitioned table
Stats partitioned table
xlight
?
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
Optimizing Drupal Performance Zend Acquia Whitepaper Feb2010
xlight
?
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed SystemsGoogle: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
xlight
?
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed SystemsGoogle: The Chubby Lock Service for Loosely-Coupled Distributed Systems
Google: The Chubby Lock Service for Loosely-Coupled Distributed Systems
xlight
?
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile ServiceHigh Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
High Availability MySQL with DRBD and Heartbeat MTV Japan Mobile Service
xlight
?
PgSQL vs MySQL
PgSQL vs MySQLPgSQL vs MySQL
PgSQL vs MySQL
xlight
?
SpeedGeeks
SpeedGeeksSpeedGeeks
SpeedGeeks
xlight
?
GOOGLE: Designs, Lessons and Advice from Building Large Distributed Systems
GOOGLE: Designs, Lessons and Advice from Building Large   Distributed Systems GOOGLE: Designs, Lessons and Advice from Building Large   Distributed Systems
GOOGLE: Designs, Lessons and Advice from Building Large Distributed Systems
xlight
?
sector-sphere
sector-spheresector-sphere
sector-sphere
xlight
?
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
xlight
?
Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004Gfarm Fs Tatebe Tip2004
Gfarm Fs Tatebe Tip2004
xlight
?
Make Your web Work
Make Your web WorkMake Your web Work
Make Your web Work
xlight
?
Capacity Management from Flickr
Capacity Management from FlickrCapacity Management from Flickr
Capacity Management from Flickr
xlight
?

颁/颁++与尝耻补混合编程