Download Embedded Functional Programming in Hume

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

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

Document related concepts

Corecursion wikipedia, lookup

Abstraction (computer science) wikipedia, lookup

Go (programming language) wikipedia, lookup

Reactive programming wikipedia, lookup

Structured programming wikipedia, lookup

Object-oriented programming wikipedia, lookup

C Sharp (programming language) wikipedia, lookup

Falcon (programming language) wikipedia, lookup

C++ wikipedia, lookup

C Sharp syntax wikipedia, lookup

Functional programming wikipedia, lookup

Programming language wikipedia, lookup

Control flow wikipedia, lookup

Scala (programming language) wikipedia, lookup

Join-pattern wikipedia, lookup

Embedded Functional
Gergely Patai
[email protected]
Budapest University of Technology and Economics
Department of Control Engineering and Information Technology
RCEAS 2007, Budapest
23 November 2007
Functional programming in a nutshell
Motivation: desirable properties
Reasons of neglect
Real-life examples in embedded systems
 Further directions
RCEAS 2007, Budapest
23 November 2007
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
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
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
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
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
 Programmers got used to thinking
RCEAS 2007, Budapest
23 November 2007
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
Example: Lava
 Haskell library to aid hardware design
 Generating VHDL code from functional
 Mary Sheeran:
Hardware Design and Functional
Programming: a Perfect Match
RCEAS 2007, Budapest
23 November 2007
Example: Erlang
Concurrent functional language
Asynchronous IPC (message passing)
Fault tolerance mechanism
Hotswap support
RCEAS 2007, Budapest
23 November 2007
Example: Lustre
 Synchronous dataflow language, a
declarative relative of Esterel
 Used in commercial safety critical products
(mostly avionics) since 1993
RCEAS 2007, Budapest
23 November 2007
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
RCEAS 2007, Budapest
23 November 2007
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
 What about you? 
RCEAS 2007, Budapest
23 November 2007
Thank you for your attention!
RCEAS 2007, Budapest
23 November 2007