• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Ft10 de smet
 

Ft10 de smet

on

  • 1,023 views

 

Statistics

Views

Total Views
1,023
Views on SlideShare
1,023
Embed Views
0

Actions

Likes
0
Downloads
9
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Ft10 de smet Ft10 de smet Presentation Transcript

    • LINQ, Take TwoRealizing the LINQ to Everything Dream
      Bart J.F. De Smet
      Software Development Engineer
      Microsoft Corporation
    • What’s LINQ?A historical perspective
      5 years ago
      Little recent innovation
      Where’s the cloud?
      Censored
    • Essential LINQLanguage Integrated Monads
      Why?
      What?
      How?
    • Could there be more?
      Essential LINQThe monadic Bind operator
      IEnumerable<T>
      IQueryable<T>
      new[]{ 42 }
      IEnumerable<T> SelectMany<T, R>(this IEnumerable<T> source,Func<T, IEnumerable<R>> selector)
      SelectMany
      Also see www.codeplex.com/LINQSQO for “Project MinLINQ”
    • Essential LINQMaybe monad (for fun and no profit)
      Null-propagating dot
      string s = name?.ToUpper();
      One single library function suffices
      Syntactic sugar
      name.SelectMany( _ => _.ToUpper(),
      s => s)
      from _ in name
      from s in _.ToUpper()
      select s
      Compiler
    • Essential LINQ
      Bart J.F. De Smet
      Software Development Engineer
      Cloud Programmability Team
      demo
    • Query Providers RevisitedWhy do we have IQueryable<T>?
      Does it really have to be a runtime check?
      Implements
      IQueryable<T>
      varsrc = newQueryProvider<Product>();
      varres = from p insrc
      wherep.Price > 100m
      groupp byp.Category;
      foreach(var p in res)
      Console.WriteLine(p);
      Compiles fine
    • Query Providers RevisitedLeveraging the query pattern
      varres = from p insrc
      wherep.Price > 100m
      groupp byp.Category;
      Syntactic sugar
      varres = src
      .Where(p => p.Price> 100m)
      .GroupBy(p => p.Category);
      No GroupBy“edge”
      Can be instance methods
      Select
      Where
      Source<T>
      Filtered<T>
      Projected<T>
    • Query Providers RevisitedTaking it one step further
      Recipe
      Method overloads
      Type state machine
      Operator overloads
      varres = fromtweet intwitter
      where tweet.
      == “Bart”
      From
      About
      From
      Location
      From
      == “LINQ”
      where tweet.
      About
      About
      About
      Location
      select tweet;
      Query “learns”
      From operator overloading
      “Has a” type
      classTwitter
      {
      publicTwitterByFromWhere(Func<TweetAboutFromLoc, FilterFrom> filter);
      // Other filter methods
      }
      classTwitterByFrom
      {
      publicTwitterByAboutFromWhere(Func<TweetAboutLoc, FilterAbout> filter);
      // Other filter methods
      // Fields with current filters
      }
      Custom syntax trees
    • Query Providers Revisited
      Bart J.F. De Smet
      Software Development Engineer
      Cloud Programmability Team
      demo
    • Asynchronous Data Access
      (𝑓 ◦ 𝑔)(𝑥) = 𝑓(𝑔(𝑥))
       
      Way simpler with Rx
      Rx is a library for composing asynchronous and event-basedprograms using observable collections.
      Queries! LINQ!
      Download at MSDN DevLabs
      • .NET 3.5 SP1 and 4.0, Silverlight 3 and 4
      • JavaScript (RxJS)
      • XNA 3.1 for XBOX and Zune
      • Windows Phone 7
    • Asynchronous Data AccessPush-based data retrieval
      Application
      Got next?
      MoveNext
      Interactive
      Reactive
      OnNext
      Have next!
      Environment
      IObservable<T>
      IObserver<T>
      IEnumerable<T>
      IEnumerator<T>
    • Asynchronous Data AccessEssential interfaces
      interfaceIObservable<outT>
      {
      IDisposableSubscribe(IObserver<T> observer);}
      interfaceIObserver<in T>
      {
      voidOnNext(T value);
      voidOnError(Exception ex);
      voidOnCompleted();
      }
      Both interfaces ship in the .NET 4 BCL
    • IQbservable<T>
      LINQ to WMI Events
      How?
      ToQbservable
      Translatable
      (Expression trees)
      IQueryable<T>
      LINQ to SQL
      ToQueryable
      LINQ to *.*
      AsObservable
      Homo-iconic
      AsEnumerable
      AsQbservable
      AsQueryable
      ToObservable
      IEnumerable<T>
      LINQ to Objects
      IObservable<T>
      LINQ to Events
      Fixed
      (MSIL)
      ToEnumerable
      Pull(interactive)
      Push
      (reactive)
      What?
      Duality
      Concurrency(IScheduler)
      Where?
      Message loops
      Distributed
      Worker pools
      Threads
    • IObservable<T>
      Asynchronous Data AccessIQbservable<T>
      interfaceIQbservable<outT> : IObservable<T>
      {
      ExpressionExpression { get; }
      TypeElementType { get; }
      IQbservableProvider Provider { get; }
      }
      interfaceIQbservableProvider
      {
      IQbservable<R> CreateQuery<R>(Expression expression);
      }
      We welcome semantic discussions.
      Extended role for some operators
      No Execute method
    • LINQ to WMI Events (WQL)
      Bart J.F. De Smet
      Software Development Engineer
      Cloud Programmability Team
      demo
    • Asynchronous Data AccessC# 5.0 and VB 11.0 “await”
      One versus many?
      IObservable<T> interface – many results
      Task<T> concrete class – one result
      Task<T> based language feature
      Rx bridge by implementing the “await pattern”
      IAsyncEnumerable<T>
    • Asynchronous Bridge for C# and VB “await”
      Bart J.F. De Smet
      Software Development Engineer
      Cloud Programmability Team
      announcing
    • Where execution happensIScheduler interface
      System.Concurrencyin System.CoreEx
      Introduction of concurrency
      interfaceIScheduler
      {
      DateTimeOffsetNow { get; }
      IDisposable Schedule(Action action);
      IDisposable Schedule(Actionaction, TimeSpandueTime);}
      ToObservable
      IObservable<T>
      IEnumerable<T>
      ToEnumerable
      Synchronous
      Asynchronous
    • Where execution happensIScheduler specifies “where”
      Imported TextBoxTextChangedevent
      var res = from word ininput.DistinctUntilChanged()
      .Throttle(TimeSpan.FromSeconds(0.5))
      from words in lookup(word)
      select words;
      Asynchronous web service call
      Indicates where things run
      Use of scheduler to synchronize
      res.Subscribe(words => {
      lst.Items.Clear();
      lst.Items.AddRange((fromwordinwords
      selectword.Word).ToArray());});
      res.ObserveOn(newControlScheduler(frm)).Subscribe(words => {
      lst.Items.Clear();
      lst.Items.AddRange((fromwordinwords
      selectword.Word).ToArray());});
    • Where execution happensIScheduler parameterization
      Baked in notion of “where”?
      Entry-point for the schema
      Custom schedulers could be very rich (e.g. server farm)
      varctx = new NorthwindDataContext();
      var res = from product inctx.Products
      whereproduct.Price > 100m
      selectproduct.Name;
      Decoupled “what” from “where”
      foreach(varproduct inres.RemoteOn(newSqlScheduler(“server”)))
      // Process product
    • Where execution happensExpression tree remoting
      Rx .NET
      fromtickerinstocks
      whereticker.Symbol == “MSFT”
      selectticker.Quote
      Observable data source
      JSON serializer
      Retargeting to AJAX
      RxJS
      stocks
      .Where(function (t) { returnt.Symbol == “MSFT”; })
      .Select(function (t) { returnt.Quote; })
    • Remoting of Query Operators
      Bart J.F. De Smet
      Software Development Engineer
      Cloud Programmability Team
      demo
    • LINQ to the unexpectedConstraint solving
      Non-persistent
      Model[
      Decisions[Reals, SA, VZ],
      Goals[
      Minimize[20 * SA + 15 * VZ]
      ],
      Constraints[
      C1 -> 0.3 * SA + 0.4 * VZ >= 2000,
      C2 -> 0.4 * SA + 0.2 * VZ >= 1500,
      C3 -> 0.2 * SA + 0.3 * VZ >= 500,
      C4 -> SA <= 9000,
      C5 -> VZ <= 6000,
      C6 -> SA >= 0,
      C7 -> VZ >= 0
      ]
      ]
      fromminctx.CreateModel(new {
      vz = default(double),
      sa = default(double)
      })
      where 0.3 * m.sa + 0.4 * m.vz >= 2000
      && 0.4 * m.sa + 0.2 * m.vz >= 1500
      && 0.2 * m.sa + 0.3 * m.vz >= 500
      where 0 <= m.sa && m.sa <= 9000
      && 0 <= m.vz && m.vz <= 6000
      orderby 20 * m.sa + 15 * m.vz
      selectm
      Cost / barrel
      Refinement %
      Max # barrels
      Min # barrels
      To compute call Solve
    • LINQ to the unexpectedJoining with reactive sources
      Observabledata sources
      fromcostSAinGetPriceMonitor("SA")
      fromcostVZinGetPriceMonitor("VZ")
      fromminctx.CreateModel(new { vz = default(double),
      sa = default(double) })
      where0.3 * m.sa + 0.4 * m.vz >= 2000
      && 0.4 * m.sa + 0.2 * m.vz >= 1500
      && 0.2 * m.sa + 0.3 * m.vz >= 500
      where0 <= m.sa && m.sa <= 9000
      && 0 <= m.vz && m.vz <= 6000
      orderbycostSA* m.sa + costVZ* m.vz
      selectm
      SelectMany
      Subscribe here!
      Parametersto decision
    • Theorem Solving using Z3
      Bart J.F. De Smet
      Software Development Engineer
      Cloud Programmability Team
      demo
    • What’s LINQ?A futuristic perspective
      Next 5 years
      Scheduler
      Remoting
      Solvers
      Rx and Ix are here!
      Toolkits
      Async
      Censored
    • © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
      The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.