Lua: Tiny Embeddable Scripting that Doesn't Suck

27
Lua: Tiny Embeddable Scripting that Doesn’t Suck Kyle Cordes Strange Loop 2010 http://www.flickr.com/photos/mikebaird/4060342528/

Transcript of Lua: Tiny Embeddable Scripting that Doesn't Suck

Page 1: Lua: Tiny Embeddable Scripting that Doesn't Suck

Lua: Tiny Embeddable Scripting that

Doesn’t Suck

Kyle Cordes

Strange Loop 2010

http://www.flickr.com/photos/mikebaird/4060342528/

Page 2: Lua: Tiny Embeddable Scripting that Doesn't Suck

About Kyle Cordes

• Blah, Blah, Blah

Page 3: Lua: Tiny Embeddable Scripting that Doesn't Suck

cat ~/.plan

Learn; (Clojure, at the moment)

Teach; (How to SaaS)

Hire; (Grow Oasis Digital)

Market; (same)

Launch Next Big Thing

Page 4: Lua: Tiny Embeddable Scripting that Doesn't Suck

Abstract“This talk will show how and WHY to

use Lua (as opposed to the zillion other scripting languages) for embedded scripting inside of larger, non-Lua

projects. Lua is safe, fast, simple, easy to learn, and more popular that you might

expect.”

(What you were sold...)

Page 5: Lua: Tiny Embeddable Scripting that Doesn't Suck

The 20-minute version

“This talk will show how and WHY to use Lua (as opposed to the zillion other

scripting languages) for embedded scripting inside of larger, non-Lua

projects. Lua is safe, fast, simple, easy to learn, and more popular that you might

expect.”

(What you will get.)

Page 6: Lua: Tiny Embeddable Scripting that Doesn't Suck

http://www.flickr.com/photos/james_michael_hill/88311128/

Use the Interwebs

http://www.lua.org/

Page 7: Lua: Tiny Embeddable Scripting that Doesn't Suck

Yet Another Scripting LanguageWhy should we care?

Page 8: Lua: Tiny Embeddable Scripting that Doesn't Suck

Because LuaDoesn’t Suck

6 Reasons

Page 9: Lua: Tiny Embeddable Scripting that Doesn't Suck

Jail

http://www.flickr.com/photos/kuzeytac/http://www.flickr.com/photos/8422710@N06/

Page 10: Lua: Tiny Embeddable Scripting that Doesn't Suck

Lua code runs in a Sandboxhttp://www.flickr.com/photos/engelsrud/158040644/

Page 11: Lua: Tiny Embeddable Scripting that Doesn't Suck

Safe By Default

Default: no I/O, safe but impotent. Lua doesn’t even have “print” built in.

Host application provides whatever limited set of APIs/primitives are warranted.

Contrast this to Java’s complex security model, for example.

Page 12: Lua: Tiny Embeddable Scripting that Doesn't Suck

Small

http://www.flickr.com/photos/kentigern/221409419/http://www.flickr.com/photos/andrewscott/577706627/

Page 13: Lua: Tiny Embeddable Scripting that Doesn't Suck

Lua is Small

To embed, hook to a handful of functions.

As small as <100 KB (DLL/LIB)

Easily runs on small devices or in small apps.

Example: Lua on the iPhonehttp://probablyinteractive.com/2009/10/18/Setting-up-iPhone-Wax.html?

Page 14: Lua: Tiny Embeddable Scripting that Doesn't Suck

Simple

http://www.flickr.com/photos/benmcleod/44336195/http://www.flickr.com/photos/slightlywinded/66875782/

Page 15: Lua: Tiny Embeddable Scripting that Doesn't Suck

Lua is Simple

• to use - well suited for small software

• to learn - ~20 keywords, ~20 operators

• to teach - plenty of non-developers use it

Page 16: Lua: Tiny Embeddable Scripting that Doesn't Suck

Flexible

http://www.flickr.com/photos/wiccked/348866434/http://www.flickr.com/photos/wainwright/351684037/

Page 17: Lua: Tiny Embeddable Scripting that Doesn't Suck

Lua is Flexible

• Dynamically typed

• First-class functions

• Easy interop

• Written in super-clean C, ports to nearly any platform

• Ample libraries off-the-shelf

Page 18: Lua: Tiny Embeddable Scripting that Doesn't Suck

Fast

http://www.autoblog.com/photos/pagani-zonda-hh-0/ http://www.flickr.com/photos/kentigern/223140455/

Page 19: Lua: Tiny Embeddable Scripting that Doesn't Suck

LuaJIT is in C++ / Java6 territory.

http://luajit.org/

Interpreted Lua is generally faster than Python, Ruby,

Perl, and PHP.

http://bit.ly/8RLpoG

Page 20: Lua: Tiny Embeddable Scripting that Doesn't Suck

http://www.flickr.com/photos/us_army_rolling_along/3342500833/http://www.flickr.com/photos/us_army_rolling_along/4509400870/

http://www.flickr.com/photos/carbonnyc/76463757/s

Momentum

Page 21: Lua: Tiny Embeddable Scripting that Doesn't Suck

• At least one external IDE• Several published books• Large community

Lua in World of Warcraft

Page 22: Lua: Tiny Embeddable Scripting that Doesn't Suck

Angry Birds

Page 23: Lua: Tiny Embeddable Scripting that Doesn't Suck

Wikipedia lists

110games with Lua scripting

(many on the PC,many on consoles,

some on handhelds)

Page 24: Lua: Tiny Embeddable Scripting that Doesn't Suck

Not Just Games

• Adobe Photoshop Lightroom

• Oasis Digital projects

• Many, many more

Page 25: Lua: Tiny Embeddable Scripting that Doesn't Suck

Lua == 42 ?

http://www.flickr.com/photos/almostinfamous/3531123548/

Page 26: Lua: Tiny Embeddable Scripting that Doesn't Suck

The right answer for every scripting need?

At my last venture, we chose JavaScript instead:

1. Better Java Integration

2. Everyone knows JavaScript

3. More tooling, easier sell

Page 27: Lua: Tiny Embeddable Scripting that Doesn't Suck

kylecordes.com

http://www.flickr.com/photos/thetruthabout/