lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Sat, Jan 28, 2012 at 05:53:28PM +0100, Francesco Abbate wrote:
> This lack of ability to detect problems is in stark contrast with a
> strongly typed programming language like OCaml where the compiler does
> an amazing job detecting almost any type of errors during compilation.

That is a bit optimistic. There are plenty of mistakes the type system
of OCaml cannot capture, and this is not theory, it's my daily
experience with it. Moreover discovering a mistake is only half of the
job. Reporting it to the user is the other half, and OCaml is not
exactly nice at that...

> I'm always dreaming of a Lua typed companion programming language. It
> could be very similar to Lua, any language should be able to call
> functions defined with the other transparently. The advantage would be
> that the typed language would be better suited for complex
> applications and could be also compiled to produce optimal code.

This is what is commonly believed, but I think it is mostly wrong.

IMO, prototypes really benefit from static typing. You don't know how to
solve a problem, so you change every basic design decision a lot of
times and the compiler drives you to all the code spots affected by your
change. But if you already know how to solve a problem, you are not
going to break all you code every minute. If you just glue together
decent libraries (decent api, decent doc) you are not going to make too
many mistakes. 

The only thing I miss is a flag to lua(c) to perform a bit of lexical
analysis, mainly to detect mistyped variable names in error handling
code (in non error handling code you immediately see the problem, since
you are going to test your code, but generating all errors is hard).

Enrico Tassi