Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Does Static Typing Limit Macros?

I was reading Paul Graham's "The Hundred-Year Language" article.

http://www.paulgraham.com/hundred.html

In there he makes a claim that static typing "preclude[s] true macros".

For example, types seem to be an inexhaustible source of research papers, despite the fact that static typing seems to preclude true macros-- without which, in my opinion, no language is worth using.

How is this true? Where are the papers? I tried searching on Google without success.

like image 533
Unknown Avatar asked Oct 17 '09 19:10

Unknown


People also ask

Does static typing reduce bugs?

In the static typing camp we have the benefits of catching bugs earlier in the development cycle, eliminating altogether some classes of bugs in deployed systems, improved things like code-assist and other tool support, and enabling compiler optimisations.

Which of the following are advantages of static typing?

Static typing has the following main benefits: It allows statically (without running the program) detecting many programming errors quickly, reliably and automatically. This helps reduce the number of bugs and reduces the time spent on debugging. Type declarations serve as automatically-checked documentation.

What is static typing in C?

A statically-typed language is a language (such as Java, C, or C++) where variable types are known at compile time. In most of these languages, types must be expressly indicated by the programmer; in other cases (such as OCaml), type inference allows the programmer to not indicate their variable types.


1 Answers

Paul Graham is a proponent of having "the whole language there all the time":

There is no real distinction between read-time, compile-time, and runtime. You can compile or run code while reading, read or run code while compiling, and read or compile code at runtime.

Running code at read-time lets users reprogram Lisp's syntax; running code at compile-time is the basis of macros; compiling at runtime is the basis of Lisp's use as an extension language in programs like Emacs; and reading at runtime enables programs to communicate using s-expressions, an idea recently reinvented as XML.

So he may be referring to the practical impossibility of defining new types at runtime in a language that expects to have all the type information at compile time, as Daniel Ribeiro points out on his blog:

Note that you cannot make type-safe runtime metaprogramming in general. For instance: even though some languages allow you to create interfaces that do not exist on compile time, the only way to invoke methods from these is through non type-safe ways (such as reflection).

I am sure that you would have no trouble finding programmers who dispute that this capability is worth giving up the benefits that they derive from static typing.

like image 154
kuzzooroo Avatar answered Sep 27 '22 16:09

kuzzooroo