Should I use common::sense or just stick with `use strict` and `use warnings`?

后端 未结 9 986
自闭症患者
自闭症患者 2021-01-08 00:37

I recently installed a module from CPAN and noticed one of its dependencies was common::sense, a module that offers to enable all the warnings you want, and none that you do

相关标签:
9条回答
  • 2021-01-08 00:42

    I would say stick with warnings and strict for two main reasons.

    1. If other people are going to use or work with your code, they are (almost certainly) used to warnings and strict and their rules. Those represent a community norm that you and other people you work with can count on.
    2. Even if this or that specific piece of code is just for you, you probably don't want to worry about remembering "Is this the project where I adhere to warnings and strict or the one where I hew to common::sense?" Moving back and forth between the two modes will just confuse you.
    0 讨论(0)
  • 2021-01-08 00:48

    The "lower memory usage" only works if you use no modules that load strict, feature, warnings, etc. and the "much" part is...not all that much.

    0 讨论(0)
  • 2021-01-08 00:51

    I have never had a warning that wasn't something dodgy/just plain wrong in my code. For me, it's always something technically allowed that I almost certainly don't want to do. I think the full suite of warnings is invaluable. If you find use strict + use warnings adequate for now, I don't see why you'd want to change to using a non-standard module which is then a dependency for every piece of code you write from here on out...

    0 讨论(0)
  • 2021-01-08 00:55

    When it comes to warnings, I support the use of any module or built-in language feature that gives you the level of warnings that helps you make your code as solid and reliable as it can possibly be. An ignored warning is not helpful to anyone.

    But if you're cozy with the standard warnings, stick with it. Coding to a stricter standard is great if you're used to it! I wouldn't recommend switching just for the memory savings. Only switch if the module helps you turn your code around quicker and with more confidence.

    0 讨论(0)
  • 2021-01-08 00:58

    Not everyone's idea of common sense is the same - in that respect it's anything but common.

    Go with what you know. If you get undef warnings, chances are that your program or its input is incorrect.

    Warnings are there for a reason. Anything that reduces them cannot be useful. (I always compile with gcc -Wall too...)

    0 讨论(0)
  • 2021-01-08 00:59

    I obviously have no common sense because I going more for Modern::Perl ;-)

    0 讨论(0)
提交回复
热议问题