# Frink

Paradigm(s) Multi-paradigm: functional, object-oriented, imperative 2001 Alan Eliasen dynamic typing, strong typing Frink Java, Perl, Ruby, Smalltalk, BASIC

Frink is a calculating tool and programming language designed by Alan Eliasen in December, 2001,[1] and presented at the Lightweight Languages 2004 conference.[2] It is built on the Java Virtual Machine and incorporates features similar to Java, Perl, Ruby, Smalltalk, and various BASIC implementations. Its main focus is on the fields of science, engineering, physics, text processing, and education.

Frink is named after the fictional mad scientist Professor John Frink from The Simpsons.

## Measurement units

One of the distinguishing characteristics of Frink is that it tracks units of measure through all calculations. This allows all values to contain a quantity and its units of measure. Frink understands how different units of measure interrelate, such as how length cubed is volume, and power multiplied by time is energy. Different units of measure can be mixed in calculations, and Frink automatically ensures that the calculations lead to a result with the expected dimensions.

```height = 10 feet
gravitation = 9.80665 m/s^2
mass = 180 pounds
potential_energy = height * gravitation * mass
println[potential_energy -> joules]  // Display in joules, number displayed without units
```

Since gravitation is given as a floating-point value, the answer is also floating point.

2440.47230699652072

The statement above could be rewritten many ways - using different abbreviations and different target units, for instance:

```3 meters 1 gravity 180 lbs -> "Calories"
//Capital-C Calories = kilocalories
//Quotes around target unit cause answer to be displayed with units.
```

Here the built-in unit "gravity" is used, which is specified in Frink's units file as a rational number. Since all the inputs are rational or integer the result is:

26689329691563/46520000000000 (approx. 0.5737173192511393) Calories

Note that different systems of measurements can be effortlessly mixed (for example, pounds, meters, and feet.) When used interactively as a desk calculator println[] and named variables are not required.

The standard distribution comes with a data file which contains hundreds of the most common (and uncommon) units of measure, along with data such as masses of elementary particles, planetary data, and historical units of measure. The standard data file uses the SI base units as its fundamental units of measure, and extends this with units for currency and information (bits). The standard data file can be completely replaced by the user, and new units and even fundamental dimensions may be added at runtime. Any unit or product of units in the file can be converted easily into any other unit which measures the same sort of quantity.

↑Jump back a section

## Other features

Frink has arbitrary-size integers, arbitrary-size rational numbers, arbitrary-precision floating-point numbers, complex numbers, and interval arithmetic. It also has a number of optimized functions for number theory computations.

Frink uses Unicode characters throughout, allowing it to represent most of the world's languages.

On systems with an internet connection, Frink can translate dozens of human languages, including some requiring right-to-left reading, and it can also convert among current currency and precious metal values as well as inflation-adjusted US dollar and British pound values.

Frink has regular expressions for text processing which are very similar to those in Perl or Ruby.

Other built-in datatypes include dynamically resizable arrays, dictionaries, sets, enumerating expressions, and anonymous functions. Frink also allows writing of object-oriented programs, although inheritance is not yet implemented.

Frink is not exactly a dynamically typed nor a statically typed language. By default, any value may be placed into any variable. However, for more safety, arbitrary constraints may be placed on any variable, ensuring that only values meeting the constraints can be assigned to the variable. For example, one can constrain a variable to only contain values that have dimensions of power. Any number of arbitrary constraints may be placed on a variable, including constraints described by user-defined functions. For example, a variable or function argument could be constrained to only contain prime numbers greater than 100.

Frink contains a pattern-matching and tree-rewriting engine that allows transformation of one mathematical expression to another. This allows symbolic manipulation of equations, solving of systems of equations, simplification of algebraic expressions, and symbolic derivatives and integrals with the proper rules defined.

Frink includes concise commands for creating graphical user interfaces as well as animated or static vector and bitmapped graphics, optionally with scaling directives for physically dimensioned drawings.

Date and time values are integrated with the units of measure. Dates and times can be specified and used in calculations in a wide variety of formats. A date/time represents a particular moment in time, and can be converted to different timezones, Julian day, Modified Julian day, Dynamical Time, and many other systems of time. Frink keeps track of the quirks of these different systems, even down to leap seconds.

Frink can call Java methods and automatically convert its internal types to and from Java types, allowing use of external Java libraries. Frink can also be embedded in a Java program with only a few lines of code.[3]

Frink Server Pages uses Frink as a language for creating dynamic web-based resources, similar to PHP or Active Server Pages.

↑Jump back a section

## Host platforms

It is implemented in Java and will run on Java Virtual Machine version 1.1 and later, or on Android 1.5 and later. (This includes nearly all personal computers and operating systems as well as many cellphones and hand-held devices.) Supported platforms include PersonalJava 1.1 implementations that include implementations of the optional `java.math` libraries. It includes a text-mode interface as well as three different graphical interfaces using the Java AWT, Swing, and Android libraries.

The interpreter is freeware, but proprietary: its source code is not available. It generally installs with one or two clicks on any machine with a recent version of Java, or it can be used via a web-based interface.

↑Jump back a section

## References

1. ^ http://futureboy.us/frinkdocs/whatsnew.html Frink changelog
2. ^ http://ll4.csail.mit.edu/Abstracts.html#Eliasen Eliasen, Alan, "Frink - A Language for Understanding the Physical World", Lightweight Languages 2004, Massachusetts Institute of Technology, Cambridge, MA, 2004
3. ^ Smedley, Richard (2008). "LXFHotPics: The best new open source software on the planet". Linux Format (Future Publishing). LXF105 (May 2008): 70–75.
↑Jump back a section