Jump to content
Wikipedia The Free Encyclopedia

Hume (programming language)

From Wikipedia, the free encyclopedia
Functional programming language
This article needs additional citations for verification . Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.
Find sources: "Hume" programming language – news · newspapers · books · scholar · JSTOR
(April 2022) (Learn how and when to remove this message)
Hume
Paradigm Functional
FamilyHaskell
Designed by Greg Michaelson
Andrew Ireland
Andy Wallace
Developers University of St Andrews
Heriot-Watt University
First appeared2000; 25 years ago (2000)
Stable release
0.8 / 25 April 2008; 17 years ago (2008年04月25日)
Typing discipline Inferred, static, strong
Platform IA-32, PowerPC
OS macOS, Red Hat Linux
Influenced by
Haskell
Hume Statue in Edinburgh

Hume is a functionally based programming language developed at the University of St Andrews and Heriot-Watt University in Scotland since the year 2000. The language name is both an acronym meaning 'Higher-order Unified Meta-Environment' and an honorific to the 18th-century philosopher David Hume. It targets real-time computing embedded systems, aiming to produce a design that is both highly abstract, and yet allows precise extraction of time and space execution costs. This allows guaranteeing the bounded time and space demands of executing programs.

Hume combines functional programming ideas with ideas from finite-state automata. Automata are used to structure communicating programs into a series of "boxes", where each box maps inputs to outputs in a purely functional way using high-level pattern-matching. It is structured as a series of levels, each of which exposes different machine properties.

Design model

[edit ]

The Hume language design attempts to maintain the essential properties and features required by the embedded systems domain (especially for transparent time and space costing) whilst incorporating as high a level of program abstraction as possible. It aims to target applications ranging from simple microcontrollers to complex real-time systems such as smartphones. This ambitious goal requires incorporating both low-level notions such as interrupt handling, and high-level ones of data structure abstraction etc. Such systems are programmed in widely differing ways, but the language design should accommodate such varying requirements.

Hume is a three-layer language: an outer (static) declaration/metaprogramming layer, an intermediate coordination layer describing a static layout of dynamic processes and the associated devices, and an inner layer describing each process as a (dynamic) mapping from patterns to expressions. The inner layer is stateless and purely functional.

Rather than attempting to apply cost modeling and correctness proving technology to an existing language framework either directly or by altering a more general language (as with e.g., RTSJ), the approach taken by the Hume designers is to design Hume in such a way that formal models and proofs can definitely be constructed. Hume is structured as a series of overlapping language levels, where each level adds expressibility to the expression semantics, but either loses some desirable property or increases the technical difficulty of providing formal correctness/cost models.[1]

Characteristics

[edit ]

The interpreter and compiler versions differ a bit.

  • the interpreter (concept prover) admits timeout and custom exceptions.
  • the compiler admits heap and stack cost bounding but exceptions only print the exception name.

The coordination system wires boxes in a dataflow programming style.

The expression language is Haskell-like.

The message passing concurrency system remembers JoCaml's join-patterns or Polyphonic C Sharp chords, but with all channels asynchronous.

There is a scheduler built-in that continuously checks pattern-matching through all boxes in turn, putting on hold the boxes that cannot copy outputs to busy input destinations.

Examples

[edit ]

Vending machine

[edit ]
dataCoins=Nickel|Dime|Fake;
dataDrinks=Coffee|Tea;
dataButtons=BCoffee|BTea|BCancel;
typeInt=int32;
exceptionEFakeCoin::(Int,string);
showv=vasstring;

boxcoffee
in(coin::Coins,button::Buttons,value::Int)-- input channels
out(drink_outp::string,value::Int
,refund_outp::string,display::string)-- named outputs
within500KB(400B)-- max heap ( max stack) cost bounding
handlesEFakeCoin,TimeOut,HeapOverflow,StackOverflow
match
-- * wildcards for unfilled outputs, and unconsumed inputs
(my_coin,*,v){- ''join-pattern'' equivalent: coin(my_coin) & value(v) -}
->letv=incrementCreditmy_coinv
in(*,v,*,showv)

-- time bounding (''within x time-unit'') raises TimeOut ()
|(*,BCoffee,v){- ''join-pattern'' equivalent: button(BCoffee) & value(v) -}
->(vendCoffee10v)within30s
|(*,BTea,v)->(vendTea5v)within30s
|(*,BCancel,v)->letrefundu="Refund "++showu++"\n"
in(*,0,refundv,*)
handle
EFakeCoin(v,msg)->(*,v,*,msg)
|TimeOut()->(*,*,*,"maybe content exhausted, call service!")
|HeapOverflow()->(*,*,*,"error: heap limit exceeded")
|StackOverflow()->(*,*,*,"error: stack limit exceeded")
;
incrementCreditcoinv=
casecoinof
Nickel->v+5
Dime->v+10
Fake->raiseEFakeCoin(v,"coin rejected")
;

venddrinkcostv=
ifv>=cost
then(servedrink,v-cost,*,"your drink")
else(*,v,*,"money is short of "++show(cost-v))
;

servedrink=casedrinkof
Coffee->"Coffee\n"
Tea->"Tea\n"
;

boxcontrol
in(c::char)
out(coin::Coins,button::Buttons)
match
'n'->(Nickel,*)
|'d'->(Dime,*)
|'f'->(Fake,*)
|'c'->(*,BCoffee)
|'t'->(*,BTea)
|'x'->(*,BCancel)
|_->(*,*)
;

streamconsole_outpto"std_out";
streamconsole_inpfrom"std_in";
-- dataflow

wirecoffee
-- inputs (channel origins)
(control.coin,control.button,coffee.valueinitially0)-- 
-- outputs destinations
(console_outp,coffee.value,console_outp,console_outp)
;

wirecontrol
(console_inp)
(coffee.coin,coffee.button)
;

References

[edit ]
  1. ^ Eekelen, Marko Van (2007). Trends in Functional Programming. Intellect Books. p. 198. ISBN 978-1-84150-176-5.

Further reading

[edit ]
[edit ]
Haskell programming
Software
Implementations
(features)
Dialects
Electronic
design
Libraries
Package managers
Windowing systems
Web frameworks
Book
Community
Eponym

AltStyle によって変換されたページ (->オリジナル) /