Formation EXCEL saisie des données, tutoriel & guide de travaux pratiques en pdf.
Lua and Lightroom Mark Hamburg
Founder, Adobe Photoshop Lightroom
When we started work on the project that would become Adobe Photoshop Lightroom, we knew we wanted to make scriptability an important part of our story, so early on we reviewed the usual suspects. What drew us to Lua was its combination of simplicity, power, ease of embedding, and relatively high-performance. Having a straightforward license helped too when it came time to talk to Adobe’s lawyers. Personally, as an old Scheme fan, I was drawn to its first-class closure support. I also found the coroutine system intriguing. The relative minimalism also resonated with a back-to-basics attitude that had us weaning ourselves away from intensive C++ usage and back toward C.
Still, it was hard to position Lua as anything other than an obscure choice. We could cite heavy use in the games community and we had set out with a mission of learning something from game developers, but if asked what mate-rials one could turn to learn Lua or where we would find experienced Lua pro-grammers, the answers were limited. For the former, we had the well-written reference manual, some good material on the Lua users wiki, and an intelligent forum on the Lua mailing list. This was good material, but there wasn’t a lot of it. For the latter question, our answer was essentially “Any programmer worth hiring ought to be able to learn Lua quickly.” This was a situation we were pre-pared to deal with and the arrival of Programming in Lua certainly helped, but it was easy to understand why it might be off putting to someone looking in from the outside.
Why this matters is that along with Lua’s simplicity come some issues that make people with backgrounds in other languages stumble. The beauty of a small core is that there is a real opportunity for mastery. This is one of C’s great strengths as well. That small core, however, comes at a price. For example, Lua has no syntax for exception handling. C doesn’t either but having one seems almost required in modern languages. Lua has a syntax for object-oriented message sends, but the actual implementation of an object system or class system is a roll-your-own affair in Lua. As a result, one sees such issues raised repeatedly on the Lua users list as people new to the language start using it and then ask “But what about ?”
Programming in Lua provides answers to some of these questions but those answers are necessarily terse. Lua Programming Gems dives deeper on these issues and many more. It shows ways to deal with threading — an issue we went through a few iterations on in Lightroom — and gives extended examples of how to hook Lua into your application. You may not always like the answers. For example, the object system presented here is quite minimalist. In the spirit of Lua, however, you remain free to roll your own using or not using the ideas presented here. The value comes in seeing the well worked examples together with a discussion of motivations and comparisons to other approaches. If this book had been around during Lightroom’s development, we probably would have happily adopted some of the techniques it presents while simply taking inspiration from others. As it was, we largely had to find our own way and while that was rewarding in itself, the Lua community and particularly new Lua users can be happy to now have a field guide that maps out some of the trails.
The broader lesson from Lightroom that I would like to leave Lua users with is that you should let it pervade your work. Lua is sometimes described as being a language for gluing pieces together, but as we discovered that glue can extend quite deep. We started out looking for a scripting language for a native code application. Then we started thinking it would be nice to allow Lua to exist as a peer to native code. In the end, we ended up with a system where native code provides the foundation, but it is effectively a second-class citizen in the application as a whole. Large portions of Lightroom ended up getting written in Lua including the object-relational mapping layer for the database and the layout system for views. Lua defines the structure of the application and its extensibility mechanisms. As a result, we had an application that was smaller by far than some of its competitors, easy to change, largely cross-platform in its implementation, and suffered essentially no compile-link cycle. The reason things work out this way is that Lua is both very expressive compared to most native languages and sufficiently efficient that you can let it do a lot more of the work than one might be tempted to in other scripting languages. At the same time, the boundary between native code and Lua is sufficiently clean and efficient that when we needed to do things in native code, it wasn’t a huge burden to expose that functionality to Lua nor to access functionality written in Lua.
I Programming Techniques
1 Lua Per-Thread Library Context
Doug Currie
2 Lua Performance Tips
Roberto Ierusalimschy
3 Vardump: The Power of Seeing What’s Behind
Tobias S¨ulzenbr ¨uck and Christoph Beckmann
4 Serialization with Pluto
Ben Sunshine-Hill
5 Abstractions for LuaSQL
Tom´as Guisasola Gorham
6 Boostrapping a Forth in 40 Lines of Lua Code
Eduardo Ochs
7 Effecting Large-Scale Change (with little trauma) using Metatables
S´ergio Alvares Maffra and Pedro Miller Rabinovitch
II Design Techniques
8 MVC Web Development with Kepler
Andr ´e Carregal and Yuri Takhteyev
9 Filters, Sources, Sinks, and Pumps
Diego Nehab
10 Lua as a Protocol Language
Patrick Rapin
11 Lua Script Packaging
Han Zhao
12 Objects, Lua-style
Reuben Thomas
13 Exceptions in Lua
John Belmonte
III Algorithms and Data Structures
14 Word Ladders
Gavin Wraith
15 Building Data Structures and Iterators in Lua
Luis Carvalho
16 A Primer of Scientific Computing in Lua
Luis Carvalho
17 Complex Structured Data Input
Julio M. Fern´andez-D´ıaz
18 Lua Implementations of Common Data Structures
Matthew M. Burke
19 Tic-Tac-Toe and the Minimax Decision Algorithm
Rafael Savelli and Roberto de Beauclair Seixas
IV Game Programming
20 Using Lua in Game and Tool Creation
Konstantin Sokharev and Vadim Groznov
21 A Dynamic and Flexible Event System for Script-Driven Games
Robert Oates
22 Lua for Game Programming
Steve Gargolinski
23 Designing an Efficient Lua Driven Game Scripting Engine
Nicolas Peri
V Embedding and Extending
24 Enhanced Coroutines in Lua
Patrick Rapin
25 Using Lua in Pascal
Jeremy Darling
26 Porting Lua to a Microcontroller
Ralph Hempel
27 Writing C/C++ Modules for Lua
Ralph Steggink and Wim Couwenberg
28 Interpreted C Modules
Jerome Vuarand