Lord KJWilliams
Member
Hello , Im new to GMS 2, and the GML language. My previous experience with programming languages is mostly C and a little of C++. I am going to ask a lot of questions about GML ( as I learn it ) , in later future posts, from a C programming point of view because I am transitioning from C to GML. All of my questions are labed like a bullet listing and are in no way in any particular order. Forgive me if I go off tangent.
In GML if you have the following :
The code above looks similar to C as a pointer being assigned the address of where a function is declared in memory, the example below, you can do this ( although I have never had the need to use it ).
When ever I see a tutorial on GML on youtube, that someone is demonstrating , that
assignment of a variable to a function reminds me of that assignment of a pointer to a functions address in memory for C or C++.
I am so used to working OS shell environments like MS-DOS and linux bash shell. Ive learned that long ago, that in order to do anything GUI, with either Gnome ( for linux ) or Windows in Visual Studio for C++ by Microsoft, you have to learn how to use the OS to talk to the machine through the platform specific langauge that is included with C++ . The learning curve for Linux is steep, but very rewarding once you know X11 ( or what ever the standard is now for X-windows ) which I never got to, because the books on the subject come in the form, like a encyclopedia. Its like learning the programming language called ADA ( and I don't plan to ever work for the department of defense, in the USA ).
( back to the original train of thought )
So far....
I suppose there are easier ways in GML to do this , than what I can think of in C that do the same things that I have shown as examples. Again, GML is new to me, but not programming. So thats just some questions and a sample of my background in programming. My big problem is that C has put my mind into a box, because I've spent so much time programming in C. I hope I can adapt to this style of programming in GML. At least GML doesn't give me that feeling like I am going to be sticking my hand into a nest of ants, like when I was trying to learn x86 asm ( which is unforgiving with little or no margin for errors when something goes unexpectedly wrong in the code ).
Thank you in advance.
- Whats the learning curve from C or C++ to GML?
- In C programming, there is something called "Undefined Behavior" which is a big issue , in GML it does not exist by that name. I tried to look it up by name in the online manual on GMS website but it does not exist. But does undefined behavior exist as something else in GML ?
- Do you have streams in GML ? In C , its stdin, stdout, stderr, and FILE* - as far as I know. In C++ its cin, cout, cerr, and FILE *; ?
- Pointers....Dont you have pointers in GML for address referencing , especially for file streams when your reading or writing data to a hard drive, or using arrays?
In GML if you have the following :
Code:
/// this is GML
var myvalue = my_object_code()
Code:
// this is a program in C
#include <stdio.h>
void mymsg(void); // just show a message
int main(void)
{
int *myfunction = mymsg(); // we're assigning the address of mymsg to the pointer
mymsg();
return 0;
}
void mymsg(void)
{
printf("Hello World.\r\l");
}
assignment of a variable to a function reminds me of that assignment of a pointer to a functions address in memory for C or C++.
- Every statement in C MUST be followed at the end by a semi-colon, unless it its a conditional test like if () { .... }. Why does GML allow statements like the following?
Code:
/// This is GML
var myvalue = my_object_code()
- There are no preprocessor directives or manifest constants in GML - what do you use instead?
Code:
// This is a program in C
// this is a preprocessor directive
#include <stdio.h>
// this is a manifest constant
#define MSG1 "Hello World"
int main(void)
{
printf("%s\r\l", MSG1);
return 0;
}
- Can you do tail recursion in functions for directory tree searching of a storage medium such as a hard drive or USB flash drives.
- The rule of thumb when declaring variables in C or C++ is that you have to initialize their values to 0. when you declare a variable, it is assigned to a address in the computer's memory which may contain a garbage value. In some ways the uninitialized variable may have a value that is 0, which I call, "good garbage", which should never be assumed. Is this true for GML or all declared variables before their assigned values initialized to 0 by GML ?
- In C and C++ , main() can also be declared as
Code:
int main (int argv, char *argc[])
I am so used to working OS shell environments like MS-DOS and linux bash shell. Ive learned that long ago, that in order to do anything GUI, with either Gnome ( for linux ) or Windows in Visual Studio for C++ by Microsoft, you have to learn how to use the OS to talk to the machine through the platform specific langauge that is included with C++ . The learning curve for Linux is steep, but very rewarding once you know X11 ( or what ever the standard is now for X-windows ) which I never got to, because the books on the subject come in the form, like a encyclopedia. Its like learning the programming language called ADA ( and I don't plan to ever work for the department of defense, in the USA ).
( back to the original train of thought )
So far....
I suppose there are easier ways in GML to do this , than what I can think of in C that do the same things that I have shown as examples. Again, GML is new to me, but not programming. So thats just some questions and a sample of my background in programming. My big problem is that C has put my mind into a box, because I've spent so much time programming in C. I hope I can adapt to this style of programming in GML. At least GML doesn't give me that feeling like I am going to be sticking my hand into a nest of ants, like when I was trying to learn x86 asm ( which is unforgiving with little or no margin for errors when something goes unexpectedly wrong in the code ).
Thank you in advance.