Welcome Guest.   Make a donation to an author on the site October 31, 2014, 06:47:19 PM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
The N.A.N.Y. Challenge 2012! Download dozens of custom programs!
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: An experiment about static and dynamic type systems  (Read 2173 times)
Armando
Charter Member
***
Posts: 2,682



see users location on a map View Profile Give some DonationCredits to this forum member
« on: September 09, 2011, 11:38:53 AM »

Moderately interesting study. Still worth sharing.
This blog article has good comments at the bottom. [Disclaimer : I haven't read the actual study]



Logged

"I suppose it can be said that I'm an absent-minded driver. It's true that I've driven through a number of red lights on occasion, but on the other hand, I've stopped at a lot of green ones but never gotten credit for it."
Glenn Gould
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: September 12, 2011, 07:00:26 PM »

Haven't had the time to look at this in detail, but the following caught my attention:
Quote
One issue is that experimenter, to reduce variables such as familiarity or different IDEs, developed his own language, Purity, in two variants.
Does that mean everybody were stuck with 'dumb' text editors? In that case, the study is pretty useless... some of the really big advantages statically typed languages offer over dynamic ones is all the assistance you get from your development tools, which is extremely hard to implement for dynamic languages.

If you add some decent type inference into the mix (C#, C++2011, Scala, ...) you gain several of the brevity benefits associated with dynamic languages, without the clusterfsck messup potential.
Logged

- carpe noctem
Armando
Charter Member
***
Posts: 2,682



see users location on a map View Profile Give some DonationCredits to this forum member
« Reply #2 on: September 12, 2011, 07:40:26 PM »

There seems to be a few methodological weirdnesses in this study, which wouldn't surprising as it's often the case with... studies.

However, there might something to explore there : "dynamic languages" for very small projects, statically typed ones for bigger ones. Makes sense... Maybe
Logged

"I suppose it can be said that I'm an absent-minded driver. It's true that I've driven through a number of red lights on occasion, but on the other hand, I've stopped at a lot of green ones but never gotten credit for it."
Glenn Gould
Renegade
Charter Member
***
Posts: 11,667



Tell me something you don't know...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: September 12, 2011, 11:21:43 PM »

...some of the really big advantages statically typed languages offer over dynamic ones is all the assistance you get from your development tools, which is extremely hard to implement for dynamic languages.

+1

C# allows dynamic typing, but I'll be damned if I'll use it if I can at all avoid it. (dynamic and var)

It has its place, but those situations are kind of specific.


I would also be interested to know about how they compare in large scale projects.

Logged

Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #4 on: September 13, 2011, 01:54:02 PM »

C# allows dynamic typing, but I'll be damned if I'll use it if I can at all avoid it. (dynamic and var)
'var' is not dynamic typing, it's used for static type inference which is super useful for DRY reasons.

'dynamic' is something to be very careful about - it tends to ripple out if you start using it.
Logged

- carpe noctem
Renegade
Charter Member
***
Posts: 11,667



Tell me something you don't know...

see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: September 13, 2011, 05:50:10 PM »

C# allows dynamic typing, but I'll be damned if I'll use it if I can at all avoid it. (dynamic and var)
'var' is not dynamic typing, it's used for static type inference which is super useful for DRY reasons.

'dynamic' is something to be very careful about - it tends to ripple out if you start using it.

I stand corrected. smiley

But close enough. When you look at it, var looks like a dynamic type. e.g. var acme = "Rocket Skates"; vs. var acyou = 500;

http://msdn.microsoft.com...-us/library/bb383973.aspx

Quote
Beginning in Visual C# 3.0, variables that are declared at method scope can have an implicit type var. An implicitly typed local variable is strongly typed just as if you had declared the type yourself, but the compiler determines the type. The following two declarations of i are functionally equivalent:

http://msdn.microsoft.com...-us/library/bb384061.aspx

Quote
Local variables can be given an inferred "type" of var instead of an explicit type. The var keyword instructs the compiler to infer the type of the variable from the expression on the right side of the initialization statement. The inferred type may be a built-in type, an anonymous type, a user-defined type, or a type defined in the .NET Framework class library.

However, this:

Formatted for C# with the GeSHI Syntax Highlighter [copy or print]
  1. var a = 1;
  2. var b = "123";
  3. var c = a + b;
  4. MessageBox.Show(c.ToString());

Outputs:

1123

And

Formatted for C# with the GeSHI Syntax Highlighter [copy or print]
  1. var a = 1;
  2. var d = a + 2;
  3. var b = "123";
  4. var c = d + b;
  5. MessageBox.Show(c.ToString());

Outputs:

3123

Which really makes it *look like* a dynamic type.

I've noticed that with dynamic -- it tends to be infectious. I've found it's useful for dealing with JSON and all that gooey webishness. smiley
Logged

Slow Down Music - Where I commit thought crimes...

Freedom is the right to be wrong, not the right to do wrong. - John Diefenbaker
f0dder
Charter Honorary Member
***
Posts: 8,774



[Well, THAT escalated quickly!]

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #6 on: September 14, 2011, 02:35:26 PM »

C# allows dynamic typing, but I'll be damned if I'll use it if I can at all avoid it. (dynamic and var)
'var' is not dynamic typing, it's used for static type inference which is super useful for DRY reasons.

'dynamic' is something to be very careful about - it tends to ripple out if you start using it.
I stand corrected. smiley

But close enough. When you look at it, var looks like a dynamic type. e.g. var acme = "Rocket Skates"; vs. var acyou = 500;
Sure, it does look like dynamic types at first, but the distinction is super-important. I personally loathe dynamic typing, but I'm a big fan of type inference, as it makes my life easier without giving up static typed goodness.

I'm not using it everywhere, though - I don't use 'var' when dealing with simple built-in types, and whether to use it when assigning a variable to a method return value isn't always clear-cut either. The goal to strive for is reducing unnecessary clutter, while not adding ambiguity; remove noise so you can focus on the important parts.

Your strings and numbers" samples show that implicit type conversions and operator overloading isn't always a good idea - and, especially since C# has such nice string formatting, it int-to-string conversion should IMHO have been explicit.

I've noticed that with dynamic -- it tends to be infectious. I've found it's useful for dealing with JSON and all that gooey webishness. smiley
Can't get by just with anonymous types? smiley
Logged

- carpe noctem
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.043s | Server load: 0.03 ]