5 ms·
I thought this was one of the main advantages of typed languages refactoring or renaming is safe and easy. What gives?
by interactivecode 5y ago
I thought this was one of the main advantages of typed languages refactoring or renaming is safe and easy. What gives?
- kibwen 5y agoWhile calling C a typed language is technically correct, I struggle to think of any typed language that's more weakly-typed than C. Arguably, Python has a stronger type system than C.
- joshuamorton 5y agoAtomically flipping a version is still difficult, as anything that needs to rely on the other version has to be fixed forward. If you instead make 5000 (or 500) small changes that affect 10-15 uses, you can solve the unique cases or roll-back and forward.
- jayd16 5y agoYou can still have plenty of issues crop up from code that's not currently in master yet, or forked projects that take patches sparingly, etc. Typed languages let you know whats broken at compile time and aides in refactoring code you can see. It doesn't help you refactor code you can't see.
- tyingq 5y agoThe C preprocessor is arguably a not type safe language unto itself.
- lupire 5y ago"arguably" is not needed. Preprocessor destroys most of the semantics and even some syntax of C.
- Someone1234 5y agoThe C preprocessor is a siren song, lures people in with the promise of "extra performance/features/structures for zero runtime cost!" but murders any readability or rationality within your codebase. Cool concept, but once you've dealt with any legacy codebase that has used it extensively, it feels like an anti-pattern/footgun. Ultimately you just want the language to do those things directly and for the compiler to be smart enough to optimize it later. Essentially it is too clever for its own good.
- lupire 5y agoNo one likes the preprocessor, but it's practicaly required if you don't want to move to C++ with template metaprogramming.
- marcosdumay 5y agoWell, C++ templates happen on the preprocessor too.
- adrianN 5y agoNo they don't. Template instantiation happens during compilation, way later than the preprocessor.
- jcelerier 5y agowhere in hell did you learn that, this is entirely false
- __d 5y agoWell, it is today. When I first learned C++, using cfront in the late 80's, lots of the language was implemented as C pre-processor macros.
- klodolph 5y agoThat’s a good question, it’s not fair that you’re being downvoted. It’s the C preprocessor that causes a mess. Tooling for C and C++, like automatic refactoring, lags behind tooling for languages like Java, C#, and Go. Refactoring tools have to deal with macros, conditionals inside #if/#else blocks, and header search paths. In this case, the refactoring involves removing a variable from the enclosing scope of a macro invocation. The most likely way to automatically refactor it would be to write a custom check in clang-tidy.
- eru 5y agoWhether something is (statically) typed or not is more of a continuum than a binary. Eg C tracks whether a variable is an int or a char. Haskell also tracks whether a function causes side effects or not. More sophisticated systems also track whether a function has to return eventually or could run forever.