killing the VAR type?

Posted By: Rackscha

killing the VAR type? - 11/12/12 12:30

Something that still feels odd when working with gamestudio is the VAR type. Something like this doesnt exist outside of gamestudio, and even the CROSSL-Language SDKs(C++/Delphi) have to deal with functions exported with this odd type.

As we are not working in the closed CScript world anymore, my vote goes towards removing this type. In my eyes its an obsolete type and we should get rid of it asap.

Less converting when working with external non LiteC things, too.

By removing this, many things become more straight forward(i.e. creating an sdk for another external language).

Is there any real reason to keep VAR? (dont go with "This will break past code" wink )
Posted By: jcl

Re: killing the VAR type? - 11/13/12 10:20

Wow, most people ask here for adding a feature, but you're the only one so far who asked for removing a feature.

If you only could ask for removing the same features that others want to be added, I could go in vacation. laugh
Posted By: MasterQ32

Re: killing the VAR type? - 11/13/12 10:27

haha, i think this will never happen laugh

but i support Rackschas opinion, wrapping the var type is really annoying and unneccessary if i want to use gamestudio from C#, C++, whatever

i'm not using var anymore in any lite-c projects just because i don't need it
float or double gives me floating point numbers, int gives me integers

(And also it won't break my past code)
Posted By: Uhrwerk

Re: killing the VAR type? - 11/13/12 10:45

On the very long run this may be a good idea. But I'm pretty sure JCL would only change this for a major release. Addiitionally at the moment there is no compellable reason to do so in the near future.

But have you also though about the consequences? Floating point numbers have got some harsh surprises for newbies.
Posted By: HeelX

Re: killing the VAR type? - 11/13/12 11:03

Originally Posted By: jcl
Wow, most people ask here for adding a feature, but you're the only one so far who asked for removing a feature.


That is not true, several people asked for it. Interestingly, I bought some days ago for nostalgic reasons the "Gamestudio 3D" book and I noticed, that the "var" type was used 'til then.

Since interactive graphics demand speed and floating point is not usually the fastest kind of arithmetic available on personal computers, fixed point arithmetic is a valid alternative, because it uses ordinary integer operations. That was cool back in the nineties, because almost all consoles like SNES, Sega Megadrive and the Gameboy didn't had floating point units (FPUs); even on the PC fixed point values were popular in games like Doom because it improved performance. Still today fixed point arithmetics are used on most low-cost embedded microprocessors and microcontrollers, that also still don't have a FPU.

That is also true for many lower-end Android devices, that is why e.g. the OpenGL ES standard supports fixed point arithmetic side by side with floating point arithmetic, too. But even though you use float's, vertices are always stored in fixed point format. On the other hand, all iOS devices come with FPUs, so, it would be a waste to use fixed point arithmetic there, because internally, all fixed point values are converted to 32bit floats for all arithmetic operations, as far as I know. And if you know, for instance, that your Android device has a FPU, it would be also not very clever to use only fixed points (with the exception for vertices).

From a convenience point of view, I vote also for replacing the fixed point "var" type with e.g. floating points; especially to overcome the +/- 99999.999 limit and to model values beneath 0.001. I also - literally - HATE doing conversions all the time.

But I can totally understand, why JCL would stick to fixed point arithmetic. If he would replace them, I guess the first candidate were floats just because of the same byte-size (4). I also don't know if this would be a hit on the overall performance; I don't know what tricks are used by JCL to increase performance (if any?), but I doubt that there would be a speed-hit on Desktop PCs.
Posted By: jcl

Re: killing the VAR type? - 11/15/12 14:01

The performance of float and var on a PC is about the same, but on low end devices there's a difference. However the main reason for vars is not performance, but better accuracy, better support of math operators and comparisons, and better access to beginners.

Vars will also be the basic variable type for the upcoming Android version.
Posted By: Rackscha

Re: killing the VAR type? - 11/16/12 11:41

Originally Posted By: jcl
but better accuracy, better support of math operators and comparisons, and better access to beginners.


Mh better accuracy? Thought vars go only down to 0.001. Yes its true that fixed point math does not suffer from mantisa problems, but a float is more acurat when in comes to calculate smaller numbers.

About comparision: I think its very important to learn for a beginner, that you DO NOT '==' compare to values if they are not integers. See this quite often in code from beginners in other languages and they always wonder why this doesnt work. By using fixed Point, it seems that this operator works more often, so beginners are misslead and learn it "wrong".

The problem in gamestudio (I think) seems to be the small gab between easy entry and overall understanding of how things work. The later one is skipped more often, i think.

I did my first steps in Programming with A5 when i was 13/14 years old, and when i left the environment of CScript, i went into a wall.

Floitingpoint precision problems, structuring a Programm without a scheduler(wait). I learned pretty quick, so it wasn't a big problem. But i have seen others.


edit: And when someone starts to work in an external language, its expectable that he is not just a bloody beginner. But at this point the VAR type just blocks easy access to the engine(as you have to "move around" it)
© 2024 lite-C Forums