Suggections about wiki content about LuaJIT, bitwise operators, etc.

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
farter
Prole
Posts: 4
Joined: Sat Aug 03, 2019 6:17 pm

Suggections about wiki content about LuaJIT, bitwise operators, etc.

Post by farter »

yes just write

Code: Select all

print(bit.bor(1,2))
you get 3 in the console. don't even need to

Code: Select all

require
.
this is some dumb experience. you may exit now if you don't want to see dumb guy complaining about himself being dumb.

problem is here.
it's known that Lua 5.1 doesn't have bitwise operators.
it's known that LuaJIT is something which rocks.
it's known that BitOp is "a Lua extension for bitwise operations on numbers." from the same author of LuaJIT.

*searches for "bit" on love2d wiki*
the page doesn't exist.
lots of data types, 32bit/64bit things, 8-bit gaming, 16-bit what what buffer....

*searches for "bitop" on love2d wiki*
nothing.

*searches for "bitwise" on love2d wiki*
two pages introducing advanced technologies.

*searches for "bitwise operation" on love2d wiki*
nothing.

*searches for "bitwise operation love2d" on google*
"simulate bit shift in love2d" yes i knoooooow that works but just shit sloooooow!!!!
"I demand that LÖVE add support of lua 5.3" i know that 5.3 has them but i don't think love2d's going to switch to 5.3 any time soon!!
(well though now i found someone very indirecly stating "Additionally, many useful features from Lua 5.2 and 5.3 (e.g. bitwise operations) are covered either by LuaJIT's FFI or (in the case of bitwise ops) by a module included with LuaJIT: http://luajit.org/extensions.html#bit)"..... others also mentioned somehow but mostly saying "that comes with luajit, if luajit is enabled blabla" maybe i missed them a bit.... all refers me to luajit.org and i'm wondering will i need to somehow install it?

that's about the second question: does love2d some with luaJIT? (since the file names doesn't indicate that)
i even saw one saying on stackoverflow: "i'm 90% sure that love2d comes with luajit".....

*searches for "LuaJIT" on love2d wiki*
looooots of "if you're using luajit", "when luajit's jit compiler is enabled", "... js a library for LuaJIT", "love uses luajit by default" (actually the last one is somehow better news)
only one that makes me really confident is in "DistanceBasedCollision"
...on, instead of the second version's three squarings. That said, Löve uses LuaJIT, so if one really needs to optimize, check which is faster.
LOVE USES LUAJIT!!!1!11!!11!!11

however, i'm still not sure if that's a separate library for luajit or built-in....
*searching "bitop" on wiki.luajit.org*
only one page with 2 matches redirecting to bitop.
*reads bitop.luajit.org*
looks very like it's a SEEEPAAAARAAATE library i need to somehow install them...
it even says "Compatible with the built-in bitwise operations in LuaJIT 2.0." whaaaat? they are TWO DIFFERENT THIINGS?????? (how can the same thing be "compatible"???) so how can i find the built-in bitwise operations?????
......

much thinking before i finally tried to directly write the code to test and realizing how dumb i was.
though i'm still confused now.
"when do love not come with luajit?"
"how can i enable/disable the jit compiler?"
"if so, i can't use bit.xxx?"
"if so, i can only play with floating point division and modulo, if not manually building love2d to add c extensions?"
at least know for now, on the latest release version of windows, i can use it directly......

my suggestion is......

create pages named "bit", "LuaJIT" on love2d wiki.... say something....
better another "bitwise operator" page, state that "YOU CAN USE IT (THE BITOP LIBRARY WHICH IS UNDER THE NAME bit WHICH COMES WITH LUAJIT2.0 WHICH COMES WITH LOVE)!!!! BY TYPING SOMETHING LIKE bit.bor(a,b)!!!!!! see http://bitop.luajit.org for more"

have a nice day.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Suggections about wiki content about LuaJIT, bitwise operators, etc.

Post by zorg »

My understanding was that the löve wiki contains information about functions and things Löve itself implemented, and not things that are pure lua or luaJIT related (the luaJIT bitops library is related to luaJIT, and has nothing to do with the bit library included with lua 5.3), since there are other websites that have such information.

Also the two searches you did for "bitwise" brought up completely unrelated pages; one about a 3rd party tilemap application method, and the bitwise inverting type of stencils, but i digress.

But to answer your questions:

"when do love not come with luajit?" - Löve is built with luaJIT (and the bitops library) by default, but since it has source distributions, people are free to build Löve with other lua backends; 5.1, 5.2, 5.3 or LuaJIT. (but if it's not luaJIT, they'll sacrifice speed a lot)

"how can i enable/disable the jit compiler?" - It's on by default (except on Android due to issues, and IOS due to Apple), but you can turn it off by doing:

Code: Select all

 local jit = require 'jit'; jit.off() -- and jit.on() turns it back on.
but you usually want it on.

"if so, i can't use bit.xxx?" - you can use bit.xxx (regardless of the jit being on or off) if you do this:

Code: Select all

 local bit = require 'bit' 
the last question's irrelevant due to the above one... although you can still load dll/so dynamic C libraries with Löve if it uses luaJIT (again, which it does by default) and run functions from them, through the FFI library that luaJIT also provides.



Lastly, i do agree that the wiki could use a bit of a cleanup, but i don't have the capacity to do such an overhaul... and even if i tried, chances are the changes would be reverted anyway :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: Suggections about wiki content about LuaJIT, bitwise operators, etc.

Post by pgimeno »

zorg wrote: Mon Nov 25, 2019 12:19 pm "when do love not come with luajit?" - Löve is built with luaJIT (and the bitops library) by default, but since it has source distributions, people are free to build Löve with other lua backends; 5.1, 5.2, 5.3 or LuaJIT. (but if it's not luaJIT, they'll sacrifice speed a lot)
Not only that, but they will also sacrifice the ffi and bit libraries, making them unable to run programs or to include libraries that use them without external counterparts, e.g. GifLoad won't work without ffi. I'm not sure if it would work with https://github.com/jmckaskill/luaffi; I didn't know it when it was written so I made no compatibility efforts regarding null pointers. It might work out of the box, or not.

zorg wrote: Mon Nov 25, 2019 12:19 pm "how can i enable/disable the jit compiler?" - It's on by default (except on Android due to issues, and IOS due to Apple), but you can turn it off by doing:

Code: Select all

 local jit = require 'jit'; jit.off() -- and jit.on() turns it back on.
but you usually want it on.
The JIT library is loaded by default into the 'jit' global, there's no need to require it. In fact, one quick'n'dirty way of checking whether the Lua runtime is LuaJIT or PUC is to check if this global is truthy. This method may fail if you use strict.lua, though.
farter
Prole
Posts: 4
Joined: Sat Aug 03, 2019 6:17 pm

Re: Suggections about wiki content about LuaJIT, bitwise operators, etc.

Post by farter »

thanks for your detailed explanation and i think these are exactly what should go in somewhere of the wiki...

i don't intend to copy exhausted docs to the wiki, instead i'm recommending to do it in a "just a mention" fashion like the last 3 entries of the left sidebar (lua-enet, luasocket, utf8), much better than "intentionally not to mention it that you won't get any tiny bit of information if you search on my wiki cuz it's none of my business". just some links will also be fine, better with a little bit of examples.
zorg wrote: Mon Nov 25, 2019 12:19 pm Lastly, i do agree that the wiki could use a bit of a cleanup, but i don't have the capacity to do such an overhaul... and even if i tried, chances are the changes would be reverted anyway :3
i don't really aim any cleanup though, instead mainly i'm to add the necessary info (or say, "friendly", which is already true for most entries among the love wiki) about, say, "bit", "LuaJIT", the fact that in official distributions it IS built-in (i can only find it in "building love") and you CAN use it regardless of whether the jit turned on or off.

---
oh i just found i can to log on to the wiki with the the forum account..... i thought it's restricted to specific wiki authors...
but my engrish :| umm i'll think about how to write something formal...
Last edited by farter on Mon Nov 25, 2019 3:33 pm, edited 1 time in total.
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Suggections about wiki content about LuaJIT, bitwise operators, etc.

Post by zorg »

pgimeno wrote: Mon Nov 25, 2019 3:07 pm Not only that, but they will also sacrifice the ffi and bit libraries, making them unable to run programs or to include libraries that use them without external counterparts...
Well, one minor detail is that lua 5.3 does have its own bit library, even if it's a bit (ha) different than luaJIT's, but it should have most if not all functions included.
pgimeno wrote: Mon Nov 25, 2019 3:07 pm The JIT library is loaded by default into the 'jit' global, there's no need to require it. In fact, one quick'n'dirty way of checking whether the Lua runtime is LuaJIT or PUC is to check if this global is truthy. This method may fail if you use strict.lua, though.
This might be so, i just like to explicitly require in the libraries i want to use (kinda the reason i asked for enet to not pollute the global namespace with its global, and only return itself) :3
farter wrote: Mon Nov 25, 2019 3:30 pm ...
Yeah, it should be mentioned at least somewhere, i agree.
And apparently also the fact that you can also edit the wiki with a forum account. :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 54 guests