Re: Whats the best language to learn...
- From: Jon Harrop <jon@xxxxxxxxxxxxxxxxx>
- Date: Fri, 22 Aug 2008 18:53:52 +0100
Pascal J. Bourguignon wrote:
thomas.mertes@xxxxxx writes:
I do not think that the programming process is slowed down
with compile-time type checking. Some reasons for this
opinion are here:
http://seed7.sourceforge.net/faq.htm#development_speed_and_type_checking
Including time to debug them.
Debugging is much faster when errors are caught at compile time by a static
type checker and the same otherwise.
For example: This variable will hold a list of s-expressions.
That parameter will hold the s-expression I want to process.
This function will return the number of bytes used to represent
the s-expression in memory. This examples might not be
LISP like, but I am quite sure that you do think over such
things while you are programming.
Indeed, types are still kept in mind, even with dynamically typed
languages. But minds are not as formal as formal systems: we can deal
with generic typing and unspecific typing more efficiently than with
specific strict typing.
When you write a function in a dynamically typed language, most often,
this function will be more generic than what you thought at the
beginning. In essence, with dynamic typing you are writting generic
code by default.
When you must specify static types, you always restrict the
applicability of your code.
That is not true. Inference of generic types (parametric polymorphism) is a
trivial counter example.
What I say is: Supplying type information is not something you
do after you finished programming. Thinking over types (what
values will be holded/returned) is something you need to do,
while you are programming. You seem to deny it, but it is really
part of the programming process.
What I say is that when you write code, that could process the most
general mathematical structure (eg. a group),
1- your statically typed programming language just won't have the
general notion you have in mind as a type (or you will need to
write kilometers of code to teach it),
You can enforce a tuple statically in ML but cannot in Lisp and you cannot
enforce a prime statically in either. Again, static typing is strictly more
powerful.
2- it is still natural to _think_ about some concrete instance of the
general structure to develop your function, but there's no reason
to impose the concrete example as a limit of the result.
There is no difference between static and dynamic typing in that context.
So if I write:
(defun fact (x)
(if (zerop x) 1 (* x (fact (- x 1)))))
or equivalently (in Common Lisp, (+) is the neutral of + and (*) is
the neutral of *):
(defun fact (x)
(if (= (+) x) (*) (* x (fact (- x (*))))))
I may write it thinking about integers, but it can work equally well
on polynoms or matrices, and there's no reason to force me to specify
that X must be of integer type. Even if I thought about integers, as
a prototype of a field.
You can do that and more with static typing so, again, static typing is
strictly more powerful. Specifically, you can (optionally) convey type
constraints that will be checked at compile time, e.g. to ensure that you
have not erroneously applied "fact" to a type for which it is known to be
invalid.
--
Dr Jon D Harrop, Flying Frog Consultancy
http://www.ffconsultancy.com/products/?u
.
- References:
- Whats the best language to learn...
- From: Gits
- Re: Whats the best language to learn...
- From: thomas . mertes
- Re: Whats the best language to learn...
- From: Roman Werpachowski
- Re: Whats the best language to learn...
- From: Juha Nieminen
- Re: Whats the best language to learn...
- From: Roman Werpachowski
- Re: Whats the best language to learn...
- From: thomas . mertes
- Re: Whats the best language to learn...
- From: Roman Werpachowski
- Re: Whats the best language to learn...
- From: thomas . mertes
- Re: Whats the best language to learn...
- From: Pascal J. Bourguignon
- Re: Whats the best language to learn...
- From: thomas . mertes
- Re: Whats the best language to learn...
- From: Pascal J. Bourguignon
- Whats the best language to learn...
- Prev by Date: Re: Whats the best language to learn...
- Next by Date: Re: Sorting a file with many already-sorted chunks
- Previous by thread: Re: Whats the best language to learn...
- Next by thread: Re: Whats the best language to learn...
- Index(es):
Relevant Pages
|