I haven't seen lua mentioned anywhere for the RPi.
I have used it and it's a nice lightweight interpretted embedded language. It is lighter and more stable than say Python.
It is intended as a scripting language. Used by, amongst other apps, luatex and Adobe Lightroom.
For us it would allow us to write controller apps for GPIO testing.
Re: lua language?
This is quite interesting. Lua never occurred to me as a potential language to use, but now that I think about it more, using Lua over (or as well as) Python seems a really good idea. There are a few things about it I don't like (1 based arrays, might make more sense to the lay person but counting from 0 is so pervasive in programming that you might as well get used to it from the off) but for the most part I think it makes a good balance between the intuitiveness of python and the lean design of C or something. Since Lua was actually designed as a language for people who don't program this has some real potential...
Even if Lua isn't used as a primary language to teach on the Pi it should be part of the default install I think.
Definitely food for thought
Angus
Even if Lua isn't used as a primary language to teach on the Pi it should be part of the default install I think.
Definitely food for thought
Angus
Re: lua language?
I'm a major Lua fan myself. I've been (happily!) sucked in to so many other things since getting a Pi I haven't pushed Lua as much as I might have hoped LuaJIT 2.0 runs great on the Pi, and of course so does Lua. I personally think LuaJIT 2's FFI is *incredibly* compelling on a device like the Pi.
Re: lua language?
Glad you guys like the idea.
What I had in mind as an educational/debug app was some kind of wrapper for the gpio and enable interactive mode. This can be done either as a C/C++ gpio module loaded into the stock lua app or compiled/linked into out own minimal C/C++ app.
Let us suppose we had a Gertboard (or whatever) with some LEDs, motor etc plugged in. Via the gpio module we could write say:
leds = gpio.whatever_setup(…)
leds[1] = 1
leds[2] = 0
…
so flashing the lights on/off under keyboard control.
We could even write:
leds = our_gpio.whatever(...)
leds.a = 1
leds.b = 1
leds.c = 0
leds.a = 0
This gives us a helloworld-ish interactive experience such as we got with BASIC where, with appropriate daughterboards, I could have done on an Apple II.
As programming skills get more advanced they can write/store their own scripts.
One of the nice features of lua is that because it is embedded the host app writer can offer as much or as little of his own API to lua. Also he can link in other extra modules, and it supports dynamic external modules.
A slightly more advanced app could include some GUI (qt bindings(?)) so not only can we talk to our daughter boards we can write pretty interfaces. The educational/practical value being that we can see all the way from the metal to the GUI.
On the point of the language features: surreptitious nil values are really irritating. You slightly mis-spell a variable name, it doesn"t complain but quietly just gives nil. In a long call stack this is a pain to debug.
The nice feature is the ubiquity of tables. It allows the implementation of object orientation(ish).
What I had in mind as an educational/debug app was some kind of wrapper for the gpio and enable interactive mode. This can be done either as a C/C++ gpio module loaded into the stock lua app or compiled/linked into out own minimal C/C++ app.
Let us suppose we had a Gertboard (or whatever) with some LEDs, motor etc plugged in. Via the gpio module we could write say:
leds = gpio.whatever_setup(…)
leds[1] = 1
leds[2] = 0
…
so flashing the lights on/off under keyboard control.
We could even write:
leds = our_gpio.whatever(...)
leds.a = 1
leds.b = 1
leds.c = 0
leds.a = 0
This gives us a helloworld-ish interactive experience such as we got with BASIC where, with appropriate daughterboards, I could have done on an Apple II.
As programming skills get more advanced they can write/store their own scripts.
One of the nice features of lua is that because it is embedded the host app writer can offer as much or as little of his own API to lua. Also he can link in other extra modules, and it supports dynamic external modules.
A slightly more advanced app could include some GUI (qt bindings(?)) so not only can we talk to our daughter boards we can write pretty interfaces. The educational/practical value being that we can see all the way from the metal to the GUI.
On the point of the language features: surreptitious nil values are really irritating. You slightly mis-spell a variable name, it doesn"t complain but quietly just gives nil. In a long call stack this is a pain to debug.
The nice feature is the ubiquity of tables. It allows the implementation of object orientation(ish).
Re: lua language?
With debian, I did "apt-get install lua", and it installed version 5.0. 5.2 is now available. It just takes a few more commands to install that. From your home (or desired directory):
wget http://www.lua.org/ftp/lua-5.2.0.tar.gz [download source]
tar xzvf lua-5.2.0.tar.gz [unpack]
cd lua-5.2.0 [switch to new directory]
sudo apt-get install libreadline5-dev [install a required library]
sudo make linux install [build & install lua]
then just Run lua
pi: lua
>print("Hello, World")
>Ctrl+C
wget http://www.lua.org/ftp/lua-5.2.0.tar.gz [download source]
tar xzvf lua-5.2.0.tar.gz [unpack]
cd lua-5.2.0 [switch to new directory]
sudo apt-get install libreadline5-dev [install a required library]
sudo make linux install [build & install lua]
then just Run lua
pi: lua
>print("Hello, World")
>Ctrl+C
-
- Posts: 405
- Joined: Sun Nov 20, 2011 11:37 am
Re: lua language?
I haven't had a chance to have a play with this yet, but I have heard good things about Love. This is a framework to help you to make games using Lua.
I have a feeling that Lua may be quite popular with young people - it's widely used as a scripting tool in MMORPGs such as World of Warcraft, Roblox, etc.
mark
I have a feeling that Lua may be quite popular with young people - it's widely used as a scripting tool in MMORPGs such as World of Warcraft, Roblox, etc.
mark
Re: lua language?
there is another good one called egsl
http://www.egsl.retrogamecoding.org/
it requires freepascal to build and i haven't got around to setting that yet but no reason it shouldn't work.
http://www.egsl.retrogamecoding.org/
it requires freepascal to build and i haven't got around to setting that yet but no reason it shouldn't work.
Re: lua language?
Lua and the RasPi get along great. What I love about Lua is the ease of integrating with 3rd party libraries. Here's a little demo of a Lua application driving the OpenVG graphics: https://www.youtube.com/watch?feature=p ... uc1A1B-H4U
Re: lua language?
@darkstar: What do you mean by more stable than Python?
The API with indexing or naming the GPIO pins would be possible in Python too.
The API with indexing or naming the GPIO pins would be possible in Python too.
Code: Select all
while not self.asleep():
sheep += 1
Re: lua language?
My only interpretation would be that lua uses less of the pi's few resources.BlackJack wrote:@darkstar: What do you mean by more stable than Python?
Re: lua language?
Darkstar,
I have to say though, that Lua is a wonderful thing. It can be used on systems much smaller than the Pi and much smaller than where you will ever see Python.
I'm curious. In what way is Python not stable? It has worked in flawlessly in production code for a long time now.It is lighter and more stable than say Python.
I have to say though, that Lua is a wonderful thing. It can be used on systems much smaller than the Pi and much smaller than where you will ever see Python.
Slava Ukrayini.
Re: lua language?
I highly recommend GameCake it is a Lua port with integrated OpenGL ES 2.0 and Joystick support that work nicely on the Raspberry PI
http://gamecake.4lfa.com/welcome
You can use "GameCake" to run the helloball.lua demo on Raspbian!
http://www.raspberrypi.org/phpBB3/viewt ... 01#p112301
http://gamecake.4lfa.com/welcome
You can use "GameCake" to run the helloball.lua demo on Raspbian!
http://www.raspberrypi.org/phpBB3/viewt ... 01#p112301
Xerxes Rånby @xranby I once had two, then I gave one away. Now both are in use every day!
twitter.com/xranby
twitter.com/xranby