static-typing

Statically typed languages vs. dynamically typed languages

How is the association of type and parameter different in a dynamically typed language than a statically typed language? ...

Is there a citation available for 'a growing rebellion' against strict typing systems?

The FAQ for the new Go language explicitly makes this claim: There is a growing rebellion against cumbersome type systems like those of Java and C++, pushing people towards dynamically typed languages such as Python and JavaScript. Is there (non-anecdotal) data to actually support such a claim? I've always found dynamic typing slo...

Inferred type appears to detect an infinite loop, but what's really happening?

In Andrew Koenig's An anecdote about ML type inference, the author uses merge sort as a learning exercise for ML and is pleased to find an "incorrect" type inference: Much to my surprise, the compiler reported a type of 'a list -> int list In other words, this sort function accepts a list of any type at all and returns a list ...

Static testing for Scala

There are some nice libraries for testing in Scala (Specs, ScalaTest, ScalaCheck). However, with Scala's powerful type system, important parts of an API being developed in Scala are expressed statically, usually in the form of some undesirable or disallowed behavior being prevented by the compiler. So, what is the best way to test whet...

OOP and Dynamic Typing (not Static vs Dynamic)

What OOP principles, if any, don't apply or apply differently in a dynamically typed environment as opposed to a statically-typed environment (for example Ruby vs C#)? This is not a call for a Static vs Dynamic debate, but rather I'd like to see whether there are accepted principles on either side of that divide that apply to one and not...

Scripting engine with static typing

Hi, I am looking for a scripting engine that can be integrated in .NET but NOT with dynamic typing! For example, JavaScript is not suitable, because it is a dynamically typed language. Do you know any? ...

What is the purpose of type ascription in Scala?

There's not much info in the spec on what type ascription is, and there certainly isn't anything in there about the purpose for it. Other than "making passing varargs work", what would I use type ascription for? Below is some scala REPL for the syntax and effects of using it. scala> val s = "Dave" s: java.lang.String = Dave scala> va...

Is it possible to specify an anonymous function's return type, in Scala?

I know you can create an anonymous function, and have the compiler infer its return type: val x = () => { System.currentTimeMillis } Just for static typing's sake, is it possible to specify its return type as well? I think it would make things a lot clearer. ...

Boo: Explicitly specifying the type of a hash

I am new to Boo, and trying to figure out how to declare the type of a hash. When I do: myHash = {} myHash[key] = value (later) myHash[key].method() the compiler complains that "method is not a member of object". I gather that it doesn't know what type the value in the hash is. Is there any way I can declare to the compil...

Does Java casting introduce overhead? Why?

Is there any overhead when we cast objects of one type to another? Or the compiler just resolves everything and there is no cost at run time? Is this a general things, or there are different cases? For example, suppose we have an array of Object[], where each element might have a different type. But we always know for sure that, say, e...

Which languages are dynamically typed and compiled (and which are statically typed and interpreted)?

In my reading on dynamic and static typing, I keep coming up against the assumption that statically typed languages are compiled, while dynamically typed languages are interpreted. I know that in general this is true, but I'm interested in the exceptions. I'd really like someone to not only give some examples of these exceptions, but tr...

Static/Dynamic vs Strong/Weak

I see these terms banded around all over the place in programming and I have a vague notion of what they mean. A search shows me that such things have been asked all over stack overflow in fact. As far as I'm aware Static/Dynamic typing in languages is subtly different to Strong/Weak typing but what that difference is eludes me. Differen...

Is there a compiled* programming language with dynamic, maybe even weak typing?

I wondered if there is a programming language which compiles to machine code/binary (not bytecode then executed by a VM, that's something completely different when considering typing) that features dynamic and/or weak typing, e.g: Think of a compiled language where: Variables don't need to be declared Variables can be created doing ru...

Are there any statically typed, embeddable scripting languages?

I am wondering if there are any statically typed, embeddable scripting languages. Python, JavaScript, etc. are great languages, but they are dynamically typed (that is, types are checked at run time). I am just wondering if anyone knows of any statically typed scripting languages that can be embedded in a C++ application? ...

Simulating aspects of static-typing in a duck-typed language

In my current job I'm building a suite of Perl scripts that depend heavily on objects. (using Perl's bless() on a Hash to get as close to OO as possible) Now, for lack of a better way of putting this, most programmers at my company aren't very smart. Worse, they don't like reading documentation and seem to have a problem understanding ...

Typed metaprogramming languages

I want to do some metaprogramming in a statically typed language, where both my programs and my meta-programs will be typed. I mean this in a strong sense: if my program generator compiles, I want the type system to be strong enough that only type-correct programs can be generated. As far as I know, only metaocaml can do this. (No, ne...

Do you know of a language with Static Type checking where Code is Data?

Can you name language with Static Type checking(like Java) and where Code is Data(like in LISP)? I mean both things in one language. ...

How to define a function that can return a pointer to itself?

I want to write code like this: /*something*/ Fn() { ... } int main() { /*something*/ fn = Fn; while(fn) fn = fn(); return 0; } Is it possible to do this is a fully type safe way? Assume C, C++, D, C#, Java, or any other statically typed language. ...

Do you know of any examples of elegant solutions in dynamically typed languages?

Imagine two languages which (apart from the type information) do have exactly the same syntax, but one is statically typed while the other one uses dynamic typing. Then, for every program written in the statically typed language, one can derive an equivalent dynamically typed program by removing all type information. As this is not necce...

Is a statically-typed full Lisp variant possible?

Is a statically-typed full Lisp variant possible? Does it even make sense for something like this to exist? I believe one of a Lisp language's virtues is the simplicity of its definition. Would static typing compromise this core principle? ...