6 replies [Last post]
jeacom's picture
User offline. Last seen 38 weeks 2 days ago. Offline
Joined: 06/02/2016
Groups: Go Science

I just want to understand why lua was choosen as the main language for recipes in foldit.

This language is such obscure, is there some quirk that makes it better than other languages for foldit?

Personally I am finding it a really strange language to deal with, mostly because the end keyword and arrays starting at 1.

Joined: 12/27/2012
Groups: Beta Folders
it wasn't my pick, but...

Actually, Lua is used as a scripting language in many other games, such as World of Warcraft. There's a whole wikipedia category page listing them (it even includes Foldit).

So it's not really that unusual a choice.

Lua does like to start at index 1 instead of offset 0, so you'll see a lot of for loops that say:

for i = 1, #mytable do
   ...
end

Most normal people would think that in a collection of things, the first thing would be thing one. Calling it thing zero would be kind of odd. So again, starting at one is not such an inexplicable choice.

Only flannel-shirted veteran C/C++/C#/Java and maybe assembler nerds think starting at zero is a Good Thing. These are the same people who gave us the mutable null-terminated string, the computer virus, and Windows, among other Bad Ideas. (Maybe Windows *is* a computer virus, a form of ransomware that demands $115 for an upgrade from "Home".)

Bottom line, Lua has been in Foldit for a good ten years at this point, so I suspect they're not likely to switch any time soon.

jeacom's picture
User offline. Last seen 38 weeks 2 days ago. Offline
Joined: 06/02/2016
Groups: Go Science
.

well that must be because its easy to implement then.

but I guess I'll never get used to starting indexes at 1, 0 makes much more sense specially for nD indexing in a 1D list.

rmoretti's picture
User offline. Last seen 1 day 10 hours ago. Offline
Joined: 01/15/2010
Groups: Foldit Staff
1-based is not Lua specific

Even if Foldit wasn't scripted with Lua, it would still have a lot of 1-based indexing. Rosetta, the biochemical computational engine behind Foldit, makes heavy (almost exclusive) use of 1-based indexing. While Rosetta is currently programmed in C++, it started out as a Fortran program, which has support for 1-based indexing, and starting counts at 1 makes a lot of sense to biochemists who are the primary audience. That wouldn't go away even with a different programming language. (As anyone who uses PyRosetta can tell you.)

Joined: 09/24/2012
Groups: Go Science
One of the strengths of Lua

I might be wrong but I think one of the strengths of Lua is its tables (or lists) which are very economic in memory. I suppose it's a reason why it's used for video games.

You don't have to reserve a square table of possible memories (like in excel). You might have a pyramidal table, a list that mixes different variable types, for example mixing constants and functions. That's economic in writing.

See for example how my JET recipe calls the sub-recipes at bottom of the code.

jeacom's picture
User offline. Last seen 38 weeks 2 days ago. Offline
Joined: 06/02/2016
Groups: Go Science
tables

Many other languages have efficient tables too, there's the python's dict that is identical to lua's table, I think JavaScript also has also it.

I think what sells lua is actually its simplicity, it doesnt have classes or advanced datatypes but is garbage collected, its simple enough to learn fast but not as scary as other languages like ALGOL.

jeacom's picture
User offline. Last seen 38 weeks 2 days ago. Offline
Joined: 06/02/2016
Groups: Go Science
tables are not memory efficient.

Also, dont let it mislead you, tables are not memory efficient comparend to lists.

Hash tables work by reserving a good chunk of memory where key-value pairs are stored almost randomly, to avoid collisions, in fact, most general purpose hash tables have to keep most of its space empty to stay efficient, programming languages actually just hide the fact that they allocate space to stay empty.

https://en.wikipedia.org/wiki/Hash_table

Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, Boehringer Ingelheim, RosettaCommons