Download presentation
Presentation is loading. Please wait.
1
23 November 2007RCEAS 2007, Budapest1 Embedded Functional Programming Gergely Patai patai@iit.bme.hu Budapest University of Technology and Economics Department of Control Engineering and Information Technology
2
23 November 2007RCEAS 2007, Budapest2 Outline Functional programming in a nutshell Motivation: desirable properties Reasons of neglect Real-life examples in embedded systems development Further directions
3
23 November 2007RCEAS 2007, Budapest3 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#
4
23 November 2007RCEAS 2007, Budapest4 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
5
23 November 2007RCEAS 2007, Budapest5 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
6
23 November 2007RCEAS 2007, Budapest6 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
7
23 November 2007RCEAS 2007, Budapest7 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
8
23 November 2007RCEAS 2007, Budapest8 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?
9
23 November 2007RCEAS 2007, Budapest9 Example: Lava Haskell library to aid hardware design Generating VHDL code from functional description Mary Sheeran: Hardware Design and Functional Programming: a Perfect Match
10
23 November 2007RCEAS 2007, Budapest10 Example: Erlang Concurrent functional language Asynchronous IPC (message passing) Fault tolerance mechanism Hotswap support http://www.erlang.org
11
23 November 2007RCEAS 2007, Budapest11 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
12
23 November 2007RCEAS 2007, Budapest12 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
13
23 November 2007RCEAS 2007, Budapest13 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?
14
23 November 2007RCEAS 2007, Budapest14 Thank you for your attention!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.