[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Strong Typing, Dynamic Languages, What to do?
Oscar Fuentes wrote:
> As Chris U. said, it is debatable if the type system must do bounds
> checking.
That's mainly because it's hard to do bounds checking statically, so it's
commonly ignored in languages which primarily rely on static type checking,
like C++. But for a type system to provide safety for its types, it must do
bounds checking, since otherwise, it can't protect the integrity of its own
types.
C++ does the best it can to warn you at compile time of the type errors it
can detect, but it isn't foolproof. That's why C++ is called an "unsafe
language". The important point is that it can't always protect the
integrity of its own types, in particular because the language itself
performs few runtime checks. I think that's the real point here.
> I can understand the POV of some people here which are academics
> teaching how to program well to future professionals.
The problem goes much further than that. The costs of developing, debugging
and maintaining C/C++ programs are much higher because of this kind of
thing.
> If you want to do type safe programming in C++ you can do it
> and the compiler will help you. The only requirement is that
> you must know what are you doing.
If you "know what you are doing", you don't need a type system at all (think
pure untyped lambda calculus, bay-bee! :) A type system that relies on you
to implement it properly isn't doing the job for which type systems are
intended. C++ does its best with static checks - and runtime checks in some
very specific cases, such as safe casts - but that's not enough for true
type safety.
Anton