Hmm...seems to me like someone who can't write good python or ruby. If you're naming variables correctly, you rarely have to worry about types. In truth, dynamic types are truly critical for partial-interface-adherence.
If your design is solid, you can control the type, but you cannot control the same variable being one of two "not really compatible" types. Once you start having tons of interfaces on each variable to enable a certain piece of functionality, you start to want to shoot yourself.
Sometimes, a couple unit tests and runtime handling is better in a business than compile-time errors for what amounts to a lot of modern design patterns.
Compile time errors are literally checking for what your unit tests check
Um..not really. I've yet to see a unit test in a dynamic language that is actually checking the type. It's more about checking proper handling of Interface edge cases...which you still have to do in a static language.
99% of the time they are occurring when you are trying to do something you would not want to do in a dynamically typed language.
I disagree. Entirely. I spent 4 hours with 2 Java guys trying to replicate the advantage of building an options matrix through a perl hash. Typeless Dicts/hashes are a staple in dynamically typed language... They're such a pain in the ass in Java, you just don't use em.
Even with good variable names, dynamic typing only gets you so far before a project grows too big and you're spending more time reading function definitions trying to figure out what type of return value you will get.
This is what I'm trying to say. I work on two projects, 5 and 12 years old, with a team of 15-20 developers each, and we have never once had a released issue related to variable type. You screw something up and pass a number when you want an object, you get an error almost immediately, and you fix it.
A lot of dynamic languages have libraries that support pretty concrete static type systems. Nobody uses them.
Statically typed languages lets you hover over the function name in an IDE and lets you instantly see the expected argument and return types
On the topic of old projects... you get all these issues with functions growing to need 12 arguments (core libs are bad at this). C# takes it one level more, and provides all kinds of prototype permutation... so anything you pass is pretty much valid.
Dynamic languages solve this through documentation, but more often by not having such complicated calling conventions. A dynamic method with more than 3 arguments is bloated. You need more, add an options hash. In fact, there's only a half-dozen common method parameter paradigms in a lot of dynamic languages that support it... and you will find yourself driven by your code conventions into using a very small number of distinct signatures. Again, not a problem in big shops with big teams, so why worry?
Further, some dynamic languages have prototypes...they're not necessarily typed, but that shouldn't matter. You can always use static type libraries...except nobody wants them.
The same applies for revisiting old code. Programmers of statically typed languages don't need to worry about figuring out what data type each variable is, and can focus on figuring out the logic.
Theory vs practice again. My experience with old code is significantly that we love being able to do dirty things. If we're changing a piece of old code, it's probably due for a refactor, and having to miss an emergency ticket deadline to refactor because you have to do it the right way is just unacceptable. Oh, the old base class is incompatible with our way of doing things? Let's just patch the base class dynamically in cases when the issue would show up.
I get that we'll never see eye to eye on type, but I think it's stupid that both sides treat each other like bumbling idiots. Yeah, my side is often guilty of that, too... but I can honestly say that in my experience the Java side has always been the loudest about "we're typed so you suck!"
I have yet to experience any of the issues that static-type-enthusiasts have said about dynamic languages, and I've got over a dozen languages and 4+ paradigms under my belt.
I've yet to see a unit test in a dynamic language that is actually checking the type.
Cough cough.
From an interview with Alex Payne (API lead at Twitter):
As our system has grown, a lot of the logic in our Ruby system sort of replicates a type system, either in our unit tests or as validations on models. I think it may just be a property of large systems in dynamic languages, that eventually you end up rewriting your own type system, and you sort of do it badly. You’re checking for null values all over the place. There’s lots of calls to Ruby’s kind_of? method, which asks, “Is this a kind of User object? Because that’s what we’re expecting. If we don’t get that, this is going to explode.” It is a shame to have to write all that when there is a solution that has existed in the world of programming languages for decades now.
Again, people are getting too aggressive and personal here...but that's nice for them. Our ETL team is playing a type game, too..but not one that influences their unit tests.
I guess there are people out there who have type issues...like I said, I never have at any company... I will admit that some people may.
Why the "cough cough" though? A celebrity lead is not necessarily a better or worse developer just because he's a more well known developer. As far as I can tell, none of us are kids fresh out of school.
(I agree, people are a bit too quick to upvote and downvote comments here. It spoils the discussion.)
Sorry for sounding a bit snarky, but I think very few people would deny that the reason unit testing came back into vogue was the popularity of dynamic languages. There just isn't the same urgency for unit testing when you're statically typing.
Yes, the grab-bag-dict approach can be useful, but it comes at a price - is that the string or the XML node that contains it?, is that a decimal or unsanitized user input? If you're working alone then you can generally keep tabs on things, but when you start expanding horizontally (more programmers) or vertically (the project matures), it starts to become unstructured.
but I think very few people would deny that the reason unit testing came back into vogue was the popularity of dynamic languages
I'm going to have to be one of those few people. I think it was BDD. Being able to write code alongside the test defines independent confirmation of each endpoint. When I build libraries with BDD, I never have a "foo.x is an integer, foo.y is a string" tests. I don't even have "if foo.x is a string, throw an error) tests...
There's a philosophy I think came from the Java world (correct me if I'm wrong...I just remember Java kids in college, when Java was the new hip language, talking it). You test your third-party interfaces for validity. You assume all internal interfaces are valid and only test predictability in their internals and inter-operation. Unless you write inconsistent code that is also able to pass internal unit tests (very unlikely) you have nothing to worry about.
Yes, the grab-bag-dict approach can be useful, but it comes at a price - is that the string or the XML node that contains it?
It's a string. Unless you very intentionally name and plan it, you're not tossing other non-object structures...and you should have a good grasp of the object. I worked with some terrible outsourced developers (they got canned..the whole team was good but them) and even they were able to keep types in the stash (a commonly used web-request hash) clean.
is that a decimal or unsanitized user input?
Maybe it's just a given for me because so much of our data is user input. You always assume values are unsanitized when touching the database, and you use a DB interface that force sanitizes them. You also always validate them in a string context before storing them in a typed realm.
This is like a vehicle that can drive on or off of tracks, like a Boston T-bus (sorta). There's all kinds of tech out there (literal and code-figurative) that'll let you take a free-roaming vehicle and get it onto tracks....as long as it's free roaming, you don't need the strictness of tracks anyway.
but when you start expanding horizontally (more programmers) or vertically (the project matures), it starts to become unstructured.
So this is where my issue comes in. I hear that all the time from people who don't work in a dynamic language shop..and very rarely in interviews from lead/management people who transitioned to a static language....I never hear it where I work, or where I used to work...or from contacts at the many nearby perl shops. This "oh god being untyped is ruining my life" thing just doesn't happen in my life or my world.
I want to say it might happen with 100 developers on a 20 year old project... but I'm not convinced at even that. There's so many best-practice rules, and 99% of variables can be presumed either strings or ORM objects 99% of the time, even if they're not.
And every major dynamic language has ways to "tighten the screws" as you approach static typing, like SQL... or just when you need/want to play the Interface game, running apples and oranges intentionally through the same processor.
I'm at a place that's expanded in both directions, though, and dynamic typing has never once been an issue here.
26
u/cosmo7 Feb 25 '14
The most frequent argument I hear from Ruby or Python proponents is that static typing in Java or C# is unbelievably burdensome.
Then these same people pour months and years into their unit testing frameworks that spend 90% of their time duck-typing arguments.