![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jul 2006
Location: England
Posts: 43
Rep Power: 0
![]() |
Whats C# 3.0 all about?
I was looking at C# 3.0(not .net 3.0) today and its quite interesting what they have lined up for the language in the future. Lambda expression, extension methods, type inferencing and LINQ.
Lambda expressions look interesting, but i dont have much knowledge of what they are about and what you would use them for. I think they are based of lambda calculus, which to generalise grately is just another way of expressing a mathamatical function. Extension methods are ways of extending a class which you dont have the source code for and dont want to make a new class inheriting the one you want to extend. Kind of usefull for adding one or two methods to a class. Maybe this would be confusing, for example in a program someone could add a method to string(or whatever) and then you have to go hunt it down to see what it does. Type inferencing looks like it could be abused. As you can say: var i = 90;
var s = "Hello World"; //C# now
List<string> s = new List<string>();
//C# 3.0
var s = new List<string>(); var s = new List<string>();
s.Add("Hello");
s.Add("World");
...
var t = s;
//now you have to go find out what type s is to know what type t is.LINQ is Language Integrated Query. Its a way of accessing data in an object oriented and typed checked way. It looks like a very good idea but to make it work it requires all the other features described to be added. I know this is quite brief and not very technical. I was wondering what other people thought about these proposed new features and if they are really needed or just add bloat to a very good language. Is this the future in programming getting more declaritive(put simply, you say what you want and the compiler goes and figures out how to do it) and the c# design team are just following the trend(if there is one). Language design is one of my interests, i find it interesting how different languages work and why some features work well and some dont. If you think im slightly insane then i agree with you lol. |
|
|
|
|
|
#2 |
|
Expert Programmer
|
I see your point, and I don't like it either. Seems sloppy. That's why I left VB6 and came to C#. Now I come to C#, and it gets sloppy? Come on people...
I guess as long as we can still do it the old way, it will be alright. I'll probably look into C# 3.0 later and post back. |
|
|
|
|
|
#3 | ||||
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
In C# 2.0: csharp Syntax (Toggle Plain Text)
csharp Syntax (Toggle Plain Text)
Quote:
Quote:
This is a phrase that is so basic as to be almost self evident. You will only write a particular line of code once, whilst that line of code may be read many times, by many different people. This reminded me of another phrase that has stuck in my mind: "Code is more easily written than it is read." This far from self evident, and I'm not sure I agree with it entirely, but it does make a lot of sense. Reading another person's code is hard. If it wasn't, then we wouldn't have to comment our code. Whether reading is harder than writing is debatable, but understanding what a piece of code does is clearly not a trivial matter. Given all this, one comes to the conclusion that readability is rather important. A factor that affects readability is how much unnecessary information there is in the code. For example, compare C# 2.0: csharp Syntax (Toggle Plain Text)
csharp Syntax (Toggle Plain Text)
On the other side of the coin, sometimes code doesn't give enough necessary information. Compare C# 2.0: csharp Syntax (Toggle Plain Text)
csharp Syntax (Toggle Plain Text)
Quote:
![]() |
||||
|
|
|
|
|
#4 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
The type inferencing can certainly be abused...like other constructs, it will just have to have some style guidlines. Such as only using it when the type is actually in the rhand, rather than another variable.
LINQ should be wildly useful. It should eliminate a lot of loops and conditions for processing data, such as finding an item in a list that meets certain criteria. The type inferencing with lamdba expressions looks like a nightmare...
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 Last edited by Dameon; Jul 22nd, 2006 at 1:53 PM. |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Jul 2006
Location: England
Posts: 43
Rep Power: 0
![]() |
Thanks Arevos, i always like to see what other people think and you have explained alot of the stuff i was not completely sure about.
I can see that lambda expressions are quite a nice feature now and im sure i will use them if they ended up in the final specification for c# 3.0. Though im still unsure that type inferencing is worth the hastle that it could create if it is badly used. I agree that writing code is easier than reading it, but i enjoy looking at how other poeple solve a problem especially if it is different from the way i solved it. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|