1 / 41

Trends in Programming Languages

Trends in Programming Languages. Bart J.F. De Smet blogs.bartdesmet.net/bart bartde@microsoft.com . The Good Old Days?. Looking at the Past…. More Control Too low-level. Richer Runtimes Ease of Use. Hardware Trends. What about SSD?. x 100,000. What about NUMA?. x 10,000.

thane
Télécharger la présentation

Trends in Programming Languages

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Trends inProgramming Languages Bart J.F. De Smet blogs.bartdesmet.net/bart bartde@microsoft.com

  2. The Good Old Days?

  3. Looking at the Past… More Control Too low-level Richer Runtimes Ease of Use

  4. Hardware Trends What aboutSSD? x 100,000 What about NUMA? x 10,000 What aboutmany-core? x 1,000

  5. Aim Higher or Lower? Higher Levels of Abstraction • Richer Frameworks (e.g. .NET) • Language Innovation (e.g. C#) • Improved Expressiveness (e.g. FP) Can we avoid the disconnect? Low-Level Plumbing • Machine Architectures (e.g. ARM) • Power Consumption (e.g. phone) • Rich Capabilities (e.g. GPU)

  6. Two Stories on Bridging the Gaps Canvas C# and VB vNext Rocket Science? HTML 5 Task Parallel Library User System Internet Explorer 9 Rendering Common Language Runtime DirectX APIs Win32 APIs Established Reality! Time GPU Acceleration Asynchronous I/O

  7. Software Trends But will it blend?

  8. Increasing the level of abstraction Functional Programming

  9. A Different Approach Theory of Computation (Lambda Calculus, Alonzo Church) LISP Heritage CLU ML Miranda Scheme SASL Haskell Modula SmallTalk C C# Java Basic C++ Reality of Hardware (Memory, John Von Neumann) Fortran Heritage

  10. Lambda Expressions are All Around Us C# var res = xs.Where(x => x % 2 == 0); Visual Basic Dim res = xs.Where(Function(x) x Mod 2 = 0) F# let res = xs |> Seq.filter (fun x -> x % 2 = 0); var res = xs.filter(function(x) { return x % 2 == 0; }); JavaScript auto res = find_if(xs.begin(), xs.end(), [] (int i) { return x % 2 == 0; }); C++0x

  11. Have We Forgotten About Math? x = x + 1

  12. Defining Functions No notion of time

  13. Aargh… Those Pesky Side-Effects Immutability is the default Binds name to value Equality != assignment letequal = sin(0.0) = sin(0.0) letsinzero = sin(0.0)insinzero = sinzero Not a pure function… letequal = DateTime.Now = DateTime.Now letnow= DateTime.Nowin now = now

  14. But We Like Side-Effects So Much… // C# syntax static void Main(string[] args) { Console.WriteLine(args.Length); } (* F# syntax *) letmain(args:stringarray) = printf"%d\n"args.Length valmain:stringarray->unit I/O is a side-effect Hmm… monads In Haskell: IO unit Philip Wadler

  15. Programming in a Functional Style But what’s a function? First class functions Referentialtransparency Immutabledata FP Essence Niceties Typeinference Patternmatching Algebraic data types

  16. F# – A General-Purpose Functional Style Language F#

  17. Functional Programming Programming with Functions

  18. An Exercise In Purity? Purify yourselves, sinners! $$$ Where doesF# fit? Erik Meijer Simon Peyton-Jones $ Pure Impure

  19. The world isn’t always typed DYNAMIC Programming

  20. Dynamic vs. Static JSON Python REST JavaScript Ruby

  21. It’s a Dynamic World • Trend on non-schematized data • Remember WSDL, SOAP, XSD? • How about REST, JSON? • The next browser war • JavaScript on the web • Optimized scripting engines • Towards metaprogramming? • Ruby community • Code as data

  22. Dynamic vs. Static a i Type tag 32-bit value Type tag 32-bit value Fetch next byte code Call generic add handler 32-bit value 32-bit value Load type tag of a Load type tag of i Select add operation Load value of a Load value of i int int 10-100 X var a = 0;for (vari = 0; i < n; i++){a = a + i;} ADD instruction Check for overflow Store type tag of result Store value of result Loop back to dispatcher

  23. Dynamic VM Advances Interpreter Inline Caching Type Specialization Hidden Classes Tracing Interpretation JIT Compiler DynamicTyping DynamicTyping AdaptiveJIT Compiler 10-100 X 3-10 X 2-3 X Operation Operation Operation DynamicTyping DynamicTyping Interpretation

  24. .NET Dynamic Programming IronPython IronRuby C# VB.NET Others… Dynamic Language Runtime Expression Trees Dynamic Dispatch Call Site Caching ObjectBinder JavaScriptBinder PythonBinder RubyBinder COMBinder

  25. Dynamic Code and Data

  26. Compiler as a Service Meta-programming Read-Eval-Print Loop Class public Foo Language Object Model Field DSL Embedding private X string Compiler Compiler SourceFile .NET Assembly Source code Source code Source code Source code

  27. Dealing with hardware reality CONCURRENT Programming

  28. Taming the Concurrency Monster Can you keep the cores busy? Gordon Moore

  29. Concurrent programming with shared state… …can be hard

  30. Parallel Extensions in .NET 4 Parallel LINQ Task Parallel Library Coordination Data Structures Operating System Threads … CPU CPU CPU CPU

  31. Task Parallel Library in .NET 4 Task<T> PLINQ Continuations CDS, etc.

  32. Expressing Parallelism – A Library Approach int[,] Multiply(int[,] m1, int[,] m2) { int m, n, o; // Left as an exercise var res = newint[m, o]; for (int i = 0; i < m; i++) { for (int j = 0; j < o; j++) { res[i, j] = 0; for (int k = 0; k < n; k++) { res[i, j] += m1[i, k] * m2[k, j]; } } } return res; } Embarrassingly Parallel Lambda expressions to the rescue int[,] Multiply(int[,] m1, int[,] m2) { int m, n, o; // Left as an exercise var res = newint[m, o]; Parallel.For(0, m, i => { for (int j = 0; j < o; j++) { res[i, j] = 0; for (int k = 0; k < n; k++) { res[i, j] += m1[i, k] * m2[k, j]; } } }); return res; }

  33. Expressing Parallelism – A Library Approach Natural Data Parallelism varsource = Enumerable.Range(1, 10000); var res = from x in source where f(x) select g(x); foreach (var x in res) Process(x); Extension methods to the rescue varsource = Enumerable.Range(1, 10000); var res = from x insource.AsParallel() where f(x) select g(x); res.ForAll(x => { Process(x); });

  34. Asynchronous Programming – Low Hanging Fruit? Reactive Events triggered Packetreceived Your Program Here I/O completed Callbacks Events

  35. Asynchronous Programming Simplified • Don’t block! UI programming, Windows Phone 7, Silverlight • Latency ahead! Dealing with networks, services, cloud A blocking call! Callback twists yourcode inside out vardata = DownloadData(…); ProcessData(data); vardata = DownloadDataAsync(…, data => { ProcessData(data); }); Visual StudioAsync CTP No longer blocking! vardata = awaitDownloadDataAsync(…); ProcessData(data);

  36. Using the TPL and the Async CTP

  37. Potential Language Constructs

  38. Exciting Times

  39. Stay up to date with MSDN Belux • Register for our newsletters and stay up to date:http://www.msdn-newsletters.be • Technical updates • Event announcements and registration • Top downloads • Follow our bloghttp://blogs.msdn.com/belux • Join us on Facebookhttp://www.facebook.com/msdnbehttp://www.facebook.com/msdnbelux • LinkedIn: http://linkd.in/msdnbelux/ • Twitter: @msdnbelux DownloadMSDN/TechNet Desktop Gadgethttp://bit.ly/msdntngadget

  40. TechDays 2011 On-Demand • Watchthis session on-demand via Channel9http://channel9.msdn.com/belux • Download to your favorite MP3 or video player • Get access to slides and recommended resources by the speakers

  41. THANK YOU

More Related