News for hackers. Stuff that matters.
Re:Statically Typed Languages Encourage Bad Code by PilotPirx on Wednesday October 20, 2010 @12:07AM (#1809934)
I don't see the point in this article. quote: "The developer has to figure out what the return types are for any methods that are called"

The developer has to figure out the return type in Python as well, since otherwise he wouldn't know, if the returned object provides the method he is calling on it next.

fido = puppies[0]

If puppies[0] doesn't return a "dog" the following call will fail. At run time!

Anyway, you can alternatively break up the code in several lines without creating a temporary variable for each step, if it's only about readability:

string fidos_name = spot.get_puppies()

               .puppies[0]

               .get_name()

               .upper() + "!";
Re:Statically Typed Languages Encourage Bad Code by silentbicycle on Tuesday October 19, 2010 @10:56PM (#1809765)
If you're making (sweeping!) generalizations about static typing, but don't even address languages that do it well, it's a rather weak argument. That's like dismissing dynamic typing as a whole because of bugs caused by string / number coercion in PHP. (Or dismissing jugglers with two arms because they're cheating.)

On the other hand, if someone seriously proficient in OCaml were to criticize static typing (in general, not just implementation details in some given language), I'd be all ears.

Loud ignorance + linkbait title? Flagged. Python is a fine language, it's too bad some of its buzz is so ignorant.

Re:Statically Typed Languages Encourage Bad Code by sz on Tuesday October 19, 2010 @11:49PM (#1809885)
Yep. Haskell is a perfect counterexample (everything is inferred).
Re:Statically Typed Languages Encourage Bad Code by silentbicycle on Wednesday October 20, 2010 @12:04AM (#1809926)
Haskell has a lot of other quirks, for better and worse. Harrrrrdly perfect, but not touching that one.

The main point is that modern static typing eliminates those stupid, tedious, verbose type annotations, as well as the stupid Python "I decided to crash because calcVaule(input) does not exist, but OMFG how could I have possibly known until I got there" errors.

The article is complaining about the problems that have been thoroughly solved for decades. Which is totally cool; if you want me, I'll be here in the corner howling about Nixon and Disco.

Re:Statically Typed Languages Encourage Bad Code by spooneybarger on Wednesday October 20, 2010 @12:16AM (#1809957)
To paraphrase Lloyd Bentsen:

I've seen bad code and that isn't bad code.

I prefer dynamic languages, but come on people. A type declaration makes 'good' code 'bad'. I can't even... I mean... really? And this got 4 points so far? Yes, I'm having a disappointed in the world night otherwise I could ignore those 4 points. Still... 3 people saw this recently and thought that was a valid argument.

Sigh.

Re:Statically Typed Languages Encourage Bad Code by silentbicycle on Wednesday October 20, 2010 @12:18AM (#1809961)
For all we know, those four points on the new feed could be from bored and drunk/coked up people waiting for more Techcrunch or Apple fanfic. The intellectual rigor often doesn't kick in until after the single digits.

See the flag button? The glowing, shiny, happy flag button?

Re:Statically Typed Languages Encourage Bad Code by spooneybarger on Wednesday October 20, 2010 @12:22AM (#1809973)
I see the flag button. I like the flag button. It is my friend. Doesn't mean I can't occasionally lash out and say 'wtf do I keep having to use this flag button'. See note about 'disappointed in the world night'.
Re:Statically Typed Languages Encourage Bad Code by gazetteer on Wednesday October 20, 2010 @05:38AM (#1810567)
I take it you find the one-liner more aesthetically appealing? I'm not arguing, just taking a survey. I'm deeply interested in what constitutes "good" code.
Re:Statically Typed Languages Encourage Bad Code by spooneybarger on Wednesday October 20, 2010 @08:01AM (#1810811)
I dont prefer the one line. I find the argument that the multiple line version becomes bad code when you add type info to it ludicrous.
Re:Statically Typed Languages Encourage Bad Code by gazetteer on Wednesday October 20, 2010 @08:21AM (#1810856)
It seems I have communicated poorly. The point is not that the type info makes the code bad code, but that one-liners are bad code and that one-liners are encouraged by requiring type declarations.
Re:Statically Typed Languages Encourage Bad Code by ggchappell on Wednesday October 20, 2010 @05:42AM (#1810578)
The writer has a good point, but he is also somewhat confused.

His argument is not really about the advantages of dynamic typing, but rather those of implicit typing, which is a more or less orthogonal concept.

Thus, as others have pointed out, Haskell, with its implicit static typing, does not have this problem.

Even C++(0x), with the new use of the "auto" keyword, allowing for implicit static typing, would not have the problem.

And Python, with its implicit dynamic typing, does not either.

But Java, with explicit static typing, does have the problem.

Re:Statically Typed Languages Encourage Bad Code by gazetteer on Wednesday October 20, 2010 @05:35AM (#1810562)
There is an inferred point in this post, touched on in the last paragraph: that this tendency to lump a lot of operations into one line is less about bad language design and more about lazy programmers. I never stated that statically typed languages ARE bad, but that they ENCOURAGE (lazy) programmers to write bad code. A lazy programmer might see that as bad code but not fix it because he doesn't want to go through the work mentioned in the post. A lazy programmer may not know the IDE functions that would do the work for him.