44
Bibliotech - smart cafe; strikead club. Programming Languages: Some news for the last N years. Ruslan Shevchenko <[email protected]> @rssh1 https://github.com/rssh

Programming Languages: some news for the last N years

Embed Size (px)

DESCRIPTION

Slides from guest lecture in bibliotech smart cafe: http://www.bibliotech.com.ua/afisha/101014.html

Citation preview

Page 1: Programming Languages: some news for the last N years

Bibliotech - smart cafe; strikead club.

Programming Languages: Some news for the last N years.

Ruslan Shevchenko <[email protected]>

@rssh1 https://github.com/rssh

Page 2: Programming Languages: some news for the last N years

Programming languages:

❖ Industry/Academic❖ what’s hot now:

❖ academic research from 70-th❖ ‘freaky’ things from 2000

Where is progress ?

What we will see in industry from today-s academic ?from today-s freaks ?

Page 3: Programming Languages: some news for the last N years

Full change of language and tools during 2-3 yearsStatement from 80-th:

Actual situation in 2014:

Top 11 languages are the same: 2010 - 2014

http://dou.ua

Page 4: Programming Languages: some news for the last N years

Can we track progress in PL ?

❖ Estimations❖ Code size / project duration

Page 5: Programming Languages: some news for the last N years

Evolution is slow

Page 6: Programming Languages: some news for the last N years

If we think about ideal language ?

Page 7: Programming Languages: some news for the last N years

• Object and processes from real world, represented in computer

• Operations with this representation.• Mapping of result back to real world

Make all good

What is:❖ all ?❖ good ?❖ make ?

Page 8: Programming Languages: some news for the last N years

Semantics [type systems]

Syntax [parsing/ast manipulation]

“New” functionality

Page 9: Programming Languages: some news for the last N years

Syntax

Traditional approach: context free grammars

Syntax structure is fixed

Now in practice:

Context-dependent keywords (C++ )

Multi-language programming

Page 10: Programming Languages: some news for the last N years

Extensible syntax

Seed 7: Syntax definitions of operations with priority

syntax expr: .(). + .() is -> 7;

syntax expr: .loop.().until.().do.().end.loop is -> 25;

Nemerle: macroses

macro for (init, cond, change, body)syntax ("for", "(", init, ";", cond, ";", change, ")", body)

XL Compiler plugins

Page 11: Programming Languages: some news for the last N years

Extensible syntax

boolCase : (x:Bool) -> Lazy a -> Lazy a -> a;boolCase True t e = t;boolCase False t e = e;

syntax "if" [test] "then" [t] "else" [e] = boolCase test t e;

// Idris

syntax "for" {x} "in" [xs] ":" [body] = forLoop xs (\x => body)

// introducing new binding

// DSL — map object to Idrix language constructions

Page 12: Programming Languages: some news for the last N years

XL: Concept programming

Active library = Library + compiler plugin

Metrics:Syntax noise / signal

Bandwidth

Concept in real life. In computer - representation

what part of concept is represented

what part of code is about business

Complexity source

Page 13: Programming Languages: some news for the last N years

Articulate programming

Avail: SmallTalk-based, static typing

Try to deduce ‘needed’ value from context.

like scala implicit, but *all* is implicit

Page 14: Programming Languages: some news for the last N years

Syntax

Multi-language programming

❖ Do nothing (mess)❖ Embed all in one language [lifted evaluation]

❖ (like LINQ or scala slick or idris DSL)❖ Define and use ‘part of grammar’ with type.

Page 15: Programming Languages: some news for the last N years

Wyvern: https://www.cs.cmu.edu/~aldrich/wyvern/

let imageBase : URL = <images.example.com>let bgImage : URL = <%imageBase%/background.png>new : SearchServer def resultsFor(searchQuery, page) serve(~) (* serve : HTML -> Unit *) >html >head >title Search Results >style ~ body { background-image: url(%bgImage%) } #search { background-color: ..

//Type-specific tokens

Page 16: Programming Languages: some news for the last N years

Wyvern: https://www.cs.cmu.edu/~aldrich/wyvern/

let imageBase : URL = <images.example.com>let bgImage : URL = <%imageBase%/background.png>new : SearchServer def resultsFor(searchQuery, page) serve(~) (* serve : HTML -> Unit *) >html >head >title Search Results >style ~ body { background-image: url(%bgImage%) } #search { background-color: ..

//Type-specific tokens

Page 17: Programming Languages: some news for the last N years

Wyvern: https://www.cs.cmu.edu/~aldrich/wyvern/

let imageBase : URL = <images.example.com>let bgImage : URL = <%imageBase%/background.png>new : SearchServer def resultsFor(searchQuery, page) serve(~) (* serve : HTML -> Unit *) >html >head >title Search Results >style ~ body { background-image: url(%bgImage%) } #search { background-color: ..

//Type-specific tokens

Page 18: Programming Languages: some news for the last N years

Type Systems

Static/Dynamic —-> Gradual

Dynamic:

❖ clojure -> core.typed❖ python -> type annotations❖ groovy -> type annotations

Static:

❖ Dynamic typefromDynamic[T]: D => Option[T] toDynamic[T](x: T) => Dynamic

needed for reflective typing

Page 19: Programming Languages: some news for the last N years

(ann clojure.core/first (All [x] (Fn [(Option (EmptySeqable x)) -> nil] [(NonEmptySeqable x) -> x] [(Option (Seqable x)) -> (Option x)])))

Clojure: core/typed.

- static empty -> nil- static non-empty -> not-nil- unknown -> x or nil,

Page 20: Programming Languages: some news for the last N years

Type Systems

typing => static analysis at compile-time

compilation => optimization of interpretation

Page 21: Programming Languages: some news for the last N years

Type Systems

Page 22: Programming Languages: some news for the last N years

Type Systems

Dependent types

Page 23: Programming Languages: some news for the last N years

Non-dependent types example

trait CInt { type Succ <: CInt }trait CPos extends CInt

trait CSucc[P <: CPos] extends CInt { type Succ = CSucc[CSucc[Int]]}

final class _0 extends CPos { type Succ = CSucc[0]}

type _1 = _0#Succtype _2 = _1#Succ

// church numeration

Page 24: Programming Languages: some news for the last N years

Non-dependent types example

trait LimitedVector[+A, N<:CInt]{

…………

def append[B <: A, NX <:CInt](x: LimitedVector[B,NX]): LimitedVector[B,Plus[N,NX]] …………..}

// shapeless full of such tricks

Page 25: Programming Languages: some news for the last N years

Dependent types example

trait LimitedVector[+A, n:Int]{

…………

def append[B <: A, nx:Int](x: LimitedVector[B,nx]): LimitedVector[B, n+nx] …………….}

// warning: pseudocode, impossible in scala

Page 26: Programming Languages: some news for the last N years

Dependent types example

data Vect : Nat -> Type -> Type where Nil : Vect 0 a (::) : a -> Vect k a -> Vect (k+1) a

// Idris

Calculus of constructions: Idris, Coq, Agda

Page 27: Programming Languages: some news for the last N years

Dependent types:

Track properties, which can be proven by structural induction

Function, which call SQL inside no more than 3 times.

Resource with balanced acquire/release for all execution paths.

Type depends from value <=> Type must be available as value

data Parity : Nat -> Type where even : Parity (n + n) odd : Parity (S (n + n))

Page 28: Programming Languages: some news for the last N years

Dependent types:

intuitionistic logic

absence (p || ~p)

Type:Type - logical bomb

Page 29: Programming Languages: some news for the last N years

// note: it is possible to make efficient type-level numbers in scala

Details: Stefan Zeiger. Type-Level Computations in Scala❖ slides

❖ http://slick.typesafe.com/talks/scalaio2014/Type-Level_Computations.pdf❖ code:

❖ https://github.com/szeiger/ErasedTypes❖ idea:

❖ define type-alias with argument for operation.❖ perform term-level computation and ‘unsafe cast’ to this alias.

abstract class CNat{ type Succ type + [T <: CNat] def value: Int …………….. def +[T <: CNat](x:n): +[T] = CPos(value+x.value).asInstanceOf[+T]}

Page 30: Programming Languages: some news for the last N years

Effects tracking:

No more IO monads !!!!

List of effects as part of type.

• Idris• Eff

Page 31: Programming Languages: some news for the last N years

Effects: - calculated as extension to ‘normal’ type. (as type-index or yet another dimension)

• possible traces of operations• set of operations.• set of resources• set of exceptions• atomicity• delimited specs • ….

type channel = effect operation read : unit -> string operation write : string -> unitend

//Handler - effects interpreter

let accumulate = handler | std#write x k -> let (v, xs) = k () in (v, x :: xs) | val v -> (v, [])

// Eff

Page 32: Programming Languages: some news for the last N years

Knowledge-based programming

Let’s add structured information about problem domain.

Wolfram Alpha:

Mathematics domain. Near 5000 built-in functions.

Differ from community repository: all interfaces are consistent

Household lexicon: approx 4000

Page 33: Programming Languages: some news for the last N years

Tweet-a-program

Wolfram:

Page 34: Programming Languages: some news for the last N years

Tweet-a-program

Wolfram:

Page 35: Programming Languages: some news for the last N years

- Syntax, defined in problem-domain specific library- Vocabulary simular to one in natural language- Advanced type theory with refinement specs.

Make all good

Page 36: Programming Languages: some news for the last N years

Implementation

Page 37: Programming Languages: some news for the last N years

Implementation

Compilation/Interpretation [both - hard]

VM/System

JVM no continuations (?)

LLVM non-trivial gc (?)

Complexity.

both - impossible without divergence

Let’s rewrite all with callbacks, because it’s more easy than fix JVM/OS

Page 38: Programming Languages: some news for the last N years

CORBA story:

Let’s do remote and local call undistinguished (1996)

Local calls: fast

Remote calls: slow

Common antipattern: build fine-grained object model in RPC

Akka:

Let’s do remote and local call undistinguished (2014)

// hope, now things will move forward more accurate

Page 39: Programming Languages: some news for the last N years

So, we must

choose one level of abstraction or

build family of systems

otherwise — abstraction leaks

Page 40: Programming Languages: some news for the last N years

Ok, assume we build ideal language. (in academia or as freaks)

When it will be in industry ?

❖ Success in sense of adoption => evolution slowdown

Haskell: ❖ avoid success of all costs => be open for evolution,

live in a water

Scala: from research to engineering

(LMS, attempt to remove skolem types, … etc )

Page 41: Programming Languages: some news for the last N years

Sociology of programming languages

Leo Meyerovich

Average ‘incubation’ period before wider adoption: 12 years

before - specialized in some niche

Adoption => social, marketing ….., not technical.

Page 42: Programming Languages: some news for the last N years

What will be in industry tomorrow: landscape now.

General purpose: need some time for current adoptionJVM land: scala, clojure

System: D / Rust instead C++ (?)

Trends: integrating other paradigms

Application/ Scripting: [ place is vacant ]// JavaScript successor [?]

Page 43: Programming Languages: some news for the last N years

What will be not in industry tomorrow:

academic/OSS

Better VM-s

New paradigms

Depends from you

// niche as social issue

Page 44: Programming Languages: some news for the last N years

Thanks.

@rssh1

[email protected]

https://github.com/rssh

If you build something interesting - ping me.