1.How are variables implemented I mean they are all var type, does it work like python and implicitly decides the what type is variable?
2.Are all vars considered auto variables or can we use static/register explicitly (I'm talking about storage classes like the ones used in C++)
3.And how can global variables be read from all files without use of extern?
4.Are there some notes about what we should avoid doing in DM to use less CPU? Some rules that apply specifically for DM.
eg
Code:
for(var/i=1; i<=10000; i++){world<<"Hi!"} //I know 10000 is an exaggeration
instead of
proc Hi()
world<<"Hi"
for(var/i=1; i<=10000; i++){Hi();}
Is it all taken care of by DM?
About multi-threading and using x64 bit architecture I've allready asked.
Sorry if my questions sound naive to some programmers :)
For the most part, yes, variables do not need to be strongly-typed (that is, have their type explicitly defined). However, if you wish to access a member of a 'class', which in BYOND is simply referred to as a 'type', then you need to define the type with the variable declaration, f.e.:
See above.
Through the use of the .dme file, which serves to link all .dm files together in compile-time.
Some things that are important to consider when programming in DM: it's going to be several magnitudes slower than anything you'd get programming directly in C++, or any other relatively high-level language out there.
My biggest tip is to recycle objects. Probably one of the most CPU intensive things you can do is construct and destruct objects. If you have an instance where you are creating and destroying a lot of them, simply create a queue where objects go when they're not being used.
In the example you posted above, directly calling logic instead of separating iterated logic into its own function is the best way to do it. You are adding an extra 10,000 (roughly) operations that the Virtual Machine has to process. This turns out to have a huge difference when optimizing excessively-large loops.