[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C vs LuaJit
- From: Pan Shi Zhu <pan.shizhu@...>
- Date: Tue, 31 Aug 2010 15:52:12 +0800
On Tue, Aug 31, 2010 at 2:33 PM, steve donovan
<steve.j.donovan@gmail.com> wrote:
> On Tue, Aug 31, 2010 at 2:29 AM, Pan Shi Zhu <pan.shizhu@gmail.com> wrote:
>> For example, if you have a vanilla lua without any modules, how can
>> you do socket communication without writing any C code? how can you
>> play music without any C code?
>
> True, but that is why there are semi-standard external libraries like
> LuaSocket and LuaFileSystem.
using luasockt does not change the fact that luasocket is written in C.
>
> Alien provides a FFI and there are some impressive examples of Lua
> speaking to libraries just using that bridge.
calling a FFI library also does not change the fact that the library
may written in C (or other compiling languages)
>
> The question is more, how can you justify _application_ code in C?
My answer is the same:
1. things cannot be written in Lua.
2. things are easier to write in C.
for example:
You've got a C++ game as the host program of lua, and you want to move
the player character from axis (1,1) to (999,999), without providing
the C++ function in Lua, you cannot do this at all.
You're the author of awesome window manager,
a window manager is undoubtly an application, and it provides features
such as window decorations and window movement, maximize, minimize,
size, zoom. and it also captures keyboard/mouse input in order to
provide shoutcuts. See http://awesome.naquadah.org/doc/api/ to check
what he had done, all those are written in C, because those has to
written in C in order that Lua can access those features.
You're a developer of a MID device, you want to access certain
features such as WiFi signal check, Bluetooth switch, LED screen
brightness, you will have to write those in C.
If that is a bit hardware-related, just think: you want to "minimize
every applications and show the desktop." Can you do that in Lua?
There's so many things cannot be done in Lua, so we must write those
in C, and provide functions in Lua.