views:

220

answers:

4

Whatever its merits, Adobe's Actionscript 3 presents what may be a unique opportunity to explore the consequences of typed versus untyped languages, because it is pretty much a strict superset of javascript, with all the syntactic benefits/overhead of strict type declarations, declarative casting, etc.

What this makes possible is comparing the same code written both ways, while factoring out essential language syntax.

This causes me to wonder if there is any quantitative evidence about the real benefit of strong typing in particular for error checking during compilation, with respect to error rates, programming productivity, and code volume; or are our perspectives entirely based on speculation and conjecture? Are there any other languages that can be used both ways (not counting old-fashioned VB - not being a highly respected language either way.)

I've spent significant time with both languages, but haven't conclusively decided which way I prefer, and I'd rather not add to the anecdotal evidence - I'm looking for objective information.

+1  A: 

In my opinion, strongly typed languages like C# can identify during compile time many overlooked errors that would not be caught in a loose typed language and would, therefore, cause a runtime error later. I don't thinks this is just an speculation, since strict compilation can anticipate issues that would later cause errors during runtime. This can potentially eliminate most of the kind of coding erros that you overlook during the implementation, but that can be easily found and fixed by the compiler.

Felipe Lima
Yes it can do this, and it's valuable when it happens. The question is about whether measurements are possible, and have taken place, to discover how much benefit this is, and what the costs are. (I don't know if I necessarily agree that most of the errors we overlook are type-checking errors).
le dorfier
+1  A: 

This is one of the great religious wars in programming, exceeded only perhaps by the conflict between the one True Editor EMACS, and the evil spawn of Satan vi.

Basically, if a program written in a dynamic language is correct, then it can be converted to a statically-typed language and still be correct, and vice versa. The advantage of a truly statically-typed langfuage is that bugs which would show up at run time in a dynamic language can be identified at compile time in a statically-typed language.

What often gets neglected in these situations, though, is that statically typed languages generally have escape hatches (like typecasts), and apparently dynamic languages can use type inference to infer, and treat as statically typed, the types of apparently dynamic expression.

What's really important, under the covers, is the programmer. If the programmer thinks the program right, then it'll be right in either a static or a dynamic language. I'm not aware of any good experimental evidence that either one is more productive or more prone to errors in practice.

Charlie Martin
They also (I've found) coerce a different mindset in the programmer. In javascript I'm much more concise and lightweight; in Actionscript I'm more exhaustive and verbose. If we're going to get past the religious wars, I'm hoping someone, somewhere might be actually collecting comparable statistics.
le dorfier
Meaning I **don't** think it's just personal preference, and it really makes no difference. There should be ways to assign the same task to two groups of randomly-assigned similarly skilled one technique or the other, and see what happens. Then switch. (for instance).
le dorfier
I agree with you in theory, but doing well-designed experiments of this sort is amazingly hard, and expensive. For example, you can't really compare groups as you suggest because it doesn't account for the learning the groups do. making your control groups be selected well is...
Charlie Martin
...also very difficult. We did a lot of stuff on this kind of experimentation 20 years ago; you might look at John Knight work for some examples. http://www.cs.virginia.edu/~jck/
Charlie Martin
A: 

The value of static typing seems pretty limited to me if you believe, as I do, that you can't say something is true about a piece of software unless you have a test demonstrating it to be the case. If you accept and practice that, then it's largely irrelevant as to whether bugs are identified at compile time or at test time.

At this point, I'd rather have the more succinct of the two types of languages, which in my experience has been dynamic languages.

The flip side, is that static typing only really helps you if you aren't writing tests. If that's the case, static typing probably isn't enough to ensure the proper functioning of your software.

pansapien
I'm emotionally closer to your position. I feel like C#/java are all about belts and suspenders, and javascript/ruby is about running shorts.
le dorfier
Where js/ruby thinks about meaningful tests and code that describes the problem domain, C#/j thnks about meaningful tests,code that describes the problem domain, and configurations, and casts, are language artifacts. But for me that's a religious statement is all.
le dorfier
I like to think of it as a subjective choice between pain A or pain B. If one approach truly had significantly less pain than the other, than that approach would eliminate the other over time.
pansapien
A: 

The OP and felipecsl are confused about the terminology used when talking about typing disciplines.

Static Typing means types are checked during compile-time (whatever compile time means in the language). Dynamic Typing means types are checked as expressions/statements are being executed. Strong Typing means that you cannot subvert (cast) a pointer into an integer, for instance. Weak Typing is the opposite of Strong Typing.

There is no "strict typing", as far as I know.

Now for someone else to answer the actual question ;-)

Here's what I think might be an example that clarifies the distinction. Does it even make sense to think about a statically typed jQuery for ActionScript?
le dorfier