Take the 2-minute tour ×

Are all scripting languages dynamically typed?

I am using TCL. It is a scripting language and it does not enforce or allow type delaration of variables. It is instead a dynamically-typed language with ducktyping. The type of a variable is assumed by the interpreter according to the value assigned to it.

I would really like to know is there are scripting languages that are strictly/strongly typed.

share|improve this question
Interpreted languages are often dynamically typed (which does not mean they "have no data types") but not necessarily: stackoverflow.com/questions/376611/… –  thorsten müller Dec 13 '13 at 9:12
Many people use "scripting language" to mean "language that I don't like, for whatever reason" or "language whose type system I don't like". Please clearly define the term "scripting language" and give examples. (interesting article) –  Matt Fenwick Dec 13 '13 at 15:13
Could you clarify what you mean as a difference between scripting and non-scripting languages? That distinction is becoming more and more blurry with every passing day. –  MichaelT Dec 13 '13 at 16:14
@user61852 that's a bit silly, isn't it? The problem here is that we don't have an objective, technical definition of "scripting language". –  Matt Fenwick Dec 13 '13 at 19:29
I actually think the Wikipedia article does a good job of illustrating the general confusion around the issue: "In principle any language can be used as a scripting language", "The term 'scripting language' is also used loosely to refer to [...]"; "[...] hence the ambiguity about whether a language 'is' a scripting language [...]", "A scripting language can be viewed as a [...]". (emphasis mine). A lot of vague words used there. –  Matt Fenwick Dec 13 '13 at 22:26
show 6 more comments

closed as unclear what you're asking by gnat, Bart van Ingen Schenau, James McLeod, MichaelT, GlenH7 Dec 13 '13 at 21:19


2 Answers

Well, in my nomenclature -- which isn't universal, but whose is? -- TCL is not a dynamically typed language, it is an untyped one like assembly languages, BCPL, BLISS.

Statically typed languages have types deduced by a static analysis.

Dynamically typed languages have a type attached to values.

Untyped one have only one kind of values (words for BCPL and BLISS, strings for TCL) and the type is deduced from the operation which is applied more or less blindly on the values.

Automatic conversion may blur the difference between dynamically typed languages and untyped one. Evolution may also give an untyped language some dynamically typed flavor (that's perhaps the case for TCL -- I've not used for too long --, it's also the case for some shells which started as untyped and then acquired values which are of a different kind -- arrays for instance) making their behavior inconsistent and difficult to explain.

Duck typing is another axis. It's a way to check type conformance. It's a variant of structural typing where only the used characteristics are checked. It can be used in statically typed languages (templates in C++ is duck typing); in dynamic languages the check may be delayed to use time.

share|improve this answer
add comment

No. Whether a language is statically or dynamically typed, or weakly or strongly typed, has nothing to do with interpretation/compilation, which is an orthogonal implementation detail.

Perhaps the best example to use here would be Hugs, The Haskell interpreter. For those unaware, Haskell is a very strongly typed language with a very powerful type system, and is somewhat of a poster child for strong type systems with solid mathematical backing.

Consider also a language such as Scala, which has a type system with similar power and is very difficult to place between compiled and interpreted. It "compiles" down to JVM Bytecode, which is then interpreted/compiled/JITted depending on various implementation details of the JVM it happens to be running on.

share|improve this answer
I may be nitpicking, but the typing discipling is decidedly not an implementation detail, but rather an important part of the language design. Also, your answer appears to exclusively use the "scripting language = interpreted" definition, which may not be what OP means. –  delnan Dec 13 '13 at 15:24
"Scripting" is not an implementation detail, it's a mode of usage. Scripting language is embedded into some larger system or used to glue smaller system components. Not sure I ever seen Hugs being used for scripting purposes (not saying it's not possible or not reasonable). –  SK-logic Dec 13 '13 at 15:32
@delnan: Er, right you are, that sentence is rather the wrong way around! –  Phoshi Dec 13 '13 at 16:52
@SK-logic: You can embed and glue stuff together in many many languages, like C! I wouldn't call C a scripting language, though it's certainly capable of acting like one and certainly is used as one. I think my definition would simply be a language which puts high semantic density above being suitable for maintenance of large applications, though I'm not sure Haskell really qualifies under those rules it certainly strikes the high semantic density one off. –  Phoshi Dec 13 '13 at 16:55
@Phoshi, if you embed C (which had been done with tcc, for example), C will become a genuine, real scripting language. C++ is a proper scripting language indeed, in ROOT, for example. –  SK-logic Dec 13 '13 at 17:27
show 3 more comments
