static-typing

Interface vs Base class

When should I use an interface and when should I use a base class? Should it always be an interface if I don't want to actually define a base implementation of the methods? If I have a Dog and Cat class. Why would I want to implement IPet instead of PetBase? I can understand having interfaces for ISheds or IBarks (IMakesNoise?), becau...

What's the best statically-typed language for a dynamically-typed language programmer to learn?

I've been a Ruby developer for several years, and a Perl developer before that, with some PHP somewhere in there. I want to expand my knowledge, and think the best way to do that will be by learning something very different from what I know. I know OO, and I know functional programming pretty well. What I don't know is a language that us...

Are there any static duck-typed languages?

Can I specify interfaces when I declare a member? After thinking about this question for a while, it occurred to me that a static-duck-typed language might actually work. Why can't predefined classes be bound to an interface at compile time? Example: public interface IMyInterface { public void MyMethod(); } public class MyClass //D...

Can someone tell me what Strong typing and weak typing means and which one is better?

Can someone tell me what Strong typing and weak typing means and which one is better? ...

Applying Extension method to generic class with generic type.

I was working with the generic class in vb.net. And it seems extension method cannot be applied to generic class without specifying the type. I have this generic class Public Class MyGeneric(Of T) 'Methods and properties go here ' ' End Class This is Ok <Extension()> _ Public Sub DoSomething(ByVal myGenericDoubleObj As ...

Script.Net vs Nemerle

I was looking into scripting to be incorporated into my apps. Then I bumped into Script.Net and Nemerle. I do know that they have different syntax and Nemerle supports macro but not Script.Net. But I would like to know more about their differences in terms of functionality, usage and flexibility. And which one would you recommend, why? ...

Must a Language that Implements Monads be Statically Typed?

I am learning functional programming style. From this link http://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads/, Brian Beckman gave a brilliant introduction about Monad. He mentioned that Monad is about composition of functions so as to address complexity. A Monad includes a unit function that transfers type...

Can automated unit testing replace static type checking?

I've started to look into the whole unit testing/test-driven development idea, and the more I think about it, the more it seems to fill a similar role to static type checking. Both techniques provide a compile-time, rapid-response check for certain kinds of errors in your program. However, correct me if I'm wrong, but it seems that a uni...

Validating Python Arguments in Subclasses

I'm trying to validate a few python arguments. Until we get the new static typing in Python 3.0, what is the best way of going about this. Here is an example of what I am attempting: class A(object): @accepts(int, int, int) def __init__(a, b, c): pass class B(A): @accepts(int, int, int, int) def __init__(a, b, ...

What does super strong typing bring to the table?

I'd like to understand the advantages of super-strong typing, a la SML or Scala, over conventionally strongly typed languages such as Java or c++. Could someone give a brief overview of the advantages of very strong typing, or better yet, post an example of an error which would be caught at compile time in very strongly typed language, ...

Does static typing mean that you have to cast a variable if you want to change its type?

Are there any other ways of changing a variable's type in a statically typed language like Java and C++, except 'casting'? I'm trying to figure out what the main difference is in practical terms between dynamic and static typing and keep finding very academic definitions. I'm wondering what it means in terms of what my code looks like. ...

Why is C# statically typed?

I am a PHP web programmer who is trying to learn C#. I would like to know why C# requires me to specify the data type when creating a variable. Class classInstance = new Class(); Why do we need to know the data type before a class instance? ...

Static/strong typing and refactoring

It seems to me that the most invaluable thing about a static/strongly-typed programming language is that it helps refactoring: if/when you change any API, then the compiler will tell you what that change has broken. I can imagine writing code in a runtime/weakly-typed language ... but I can't imagine refactoring without the compiler's h...

When is sqlite's manifest typing useful?

sqlite uses something that the authors call "Manifest Typing", which basically means that sqlite is dynamically typed: You can store a varchar value in a "int" column if you want to. This is an interesting design decision, but whenever I've used sqlite, I've used it like a standard RDMS and treated the types as if they were static. Inde...

F# and Operator Overloads

Ok, so can someone explain to me why F# allows you to overload the > and ^ operators, but doesn't allow you to use them? + (op_Addition): Works just fine. ^ (op_Concatenate): Compiler error in F#. Apparently only strings can be concatenated. > (op_GreaterThan): Runtime Error – Failure during generic comparison: the type Program+OppTest4...

assign type to variable, use variable with generic static class

I'm working in a C# web service with a generic static class that takes a type. I was wondering why this does not compile: Type type1 = typeof(MySnazzyType); Assert.AreEqual(0, ConnectionPool_Accessor<type1>._pool.Count); It gives this error: The type or namespace name 'type1' could not be found (are you missing a using directive ...

Python 3 and static typing

I didn't really pay as much attention to Python 3's development as I would have liked, and only just noticed some interesting new syntax changes. Specifically from this SO answer function parameter annotation: def digits(x:'nonnegative number') -> "yields number's digits": # ... Not knowing anything about this, I thought it could ...

Why Is Dynamic Typing So Often Associated with Interpreted Languages?

Simple question folks: I do a lot of programming (professionally and personally) in compiled languages like C++/Java and in interpreted languages like Python/Javascript. I personally find that my code is almost always more robust when I program in statically typed languages. However, almost every interpreted language I encounter uses dyn...

What is the difference between statically typed and dynamically typed languages?

Hi, I hear a lot that new programming languages are dynamically typed but what does it actually mean when we say a language is dynamically typed vs. statically typed? Thanks ...

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...