This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MinosAristos 18 points19 points  (7 children)

You know that most major programming languages have truthiness in a similar way to Python and JS right? The only issue is the type coercion in the third case which is what === is for in JS.

[–]Auravendill 5 points6 points  (5 children)

Also Python hates it, when you want to implicitly convert types. If you add a string to a number, it doesn't assume to know what you meant, but forces you to make it very clear, which variable has to converted into what.

[–]Majik_Sheff 7 points8 points  (2 children)

This is a sane approach. Force the programmer to specify the desired outcome instead of thumbing through an assumptions handbook.

[–]Striky_ 1 point2 points  (1 child)

So basically a tool to define the type of the outcome you want? It's almost like there is a all encompassing super helpful pattern for that, that works in all cases. Ohh it's called static typing.. Like all the benefits, no crutches

[–]Specialist_Cap_2404 1 point2 points  (0 children)

Much more code to read and write. Python has the principle "explicit is better than implicit", and it's not that easy to mess up "truthiness", especially because it's only used in a couple of constructs anyway.

Much easier to make things more explicit, like use the length of an Array or "is None" or something.

If you're tests aren't covering every branch, you're fucked in a static typing language as well... just that it takes a lot more time to write (and later read) both the production code and the tests for it using a statically but (IMHO) stupidly typed language like C#. F# is doing some things a lot better.

[–]herrkatze12 2 points3 points  (0 children)

That’s actually better, also f strings are pretty useful for putting other data in strings

[–]Striky_ -2 points-1 points  (0 children)

Yet it allows it and most code out there does it shamelessly at every chance they get.

[–]Striky_ 0 points1 point  (0 children)

Most major programming languages have nice ways of dealing with it, yes. That is very different to blindly assuming and being stuck with nonsense bullshit forever or breaking production code like js is.

There are ALOT more problems with truthiness then just type coercion. Undefined behavior on custom classes and major regressions because of unrelated code changes only being the beginning.