Languages
Languages
This post explains how to get the CSharpCodeProvider compile C# 3.0 code.
Here's the magic line:
var csc = new CSharpCodeProvider(new Dictionary() { { "CompilerVersion", "v3.5" } });
One of the questions I've had about the new lambda expression syntax in C# 3.0 is how to pronounce it when reading code. (If you are wondering what lambda expressions are, Scott Guthrie has recently written a good introduction.) I've been using "begets" as a humorous interim term! Eric White, the XLink technical writer at Microsoft, in his post on lambda expressions suggests "such that" for predicate lambda expressions. He says that some people use "goes to" in general. Hey, I guess begets isn't that bad after all!
If your interested in the history of Lambda expressions and the evolution of C# 3.0, The June 2007 issue of MSDN Magazine has a nice article that explains how the LINQ project influenced the development of lambda expressions and other features. If you want the inside track, read Matt Warren's posting IQueryable's Deep Dark Secret.
RIA is currently populated by AJAX and Flash/Flex. Silverlight is an interesting newcomer because it provides one designer/developer experience for the all the UI offerings: Desktop, RIA, Mobile. And you can use your language of choice in a rich Design/Development experience.
Sun is attempting to get in to the RIA space with, in my opinion, a weak offering. JavaFX. Mary Jo Foly, of Microsoft Watch, I think has the most succinct analysis:
Sun's JavaFX fannouncement elt more to me like Sun's to reset Java and get the platform back on track than to break new ground.
This Q&A with a member the TWITTER team shows that Ruby on Rails (RoR) is not, at this point, a scalable technology. The language itself is show (can be solved) and the reflection based idioms are also slow (could be solved with machine code generation, I suppose) and it's ability to scale out has limitations.
Microsoft is building a CLR-based Ruby implementation, IronRuby, which should be a lot quicker than current implementations. But this damning comment from the Q&A makes one wonder whether an enterprise should bet on this technology:
Once you hit a certain threshold of
traffic, either you need to strip out all the costly neat stuff that
Rails does for you (RJS, ActiveRecord, ActiveSupport, etc.) or move
the slow parts of your application out of Rails, or both.
My immediate question on the news of the Microsoft/Novell Linux agreement was: does this cover Mono? It does! You can now safely deploy Mono applications without fear of patent police coming after you! Put that together with the news of a .NET Runtime kernel in WFP/E we can envision the reach of the CLR/CLI slowly beginning to expand beyond windows.
A few months back,
Kirk Evans and I were wondering out loud what Don Box might keep himself busy on now that he's conquered the Web stack. Given Don's communication on Workflow Foundation and continuations, I wondered if he might be working on moving the new threading model people in Microsoft Research had cooked up into the CLR and/or C#. It's interesting that Don
linked to a blog entry by CLR program manager Joe Duffy that
suggests just that. Don's entry doesn't really hint at it though. It would seem odd for WF itself to be pulled into the language.
Microsoft just release the proposed specification to C# 3.0. Topics:
- Implicitly typed local variables
- Extension methods
- Lambda expressions
- Object and collection initializers
- Anonymous types
- Implicitly typed arrays
- Query expressions
- Expression trees
Enjoy!
I've referenced info on the new Nullable<> type and new access guidelines. I haven't referenced the fact that Nullable<> is not used throughout the .NET 2.0 framework, especially for Windows Forms and SqlType. Bad, bad, bad. However they did fix some basic errors dealing with boxing and null. Kudos to the folks who burnt the midnight oil for our benefit.
Wesner Moise reads between the lines for us and gets to the root of the probable changes in C#. Including his other recent post on new features we have quite a list to chew on 'til the PDC.
- Dynamic typing (Chis and Don weren't just playing around, as I suspected. Ya gotta watch that Microsoftee "chatter") including:
- tuples
- implicit types
- lambda expressions
- extension methods
- expression trees
- Query support for XML and SQL via IQF
His other post on new features details a lot more that may appear in 3.0 or 4.0 including contracts (Can anyone say Eifel?). Concurrency features are not mentioned however.
But why wait for Orcas? Matt Warren explains C# 4.0 now (tongue in cheek).
Don Box's recent
post about a proposed Java Web Service tool,
Alpine, foreshadows further work in C-Omega. Is the great
O/X/R convergence really going to happen? On the same note,
Chris Anderson has been playing with IronPython and reflects on moving to dynamic type systems. Don's post hints at news about supporting dynamic typed languages at the PDC. Stay Tuned!
Microsoft BCL folks have announced that generics will be a required part of the CLS as of the .NET 2.0 release. This is huge news, not only for the many managed languages that must be updated to support generics, but also for the developer, who now has to deal with them in public APIs whether you like to or not. Coming from a C++ background where I used generics extensively, I'm “pickled tink”.
Brad Abrams suggests taking a good look at the Generics Design Guidelines. I do too!
On page 3 of a an eweek article about an OOPSLA roundtable discussion with Don Box, Anders Hejlsberg, and leads at Sun and IBM, Anders states that he's “spending a large portion of my time trying to figure out how to solve” “the enormous impedance mismatch between databases and enterprise programming languages.”
Now, it's possible that he's working on ObjectSpaces; but I think, rather, that he's looking at how to migrate features from C-Omega into C#.
Don has some funny comments about the discussion here.
Girish Bharadwaj posted some thoughtful comments concerning my posting C# Language Bigotry? No, Calculated Business Sense. I wanted to clarify some misconstuerage.
Girish mentioned Java as an alive and kicking language, something I've posted about before. I was thinking about mentioning that myself, but did not because I was focusing on the .NET stack. Why? The reason is that not only am I a technology architect at my company, I'm the .NET technology architect. We also have a Java architect with whom I get along famously. I am encouraged by a little language feature competition. I am not a “true believer” when it comes to language/platform and have recommended Java and worked with both J2EE and Axis myself in the past. However, when it comes to the .NET stack, everyone knows that Microsoft itself is committed to writing its core libraries in C# and links it very closely with the CLI. It is the scion of the runtime.
I am sad that Jay Kimble took offense at my preference of C# for core language development within my own organization. I was not intending that this ought to be the choice for all development organizations or that every developer ought to be a C# developer. Neither do I have the intention to push C# as the “true language” at my company. There are several pragmatic reasons and some strategic reasons to write a piece of software in VB.NET. I also feel that there are many excellent programmers who primarily write their code in VB.NET. You can write a .NET assembly with just as high a quality in VB.NET as you can in C#, no question. However, as I said, in my position, I need to take a long-range portfolio-driven approach to the code base, especially as it relates to long-lived, reusable, oft-referenced, and oft-maintained code. I feel the safer decision is to put my money where MS has put theirs for Framework code — and that would be squarely in the lap of C#.
I've been accused of language bigotry. I rather think I'm engaging in long range business planning in regards to my software assets.
Rather than compare language features and syntax (though you can do that here), I think someone in my position (enterprise technology architect) needs to look at things from a business and portfolio perspective. Here are some important factors from a planning perspective.
- C# is an international standard. While certainly not always a good thing (cf. XML Schema). An international standard whose innovation is efficiently managed by a for-profit entity (as I previously alluded) rather than a bloated bureaucracy is, indeed, a good thing.
- The Developer Tools Roadmap specifies that C# is intended for class library development and VB for RAD development.
- You are more statistically more likely to get high quality developers in the C# world than in the VB world. This is simply a corollary of the previous point. It is not a statement of what “should be” but of what “is”. Business decisions need to be based on pragmatic foresight and reality, not purist absolutes.
- C# has already been released on other platforms (Mono 1.0) and, therefore, has much greater potential for widespread adoption, not only by developers but also by platforms. For example the My namespace is Microsoft proprietary and does not have a great probability of being maintained outside of the MS VB team.
- C# has lead in the language extension arena. You don't see MSR or other research groups extending VB for new language ideas, for example. As mentioned in my previous post, the “Convergence” has already resulted in nullable types in C#; you don't see it in VB. Just look at the list of new features for VB 2005. Looks like a lot of catch-up to me. Again, this is a language/feature comparison, but rather a strategic long-range planning issue.
True, it all compiles down to MSIL, however, people don't code in MSIL and the longevity of the codebase is an important asset choice for a corporation. I think the issues presented above have bearing on the issue and point to a strong conclusion.
Here's an awesome demo of C-omega with Gavin Bierman of MSR UK. It shows SQL, XML, and XQuery built into a MSIL language. Very Nice! Best of all, the compiler preview is available for download and compiles down to MSIL like any other .NET language: You can write your favorite application in it if you want!
Gavin was asked whether C-omega would be making its way into the next C#. One thing to consider is that one feature, nullable types, have already made it in!
It also would be a good reason as to why MS has strategically chosen XQuery over XSLT.
Given Don Box's recent musing on “the impedance mismatch” which was previously championed by Dare Obasanjo, “The Great Convergence” does not look so far off.
By the way, this, to me, is probably the most important reason to switch to C# from VB.NET, etc. C# is a future language with international standardization muscle; the others are just legacy language reruns. Don't write new code, especially class library code, in them!
Now that Mono 1.0 has been released successfully, the cross-platform landscape is forever changed. What are our ximian friends at Novell working on now? They are shooting for a 1.2 release in February. Details here.
Focus is on:
- C# 2.1 implementation
- AMD64 JIT port.
- Visual Basic compiler.
- Improved IO-Layer and Internationalization framework.
- Gtk# improvement and GUI designer.
- Mono Debugger.
- Windows.Forms support.
- JIT performance work.
- Integration of patches that were too big to make it into the 1.0 release.
- Code Access Security Framework.
- Continued bug fixing of major and critical bugs.
I found a nice long gotdotnet message board thread on the new nullable C# syntax. Eric Gunnerson gets his hands dirty.
This was posted a couple days ago by Chris Sells, but it is not to be missed:
It turns out that the add-in model for Reflector 4.0 is so powerful that it enabled Denis Bauer to build an add-in that leverages the built-in R4 disassembler to disassembly an entire assembly into source code files. Very handy for curling up on a sunny afternoon with a chuck of source from your favorite assembly, a cigar and a single malt Scotch.
Being one that had to recover code this way when I accidentally deleted a source file, I'm glad this is now available! Don't delay! Get the goods here.
Anders Hejlsberg, et al., shared with the MVPs in April about extending the C# syntax to support nullable value types. In essence, int? maps to Nullable<System.Int32> just as int maps to System.Int32. They also introduce a ternary ?? operator such that x ?? 0 means (x != null) ? x : 0. Very interesting. They got some howls but I hope this goes through. It's a baby step to X# bliss. [Via Ted Neward on TheServerSide.NET]
Microsoft has shipped a beta for a tool that analyzes SQL Server objects,
Microsoft SQL Server Best Practices Analyser, to conformance to best practices, similar in concept to
FxCop for .NET code. [via
Chris Sells]