where are programming languages...

30
Where are Programming Languages Going? Anders Hejlsberg Microsoft Technical Fellow [email protected]

Upload: others

Post on 22-Jul-2020

35 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Where are Programming

Languages Going?

Anders Hejlsberg

Microsoft Technical Fellow

[email protected]

Page 2: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write
Page 3: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Since then…

x 10,000

x 100,000

x 1000

Page 4: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

But…

program HelloWorld;var

I: Integer;begin

for I := 1 to 10 doWriteLn('Hello World');

end.

x ?

using System;

class HelloWorld{

static void Main(string[] args) {for (int i = 0; i < 10; i++)

Console.WriteLine("Hello World");

}}

=

Page 5: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Languages, Frameworks, Tools

Then

Now

Page 6: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Increasing Abstraction Level

Page 7: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Trends

Page 8: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Declarative Programming

What

How

Imperative Declarative

Page 9: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Domain Specific Languages

“… a programming language or

specification language dedicated to a

particular problem domain, a

particular problem representation

technique, and/or a particular

solution technique.”Source: Wikipedia

Page 10: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Domain Specific Languages

DSLGPPL

GPPL

DSL

External DSL Internal DSL

Page 11: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

External DSLs

<?xml version="1.0" ?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="xml" indent="yes"/> <xsl:template match="/persons">

<root><xsl:apply-templates select="person"/></root></xsl:template> <xsl:template match="person">

<name id="{@username}"><xsl:value-of select="name"/></name></xsl:template>

</xsl:stylesheet>

SELECT Name, Address, CityFROM CustomersWHERE Country = "Denmark" rm -f /tmp/listing.tmp > /dev/null 2>&1

touch /tmp/listing.tmpls -l [a-z]*.doc | sort > /tmp/listing.tmplpr -Ppostscript_1 /tmp/listing.tmprm -f /tmp/listing.tmp

Page 12: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Internal DSLs

class Order < ActiveRecord::Basebelongs_to :customerhas_many :details

end

var query = db.Customers.Where(c => c.City == "London").OrderBy(c => c.CompanyName).Select(c => c.CompanyName);

Pattern socialSecurityNumber = Pattern.With.AtBeginning.Digit.Repeat.Exactly(3).Literal("-").Repeat.Optional.Digit.Repeat.Exactly(2).Literal("-").Repeat.Optional.Digit.Repeat.Exactly(4).AtEnd;

Page 13: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

LINQ Demo

Page 14: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Functional Programming

FP

First class functions

Immutable

data

Referential

transparency

Algebraic data types

Type

inference

Pattern

matching

Page 15: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Imperative vs. Functional

x = x + 1

Page 16: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Imperative vs. Functional

y = x + 1

Page 17: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

public class Point{

public int x;public int y;

public Point(int x, int y) {this.x = x;this.y = y;

}

public void MoveBy(int dx, int dy) {x += dx;y += dy;

}}

public class Point{

public readonly int x;public readonly int y;

public Point(int x, int y) {this.x = x;this.y = y;

}

public Point MoveBy(int dx, int dy) {return new Point(x + dx, y + dy);

}}

Imperative vs. Functional

ImperativeImperative

FunctionalFunctional

Page 18: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

F#

Page 19: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

F# Demo

Page 20: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Dynamic vs. Static

Page 21: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Meta-Programming

“Meta-programming is the writing of

programs that write or manipulate

other programs (or themselves) as

their data…”Source: Wikipedia

class Order < ActiveRecord::Basebelongs_to :customerhas_many :details

end

Page 22: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

.NET Dynamic Programming

Dynamic Language Runtime

IronPythonIronPythonIronPython IronRubyIronRubyIronRuby C#C#C# VB.NETVB.NETVB.NET Others…OthersOthers……

Statement TreesStatement TreesStatement Trees Dynamic DispatchDynamic DispatchDynamic Dispatch Call Site CachingCall Site CachingCall Site Caching

Python

Binder

PythonPython

BinderBinderRuby

Binder

RubyRuby

BinderBinderCOM

Binder

COMCOM

BinderBinderJavaScript

Binder

JavaScriptJavaScript

BinderBinderObject

Binder

ObjectObject

BinderBinder

Page 23: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Static and Dynamic

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

object calc = GetCalculator();Type calcType = calc.GetType();object res = calcType.InvokeMember("Add",

BindingFlags.InvokeMethod, null,new int[] { 10, 20 });

int sum = Convert.ToInt32(res);ScriptObject calc = GetCalculator();object res = calc.Invoke("Add", 10, 20);int sum = Convert.ToInt32(res);

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

Statically typed to

be dynamic

Statically typed to

be dynamic

Dynamic method

invocation

Dynamic method

invocationDynamic

conversion

Dynamic

conversion

Page 24: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Concurrency

Page 25: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Operating System ThreadsOperating System Threads

Parallel Extensions for .NET

Parallel LINQParallel LINQ

Task Parallel LibraryTask Parallel LibraryCoordination Data

Structures

Coordination Data

Structures

CPUCPU CPUCPU …CPUCPU CPUCPU

Page 26: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Parallel Extensions Demo

Page 27: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Potential Language Constructs

Page 28: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Interesting Times

Ruby

Python C#Java

Jav

aS

crip

t

ScalaE

rla

ng

F#

Fo

rtre

ssNemerleBooGroovy

PHP

PerlLua

PowerShell

D

C+

+

Page 29: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

Resources

http://msdn.microsoft.com/fsharp

http://msdn.microsoft.com/concurrency

Page 30: Where are Programming Languages Goingjaoo.dk/dl/jaoo-aarhus-2008/slides/AndersHejlsberg_WhereAreProgra… · Meta-Programming “Meta-programming is the writing of programs that write

© 2007 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.