4 ms·
You really should be using a logging framework instead though, if you're working on a large application.
by rococode 8y ago
You really should be using a logging framework instead though, if you're working on a large application.
- akvadrako 8y agoYou use logging for production, but if you just want to see what a value is while when you run your program in the IDE and might not for a logger imported, print is handy.
- rpeden 8y agoIf you're running from an IDE and want to inspect values, why not just set a breakpoint?
- tormeh 8y agoDoesn't work with multithreaded applications and works poorly with non-deterministic behavior, so sometimes you just have to print lots of info and see if anything interesting pops up. It also requires knowledge about tooling for the language you're working on right now, which as a polyglot you might not care to learn.
- all2 8y agoComing from python I like to set a breakpoint, and dive in with pdb. It's super easy to navigate through the stack frame and poke around to see what all the variables are. I get more out of inspecting state from inside of pdb than I do out of print statements. On the other hand, I tend to use only print statements when I'm roughing in a program in an iPython Notebook. This gives a sort of visual documentation when navigating a library that I'm new to, and allows me to glance back at a verbose description of otherwise opaque data structures.
- LoSboccacc 8y agoNah there's debugging for that
- WaxProlix 8y agoExcept you don't want to have your logger in all places: unit tests, early in startup lifecycle when guice or spring haven't wired everything up yet, etc. Printing to stdout is simple and ubiquitous.
- dragonwriter 8y ago> Except you don't want to have your logger in all places Yes, I do. Now, I may have to work with a language/ecosystem that makes that awkward, sure, but that's a problem, if an incredibly common one (Julia is one of the few languages that avoids it.)
- amelius 8y ago... which you can build using a LoggingFrameworkFactory.
- xxs 8y agoIt's java.util.logging.Logger.getLogger(...), and normally you'd have "java.util.logging.Logger" imported.