Sending multiple values with LUBE

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

Re: Sending multiple values with LUBE

Post by cohadar »

It is their fault.
This fails:

Code: Select all

	local text = tostring(math.pi)
	local pi = tonumber( text )
	assert( math.pi == pi )	
This works:

Code: Select all

	local text = string.format("%.17g", math.pi)
	local pi = tonumber( text )
	assert( math.pi == pi )
They just need to use proper double-precision formatting, it is not that much to ask really.

Noone needs self references in netcode data.
And when it comes to networking every ounce of speed matters.
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: Sending multiple values with LUBE

Post by I~=Spam »

cohadar wrote:It is their fault.
This fails:

Code: Select all

	local text = tostring(math.pi)
	local pi = tonumber( text )
	assert( math.pi == pi )	
This works:

Code: Select all

	local text = string.format("%.17g", math.pi)
	local pi = tonumber( text )
	assert( math.pi == pi )
In the open source world complaining about something like this is pointless and hinders progress. Open an issue. It is fine to show problems with this but do keep in mind that this is a very small error and you are using to show that these libraries are awful. That is like me saying an entire OS with billions of dollars of effort put into it is all bad because of one bug or problem. I hope you see the issue here.
cohadar wrote:Noone needs self references in netcode data.
Umm you can't say that. Just because you cannot think of a case doesn't mean it won't happen. This is an argument from ignorance.
cohadar wrote:And when it comes to networking every ounce of speed matters.
While you do have a point there keep in mind that this is jit compiled. So the lua code has the potential to take advantage of fast features unique to that computer. This becomes especially true when using luajit v2.1 (currently in beta even though it is pretty stable) which has even better jit support.

Also keep in mind most people here do not want to make an MMO. Anyone who wants to might want to consider using c/c++ not lua because the tiny benefit from using json is so small that it means nothing. C/C++ would be better. Although I do find it interesting that many servers are written partially in python (namely the networking part). In comparison to luajit, python is really, really slow. So it seems that in the gaming making world network speed just isn't the problem that it used to be.

EDIT: wrote luajit version incorrectly...
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

Re: Sending multiple values with LUBE

Post by cohadar »

When a serialization library does not deserialize exactly same data as on input it is NOT a small problem.
The whole point of serialization is to save data and get the same data back later.

The fact that number differences are small like 0.000000001 does NOT mean that this is a small problem.
And this is especially not a small problem in networked games where any difference between client and server means that a desync has happened and that game state is invalid for some player.
In FPS games desync is often non fatal, just introduces more lag to the player.
In RTS games desync is fatal and player gets disconnected.

I have submitted this issue on github to several libraries.

And no, seriously, noone needs self-referencing tables in netcode.
99.999999% of games in the world have netcode written in languages that don't have self-referencing data.
Self-referencing is a non-essential feature of a particular language, like for example how Java uses checked exceptions, but almost no other language does.

Regardless of all our pro and con arguments so far, having JSON support in love would be a good thing, talking to web API-s is becoming an essential feature in modern gaming. Stats-tracking, achievements, etc..
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: Sending multiple values with LUBE

Post by I~=Spam »

cohadar wrote:When a serialization library does not deserialize exactly same data as on input it is NOT a small problem.
The whole point of serialization is to save data and get the same data back later.

The fact that number differences are small like 0.000000001 does NOT mean that this is a small problem.
And this is especially not a small problem in networked games where any difference between client and server means that a desync has happened and that game state is invalid for some player.
In FPS games desync is often non fatal, just introduces more lag to the player.
In RTS games desync is fatal and player gets disconnected.
Floats are approximations themselves. So adding accuracy in the serialization generally is just that: only adding accuracy. If one needs perfect precision of floats they shouldn't be using the built in lua number type (ie. use infinite precision libraries that are available in c/c++). If might seem confusing why I am stating this because it seems obvious that one would want to replicate the float exactly. Except you seem to have forgotten that floats are platform specific. Any variation from the server's implementation of float (specifically the precision) while cause a mis-match. It is REALLY bad practice to force your game to be locked like that. Thus, it is not a good idea in the first place to expect that the floats will be exactly the same on the other end. The server should be built so that error is expected in the first place.

On the other hand. A int definitely should be replicated perfectly.

If you REALLY care still and you think I am wrong about this (and I might be) fork the repo. You are using the libraries as evidence to show that lua tables are bad. The libraries are not lua tables. That is like me saying that because a table to json library loses precision json shouldn't be used. That is just really logically incorrect.
cohadar wrote:I have submitted this issue on github to several libraries.
Great! Then stop using this as something to show that these entire libraries are bad!
cohadar wrote:And no, seriously, noone needs self-referencing tables in netcode.
99.999999% of games in the world have netcode written in languages that don't have self-referencing data.
Self-referencing is a non-essential feature of a particular language, like for example how Java uses checked exceptions, but almost no other language does.
Why do you think that java has that? I think you can answer this for yourself.
cohadar wrote:Regardless of all our pro and con arguments so far, having JSON support in love would be a good thing, talking to web API-s is becoming an essential feature in modern gaming. Stats-tracking, achievements, etc..
Love is a minimalistic engine. Things don't just get added because they are nice to have. They get added because they are a must. Json support is definitely not a must because there is the lua equivalent and also json parsers written in lua.

Why are you defending this like your it is your own life? You haven't even addressed the problem that it might not even be faster because of the JIT compiling. (Calling C functions repeatedly is expensive and the api exposed to C is not going to be able to make lua tables as fast.) Json is missing features. Json is easy converted to lua tables. There isn't any reason for json. There is no reason to put more baggage into love when it already can do it just as fast.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
User avatar
cohadar
Prole
Posts: 25
Joined: Mon May 04, 2015 5:46 am
Contact:

Re: Sending multiple values with LUBE

Post by cohadar »

Accuracy and precision are not the same thing.
Floats are not platform specific, they are international standard.

And you are absolutely right about love not needing extra baggage.
I guess I got carried away in the argument.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Sending multiple values with LUBE

Post by Robin »

  1. loadstring is way faster than anything you could write in Lua that only loads data. Believe me, I've tried.
  2. Thanks for the heads-up, cohadar. Bug: fixed.
Help us help you: attach a .love.
User avatar
I~=Spam
Party member
Posts: 206
Joined: Fri Dec 14, 2012 11:59 pm

Re: Sending multiple values with LUBE

Post by I~=Spam »

cohadar wrote:Floats are not platform specific, they are international standard.
If it wasn't application specific than the c/c++ standard wouldn't state that this header is platform specific. I don't really know where is kept in the standard so this is close enough... http://www.cplusplus.com/reference/climits/

Yes there are standard definitions but depending on these is VERY bad coding. Seriously this is lua not c or c++. The code should be platform agnostic so long as the hardware has the features so no lua features have to be disabled.
My Tox ID: 0F1FB9170B94694A90FBCF6C4DDBDB9F58A9E4CDD0B4267E50BF9CDD62A0F947E376C5482610
Post Reply

Who is online

Users browsing this forum: Google [Bot], hmmmmxd and 5 guests