# Controlling robots in remotely-operated laboratory using Objection language

Our goal is to enable robots in virtual laboratory to be controlled using the Objection programming language.

## Contents

## Challenges

- The Objection language runtime is written in Delphi and has not been ported to platforms other than Win32 yet
- The codebase of Objection language needs to be reorganized in a way that will allow extending it with Robot library bindings, yet ensure that the runtime core remains independent of it.
- It should be possible to replace the runtime core with a newer Objection version with as little effort as possible
- Integration to existing virtual laboratory system
- End user interface

## Language

Objection is a multiparadigm programming language, written partially in itself. Every value is a first class object, including functions. Blocks of code are anonymous functions and language constructs such as loops only manipulate with functions. All of this is hidden underneath a classical, structured syntax, but remains fully accessible for advanced user to explore.

Here is a short list of Objection features:

- garbage collection
- optimized tail recursion
- first class functions
- anonymous functions
- closures
- generators (via the yield keyword)
- duck typing
- all values are objects
- prototype object model (can be used indirectly using class-like syntactic sugar)
- operator overloading
- basic data structures literals
- infinite lists (via generators)
- classes and metaclasses
- objects ex nihilo
- classical language constructs
- powerfull built-in higher order operators
- eager evaluation
- support for return, break and continue commands
- compiled to bytecode interpreted by Objection Virtual Machine
- editor supporting syntax highlighting (Windows only)

Here is a short list of features that Objection currently *lacks*:

- short circuit evaluation of boolean operators
- call-by-reference for function arguments
- exceptions
- properties
- large numbers
- sane class library
- API for calling external libraries
- speed

## Very basic language examples

### Some prime numbers

var primes := {} for n in 2..100 do [ var isPrime := yes for p in primes do if n mod p = 0 then [ isPrime := no break ] if isPrime then primes.Add(n) ] print primes

# The same, still slow, but a bit compressed var primes := {} for n in 2..100 do if not ([p | n mod p = 0] in primes) then primes.Add(n) print primes

### Quicksort

# This code can be written way shorter, and way less readable function Sort |list| if list.Length() = 0 then return {} var pivot := list.Head() var lesser := Sort(list.Tail() where [x|x<=pivot]) var greater := Sort(list.Tail() where [x|x>pivot]) lesser ++ {pivot} ++ greater

### Computing factorial using Y combinator

# Actually using applicative-order version of Y combinator for "recursion" var Z := [f| [x|f([y|x(x)(y))]([x|f([y|x(x)(y))]) ] var Fact := [f| [x|if x = 0 then [1] else [x*f(x-1)]]] print Z(Fact)(6)

### Infinite lazy lists

function Naturals var i := 0 while yes yield i i ++ 1 for i in Naturals.Take(50) do print i # prints numbers 0 .. 50 var squares := Naturals change [x|x^2] # "squares" now contains ordered squares of all natural numbers var squaresGreaterThanMillion = squares where [x|x>1000000] print squaresGreaterThanMillion.Take(1) # Prints first square of a natural number greater than million

### More examples and tutorial

More examples and a somehow lacking and incomplete language tutorial can be found at [[1]]. The site also contains a full listing of Objection standard library (written in Objection), from which a lot of more advanced language features can be deduced. A minimalistic language IDE and a runtime can be obtained at [[2]] for experimentation. All information provided there is unfortunately in Slovak language only.

## Project implementation notes

The Robot library bindings are accessible as a class methods of class Robot in Objection runtime.