the blog for developers

Dynamic typing as safe as static typing is based on wrong assumption


Update 3: Because I got stalked, I change the tilte of the post from “The unit testing lie aka dynamic typing testing lie”. I like this blog, but it’s not worth it. The view that dynamic typing and static are equally safe is based on the assumption that dynamic developers do more unit testing (what the compiler otherwise does) than static developers to ensure safety.

Update 1: Thanks to Graeme. I have been unclear with my post. The lie I’m talking aboutis that there is no problem with dynamic languages or a difference between dynamic languages and static languages concerning type bugs you can write unit test, suggesting that developers really write unit tests to cover type checks. All would be good if people write tests. Josh as someone who fixes Rails projects says that he often sees not enough or no unit tests in the Rails projects they are called to fix. If you use dynamic languages and have >90% test coverage including duck typing, you’re safe and this post does not apply

Update 2: If you want to make a sensible comment, you could say “Lie is an exaggeration, could it be a logic fallacy?” and I would reply “Saying knowingly not the truth is lying”. Or you could say “From the 37 projects in [Dynamic Language Of Your Choice] which I have investigated, the lowest code coverage with unit testing was 80%” and I would reply “Thanks for the facts, seems contrary to the facts in my post unit testing is widespread in dynamic language projects” and change the title. Or you could give your opinion about any topic you wish, attack me and spare me facts.

Stumbling upon one of the very best articles about web programming for some time: Rails Worst Practices: 13 Coding Nightmares You Should Avoid by Josh Symonds. One of the experiences Josh is that developers don’t do – enough – unit testing:

[Testing] This should probably be higher since it’s one of the most annoying things about picking up an existing codebase. A lot of the code we get isn’t well tested, or even tested at all. Untested code is very very difficult to alter: you’re not sure if the small change you’re making will break functionality out in the middle of nowhere, and you have no way of testing it without following through the application flow every time you make a change.

When discussing dynamic vs. static languages, the arguments for not needing static type checks are based on more unit tests.

The blog post says: Nada, developers don’t test. [1]

This reflects my experience. Developers don’t test. They do test after they got a bloody nose several times, best a bug lost some money, lost bookings or orders or the plattform was down. Then developers literally yearn for more security. They write tests if you tell them again and again (or they are very very good). And you need hard coverage metrics and goals – even if it’s 100% (some won’t agree). Otherwise they are over-optimistic, over-confident and always under deadline preasure. Unit tests are hard to explain to business users and managers – they can be explained but often developers do a bad job at explaining them.

I was astonished by the claim that everything is fine in Rails-land and developers, contrary to most of their brethren, do extensive (even more than for static languages) unit testing. Seems to be mostly a myth – especially with more Rails developers as the experience level goes down. You can have a community of 1000 top coders, but not of 100.000 top coders, there aren’t enough.

There is much more interesting insight in the article:

Chubby Controllers Must Die
There should be no business logic in a controller.

It’s not about Rails. Every project and every web framework I’ve seen has been abused by developers. They put code into parts where they should not. In Struts, in JSF, all the time. Developers don’t change and a web framework won’t help. Strict coding practices and reviews help.

NEVER Assume You Don’t Have Nil
Maybe you assume that your ActiveRecord object has an association on it, like address. So you innocently type user.address.telephone and blam! Your application blows up because address was, in fact, nil.

Again the same experience. The biggest problem in Java are Null Pointer Exceptions, people don’t check for null often enough. The don’t use Either style error checking either (ha!). And Java doesn’t support safe dereferencing yet:

Null dereference expressions – Null checks with ‘?’ syntax similar to Groovy… lettign developers avoid a nest of null checks.

Another one from the post:

Check ActiveSupport (and other Rails/Ruby classes) FIRST
I see a ton of methods that already exist in ActiveSupport that are hand-coded from scratch. Stuff like Time#beginning_of_week and pluralize pops right to mind. Also there are a lot of people who do scratch versions of time_ago_in_words and number_to_currency (two of the most helpful ActionView Helpers)

Would easily translate to “Check commons” in Java. Or check the JDK. Especially reuse JDK code when someone asks you this in an interview

All in all, excellent post, go read it.

Thanks for listening. As ever, please do share your thoughts and additional tips in the comments below, or on your own blog (I have trackbacks enabled).

[1] All generalizations outside of physics, mathematics and chemestry are wrong. Without them one cannot make meaningful descriptions about the world. This should read most developers and “test enough”.

Update:
Because people are not accustomed to the discussion, some entry points into the dynamic vs. static discussion, how static typing is just a kind of test and how unit tests are better than static typing.

About using unit tests to find usual compiler errors by Steve:

But the argument that I’m making is NOT that compilers don’t occasionally help you catch errors. The argument that I’m making is that you’re gonna catch the errors one way or the other. Especially if you’ve got unit tests, or QA or whatever.

About dynamic language users doing more unit tests:

People who use languages with strong static type systems seem to do a lot less unit testing.

In a paragraph about “The strong vs. weak typing issue really gets people worked up.”:

We can achieve sufficient reliability through a combination of rigorous unit testing and agile development practices.

About useful code coverage for Rails by David:

In terms of new features, we’ve been able to add new features to the lift code with fewer defects than with the Rails code. Our Rails code had 70% code coverage. We discovered that anything shy of 95% code coverage with Rails means that type-os turn into runtime failures. We do not have any code coverage metrics for the lift code, but we have seen only 1 defect that’s been checked in in the 2 weeks since we started using lift (vs. an average of 1 defect per checkin with the Rails code.)

About how unit testing helps to find bugs in your code when using Groovy (that otherwise the type system finds):

“It might be scary to do away with all of your static typing and compile time checking at first. [...] You should make all efforts to use unit tests to verify your intended behavior.”

About the importance of unit tests in the Rails community by Eric:

“The Rails framework and the Rails community are both built on a culture of good programming habits.
[...] Unit tests? Built in and highly encouraged.

A variant of the argument about testing, which says: Static typing doesn’t help you much, because it doesn’t verify all behavior, you need unit test nevertheless. Suggesting that people do unit tests, by Bruce:

The only guarantee of correctness, regardless of whether your language is strongly or weakly typed, is whether it passes all the tests that define the correctness of your program. And you have to write some of those tests yourself. These, of course, are unit tests.

This should help as a starting point in the static vs. dynamic typing discussion. Unit tests are a great invention, I suggest you have 100% CC coverage. But don’t read those comments on dynamic languages and feel safe. You need to write tests, otherwise they will not help you.

You can leave a Reply here. Of course, you should follow me on twitter here.

You can share this post!
Do you want to tell others about this article? Use the social bookmark icons to submit this artice to the service of your choice. Thanks.

About the author: Stephan Schmidt is head of development at brands4friends. He has more than 15 years of internet technology experience and 10 years experience in agile. He was head of development, consultant and CTO and is a speaker, author and blog writer. He specializes in organizing and optimizing software development helping companies by increasing productivity with lean software development and agile methodologies. Want to know more? All views are only his own.
Leave a reply.

Comments

so say we all!

ps: thx for the “rails worst practice” link, very useful post.

stephan

@blaxter: Thought so too, very useful post (from an often overlooked maintenance point).

Craig

Even when tests coverage is 100%, most tests only exercise the happy path. FWIW, coverage is not a good measure of test quality.

stephan

@Craig: When you have 100% test coverage (tested in path coverage, see Cobertura / Clover), then you should have tested all paths, not only the “happy path” (McCabe is a good coarse measure). Did I misunderstand path coverage / CC?

“[...] coverage is not a good measure of test quality.”

No it’s not, it’s a measure about test density. I didn’t want to imply that it’s a metric for test quality. And after reading the post again, I don’t think I have.

Hi Stephan,

Some observatons. All the points you raise are equally applicable to static languages too. I’ve yet to come across a project that lacked tests yet the code quality was some how preserved by the presence of static type checks.

Writing tests after the code is difficult and time consuming and like you say often gets dropped or is incomplete due to time pressures.

Writing tests before writing the code is a different thing entirely. Here testing is an intrinsic programming step. Tests are interface specifications, or better still “behaviour specifications”. Making the testing language redundant, and allowing the programmer to know when his code works (when the design spec is met), and allowing him to clean up his code knowing that he hasn’t broken anything.

If you do not specify what your code is meant to do in an executable specification, then you don’t know whether the code works and meets your intent. You don’t know when you’re done.

If you do not specify what your code is meant to do in an executable specification, then you don’t know whether a refactor will break your code or not. You cannot clean up your code with safety.

Without refactoring and cleaning up your code, and without a way to verify your design, a team can quickly end up with a code base that resembles a big ball of mud (Fred Brooks).

Facing a ball of mud, I would rather it was written in a static language then a dynamic one. At least then my compiler provides me with a minimal executable specification, based on types.

Having said this, I would rather not work with a ball of mud. So the real issue is how do you keep your code clean in the first place. Compilers don’t generate clean code, so In my eperience static types don’t help to keep code clean. They just make unclean code more tolerable.

Clean maintanble code comes down to programmers. No silver bullet (Fred Brooks again).

Paul.

stephan

@Paul: Nice observations, I don’t see how they are relevant to the post?

Especially

“Some observatons. All the points you raise are equally applicable to static languages too. I’ve yet to come across a project that lacked tests yet the code quality was some how preserved by the presence of static type checks.”

looks like false logic in context of my post. I don’t see my post talking about code quality in general.

“No silver bullet (Fred Brooks again).”

I’m not sure why everyone cites Fred Brooks on my blog, I have never sold silver bullets here. On the contrary.
It goes against the silver bullet of dynamic typing: unit testing.

“When discussing dynamic vs. static languages, the arguments for not needing static type checks are based on more unit tests.”

Could you explain how my post is advocating silver bullets?

Otherwise I consider your whole post a strawman attack.

Thanks for your observations though.

Hi Stephan,

Its kind of difficult to pin you down. Now lets start with the title: “The unit testing lie aka dynamic typing testing lie”. Which lie? whose lying? Can you provide a link?

The you go on to say:

” The myth/lie I’ve meant is that there is no difference between dynamic languages and static languages concerning type bugs because developers write unit tests – even considered better than static typing – to cover type checks. ”

I am not aware of anyone propagating this lie. I agree, a compiler can help to detect type errors without the need to run your code. So you can detect type errors with a static type check without tests. This says nothing though about whether your code is bug free and will actually ‘work’ as expected at runtime.

You then go one to quote poor programming practice with rails as some how supporting your argument. What ever your argument is!

Given the vagaries of your post, I decided to rewind the clock and get back to first principles, hence my references to Fred Brooks. Even the most ardent advocates of static type checking would agree that a static compiler will not write clean code for you, rendering your references to poor rails practice as irrelevant. A ball of mud is still a ball of mud in any language.

The problem I think you are facing is that you have started with the premise that “you are right” (about something), and then you fish around for supporting evidence.

I would understand if you said that I write poorer quality code with a dynamic language as compared to a static one. This is common for a lot of people, since dynamic languages require a different programming style and a different skill set.

Your blanket statement about “lies”, doesn’t allow for the fact that some programmers are both more productive and produce higher quality code using dynamic languages as compared to a static language.

Instead you choose to label these programmers as liars :)

Hence my second reference to Fred Brooks. We tend to get overly attached to our favorite tools and forget that good people are far more important. I have been programming with languages with varying degrees of static type checking for over twenty years now, and for most of that time the programs I worked on were riddled with runtime bugs. So static analysis is “No Silver Bullet”.

(Incidentally the static language programs I have worked on that were largely bug free all had an extensive unit test suite, and were written test first by competent programmers).

Paul.

stephan

Hi Paul,

sorry I didn’t know that you don’t know the topic. The “We just do more unit testing to prevent type errors” meme is quite prevalent in the blogosphere.

Bruce Eckel
” In a dynamic language you have the flexibility to do rapid experimentation which is highly productive, but to ensure that your code is airtight you must be both proficient and diligent at unit testing. ”

Robert Martin
“About two years ago I noticed something. I was depending less and less on the type system for safety. My unit tests were preventing me from making type errors. The more I depended upon the unit tests, the less I depended upon the type safety of Java or C++ (my languages of choice).”

etc.

“I am not aware of anyone propagating this lie.”

http://letmegooglethatforyou.com/

“The problem I think you are facing is that you have started with the premise that “you are right” (about something), and then you fish around for supporting evidence.”

No, quite to the contrary. I’ve read a blog post from someone who has fixed lots of Rails code and from there deduced that developers don’t do more unit tests in dynamic languages than static languages (which they needed to do to find bugs which the compiler usually finds). Have you read my post?

I don’t know why you resort to straw man attacks again

“Even the most ardent advocates of static type checking would agree that a static compiler will not write clean code for you, [...]”

but I’m tired of a discussion about points I didn’t make.

Hi Stephan,

You lack precision in your argument.

You said:

” The myth/lie I’ve meant is that there is no difference between dynamic languages and static languages concerning type bugs because developers write unit tests – even considered better than static typing – to cover type checks. ”

None of your quotes say that “there is no difference between dynamic languages and static languages concerning type bugs”

What Bruce Eckel and Bob Martin are saying are that they (as programmers) get feedback on the correctness of their code by running the code through tests.

This feedback means that they no longer rely on the feedback that they get from a static type checking compiler. Making the type checks performed by the compiler, redundant for them.

This is a statement about their programming style.

Calling them liars and using the programming practices of “others” as proof makes no sense.

Muddled thinking my friend :)

“but I’m tired of a discussion about points I didn’t make.”

I can tell. You seem to have a difficulty listening to the voices of others. Hence your total misrepresentation of what both Bruce Eckel and Bob Martin actually said.

I’ll leave you to your soap box.

Paul.

stephan

The quotes were to my statement:

“We just do more unit testing to prevent type errors” meme is quite prevalent in the blogosphere.”

and form the basis of the type testing and dynamic language arguments.

I did not imply that they have lied. The lie is that there is no problem with dynamic typing because developers do unit tests:

1.) Unit testing prevents type bugs (see quotes)

2.) Developers in dynamic languages do (more) unit testing

3.) Therefor there are no type problems at runtime with dynamic languages

As quoted in the post, the argument breaks down because 2 is a lie (as in “not the truth”), developers don’t do more tests in dynamic languages according to the cited post.

Your quite notorious at twisting what I’ve said.

“Muddled thinking my friend :)”

I’m sure we’re not friends.

Update:As you accuse me of muddled and vague ideas, I would love to see more research papers on this topic. As I’m no longer in research I don’t have the time to write those kind of peer reviewed papers anymore. This blog posts are not scientific, peer reviewed research papers. Thanks for understanding the difference.

Hi Stephan,

The issue isn’t research. The issue is understanding plain English. Both Bruce and Bob were speaking about their programming styles.

“I’m sure we’re not friends”

If you stopped and thinked about what I’m saying for a moment, you would realise that perhaps I am your friend. Only a friend would take the time to point out your blind spots:)

If you choose to see my words as a personal attack then I think that points to your own insecurity.

Hopefully your readers will view me as a friend for pointing out the flawed logic in your post.

Mud as an unfortunate habit of sticking, and when you decide to call fellow programmers liars you really need to build an iron clad case first.

You haven’t.

Paul.

stephan

“Both Bruce and Bob were speaking about their programming styles.”

Yes, and as I commented this is the base for the argument for dynamic languages. See my comment.

“If you stopped and thinked about what I’m saying for a moment, you would realise that perhaps I am your friend.”

Hard to imagine as you deliberately twist most of the things I write and imply I’ve written things which I haven’t.

“If you choose to see my words as a personal attack then I think that points to your own insecurity.”

Insecurity? After some self reflection – no, probably not.

Again:
“Mud as an unfortunate habit of sticking, and when you decide to call fellow programmers liars you really need to build an iron clad case first.”

You twist my words. I haven’t called them liars. You deliberately suggest that I have.

To quote myself:
“1.) Unit testing prevents type bugs (see quotes)
2.) Developers in dynamic languages do (more) unit testing
3.) Therefor there are no type problems at runtime with dynamic languages”

And you better stop telling people I called Bruce Eckel and Robert Martin liars, otherwise I will need to defend myself.

“The issue is understanding plain English.”

Sorry, not all of us can be native speakers, we wish we could, but some of us are born to start with inferior languages – call yourself lucky to be born into the elite of native English speakers and keep helping us poor ones.

Update: “The issue isn’t research.” If you’ve read my comment, and not assumed things, you would have seen that my comment was not about research but the style of peer reviewed research papers.

stephan

@Paul: Interesting to read your blog and the comments ;-)

“[...] Linux (Linus Torvald) [...]”

From my understanding Linus mostly wrote the Linux kernel not the system. Perhaps it would be best on your blog to be more precise.

I’ve also liked the comment

“Paul, your ad-hominem remark is both unwelcome (as you no doubt intended) and incorrect, [...]”

After more thinking your comment about my English made me cry.

Haven’t we non native speakers listened to BBC podcasts all day? Haven’t we watched Red Dwarf? Haven’t we watched Fawlty Towers and laughed about the Germans? Haven’t we watched every Flying Circus episode? Didn’t we try as children to understand the bizarre nature of The Trap Door? Didn’t we laugh at the First World War episodes of Black Adder?

And still, how wrong our understanding of the English language is. What tragedy!

OK. I think we are making progress of sorts :)

“Sorry, not all of us can be native speakers, we wish we could,…”

So you are willing to accept that perhaps you misunderstood what Bruce and Bob were saying.

If you start with the understanding that “dynamic languages in themselves lead to bug free code” then I agree this is a lie which is self evident from the fact that dynamic language projects have bugs too.

But no one is saying this. What people are saying is that the real issue is producing defect free software and that there is more than one way to achieve this.

One approach stems from the REPL (Read-Evaluate-Print-Loop) idea from Lisp. Were you gain quick feedback about the correctness of your code by running it often (I like to call this approach suck-it-and-see).

Suck-it-and-see is only effective if the time it takes to get feedback is short. So languages that require a long compile cycle aren’t well suited to a REPL approach. Dynamic languages on the other hand provide the opportunity for fast feedback as Bruce Eckel rightly points out.

Fast feedback in itself isn’t sufficient however, the feedback needs to point you to the defect. So with regards to type safety, a language which provides strong dynamic type safety will provide you with fast and accurate feedback about type errors at runtime.

TDD/BDD build on these ideas. In fact Kent Beck invented TDD in the context of a dynamic language: Smalltalk. With TDD you only write code once you have specified a failing test. You then run your code as part of your test suite to gaining instant feedback.

Now if you are good at TDD and are only writing code in response to a failing test then it is very difficult for your code to pass all your tests whilst containing type errors. Any type errors will be readily detected by the runtime.

This is what both Bob and Bruce mean when they say that static type error detection is redundant for them. Of course if you aren’t skilled in this programming style and you don’t write tests first, then you won’t get the same results.

It comes down to the programmer and how adapt he or she is in using their chosen tool.

So talk of “lies”, is irrelevant. The real issue is understanding the skills needed to use dynamic languages effectively.

The same can be said for static languages too. Hence why most teams spend 60% of project time finding and removing bugs that could have been avoided if they had used TDD.

Paul.

stephan

“If you start with the understanding that “dynamic languages in themselves lead to bug free code” then I agree this is a lie which is self evident from the fact that dynamic language projects have bugs too.”

You’re right, but I haven’t said this, have I?

Funny how you try to educate me on TDD/BDD, unit testing, dynamic languages and agile. Or Smalltalk.

I have been a agile proponent and Scrum master for some years, have been writing software for around 26 years, have mentored developers, have done dozens of projects in dynamic languages during the 90s (Perl, Python, Tcl/Tk, Ruby, PHP), love a Lisp book from the 60s, wrote frameworks for dynamic languages, have been doing unit testing since Kent published his first XP book in the 90s and gave some speeches about unit testing and how to achieve 100% test coverage in nasty places like DAOs, databases, Swing, Emails and Exceptions.

You’re assuming lots of things about me, my knowledge and my attitude in your posts. You might be wrong. As far as I can see none of your comments talk about the things I’ve written in my blog post.

Whoops…

Looks like I’ve hit a nerve :)

And you are right. There is nothing you can learn from me or anyone else, because you know it already :)

I won’t waste anymore of your time.

Paul.

stephan

Oh, don’t worry, I can learn from everyone. Mu.

But you’re partially right, perhaps not from someone who doesn’t want to help, but who wants to be on top – even when he needs to resort to ad hominem attacks and twist other peoples arguments to achieve his goal.

“Oh, don’t worry, I can learn from everyone. Mu”

Just not Paul Beckford, Bruce Eckel, Bob Martin and… anyone else who so happens to hold a different point of view.

“But you’re partially right, perhaps not from someone who doesn’t want to help, but who wants to be on top – even when he needs to resort to ad hominem attacks and twist other peoples arguments to achieve his goal.”

Now who is implying motive? I was truly trying to help you sieve through what seem to me to be muddled thoughts.

I guess my help wasn’t appreciated :)

Paul.

stephan

“Just not Paul Beckford, Bruce Eckel, Bob Martin [...]”

I looks a little bit too – self confident doesn’t give the right impression …. – hmm, to place oneself between Eckel and Martin.

“I won’t waste anymore of your time.”

It seemed too good as a promise as to be true. How do you call your statement as a native speaker?

Hi Stephan,

“2.) Developers in dynamic languages do (more) unit testing”

Who is saying this? Have they done a survey? Do you have a link?

It amazes me just how difficult some programmers find it to say “I don’t know”.

The psychology of it fascinates me. Otherwise intelligent people end up boxing themselves into stupid positions just because they can’t admit that they don’t understand, or perhaps someone else has a insight that perhaps they’ve missed or maybe they have a bind spot.

Thanks for the discussion. I’ve been meaning to blog about this phenomena for a while, and you’ve kindly provided me with plenty of material :)

Kieth Braithwaite makes a similar point in an interview on InfoQ:

http://www.infoq.com/interviews/Agile-Skeptic-Keith-Braithwaite;jsessionid=FCE66C551EE2C3046F6952A81EC59E5F

He speaks about people who attempt to do Agile “by the book” without ever questioning whether they know what they are doing and whether things are actually working for them, leading to Agile as a “one size fits all” commodity.

I think it has to do with an organisational culture where you are penalised for admitting that you don’t know. But if you can’t admit you don’t know, how can you ever learn? As a consequence whole organisations eschew learning and become stuck in a rut.

PS. Sorry if I caused offence. This was not my intention. If you read back what I have said once the emotion has subsided then you will see that I was genuinely trying to shed light on an often misunderstood topic.

Paul.

Finished my post. I can’t work out how to do a link back so here is a link:

http://pab-data.blogspot.com/2009/01/i-dont-know.html

Peace.

Paul.

niv

I’ve reading this exchange between Stephan&Paul.
I think the issue here is mainly a misunderstanding, I think Paul here, from the first post, is trying to answer points that Stephan never raised.
That’s why Stephan answered to Paul “Nice observations, I don’t see how they are relevant to the post?”. Because they aren’t! I think Paul misread what Stephan tried to say because Stephan used the expression “lie/myth”. From the first post, Stephan answered unpolitely, then all went downhill.

Proposition A: “Okay, pretty darn good units tests cover all type errors and more. Then, dynamic typing with good unit tests won’t probably have a typing error (then again, if we consider Null pointers exceptions to be some kind of typing errors, then they’re pretty common even in static typed languages like Java). Therefore dynamic typed languages are as safe a static typed languages”.
Stephan says this is a bit of a lie, because most dynamic typed projects don’t have pretty darn good unit tests.
I’m guessing this is truth, besides, this dude, Josh, says he has seen this.
But Stephan never argued that if you DO write pretty darn good unit tests you are within the “lie”. And this is what Paul is trying to argue against.

Myself? I think Stephan is right, has said no false statements AFAIK, but he isn’t saying too much. “Yes if you do write good unit tests your ass is saved but if you don’t then you don’t” doesn’t say anything to me, it is an obvious statement. The fact that most developers don’t test still doesn’t say anything to me, THEY SHOULD do pretty darn good unit testing, and maybe with time it will become a more and more common practice.

[Removed by blog author]

stephan

@Paul: I thought we have been through with this.

I’ve made several times my intentions with the quotes clear.

You have been warned not to repeat this. You have the fame for being the first to be banned from further comments and your recent comment after my last warning is deleted.

[Removed by blog author]

If you are going to ban me, then ban everything I say. Don’t selectively quote me out of context.

You seem to want to make this a nationalist thing. Well I’m not biting.

Please remove your last comment as it quotes me without containing the full text of what I actually said.

Thanks,

Paul.

stephan

“If you are going to ban me, then ban everything I say. Don’t selectively quote me out of context.”

Don’t comment and I won’t quote you out of context.

“You seem to want to make this a nationalist thing. Well I’m not biting.”

You’re so twisted, it’s beyond words. How you could construct a “national” thing out of my comment is beyond me. I added “Germany” because otherwise you would again call me “vague”.

“Please remove your last comment as it quotes me without containing the full text of what I actually said.”

With your comments we have left “please” behind us. I asked you not to comment, but to no avail. No, I won’t remove my comments. Just yours. Stop commenting. I told you.

Thanks
Stephan

stephan

I’ve followed your request and removed my comment as a gesture.

Please, could we now stop this. Could you stop twisting my words, could you stop insulting me, could you stop attacking me personally?

For reference to make sense out of my last comment:

“Hmm… Banning free speech?”

Yes. At least here in Germany there are limits on free speech. Concerning libel and insults for example.

I posted this to comp.lang.python, but it applies to Groovy:

I am a Java developer. There, I said it :-).

When I am writing code, I can rely on the compiler to confirm that
any methods I write will be called with parameters of the “right”
type. I do not need to test that parameter #1 really is a String
before I call some method on it that only works on Strings.

If I am writing in Python, since it is dynamically, but strongly
typed, I really should check that each parameter is of the expected
type, or at least can respond to the method I plan on calling (“duck”
typing). Every call should be wrapped in a try/except statement to
prevent the method (and program) from crashing when my method is
called with an integer instead of the expected string.

Is this the experience that Python programmer (of large projects) see?
Do you also write unit tests to confirm that the methods actually
check for and catch “bad” parameter types? If I am writing small one-
off scripts, I wouldn’t worry about it, but if I am writing a large
system that must have 99+% uptime without constant monitoring, this
really should be verified.

Up for discussion…

Leave a Reply

What people wrote somewhere else:

Additional comments powered by BackType