Janus
Jump to navigation
Jump to search
Janus is a high level reversible programming language created by Christopher Lutz and Howard Derby [1] as part of a class they taught. It was later discovered and developed further by Yokohama, Gluck et. al [2]. Any program written in it can be run forwards or backwards. A compiler from Janus to PISA was described in [3].
Example
procedure init(int n, stack list) local int q=0 n += 4 q+=9 push(list,q) q+=7 push(list,q) q+=1 push(list,q) q+=5 push(list,q) delocal int q=0 procedure makeidperm(int n, stack perm) local int i=0 local int z=0 from i=0 do skip loop push(perm,z) perm[i] += i i += 1 until i=n i -= n delocal int z=0 delocal int i=0 procedure sort(int n, stack list, stack perm) local int i=0 local int j=0 from i = 0 do skip loop j += n-2 from j = n-2 do skip loop if list[j] > list[j+1] then list[j] <=> list[j+1] perm[j] <=> perm[j+1] else skip fi perm[j] > perm[j+1] j -= 1 until j = i-1 j -= i-1 i += 1 until i = n-1 i -= n-1 delocal int j=0 delocal int i=0 procedure main(int n, stack list, stack perm) call init(n,list) call makeidperm(n,perm) call sort(n,list,perm)
References
- [1] Janus: a time-reversible language (1986) - The creation of Janus in a Letter from Christopher Lutz to Rolf Landauer.
- JANUS: A TIME-REVERSIBLE LANGUAGE - HTML version of the same letter. (dead link)
- [3] Clean Translation of an Imperative Reversible Programming Language (Axelsen 2011) - Details the compiler from Janus to PISA. (dead link)
- [2] A reversible programming language and its invertible self-interpreter - Tetsuo Yokoyama and Robert Glück. - Defines the term Reversibly-Turing Complete and proves that Janus is including a self interpreter.
External resources
- Program Inversion and Reversible Computation - Modern Janus interpreter in Javascript by Claus Skou Nielsen and Michael Budde.
- An article about Janus on Wikipedia.