M
Marshall Spight
Pascal Bourguignon said:The only untyped languages I know are assemblers. (ISTR that even
intercal can't be labelled "untyped" per se).
Are we speaking about assembler here?
BCPL!
Marshall
Pascal Bourguignon said:The only untyped languages I know are assemblers. (ISTR that even
intercal can't be labelled "untyped" per se).
Are we speaking about assembler here?
Pascal Costanza said:What can happen in Java is the following:
- You might accidentally use the wrong class in a class cast.
- For the method you try to call, there happens to be a method with the
same name and signature in that class.
In this situation, the static type system would be happy, but the code
is buggy.
In a decent dynamically typed language, you have proper name space
management, so that a method cannot ever be defined for a class only by
accident.
Pascal Costanza said:Dirk Thierbach wrote:
As long as I am writing only tests, I don't care. When I am in the
mood of writing tests, I want to write as many tests as possible,
without having to think about whether my code is acceptable for the
static type checker or not.
Joachim Durchholz said:A test suite can never catch all permutations of data that may occur (on
a modern processor, you can't even check the increment-by-one operation
with that, the universe will end before the CPU has counted even half of
the full range).
Pascal Costanza said:In a statically typed language, when I write a test case that calls a
specific method, I need to write at least one class that implements at
least that method, otherwise the code won't compile.
In a dynamically typed language I can concentrate on writing the test
cases first and don't need to write dummy code to make some arbitrary
static checker happy.
Yes it is a very big deal.
Marshall said:How can a method be defined "by accident?" I can't figure out what
you're trying to say.
[email protected] said:Uh...the type system will let you *write* what you want, it will just
stop you from *running* those tests. Which are obviously going to
fail anyway. Okay, so perhaps you for some reason needs to write the
tests for nonexistent code, and then run something else that you keep
in the same file.
Marshall Spight said:I find that an odd conclusion. Given that the cost of bugs is so high
(especially in the cited case) I don't see a good reason for discarding
*anything* that leads to better correctness. Yes, bignums is a good
idea: overflow bugs in this day and age are as bad as C-style buffer
overruns. Why work with a language that allows them when there
are languages that don't?
Marshall said:This is a non-issue. In both cases, you need the implementing code
if you want to be able to run the testcase, and you don't need the
implementing code if you don't.
Marshall Spight said:I find that an odd conclusion. Given that the cost of bugs is so high
(especially in the cited case) I don't see a good reason for discarding
*anything* that leads to better correctness. Yes, bignums is a good
idea: overflow bugs in this day and age are as bad as C-style buffer
overruns. Why work with a language that allows them when there
are languages that don't?
Pascal Costanza said:Assertions cannot become out-of-date. If an assertion doesn't hold
anymore, it will be flagged by the test suite.
Pascal Costanza said:... there exist programs that work but
that cannot be statically typechecked. These programs objectively exist.
By definition, I cannot express them in a statically typed language.
Marshall said:I agree these programs exist.
It would be really interesting to see a small but useful example
of a program that will not pass a statically typed language.
It seems to me that how easy it is to generate such programs
will be an interesting metric.
Anyone? (Sorry, I'm a static typing guy, so my brain is
warped away from such programs.
Kenny Tilton said:Lights out for static typing.
Paul F. Dietz said:(7) Developing reliable software also requires extensive testing to
detect bugs other than type errors, and
(8) These tests will usually detect most of the bugs that static
type checking would have detected.
Pascal Costanza said:Have you ever used a program that has required you to enter a number?
The check whether you have really typed a number is a dynamic check, right?
Pascal Costanza said:No, in a dynamically typed language, I don't need the implementation to
be able to run the testcase.
Among other things:
- the test cases can serve as a kind of todo-list. I run the testsuite,
and it gives me an exception. This shows what portion of code I can work
on next.
- when a test case gives me an exception, I can inspect the runtime
environment and analyze how far the test case got, what it already
successfully did, what is missing, and maybe even why it is missing.
With a statically typed language, I wouldn't be able to get that far.
Furthermore, when I am still in the exceptional situation, I can change
variable settings, define a function on the fly, return some value from
a yet undefined method by hand to see if it can make the rest of the
code work, and so on.
Brian said:Yes, but this doesn't imply we can't write a statically-typed program to
handle the situation...
I can imagine Haskell code like
y = do x <- myread "34"
return x * 2
z = do x <- myread "foo"
return x * 2
where
myread :: String -> Maybe a
y, z :: Maybe Int
and "y" ends up with the value "Just 68" whereas "z" is "Nothing".
Pascal Costanza said:No, in a dynamically typed language, I don't need the implementation to
be able to run the testcase.
Among other things:
- the test cases can serve as a kind of todo-list. I run the testsuite,
and it gives me an exception. This shows what portion of code I can work
on next.
- when a test case gives me an exception, I can inspect the runtime
environment and analyze how far the test case got, what it already
successfully did, what is missing, and maybe even why it is missing.
With a statically typed language, I wouldn't be able to get that far.
Furthermore, when I am still in the exceptional situation, I can change
variable settings, define a function on the fly, return some value from
a yet undefined method by hand to see if it can make the rest of the
code work, and so on.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.