Download Embedded Functional Programming in Hume

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Scala (programming language) wikipedia , lookup

C Sharp syntax wikipedia , lookup

Control flow wikipedia , lookup

Corecursion wikipedia , lookup

C++ wikipedia , lookup

Abstraction (computer science) wikipedia , lookup

Join-pattern wikipedia , lookup

Programming language wikipedia , lookup

Object-oriented programming wikipedia , lookup

Reactive programming wikipedia , lookup

Falcon (programming language) wikipedia , lookup

Structured programming wikipedia , lookup

Go (programming language) wikipedia , lookup

C Sharp (programming language) wikipedia , lookup

Functional programming wikipedia , lookup

Transcript
Embedded Functional
Programming
Gergely Patai
[email protected]
Budapest University of Technology and Economics
Department of Control Engineering and Information Technology
RCEAS 2007, Budapest
23 November 2007
1
Outline




Functional programming in a nutshell
Motivation: desirable properties
Reasons of neglect
Real-life examples in embedded systems
development
 Further directions
RCEAS 2007, Budapest
23 November 2007
2
Functional programming
 Declarative programming paradigm
 Programs defined as series of equations
 Typical characteristics:
 Lack of side effects (a.k.a. ‘purity’)
 Strong, static typing and type inference
 Succinctness
 Some languages: Haskell, ML family,
Scheme, Clean, F#
RCEAS 2007, Budapest
23 November 2007
3
FP properties: purity
 Referential transparency
 Function return values depend only on the
explicit arguments, not the context
 Context-free expressions: easier testing and
debugging, richer static analysis possible
 No variables
 Comparatively little state space
 Safe concurrency
 Loops expressed with recursion
 I/O clearly separated from logic
RCEAS 2007, Budapest
23 November 2007
4
FP properties: type system
 Strong typing
 Protection against misinterpreting data
 Type inference
 Types don’t need to be specified explicitly
 Every subexpression has a well-defined type
 Inconsistencies detected at compile time
RCEAS 2007, Budapest
23 November 2007
5
FP properties: succinctness
 Typically little boilerplate
 Code/structure reuse possible at a small
level of granularity
 Loops are often abstracted away
 In general shorter by a factor of two to ten
RCEAS 2007, Budapest
23 November 2007
6
Why is it not widely used?
 FP originates around 1960 with LISP
 Too resource intensive for that time
(garbage collection, reflection…)
 Imperative languages pervaded the
industry
 Programmers got used to thinking
imperatively
RCEAS 2007, Budapest
23 November 2007
7
Is it really not used?
 Modern languages keep adopting features
of functional languages
 Managed memory
 Type inference
 Lambda expressions (unnamed functions)
 Why not adopt the whole paradigm?
RCEAS 2007, Budapest
23 November 2007
8
Example: Lava
 Haskell library to aid hardware design
 Generating VHDL code from functional
description
 Mary Sheeran:
Hardware Design and Functional
Programming: a Perfect Match
RCEAS 2007, Budapest
23 November 2007
9
Example: Erlang





Concurrent functional language
Asynchronous IPC (message passing)
Fault tolerance mechanism
Hotswap support
http://www.erlang.org
RCEAS 2007, Budapest
23 November 2007
10
Example: Lustre
 Synchronous dataflow language, a
declarative relative of Esterel
 Used in commercial safety critical products
(mostly avionics) since 1993
 http://www-verimag.imag.fr/SYNCHRONE
RCEAS 2007, Budapest
23 November 2007
11
Example: Hume
 Experimental language, still developing
 Programs: boxes connected with wires
 Wires: persistent state, one input and one
output each
 Boxes: buffered combination networks




Compile-time resource limit guarantees
Execution: VM, native code (C), FPGA
http://www.hume-lang.org
http://www.embounded.org
RCEAS 2007, Budapest
23 November 2007
12
Where to go from here?
 Functional languages viable in a wide
range of applications
 An underrated (or just unknown) paradigm
 Our ongoing experiments:
 Hume on embedded platforms (Tmote Sky,
Mindstorms NXT, mitmót)
 Haskell on the desktop for remote controlling
robots
 What about you? 
RCEAS 2007, Budapest
23 November 2007
13
Thank you for your attention!
RCEAS 2007, Budapest
23 November 2007
14