Archive for October 27th, 2008

The Future of C#

No Comments »

Live from the session:

Will cleanup later:

evolution

1.0 – 2.0 – 3.0

impedence mismatch – programming languages and data

LINQ

Trends: Declarative / Dynamic / Concurrent

Declarative Programming

Imperative –> Declarative
How           -    What

 

Dynamic Languages

* Simple and succinct
* Implicitly typed
* Meta-programming
* No compilation

Static Languages

* Robust
* …

Concurrency

The elephant in the room
Moores law has stopped working
Not one single silver bullet

C# 4.0

Dynamic programming

Dynamically types objects
Optional and named parameters
Improved COM interoperability
Co- and Contra-variance

Dynamic Language Runtime
* Expression trees
* Dynamic dispatch
* Call Site Caching

IronPython & IronRuby today

Tomorrow: C# and VB.NET and others…

Object Binder: .NET
JavaScript Binder: Silverlight
Python Binder: python
Ruby Binder: Ruby
COM Binder: Office

Calculator calc = GetCalculator();
int sum = calc.Add(10, 20);

object calc = GetCalculator();
Type calcType = calc.GetType();
object res = calcTYpe.InvokeMember(…);
int sum = Convert.ToInt(res);

C# 4.0:
dynamic
calc = GetCalculator();
int sum = calc.Add(10, 20);

=   : dynamic conversion
.Add  : Dynamic method invocation

dynamic x = 1;
dynamic y = “Hello”;
dynamic z = new List<int>  {1, 2, 3, 4};

When operand(s) are dynamic

* Member selection deferred to run-time
* At run-time, actual type(s) substituted for dynamic
*
Static result type of operation is dynamic

IDynamicObject ( duck typing)

optional and named parameters:

OpenTextFile(string path, Encoding encoding = null, bool detectEncoding = true, bufferSize = 1024);

OpenTextFile(….);

Improved COM interop

No more ref missing…  doc.SaveAs(“Test.docx”);

Co- and Contra-variance

string[] strings = GetStringArray();
Process(strings);
void Process(object[] objects) { … }

C# 4.0 supports safe co- and contra-variance.

public interface IEnumerable<out T>
{

}

out = Co-variant Output positions only

public IComparer<in T>
{

}

in = Contra-variant input positions only

Variance in C#4.0

*Supported for interface and delegate types
* “Statically checked definition-site variance”
*Value types are always invariant
** IEnumerable<int> is not IEnumerable<object>
** Similar to existing rules for arrays
* ref and out parameters need invariant types

Compiler as a Service

Source files –> Compiler –> .NET Assembly

* Meta-programming
* Read-Eval-Print loop
* Language Object Model
* DSL Embedding

CSharpEvaluator ev = new CSharpEvaluator();
ev.Usings.Add(“System”);

[Damn, all this is so cool]
ev.Eval(“for (int i = 0; i < 10; i++) Console.WriteLine(i * i)”);


Microsoft Windows Azure revealed!

No Comments »

P1020458

P1020459 Microsoft’s new services platform
US first – rest of the world later
CTP now
fraction of functionality now