Question

I have some questions:

  • A dynamic programming language is always interpreted? I think so, but why?
  • Are there any dynamic languages ​​with static typing system?
  • A programming language with static typing system is always compiled?

In others words, are there really a link between :

  • Static / dynamic typing system and static / dynamic language
  • Static / dynamic typing system and compiler / interpreter
  • Static / dynamic language and compiler / interpreter
Was it helpful?

Solution

There is no inherent connection between the type system and the method of execution. Dynamic languages can be compiled and static languages can be interpreted. Arguably static type systems make a lot of sense with programs which are compiled before execution, as a method of catching certain kinds of errors before the program is ever executed. However, dynamic type systems solve different problems than static type systems, and interpreted execution solves different problems than compilation.

See What to know before debating type systems.

OTHER TIPS

A dynamic programming language is always interpreted? I think so, but why?

No. Most dynamic languages in wide use internally compile to either bytecode or machine code ("JIT"). There are also a number of ahead-of-time compilers for dynamically-typed languages. There are a number of compilers for Scheme and Lisp, as well as other languages.

Are there any dynamic languages ​​with static typing system?

Yes. The terms your are looking for here are "optional typing" and "gradual typing".

A programming language with static typing system is always compiled?

Most are, but this isn't strictly required. Many statically typed functional languages like ML, F#, and Haskell support an interactive mode where it will interpret (or internally compile and execute) code on the fly. Go also has a command to immediately compile and run code directly from source.

In others words, are there really a link between :

Static / dynamic typing system and static / dynamic language Static / dynamic typing system and compiler / interpreter Static / dynamic language and compiler / interpreter

There's a soft link between the two. Most people using dynamically typed languages are using them in part because they want quick iteration while they develop. Meanwhile, most people using statically typed languages want to catch as many errors as early as they can. That means that dynamically typed languages tend to be run directly from source while statically typed languages tend to compile everything ahead of time.

But there's no technical reason preventing you from mixing it up.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top