Any under-the-hood differences between variable types?

Discussion and feedback on Construct 2

Post » Wed Feb 11, 2015 6:39 am

I was wondering if variable types had any impact on performance in games just out of sheer curiosity. Like my friend told me in programming text variables are most intensive and then numeric and then boolean variables. Was just curious if this holds true for C2 and if there's anything else they impact besides that.
B
45
S
13
G
1
Posts: 236
Reputation: 4,010

Post » Wed Feb 11, 2015 8:26 am

It is true for normal programming! booleans, integer, floating point, text... I am also curious about C2.
B
58
S
18
G
13
Posts: 447
Reputation: 10,740

Post » Wed Feb 11, 2015 11:21 am

Well there is global, and then there are regular variables.
B
8
S
2
Posts: 134
Reputation: 1,001

Post » Wed Feb 11, 2015 11:37 am

truefalcon wrote:Well there is global, and then there are regular variables.

That's not what they mean, turefalcon - in "proper" programming it is possible to set a variable type depending on projected usage - like int (only round numbers), float (numbers with decimals), string (for words and such) and also different subtypes (how big the number can get - up to 255, or up to 32767 or 2 billion something), signed or unsigned, etc. In olden times this had a big effect on the memory usage. I don't think it matters that much nowadays, but it would be neat to know for sure.
B
19
S
6
G
7
Posts: 1,101
Reputation: 6,146

Post » Wed Feb 11, 2015 12:46 pm

Somebody wrote:I don't think it matters that much nowadays, but it would be neat to know for sure.


It does not. Nowadays developers don't have to pay that much attention to declaring the proper type of variables to save memory. You can save much more memory by cutting off the unnecessary transparent parts of the images your project uses.
B
135
S
33
G
17
Posts: 1,560
Reputation: 20,734

Post » Wed Feb 11, 2015 2:33 pm

I am pretty sure that all number variables are handled as floating point numbers. This can cause some strange things to happen if you're not ready for it. See here for some discussion on it.
A big fan of JavaScript.
B
76
S
20
G
74
Posts: 2,255
Reputation: 46,484

Post » Wed Feb 11, 2015 3:19 pm

Yeah, it is interesting, I remember when I read programming books about the importance to use proper variable because if you do not declare it as anything you will get the most wasteful one, oh the horrors! ;D

but @glerikud is right, now in comparison, there are so many other things that are more wasteful..
B
58
S
18
G
13
Posts: 447
Reputation: 10,740

Post » Wed Feb 11, 2015 3:48 pm

Colludium wrote:I am pretty sure that all number variables are handled as floating point numbers. This can cause some strange things to happen if you're not ready for it.


That's true, but in these cases you can use the int() function to convert the number to an integer value.
B
135
S
33
G
17
Posts: 1,560
Reputation: 20,734

Post » Wed Feb 11, 2015 3:58 pm

That was back when computers would actually slow down while trying to do math.
Putting your trash can back under the cupboard was important when your kitchen wasn't wide enough for two people, but it's a warehouse now. It will only make a difference to the neurotic. ;-)

Ashley's Blog: Optimisation: don't waste your time
https://www.scirra.com/blog/83/optimisa ... -your-time
B
240
S
62
G
33
Posts: 903
Reputation: 40,589

Post » Wed Feb 11, 2015 8:53 pm

Yeah, don't waste your time. Or, answer the question yourself! This question might have mattered in say 1990 when processors were around 25MHz so you might have noticed this sort of thing.
Scirra Founder
B
399
S
236
G
89
Posts: 24,546
Reputation: 195,436

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests