i of course grabbed that last night :slight_smile:
Norns is 32 bit dev?

pp

er, not sure i understand the question. the norns hardware (CM3) is an arm64 platform, and the lua on norns uses the default 64-bit precision for numbers. (this is a compile-time option for the Lua language.)

should the lua stuff on windows be /Program Files [64bit] or /Program Files (x86)

i think i just dont grasp it yet. I need a new language and i need some basic TOOTs we used to call them in Csound olden days

some Lua Toots :slight_smile:

I am going to pull some SuperCollider Files too from the vaults and hopefully get inspired

Does anyone know if integer divide // is faster than the regular / operator on integers? How can I check the implementation or test run speeds?

no, it’s not really an optimization device. use floor division (//) when you want floor(a/b) and use division (/) when you want a/b. standard division always returns a float even if the operands are both integer, and vice versa for floor division.

How can I check the implementation

look at the lua source

this tells us, if the operands are both int, luaV_div is called, otherwise you get some macros, after which unwrapping are simply the C expression floor(a/b)

or test run speeds?

check system time, perform many calculations, check time again.

but my advice is to not waste your time with this. lua is fast for a scripting language but it’s not C or ASM. each operation in lua involves many processor instructions as it performs type checking, handles edge cases &c. the actual arithmetic is going to be done in a single instruction and is relatively insignificant. if you need to rapidly perform thousands or millions of calculations then maybe doing it in lua is not the way to go.

1 Like

A bit of an aside, but: is there any reason why Lua on the norns is 5.1.5 (dated Feb 2012)? Latest official release is 5.3.5.

no… that’s weird. it must be whatever comes with raspbian stretch.

the lua environment that actually runs norns scripts is 5.3 (we just link from liblua5.3-dev)

Oh - it never occurred to me that the norms environment would be running something other than the default /usr/bin/lua. Does the 5.3 installation have a command line component? I want something for running unit tests. (Matron might do that for me, but I’m not seeing any summary output from them.)

I ran into this the other day when trying to run some unit tests. The lua 5.3.x command line is available as a separate package (which is not installed in the norns image by default). I did the following on my dev device.

  • sudo apt-get install lua5.3
  • Install luarocks
  • luarocks install luaunit

One has to invoke lua5.3 explicitly to get the newer runtime.

1 Like

Thanks for that - I was wondering about the wisdom of doing an apt-get install - though as a Mac user I suppose I could just SMB-mount the norns drive and run a Homebrew-installed Lua from macOS instead…

I find it useful to have a functional environment on both the device and my laptop. When working on particularly ambitious projects I separate code into norns specific and platform independent so that a subset of the tests can be run off device.

Quite so. The lower-level grid driving code probably won’t get added to the tests, but I’ll keep that as simple as possible. The complex higher level stuff is (or will be) pure Lua, and I can probably mock the lower-level stuff for testing if I need to.

out of curiosity have any first time programmers had success reading through Programming in Lua?

I thought it was pretty well written but I had prior programming experience before going into it

2 Likes

Nope, might try gradually

seems comprehensive (and therefore somewhat daunting)

2 Likes

same. looks like a great resource, but today i was reading microsound, then started max/msp free trial, and then tried reading this and it was a bit of an overload lol :face_with_head_bandage: thanks 4 sharing tho ~

1 Like

yea, fair enough, i was relying on it more for the advanced topics but the starter pages are probably a little too dense

how do people feel about the english language syntax in lua (i.e. if then end do) ? as an experienced programmer it’s a minor annoyance, but for newcomers, I’m curious if it’s helped anyone come to grips with the logical operations or made code more readable compared to c-style:

if (true) {
    thing()
} else {
    otherthing()
}

technically lua was my first programming language and my intro to these concepts, but I do not remember back that far : )

I forget the then almost every time

1 Like

don’t get me started on if do

the thing that bothers me is the other way round, writing some javascript after a session of lua writing adding in then from muscle memory constantly