TeSLa researchproduct. Why The Visual Basic Imports SySTem.STriNg Module Demo Public Sub Main() Dim S = Join(", ", { "Hello", "World"}) End Sub.

Slides:



Advertisements
Similar presentations
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
Advertisements

The Microsoft Technical Roadshow 2007 Language Enhancements and LINQ Daniel Moth Developer & Platform Group Microsoft Ltd
CH4.1 Type Checking Md. Fahim Computer Engineering Department Jamia Millia Islamia (A Central University) New Delhi –
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 12 Introduction to ASP.NET.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 10.
LINQ and Collections An introduction to LINQ and Collections.
1 Programming Languages (CS 550) Mini Language Interpreter Jeremy R. Johnson.
Semantic Analysis Chapter 6. Two Flavors  Static (done during compile time) –C –Ada  Dynamic (done during run time) –LISP –Smalltalk  Optimization.
Programming Languages and Paradigms The C Programming Language.
Extension Methods, Anonymous Types LINQ Query Keywords, Lambda Expressions Svetlin Nakov Telerik Corporation
Copyright © 2012 Pearson Education, Inc. Chapter 9 Delegates and Events.
.NET 3.5 – Mysteries. NetFx Evolution NetFx 1.0 C# 1.0, VB 7.0, VS.NET NetFx 1.1 C# 1.1, VB 7.1, VS 2003 NetFx 2.0 C# 2.0, VB 8.0, VS 2005 NetFx 3.0 C#
C# and LINQ Yuan Yu Microsoft Research Silicon Valley.
Compiler Construction
C# 3.0 & LINQ Raimond Brookman – IT Architect
LINQ: Language-Integrated Queries (To be included in C # 3.0) Technology developed by Anders Hejlsberg & friends at Microsoft (2005) Presented by Tal Cohen.
C# 3.0 Tom Roeder CS fa. Version 3 From PDC 2005 preview compiler available LINQ: language-integrated query High level points: adds native query.
1 Type Type system for a programming language = –set of types AND – rules that specify how a typed program is allowed to behave Why? –to generate better.
2.3 Cool features in C# academy.zariba.com 1. Lecture Content 1.Extension Methods 2.Anonymous Types 3.Delegates 4.Action and Func 5.Events 6.Lambda Expressions.
A tour of new features introducing LINQ. Agenda of LINQ Presentation We have features for every step of the way LINQ Fundamentals Anonymous Functions/Lambda.
XML files (with LINQ). Introduction to LINQ ( Language Integrated Query ) C#’s new LINQ capabilities allow you to write query expressions that retrieve.
LINQ Programming in C# LINQ CSE Prof. Roger Crawfis.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Extension Methods Programming in C# Extension Methods CSE Prof. Roger Crawfis.
LINQ, An IntroLINQ, An Intro Florin−Tudor Cristea, Microsoft Student Partner.
Eric Vogel Software Developer A.J. Boggs & Company.
MongoDB An introduction. What is MongoDB? The name Mongo is derived from Humongous To say that MongoDB can handle a humongous amount of data Document.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics LINQ to XML: A Brief Overview Pavel Ježek.
Variable, Expressions, Statements and Operators By: Engr. Faisal ur Rehman CE-105 Fall 2007.
Week 9 PHP Cookies and Session Introduction to JavaScript.
Putting it all together: LINQ as an Example. The Problem: SQL in Code Programs often connect to database servers. Database servers only “speak” SQL. Programs.
Extension Methods, Anonymous Types LINQ Query Keywords, Lambda Expressions Based on material from Telerik Corporation.
Лектор: Борислава Палева. Galin Iliev MCT, MCPD, MCSD.NET LINQ to XML.
LINQ: It’s Not Your Father’s Data Access Denny Boynton Anheuser-Busch Companies.
The.NET Language Integrated Query Project Anders Hejlsberg TLN306 Technical Fellow Microsoft Corporation.
Neal Stublen How does XMLReader work?  XmlReader.Read() Advances to next node XmlReader properties access node name, value, attributes,
Hoang Anh Viet Hà Nội University of Technology Chapter 1. Introduction to C# Programming.
Chapter 9: Functional Programming in a Typed Language.
I2RS draft-rfernando-yang-mods.txt I2RS Yang Extensions draft-rfernando-yang-data-mods R.Fernando, P.Chinnakannan, M.Madhayyan, A.Clemm.
1 © The ATHENA Consortium. XML, eXtensible Markup Language (1) The format for structured information exchange. –Primary structuring is containment.
C#: Future Directions in Language Innovation Anders Hejlsberg TLN307 Technical Fellow Microsoft Corporation.
Object Oriented Programming Generic Collections and LINQ Dr. Mike Spann
Static. 2 Objectives Introduce static keyword –examine syntax –describe common uses.
CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Advanced.NET Programming I 10 th Lecture Pavel Ježek
Concepts of programming languages Chapter 5 Names, Bindings, and Scopes Lec. 12 Lecturer: Dr. Emad Nabil 1-1.
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
Satisfy Your Technical Curiosity C# 3.0 Raj Pai Group Program Manager Microsoft Corporation
1 C# / VB.NET Language Primer Chris J.T. Auld Microsoft MVP, Mobile Devices Managing Director Kognition Consulting Limited.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises 1 Xiang Lian The University of Texas – Pan American Edinburg,
“The world’s most misunderstood language has become the world’s most popular programming language” Akshay Arora
Rich Internet Applications 2. Core JavaScript. The importance of JavaScript Many choices open to the developer for server-side Can choose server technology.
CIS 200 Test 01 Review. Built-In Types Properties  Exposed “Variables” or accessible values of an object  Can have access controlled via scope modifiers.
Module 3: Using XML. Overview Retrieving XML by Using FOR XML Shredding XML by Using OPENXML Introducing XQuery Using the xml Data Type.
CSE 6331 © Leonidas Fegaras XQuery 1 XQuery Leonidas Fegaras.
LINQ Language Integrated Query LINQ1. LINQ: Why and what? Problem Many data sources: Relational databases, XML, in-memory data structures, objects, etc.
Dr. M. Al-Mulhem Introduction 1 Chapter 6 Type Systems.
XML: Extensible Markup Language
A variable is a name for a value stored in memory.
VBA - Excel VBA is Visual Basic for Applications
VBA - Excel VBA is Visual Basic for Applications
Introduction to LINQ and Generic Collections
Lambda Expressions By Val Feldsher.
2. Understanding VB Variables
.NET and .NET Core 5.2 Type Operations Pan Wuming 2016.
.NET and .NET Core 9. Towards Higher Order Pan Wuming 2017.
Compiler Construction
CSCI 3328 Object Oriented Programming in C# Chapter 8: LINQ and Generic Collections – Exercises UTPA – Fall 2012 This set of slides is revised from lecture.
Compiler Construction
Chengyu Sun California State University, Los Angeles
Presentation transcript:

TeSLa researchproduct

Why The Visual Basic Imports SySTem.STriNg Module Demo Public Sub Main() Dim S = Join(", ", { "Hello", "World"}) End Sub End Module Case insensitive Static class Class imports

Why The Visual Basic Class Dog Public Event Bark() End Class Dim WithEvents D As New Dog() Sub OnBark() Handles D.Bark Console.WriteLine("Call 911") End Sub Declarative Event Handling "AOP"

Why The Visual Basic Function F(X As Integer, _ Optional Flag As Boolean = False) _ As String … End Function F (Flag := True, X := 4711) Optional parameters Named arguments

Why The Visual Basic Class Dog Public Event Bark() Public Default Property Toys(Name As String) _ As Object Get … End Get Set (Value As Object) … End Set End Property End Class Line continuations Indexed Properties

With Scope (Power is in the ".") Why The Visual Basic Dim D As New Dog() With D.Toys("Bone") = New Bone().Toys!Cat = CatchNeighboursCat() Console.WriteLine(.Toys("Ball").Color) End With With Statement Late binding

Late Binding K = J+3 For I=0 To 10 Console.WriteLine(I) Next Dim X As String = 4711 Function F(X) Return X+3 End Function Implicit Explicit Conversions Option Implicit Types Optional

Dim WithEvents B As New Button() Sub OnClick(sender As Object, e As EventArgs) _ Handles B.Click End Sub Sub RelaxedOnClick(sender As Object, e As Object) _ Handles B.Click End Sub Can call it can handle it Relaxed delegates

Delegate Function F(A As S) As T Function G(B As P) As Q New F(AddressOf G) New F(Function(A) CType(G(CType(A,P)),T) Relaxed delegates Conversion stub

_ Function FindName(Source As Object, Name As String) As Object On Error Resume Next If Source.Name = Name Then Return Source End If Dim Children As Object = Source.Children If Children IsNot Nothing Then For Each Child As Object In Children FindName = FindName(Child, Name) If FindName IsNot Nothing Then Return FindName End If Next End If Return Nothing End Function "AOP" Extension Methods Why The Visual Basic Unstructured Exception Handling Late binding

Late Binding! G |- e As S ~~> e G |- a As T ~~> a Sm(T) As R ~~> f G |- e.m(a) As R ~~> f(e,a) Type Rule For Early-Bound Method Invocation

Late Binding! G |- e As Object ~~> e G |- a As T ~~> a T g G |- e.m(a) latecall("m", e, g(a)) Type Rule For Late-Bound Method Invocation

Late Binding! s.GetType() S, t.GetType() T Sm(T) f R h latecall(m,s,t) h(f(s,t)) Operational Semantics For Late-Bound Call VB has multi- methods!

Late Binding Class A Sub F(X As String) WriteLine("F(String)") End Sub Sub F(X As Object) WriteLine("F(Object)") End Sub Sub Main() Dim A = New A() Dim S As Object = "Hello" A.F(S) REM Early F(Object) CObj(A).F(S)REM Late F(String) End Sub End Class Type Inference Imports System.Console

Meta-circular interpreter [ A+B ] = Add( [ A ], [ B ]) [ A.m(B) ] = Call( [ m ], [ A ], [ B ]) Self interpretation is litmus test for dynamic language

G |- e e G |- a a T f G |- m m' G |- e.(m)(a) latecall(m', e, f(a)) Replace Constants By Variables Later binding

Later Binding Class A Sub F(X As String) WriteLine("F(String)") End Sub Sub F(X As Object) WriteLine("F(Object)") End Sub Sub Main() Dim A = New A() Dim S As Object = "Hello" A.(Console.ReadLine())(S) End Sub End Class

Static Typing Where Possible Dynamic Typing Where Necessary VB as the ultimate scripting language

e = \ + 10 d = def options(a=99, b=a+1) [a,b] end redirect_to :action => 'show', :id => 4711 Ruby Smart "inference" Line continuation Default arguments Named arguments via hashes

LINQ Project == monad comprehensions in C# & VB VB 9C# 3.0… Standard Query Operators DLinq (relational) XLinq (xml) LINQ Framework

Swartz, SETL 1970; Burstall and Darlington, NPL 1977; Turner, KRC 1981; …. Haskell, Python, Scala, … Write programs using mathematical ZF set comprehensions syntax. Wadler 1989 List comprehensions are related to the relational calculus. Wadler 1992 List comprehensions are a special case of monad comprehensions. The Origins of LINQ

SELECT X.FirstName, X.LastName FROM Authors AS X WHERE X.City = 'OakLand' oaklands = do{ x <- table authors ; restrict (x!city.==. constant "Oakland") ; project ( au_fname = x!au_fname, au_lname = x!au_lname ) } HaskellDb Query Monad (1997) Query monad intentional representation for expressions

var contacts = from c in customers where c.State == "WA" select new { c.Name, c.Phone }; var contacts = customers.Where(c => c.State == "WA").Select(c => new{c.Name, c.Phone}); Query Comprensions In C# 3.0 Syntactic sugar over standard query operations -expression Type inference

Query Comprensions In Visual Basic 9 Dim Squares = From N In Range(0,99) Select N*N Dim Pairs = From N In Range(0,9) From C In "ABCDEFGHIJ" Select N, C Dim Evens = From N In (0,99) Where N Mod 2 = 0 Select N Dim ByDigit = From N In (0,99) Group By N Mod 10 Select Key, It

Dim Contacts = From C In Customers Where C.State = "WA" Select C.Name, C.Phone Dim Contacts = _ Customers. Where(Function(C) C.State = "WA"). Select(New With {.Name = C.Name,.Phone = C.Phone }) In Visual Basic 9

Query Comprensions In Visual Basic 9 Dim MyCDs As IEnumerable(Of _ { Title As String, Artist As String }) = _ From CD In MyMusic Where CD.Genre IsNot Classic Group By Genre = CD.Genre Where Count(CD) > 10 Select Group(CD.Title, CD.Artist) Aggregate comprehensions

Query Comprehensions X X,Y From Y In F(X) Joined Xs.SelectMany((X) _ F(X).Select((Y)_ New {X,Y})) Compiled To Standard Query Operators

Query Comprehensions X,Y Order By F(X,Y) X,Y Sorted XYs.OrderBy((XY) _ F(XY.X, XY.Y))

Query Comprehensions X,Y Where P(X,Y) Filtered XYs.Where((XY) _ P(XY.X, XY.Y))

Query Comprehensions A,B Select A = F(X,Y), B = G(X,Y) X,Y projected XYs.Select((XY) _ New {A = F(XY.X, XY.Y), _ B = F(XY.X, XY.Y) })

Query Comprehensions A,B, X,Y Group By A = G(X,Y), B = H(X,Y) grouped X,Y XYs.GroupBy((XY) _ New {A = G(XY.X, XY.Y), _ B = H(XY.X, XY.Y) })

Extension Methods static class Integer { static void Times (this int x, Action f){ for(var i = 0; i < x; i++) f(i); } 3.Times((x) => { Console.WriteLine(x); }

var contacts = customers.Where(c => c.State == "WA").Select(c => new{c.Name, c.Phone}); static class System.Query { public static IEnumerable Where (this IEnumerable src, Func > p); … } Extension Methods Extension method for IEnumerable IEnumerable

Dim Contacts = _ Customers.Where(P).Select(R) Module MyExtensions _ Function Where(Of T)( _ [Me] As IEnumerable(Of T), _ P As Func(Of T, Boolean)) _ As IEnumerable(Of T) … End Module In Visual Basic 9 Just CA

var contacts = customers.Where(c => c.State == "WA").Select(c => new{c.Name, c.Phone}); class Table : IEnumerable { public Table Where(Expression > p); … } Expression Trees Intensional representation of delegate Table

Dim F As Expr = Function(X)X+3 Dim G = F.Compile() Dim Z = G(5) Expression Trees Compile to delegate Convert to expression tree by type Execute

var contacts = from c in customers where c.State == "WA" select new { c.Name, c.Phone }; var Joe = new Person{ Name = Joe, Age = 42, Address = { Street = 1th St, City = Seattle } } Anonymous types, Object initializers Anonymous types Initialize RO member Object Initializers

Dim Contacts As IEnumerable(Of _ { Name As String, Phone As Integer } = From c In customers _ Where C.State == "WA _ Select c.Name, c.Phone Dim Joe As Person = New With { _.Name = Joe,.Age = 42, _ Address With { _.Street = 1th St,.City = Seattle } } In Visual Basic 9 Anonymous types Syntax new

Dim S1 As String? = Nothing Dim S2 As String? = Hello Dim S3 = S1+S2 Nullable Null propagating + In VB Nothing is default

XML DOM Dim PO As New XmlDocument Dim purchaseOrder As XmlElement = _ PO.CreateElement("purchaseOrder") PO.AppendChild(purchaseOrder) Dim orderDate As XmlAttribute = PO.CreateAttribute("orderDate") orderDate.Value = " " purchaseOrder.Attributes.Append(orderDate) Dim shipTo As XmlElement = PO.CreateElement("shipTo") purchaseOrder.AppendChild(shipTo) Dim country As XmlAttribute = PO.CreateAttribute("country") country.Value = "US" shipTo.Attributes.Append(country) What does this program do?

Dim Item = _ New XElement("item", _ New XAttribute("partNum", "926-AA"), _ New XElement("productName", …"), _ New XElement("quantity", 1), _ New XElement("price", 39.98), _ New XElement("shipDate", " ")))) Functional (expression- based) construction Context-free (no document scope) Simple XLinq API

table :: TABLE table = cells :: [[(Int,Int)]] cells = [[ (x,y) | x <- [1..16] ] | y <- [1..16] ] mkRows :: [[(Int,Int)]] -> [TR] mkRows = map $ \cs -> mkColumns :: [(Int,Int)] -> [TD] mkColums = map $ \c -> Haskell Server Pages XHTML Literals (1998) ASP-style embedding Translated to universal DOM representation

Dim PO = Alice Smith 123 Maple Street Mill Valley CA <%= Select > From O In Orders Where O.Name = "Robert Smith" %> Translated to XLinq constructor calls ASP-style embedding Includes full namespace support

Late binding over XML Child axis BillTo. BillTo.Elements(street) Attribute axis BillTo.Attributes(country) Descendants axis PO... PO.Descendants(item)

Tools & IDE Type system & Language extensions Runtime & Library support Transactions everywhere Tesla

VB IsNot C# VB = static typing where possible, dynamic typing where necessary. Conclusion