Stop coding Pascal. Saturday, April 6, 13

Similar documents
Refactoring to Functional. Hadi Hariri

Concepts of Programming Languages

G Programming Languages - Fall 2012

Chapter 11 :: Functional Languages

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

Fundamentals and lambda calculus. Deian Stefan (adopted from my & Edward Yang s CSE242 slides)

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. Haskell Programming

CS 242. Fundamentals. Reading: See last slide

CSCI.4430/6969 Programming Languages Lecture Notes

Functional Programming

Functional Programming Lecture 1: Introduction

Functional Languages. CSE 307 Principles of Programming Languages Stony Brook University

Com S 541. Programming Languages I

Introduction to Functional Programming and Haskell. Aden Seaman

Introduction. A. Bellaachia Page: 1

Programming Language Pragmatics

Fundamentals and lambda calculus

Chapter 6 Control Flow. June 9, 2015

11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations

COP4020 Programming Languages. Functional Programming Prof. Robert van Engelen

More Lambda Calculus and Intro to Type Systems

CSCC24 Functional Programming Scheme Part 2

Functional Programming. Big Picture. Design of Programming Languages

From the λ-calculus to Functional Programming Drew McDermott Posted

Lecture 15: Iteration and Recursion

Simply-Typed Lambda Calculus

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

8/27/17. CS-3304 Introduction. What will you learn? Semester Outline. Websites INTRODUCTION TO PROGRAMMING LANGUAGES

Functional Programming and λ Calculus. Amey Karkare Dept of CSE, IIT Kanpur

Welcome to. Instructor Marc Pomplun CS 470/670. Introduction to Artificial Intelligence 1/26/2016. Spring Selectivity in Complex Scenes

15. Functional Programming

CPL 2016, week 10. Clojure functional core. Oleg Batrashev. April 11, Institute of Computer Science, Tartu, Estonia

Functional Languages. Hwansoo Han

Introduction to Concepts in Functional Programming. CS16: Introduction to Data Structures & Algorithms Spring 2017

CS 11 Haskell track: lecture 1

SD314 Outils pour le Big Data

Introduction to Scientific Computing Languages

CS 415 Midterm Exam Spring 2002

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

More Lambda Calculus and Intro to Type Systems

LECTURE 16. Functional Programming

Closures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

Functional Programming Principles in Scala. Martin Odersky

CMSC 330: Organization of Programming Languages

CSE 505: Concepts of Programming Languages

Is Functional Programming (FP) for me? ACCU Conference 2008 Hubert Matthews

4/19/2018. Chapter 11 :: Functional Languages

Lecture 5: The Untyped λ-calculus

Homework. Lecture 7: Parsers & Lambda Calculus. Rewrite Grammar. Problems

Elixir, functional programming and the Lambda calculus.

COMP80 Lambda Calculus Programming Languages Slides Courtesy of Prof. Sam Guyer Tufts University Computer Science History Big ideas Examples:

Programming Languages, Summary CSC419; Odelia Schwartz

The Haskell HOP: Higher-order Programming

SOFTWARE ARCHITECTURE 6. LISP

Introduction to Scientific Computing Languages

JVM ByteCode Interpreter

CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009

Handout 10: Imperative programs and the Lambda Calculus

Presented By Andrew Butt

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus

Formal Semantics. Aspects to formalize. Lambda calculus. Approach

dynamically typed dynamically scoped

CS Exam #1-100 points Spring 2011

CS152: Programming Languages. Lecture 7 Lambda Calculus. Dan Grossman Spring 2011

9/23/2014. Why study? Lambda calculus. Church Rosser theorem Completeness of Lambda Calculus: Turing Complete

CSCI 2041: Lazy Evaluation

Type Systems Winter Semester 2006

Goal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler.

CMSC330. Objects, Functional Programming, and lambda calculus

Formal Systems and their Applications

Introduction to the Lambda Calculus

Optimising Functional Programming Languages. Max Bolingbroke, Cambridge University CPRG Lectures 2010

CS558 Programming Languages

COMP 1130 Lambda Calculus. based on slides by Jeff Foster, U Maryland

Programming with Math and Logic

Programming language design and analysis

What Is Computer Science? The Scientific Study of Computation. Expressing or Describing

Introduction. chapter Functions

CIS 500 Software Foundations Fall September 25

CMSC 330: Organization of Programming Languages. Lambda Calculus

Control Flow February 9, Lecture 7

Concepts of Programming Languages

CS 6110 S14 Lecture 1 Introduction 24 January 2014

Haskell Functional Programming

Functional Programming Languages (FPL)

Functional Programming and Haskell

Lambda Calculus. Lambda Calculus

Why are there so many programming languages? Why do we have programming languages? What is a language for? What makes a language successful?

St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

To figure this out we need a more precise understanding of how ML works

Programming Languages 2nd edition Tucker and Noonan"

Better Stories, Better Languages

Modules Matter Most. Robert Harper Carnegie Mellon University. MacQueen Fest Chicago May 2012

CS Lecture 6: Map and Fold. Prof. Clarkson Spring Today s music: Selections from the soundtrack to 2001: A Space Odyssey

CS Lecture 6: Map and Fold. Prof. Clarkson Fall Today s music: Selections from the soundtrack to 2001: A Space Odyssey

General Concepts. Abstraction Computational Paradigms Implementation Application Domains Influence on Success Influences on Design

Transcription:

Stop coding Pascal...emotional sketch about past, present and future of programming languages, Python, compilers, developers, Life, Universe and Everything

Alexey Kachayev CTO at KitApps Inc. Open source activist About me Functional programming advocate Erlang, Python, Scala, Clojure, Go, Haskell @kachayev kachayev <$> gmail github.com/kachayev/fn.py

Einstein problem solving principle

So, next 55 minutes we will talk about the core of the problems

difference between syntax and semantic What are we going to talk about? imperative code: when and WHY? machine VS language: problems and solutions where did Python features come from what is the current problem why should I care?

Simple task count of unique substring

Pascal

* just sample... it s really hard to show Pascal version in slide

Python v.1

Python v.2

Haskell

What the difference is? pascal VS python.v1 - syntax (mostly) python.v1 VS python.v2 - semantic python.v2 VS haskell - (mostly) syntax (*) * iterators VS. lazy-evaluation is a different story

Let s dig deeper

Why is Haskell code so compact? transformations compositions * unix way, BTW

Where did all these i, j, k come from?

Instructions VS. Transformations

... and deeper

Turing machine VS. λ-calculus

Turing machine infinite memory instructions (finite)

terms λ - calculus abstraction application β-reduction

The are many application operators in Haskell, ML application abstraction (λx.2 * x + 1) 3 β-reduction

Q: How it s possible that everything is a transformation?

A: Have you ever thought about how (4+5-2*9) works?

Hardware & compiler VS. Programming language

What the problem is? reusability && composability... oh, off course modularity matters, but we created many ways to split our programs since goto

hard to reuse/compose (context) hard to test (context) interactive style is hard Imperative it s not the language that I want to talk parallelism is impossible... but it s widespread... but it s common... but it s hard to see the root of the problems ( Vietnam )

Imperative advantages(?) algorithms O(*) - the same low level optimization? - oh, not in Python manual memory control? - oh, not in Python

Logic combinators Set theory Type theory λ-notation λ-calculus AST-base λ-calculus as PL ML (family) Lisp (family) Python Haskell OCaml ABC Pascal С SETL Algol 60/8 Fortran Speedcoding Assembly Turing machine

When somebody tells you that each language is sugar over Turing machine... do not believe

mostly imperative, but... higher-ordered functions (*) lambdas (*) Python no for(i=0;i<10;i++) (**) iterators (**) map/filter/zip/itertools (**) generators (**) * ast/abt ** sequence-based semantic futures (concurrency, tulip)

Move on to more practical questions * starting from easiest: looking for high-level patterns

http://wrongsideofmemphis.files.wordpress.com/2013/03/screen-shot-2013-03-23-at-12-32-17.png

Do you see the patterns?

Do you see the patterns?

Do you see the patterns?

Do you see the patterns?

Do you see the patterns? * we already talked that loops do not compose

Do you see the patterns?

transformations instead of instructions Not only syntax... reduction declarations without dealing with application reuse pure function in some context (functor) high(er) level of composability

When syntax sucks...

Iterators is not only about lists... this is the semantic way to think about possible solutions

Only last function matters... other functions are common and you can find them in Python documentation or implemented in Fn.py library

More examples Lazy evaluation and declarative approach: http://kachayev.github.com/talks/

iterators generators lazy-evaluation What stuff do you know about? undelimited continuations delimited continuations coroutines macros monads staging deref scope

iterators generators lazy-evaluation What stuff do you use in code? undelimited continuations delimited continuations coroutines macros monads staging deref scope

iterators generators lazy-evaluation What stuff do you want to use? undelimited continuations delimited continuations coroutines macros monads staging deref scope

I saw many coroutines during conference talks

I never saw coroutines in real-life projects

Can you describe* coroutine advantages? * using one word

Can you describe coroutine disadvantages?

easy to start with simplest stuff (it s cool, but don t stop!) habits, traditions (???) What the problem is? mutable variables and assignments dictate (*) syntax doesn t support non-imperative semantic ( for is only one good example of support, yield from is also cool) (**) internal contradictions (***)

Can you see semantic under the syntax?

https://gist.github.com/e000/1023982

Are you getting on a bit?

Can you see ABT under your AST?

I don t want you to write code this way I just want you to understand how it works and why it s possible

BTW, it s common pattern in JS code...

yield from is not only the new syntax!

It s all about composition.

You can (*) write pointfree (**) code * you just don t have readable syntax to do this ** applytwice is good example to show

Isn t this wonderful?

no composition syntax!!! okay... def new function (not readable enough) no recursion!!! Contra okay... the list is...? iterators is...? oh, I know! recursion = fold + unfold :) no fold!!! we have list comprehensions but... LC = map&filter... okay...

Code vs. Ideas So now reduce(). This is actually the one I've always hated most,... almost every time I see a reduce() call with a non-trivial function argument, I need to grab pen and paper to diagram... it's better to write out the accumulation loop explicitly. (c) Guido Van Rossum

fold / unfold... dig deeper

Everybody knows this examples...

Dig deeper.

I want you to think about semantic

In 5 years Python will solve other problems

In 5 years Python should (*) solve other problems * technologies are changing very fast

Is Python ready to be a cutting-edge language?

Are you ready?

Questions? * other talks: https://kachayev.github.com/talks ** fn.py: https://github.com/kachayev/fn.py