The Artima Developer Community
Sponsored Link

Agile Buzz Forum
C# 3.0

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
C# 3.0 Posted: Mar 9, 2006 5:35 PM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: C# 3.0
Feed Title: Travis Griggs - Blog
Feed URL: http://www.cincomsmalltalk.com/rssBlog/travis-rss.xml
Feed Description: This TAG Line is Extra
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Travis Griggs - Blog

Advertisement

Following various diggdot.us links, I was amused by this post about new language features in C# 3.0.

First of all, I'm amused that people continually get more excited about language feature creep than better libraries using the language. It's always "bolt some more syntax on."

The first thing to get excited about it is the "i don't know what my variable type is/i'm too lazy to type the var type" feature. If you declare a variable and assign it a type that the compiler can figure out because you put the literal expression right after that, you can use var. Apparently it's a whole lot easier than "string". And "int". Ergonomic studies probably show that the 3 character sequence var is easier to type than int. The comments rant back and forth about this "feature." My favorite example is this one:

for (var i = 0; i < 2147483648; i++)
You don't have to know that you could/should use an int64 instead of an int32. Wow. My excitement bubbleth over. I wonder if it deals with:
for (var i = 0; i < 2147483647; i+=3)
The interested student can figure out what's going to go wrong with that if it get's excited and uses int32 there. So, I think this var thing is pretty overrated basically. I'm of course not used to declaring types at all. Why can't the compiler just be smart enough to "assume" the "var" when I don't put anything there? Of course, you can only use this var thing in certain situations. If the compiler can't figure it out for you, you have to figure it out for you. Why don't people see where this kind of inconsistency just adds more confusion than it might offset.

Object initializers are another new and nifty feature. Basically put the class name, followed by a paren list of varname/value pairs and you get an object with that. The Smalltalk code to do that without extending the language is:

Object class>>properties: aDictionary
  | result |
  result := self basicNew.
  aDictionary keysAndValuesDo: [:key :value |
    result instVarAt: (self instVarIndexFor: key) put: value].
  ^result

Variations that use arrays and or optionally send messages ad nauseum. It's all in the messages. No new language feature necessary.

Anonymous types are next. Apparently, they're missing ad hoc structure defs. What to say. I'm sorry. This kind of stuff just isn't a big deal for us. I could make a proxy object that would do something like what it does. Again, it's all in the objects and messages. No syntax necessary.

And finally extension methods. Now this is a handy language feature. One of these was worthwhile. It should have been in version 0.0 of the language spec. Of course, Smalltalk and Objective-C have both been doing this for a while. So it's just more catchup.

Read: C# 3.0

Topic: Sci Friday wrapping for the year Previous Topic   Next Topic Topic: Looking for DSM

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use