Re: Whats the best language to learn...



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
.



Relevant Pages

  • Code Red
    ... Is screaming normal when programming VB. ... For some weird reason the code text behind all of my forms keeps turning ... Whilst I am typing it insists on jumping back one ...
    (microsoft.public.access.formscoding)
  • Re: RAD vs. performance
    ... All of the implementations are either slow to compile ... exactly the same for a dynamically typed language as it is for Ocaml? ... Then you're implementing static typing. ... course, I think you must), then it follows that dynamic typing does NOT ...
    (comp.lang.misc)
  • Re: RAD vs. performance
    ... Then you're implementing static typing. ... type checking work to compile time as possible. ... that it is possible to invent dynamically typed languages that compile ...
    (comp.lang.misc)
  • Why I dont believe in static typing
    ... relative merits of static versus dynamic typing I thought I'd spoil it all ... delivered by an ad server, which was already up and running. ... to part of the system, compile it, and the compiler errors would point you ... The introduction of credit card billing ...
    (comp.lang.lisp)
  • Re: PEP 3107 and stronger typing (note: probably a newbie question)
    ... typing is to provide optimization clues for the compiler. ... Computer Programming", call "totally open programming". ... Alice as interoperable languages without and with static typing, ... "Dynamic typing is recommended", they conclude, "when programs must be ...
    (comp.lang.python)