Re: RAD vs. performance
- From: "Curtis W" <cwarren89@xxxxxxxxx>
- Date: 28 Jun 2006 10:06:47 -0700
Obviously there's some confusion here. Let's step back and look at thisYou are also aware that if a language has the same types and operations
as Ocaml (e.g. ints and floats using + and +.), then doing type
inference (for purposes of generating efficient code) is going to be
exactly the same for a dynamically typed language as it is for Ocaml?
To the extent that your statement is true, it is meaningless.
On the contrary. This is the heart of the issue. You keep claiming that
type inference can't be done both efficiently and effectively in dynamic
languages; my statement asserts that it can be done using the exact same
methods that are used for statically typed languages, with the same
efficiency, and the same effectiveness.
Then you're implementing static typing.
from an abstract point of view: static typing is basically any type
system that completely checks all types at compile time and possibly
run time (see: incomplete pattern matches/casting). Dynamic typing is
basically the complete opposite of this: checking is done at run time
to make sure it only complains when there *is* an error. This is the
general philosophy behind dynamic typing, so it's generally safe to
assume that, as long as something is completely provable to be an
error, it doesn't matter if it complains at compile time. Now, given
these definitions, you can derive the facts that 1) a completely
inferred, static language (nonexistant) with structural subtyping is
very similar to dynamic typing and 2) the case in which it's different
is when you're dealing with *possibly* erroneous expressions, in which
case the static language requires you to acknowledge this, whereas the
dynamic language just warns you. There you go, a complete break down of
the similarities and differences of static and dynamic typing.
Do you have an example of this?And that the only cases in which you wouldn't be able to infer the type,
and thus would fall back to boxing and run-time dispatch, is when Ocaml
would reject your program?
That is definitely not true. Look at rectypes, polymorphic recursion etc.
So you're saying that Ocaml accepts (some) programs for which it cannot
infer the types?
No, I am saying that you have incorrectly assumed that OCaml can't
infer more because it is not "smart" enough. In fact, OCaml can infer
more but chooses not to because it weakens the type system and allows
significantly more bugs to creep in. You can control the amount of
inference in OCaml and good OCaml programmers deliberately choose not
to infer everything because it slows development and makes for less
reliable software.
Circumstantial evidence. That's obviously a deficiency in theCommon Lisp would be a different story, because Common Lisp does mandate
that you have a full numeric tower. So if the compiler cannot prove that
you will only ever need fixnums, it will need to emit less efficient
code.
Even if you litter the source with type declarations to evade that
problem, SBCL and CMUCL still produce much slower code. IIRC, a slow GC
was a major reason but even with lots more code to alleviate the GC,
Lisp was still much slower than the statically-typed languages and
Stalin-compiled Scheme.
implementation.
I certainly do. It might require slightly more work from the programmerI have run Stalin on many programs and it is always orders of magnitude
slower than any other compiler that I have seen.
Yes, and you suggest that this is because of the language it compiles. I
contend it may also be an implementation issue.
You think that someone can write a Scheme compiler that generates code
that is almost as efficient whilst taking a reasonable time to compile?
compared to a baseline, unoptimized version, but it'll still probably
be shorter than the statically typed version or at most equivalent in
size.
Dynamic typing is not a "special case" of static typing--they're both(2) you'd rather
have the programmer do a little extra work each time he needs dynamic
typing, than have the compiler do extra work to generate efficient code
from a higher level language.
Dynamic typing is not "higher level". It is a special case of static
typing.
two different ways to implement a type system. One does more checking
at compile time, the other doesn't.
You can argue for a more powerful type system. I'd like type classesIronically, the general coding style in OCaml is probably so incredibly
and performance...
rigid because of the "shunning" of type classes and their equivalents
(OCaml modules, classes).
.
- Follow-Ups:
- Re: RAD vs. performance
- From: Dr Jon D Harrop
- Re: RAD vs. performance
- References:
- Re: RAD vs. performance
- From: cr88192
- Re: RAD vs. performance
- From: Jon Harrop
- Re: RAD vs. performance
- From: Robbert Haarman
- Re: RAD vs. performance
- From: Curtis W
- Re: RAD vs. performance
- From: Jon Harrop
- Re: RAD vs. performance
- From: Curtis W
- Re: RAD vs. performance
- From: Jon Harrop
- Re: RAD vs. performance
- From: cr88192
- Re: RAD vs. performance
- From: Robbert Haarman
- Re: RAD vs. performance
- From: Jon Harrop
- Re: RAD vs. performance
- From: Dr Jon D Harrop
- Re: RAD vs. performance
- Prev by Date: Re: RAD vs. performance
- Next by Date: Re: RAD vs. performance
- Previous by thread: Re: RAD vs. performance
- Next by thread: Re: RAD vs. performance
- Index(es):
Relevant Pages
|