Hello! I am making a module that checks types for every function, this is to let the scripter know if they are making a mistake instead of just throwing an error line. However, I have noticed that this might not be the best for people that prefer performance and so it hit me. Is there a way I can include optional type checking? I am talking about a variable that if enabled will stop all type checks. The reason I am asking is that I want to know if it is performant and if it is even worth it. After all, if you do not want type checking then that means you might be very strict with loading times and as such I wonder if it is even worth to do so.
So should I do that? Should I add an if statement for every type check to improve loading times, or does the simple fact I am checking with an if statement makes it unnecessary?
There is already a module that does this in my knowledge. I believe its named t and yes I know, it sounds weird but believe me its a thing. And as @5uphi mentioned luau does have its own typechecker, which you can force by commenting --!strict at the top of the script/module, but t provides more flexibilty.
Here is the module if you wanna check it out.
Also hey suphi kaner in the chat, love ur vids man.
But wouldn’t that already nullify me trying to stop this behavior? I haven’t checked in depth but I believe this module does what I already did in the sense that they call type:
That should in fact take less that the module since I am not indexing or calling separately. Remember that I am doing this for speed and sadly I think this won’t make it faster.
Well tbh then I rly dont c a point in implementing what u want bcuz its alr done by a typechecker. And as for your statement of default typechecking not working with a larger scope, your quite wrong there bcuz it does work, if thr typings are already set in tht module’s function.
It still calls type every time. That is what I mean. And I mean that is a fair point so I guess I won’t bother for now. But yes it does call type every time you want to check it.
I heard from somewhere that using type causes inefficiency and when I saw I was using so many type calls I decided it could be good if these were toggable. (If you know what you are doing then there is no need to type check and that will improve performance). However, I do not know if it is even worth it at all since it might not be such a big difference to do this:
No I don’t think typing causes any perfofmance issues, so u can very well go ahead and implement typechecking in your functions and just an FYI, top libraries like Knit does the exactly same thing that your doing and there is no performance issues with it. I will update my reply if I find other drawbacks but as of now, i believe there is none.