On Sat, Feb 17, 2018 at 4:11 PM, boB Stepp <robertvst...@gmail.com> wrote: > On Fri, Feb 16, 2018 at 10:25 PM, Chris Angelico <ros...@gmail.com> wrote: > >> >> 1) Type safety. >> >> This is often touted as a necessity for industrial-grade software. It >> isn't... > > Chris, would you mind expanding on this point? What is necessary for > industrial-grade, safe, robust software? Do statically-typed > languages give any real advantage over dynamically-typed languages in > this context? I know much is achieved by how the software is designed > and the practices used to implement the design that are independent of > the language used. But what language features/components are > essential for industrial-grade software? >
I've expanded on it a bit in my other post (which crossed in the mail with this of yours). Basically, type checking ("type safety" is a bit of a misnomer anyway) is just one of many possible ways to potentially catch bugs. So it's not a *necessity*, any more than correct indentation is a necessity. Both of them are valuable; neither of them is crucial. And code review can do what the language doesn't. Would you accept this JavaScript function in code review? function calculateSpam(x) { if (x>5) { return "spaaaaaaaaaam"; } else { return "spam"; }} The indentation doesn't matter, right? Not in JS. But it does to humans. Same goes for sane use of data types: def is_valid(x): if yada_yada: return "yes" return [x] Again, Python doesn't care if a function (a) sometimes returns a string and sometimes a list, and (b) always returns a truthy value, despite having a name that suggests a boolean return. But code review should catch this. Once you identify a common problem, you can get the computer to catch it for you, so it doesn't come up in code review all the time. Does that mean type declarations? Go for it, use them. Does it mean a pre-commit hook that rejects wonky indentation? Make it so. Does it mean using a programming language that uses variable declarations? Go for it. Or maybe it means using a language that DOESN'T use variable declarations. That's also an option. Ultimately, you use whatever helps you to produce the least-buggy code you can. No single feature is 100% necessary; no single feature is utterly useless. (And yes, the choices you make depend on context. Some tools are useful in large collaborations but pointless overhead in small projects, etc. Be smart, don't be rigid.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list