Is JavaScript not a proper language? Is Lua not a proper language? Is Python not a proper language? Is Perl not a proper language? Is PHP not a proper language? ... GameMaker Language has data types - you just don't have to be syntactically explicit. C# has supported implicit typing at variable declaration with the 'var' keyword for a decade.
Just because C# has the ability to use "var" as a declaration doesn't mean that it's usage is a good idea in the first place. It can be convenient, but it can open a whole can of worms.
Example:
Code:
var test = "I am a String!"; //Easy: var is now a string.
var test2 = GameEntity.getVelocity(); // WTF IS VELOCITY?
What is a Velocity? Is it a struct (with seperate x and y velocity)? an object? is it a single float value (the speed of the velocity)?
Also, Javascript, PHP and Python do have their own problems when it comes to that sort of stuff. (They should by no means be taken as the languages which "do it the right way".
I would never in my life choose pure javascript over Java or C# when it comes to game development on more complex/advanced projects. (And there is a reason for that.)
It wouldn't change much for more advanced users either. Say you write a script that takes a number parameter - you don't care if that number is an int16, a uint64 or a double or float. All you care about is getting a number. Now imagine you had strong typing in GML and you download a Marketplace script collection, where it's not unlikely that a person who feels (or wants to feel) advanced has required uint16s, bytes and other stupid types where a number is needed and no benefit comes from it. That just leaves you with the headache of converting all your variables to the right type and do bounds checking. Or maybe they update their script collection and change a few types because they just learned about them. That doesn't sound like much of an improvement to me...
I would consider myself a more advanced user and i have to say that it would change A LOT for me.
I actually do care what type the given variable has. There are multiple reasons for that:
- I could optimize the memory usage (please don't use the argument that "todays computers have enough memory so that this isn't an issue."). There is a BIG difference in initialising an (3D) 1024Âł byte array and an 1024Âł 32 bit int array when it comes to memory consumption.
- (in the case of GM which stores all numbers in floating point format) if i assume/require a variable to be a non-floating point number, i would simply create an int instead of a float. If i do some mathematical calculations (like dividing 5/2 which would result in 2.5 in GMs case) and pass this value to a function which assumes the number to be in a rounded (non floating point format) it could lead to wrong results as i (as the developer) assume that the value is in a rounded format. (int a = 5/2 would result in a 2!) Of course i could round the value after each operation manually, but this is really tedious and unsafe. (Had this issue with PHP a lot of times...)
- No errors due to passing wrong types to a function/method which could lead to either A) undefined behaviour or B) straight up crashes. As an example: Accidentally screwing up and passing a string (or object ID ) nto a function which requires a floating point value. (It can happen that those errors don't crop up immediately. It may not crash, but it can lead to strange bugs. > Had this happen in GM.) >>> TYPE SAFETY
- You can't accidentally overwrite a variable with a different type. like
Code:
int A = 512;
A = "YAY, i can't do that!"; // not possible (which is a good thing)
I could go on but those are those things which immediately come to my mind.
Type safety is important. You can catch bugs immediately and be sure that the code/values behave in the exact way you (as the programmer) inteded them to do so. Especially if you work in a team (where you have to work with code which someone else has written.)
Now imagine you had strong typing in GML and you download a Marketplace script collection, where it's not unlikely that a person who feels (or wants to feel) advanced has required uint16s, bytes and other stupid types where a number is needed and no benefit comes from it.
Just because "someone" doesn't feel (or doesn't want to feel) "advanced" enough doesn't mean that type safety (or explicit typing) should be completely thrown out of the window.
(Types also exist for a reason. They aren't in any way "stupid".)
That just leaves you with the headache of converting all your variables to the right type and do bounds checking.
It's quite the opposite. Everytime i use scripts (and it's not clear what exactly it does/returns) i have to delve into them and look what exactly they are returning (is it a string?, an integer?, an object?, etc...)
It's also really tedious to be very careful and do those indirect casts (as an example from float to int by rounding those values) or type checks (like is_array(), is_sring(), etc...) manually... (Casts are completely fine. But they should be done properly.)
Or maybe they update their script collection and change a few types because they just learned about them.
So... we should assume that everyone who is using GM is a complete idiot and isn't able to learn the difference between a boolean, an integer and a float?
Types are already present in GM. (albeit a bit limited.) The sooner people start learning about the fundamentals of programming, the better. (Helps the code mantainability, predictability, workflow and overall knowledge about the underlying computer system.)
I understand that YYG wants to keep it simple and beginner friendly. But sacrificing features which are important for more advanced users (and more complex projects) is (in my opinion) not the right path to take.
Of course, Game Maker is owned by YYG and it's their decision as to what they do with their software and how they approach the further development. (They know pretty well what they want to do with their software and who the target audience for GMS is.)
Now, i hope you don't interpret this as an attack on you or on YYGs. I just express my concern and my standpoint on this topic as someone who has worked in multiple languages (Java, C#, Javascript, Actionscript (Flash), PHP, Python, GML, a little bit simplified assembly and a little bit C++), who works on a larger project in GMS 1.4 and has seen/experienced the advantages and disadvantages on such topics like implicit/explicit variable types and type safety.
I want Game Maker to become better. (Both for beginners AND for more experienced users.)
I love the simplicity which GM offers to us, but i would be more than happy to have more control over this stuff. (GML in its current form leaves a lot to be desired.)
One positive thing that i can say is that i've heard from
rwkay in a different topic (which sadly was closed as it derailed in an offtopic flamewar) that there might be something coming sometime in the future. (And i'm looking forward to whatever is planned for GML.
)
It's still a beta after all.