Bindings, Platforms, and Innovation
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
Tracking change and innovation in the enterprise software development community
Posted by Jonathan Allen on May 14, 2007 11:34 AM
When VB.NET and C# were first released, they were often thought of as the same language with a different syntax and minor differences. As time goes on, these differences are becoming more pronounced. For example, their treatment of anonymous types is worlds apart.
In order to support data structures like hash tables and query operations like grouping, anonymous types created by LINQ must provide stable hash codes. Hash codes are normally created from the fields in the object.
The early versions of anonymous types were mutable. Or in other words, the values contained by the object could be altered. Changing these values would change the hash code, which would in turn break any hash table or dictionary that the object happened to be stored in.
Taking the direct route, the C# team made anonymous types immutable. If the object cannot be altered, then the hash code will never change either. The usually rules for immutable types were put into place such as no default constructors and only getters for properties.
The VB team was not so willing to give up the ability to modify anonymous classes. Paul Vick writes
In looking at this problem, though, we didn't want to throw the baby out with the bathwater. Anonymous types are somewhat limited at the moment because they cannot be named, but you can use late binding to work with them even outside of the context in which they were declared. And future features that we're interested in exploring, such as nominal anonymous types and dynamic interfaces, may make anonymous types even more useful. As such, it seemed too drastic to simply make them immutable, especially because this would be a one-way decision--once they were immutable, compatibility would make it extremely difficult to make them mutable again in the future if it become more desirable to do so.
They choose a solution that is more complex, but also gives the developer more flexibility. When creating anonymous classes, programmers can use the modifier "Key" to indicate which fields are immutable. In addition to making the property read-only, the hash code function will only use these 'key' fields to generate the hash code. As a result, the hash codes are guaranteed to be stable. Fields will also be automatically marked as Key by the compiler when used in joins and group by clauses.
The reason VB and C# can use different implementations is that anonymous types are a compiler feature. The CLR itself doesn't have any notion of anonymous types and sees them as normal classes with automatically generated names.
Like much of the VB syntax, this functionality is expected to not be available until Orcas Beta 2.
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.
This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.
This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.
This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.
After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.
IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.
Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.
No comments
Watch Thread Reply