4 ms·
> A typo can certainly lead to incorrect code in the most strongly typed, staticest language there is Yes but the >99% of possible typos (and nearly 100% of ty
by alexvitkov 3y ago
> A typo can certainly lead to incorrect code in the most strongly typed, staticest language there is
Yes but the >99% of possible typos (and nearly 100% of typos in identifier names) will be caught by the compiler. That's good enough for me to say "static typing helps with typos".
> What's worse: a runtime error or no error that produces the wrong result
From most bad to least bad:
1. No error, wrong behavior
2. Runtime error
3. Compile error
4. Red squiggly line telling you "this is bad" before you even compile
> Running a Python project might be quicker than compiling a C++ project
Yes, C++ is an insane language. You can have large C++ projects that compile fast, but you have to spend a non-zero amount of engineering effort. Generally "avoid templates" and "write the code in .cpp files, not headers" will ensure that you won't have hour-long compiles.
This is a problem with C++, not with type-checking in general.
> Dynamically typed languages can do better than grepping for function calls.
I'd love to hear how, I was doing quite a bit of JS at my previous job (not TypeScript, couldn't convince them :) and I never found a more reliable way to find callsites/variable usages, than grepping for the function name. And even that is not 100% guarentee, since you can call a function in some pretty insane ways,
anObject[`asdf${some string}`]
and then good luck finding this callsite when searching for anObject.asdf123
- ReflectedImage 3y agoWhat you are complaining about is completely solved via microservices.
- alexvitkov 3y agohow?
- ReflectedImage 3y agoYou restrict the code area you need to search via strong encapsulation.
- pdimitar 3y agoThis does not address the example given above.
- ReflectedImage 3y agoIt actually does.
- alexvitkov 3y agoAdd microservices and typos are still runtime errors, except now on another, except inside a container on another computer. You still have to grep for callsites, although the scope is smaller. A much better way to reduce the scope is with modules - if a function is module-internal, you only have to grep that module for callsites. Better than having to scan the entire codebase, worse than not having to do it at all. Performance with microservices + dynamic language is unjustifiably terrible if you're the one who's paying for the servers. You're already eating a 100x slowdown for using a scripting language, add microservices and you're eating easily another 100x for replacing regular function calls with network packets. I'm not willing to run a k8s cluster for a program my laptop could handle had I used the hardware better. That's all assuming microservices are even an option, which is a very tiny percentage of all software.