Sponsored Ad

Thursday, October 29, 2009

C# 4.0 goes dynamic

With C# 3.0 still so new that plenty of are only beginning to appreciate, let alone use, its new features it might seem premature to be discussing the next version of the most popular .NET language. Microsoft, however, has its designs for C# 4.0 well advanced, & the changes are so important that you might not recognise your favourite language after the upgrade. Now is the time to look over the horizon in the hope that finish users can influence the outcome.

The first thing to say is that C # has a special place in the panoply of. NET. When presented was essentially individual classes corresponding Windows developers with the expertise and the use of either VB or C + +. The division is clear as VB was easy to learn and easy to use but limited C, & + + was hard to imagine but could do nothing. You can even think of C + + as an object-oriented machine-independent assembly language if required, but VB is interpreted, well away from the machine building, was not so. Moreover, the distinction was also to take into account aesthetics - is disorderly and pragmatic VB and C + + pure logic. None of the courses of these characterizations is 100% true, are approximations to a true medium that is at least recognized by most developers, even if they had been discussing the fine details.

Not quite C++ nor VB

Currently they still have VB and C++ so where does C# fit in to today’s landscape? Again there is no absolute truth to be found, but a reasonable answer is that C# was originally designed to be an not as hard to use C++. It aspired to be more logical and cleaner, yet still easy (not as hard) to use. This ease of use not only derives from the language structure but from the simplicity of the Framework and the IDE (i.e. Visual Studio). The Framework simplifies everything by the simple act of dumping COM as a component object technology. The IDE makes generating a C# program much not as hard to generate than a C++ program basically by providing a drag-and-drop editor. User interface construction was seldom very complicated in C++, but equally its IDE support seldom rose much above the simple dialog box designer. (The fact that today you can use C++ as a standard .NET language complete with drag-and-drop interface designers is something of an anomaly that doesn’t fit in to the overall picture – a fact I and most other programmers pick to ignore in favour of C#.)

Thus C # is an "easy" to C + + with all its advantages? Not really. The problem is that C # is not as powerful as C + + and this is presented as a design decision. C # creates security, applications management and as such, simply can not provide the programmer with all hazardous installations of C + + pointers and direct memory access. (Of course, if you go out of their way to put them into practice, many of the dangerous mechanisms in C + + can be yours in C #, but that's another story). The result is that C # programmers migrating to C + + can be a little disappointed that his dangerous tools have been confiscated, but for the Visual Basic programmer who looks like a very sharp knife indeed. The only drawback to the programmer of VB migration is that C # is not as easy to use. It's a little logic and far too restrictive. They tend to insist on doing things "right."

You can not wriggle out of the object-oriented programming in C # and make this right is a big learning task. However, after the ideas are learned and object-oriented programming in C # seems natural, most VB programmers still can not understand why C # is strongly typed. Strong typing is designed to make it possible to detect stupid programming errors at design time rather than run time. The argument goes that automatically picks up any attempt to store apples in a container designed to store oranges. This sounds good and there is plenty of logic in the argument, but when a Visual Basic first encounter the problem like this:

string i;
i = 1;

Of course you can not assign an integer to a string - that's just dumb. However, a user of Visual Basic (or any user of a dynamic language) is far from being stupid and wonder why they have to go to so much trouble to make explicit type conversion when they have been accustomed to the compiler / Language is not all work for them. In short a dynamic language, does not care much for writing and attempts to make things "just work".
A dynamic language is not strongly typed because the write data is considered a matter of the mechanics of low-level hardware. An integer is just a way to store a number that makes some types of simple arithmetic, but are more difficult. In a dynamic language makes data that was said and if you say you do not reasonable, then an exception should be handled properly to create a solid program.

0 comments:

Post a Comment

Sponsored Ad

Website Update

Followers