Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add penlight? #479

Closed
catfact opened this issue Aug 2, 2018 · 7 comments
Closed

add penlight? #479

catfact opened this issue Aug 2, 2018 · 7 comments

Comments

@catfact
Copy link
Collaborator

catfact commented Aug 2, 2018

with more people coming on board, there is more demand and discussion around adding common utility functions.

penlight is maybe the closest thing to a lua standard library and has many functions for manipulating strings, tables, paths, sequences, classes, &c &c.

we already indirectly use it for development as a dependency of ldoc (same author i think.)

so should we maybe add luarocks install penlight add penlight to an update script?

pros:

  • greatly extends the language, freeing us from reinventing the wheel over and over

cons:

  • greatly extends the language, possibly interfering with the learning curve. (particularly if people use the class system)

  • many penlight features rely on code generation / metaprogramming, creating performance pitfalls

@junklight
Copy link

junklight commented Aug 2, 2018

+1 from me - there is some essential stuff in here that would be really nice to have by default. You will end up with bits of this functionality cut and pasted in anyway without it. As was pointed out in the forum - things like Python come with all this stuff anyway. Although list comprehensions using executable strings - ugh - that's just asking for trouble. whatever possessed them...

@catfact
Copy link
Collaborator Author

catfact commented Aug 2, 2018

well, that speaks to my reservations. like many things in penlight, list comprehensions ultimately work by using loadstring, invoking the lua parser and code generator. not good for, say, a timer callback... (updated "cons" above)

@artfwo
Copy link
Member

artfwo commented Aug 2, 2018

updates should be executable offline, so it's better not to use luarocks, but rather ship the lib in the update tarball and install it somewhere in the search path.

@samdoshi
Copy link

samdoshi commented Aug 2, 2018

Echoing what @junklight says, we either have homegrown versions of it, with homegrown bugs and worse documentation, or use an existing library.

It will increase the learning curve, but if the documentation is included then the discoverability will be high, and that in itself can help new programmers (i.e. why is there a copy and a deepcopy function... reads documentation / Google).

On a more abstract note, if we're looking at generally introducing people to coding then using libraries and standard libraries is part and parcel of it, and is a really good transferable skill (unless we're planning on going full SICP and starting from scratch).


The Penlight README.md has docs on installing manually. Also Debian has packages for lua-penlight (and lua-ldoc) if you want to stop using luarocks. You could include the deb in the update and install with dpkg (don't forget any dependencies too).

(If you do install lua-ldoc with dpkg you'll need to remove the existing version first!)

@pq
Copy link
Collaborator

pq commented Aug 2, 2018

updates should be executable offline,

👍

so it's better not to use luarocks

actually, it looks like there are a few options for offline use. according to folks on stackoverflow, you can install local rocks or alternatively you can setup a local luarocks server.

FWIW, i'm keen to see a solution here too. adding the penlight library would be great for everyone. having a story for lua libraries would also help pave the way to new and exciting norns features that could leverage existing work. (as one example, see scry, the simple lua language server i've been playing around with).

@tehn
Copy link
Member

tehn commented Aug 8, 2018

i'm starting to feel less imperative that updates should be executed offline: if we need to get a file from the internet, put it on a USB stick, then insert it?

if we can make wifi connection reliable soon (fix timesync crash) i'd be up for reconsidering the update method entirely.

i see less of an issue using luarocks and am generally very much in favor of including something like penlight to reduce the amount of re-invention while coding

@mimetaur
Copy link
Contributor

I’m wondering if to reduce complexity it would be friendlier to keep handpicking utility code to add to the Norns library, like the kind of functional utilities we see in fnutils/underscore.

As a script author I can always download a script on my dev machine (via luarocks or github, etc) and put it in my own script’s lib folder.

The only ugly part of this approach is if tons of third party scripts all use, eg, json and all have their own different copies in lib. I have not seen this yet though.

@tehn tehn closed this as completed Mar 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants