November 2011
Abstract
Obix is a new, open-source, object-oriented programming language specifically designed to write more reliable code in less time. This article tells you what you can do with Obix and why Obix helps to write more reliable code.
"Why still another programming language?" you might ask. Before answering this justified question, let us first briefly describe the main characteristics of Obix.
Obix is:
a high-level, object-oriented, statically-typed, compiled, portable programming language
open-source, licensed under the AGPL version 3
currently in beta version
The compiler generates Java binary code (.class files). Hence, applications written in Obix can run on any system with a Java Virtual Machine (JVM) installed, such as Linux, MacOS, Windows, etc.
You can download a binary distribution for Linux or Windows (free of charge) from www.rps-obix.com. A tutorial, reference manual, API browser, and links to a bug tracker and the Git source code repository are also available on the website.
There is currently no support for an Integrated Development Environment (IDE) such as Eclipse. All tools for managing projects and compiling, running and testing code are executed from the command line.
Do you like bugs in programs? Nobody likes them! They frustrate programmers, users, managers, bosses and other people. The software industry reveals that finding and repairing bugs has cost huge amounts of time and money. Projects have failed because of 'too many bugs' and numerous bugs have created high damages. For concrete examples, just search for something like 'expensive software bug' on the net.
For that reason Obix has been designed from the outset on with a very specific main goal in mind, namely to help writing more reliable code. In practice this means that:
once your code passes compilation it contains less bugs
remaining bugs are more quickly detected at runtime
As a result you can expect to reduce development time and costs.
The 'more reliable code' goal is achieved through the following very important Fail fast! rule which is consistently embedded in the language and the libraries:
Every coding error should be detected as early as possible,
preferably at compile-time, or else as early as possible at run-time.
This rule is important and effective because studies done by prominent companies such as IBM and NASA show that costs generated through software bugs increase exponentially when the bugs are detected late in the software development process. The following figure demonstrates this schematically.
To achieve the goal of early error-detection Obix incorporates a unique combination of over 20 proven and innovative 'Fail fast!' concepts. Some of the most important built-in error-preventing concepts are:
Because all Fail fast! concepts are part of the language they work and evolve seamlessly together. They are easy to use and there are no version conflicts or dependencies on third-party extensions.
To illustrate one of Obix's unique features for more reliable code, look at the following example source-code:
int server_port = 8080 int age_of_my_elephant = server_port
Can you see the error? Of course, you can.
Can your compiler see the error? No, it can't. Although server_port and age_of_my_elephant are obviously two semantically different values, the compiler can't see an incompatibility, because both values are of type integer. Moreover, no run-time error will be generated, despite the fact that elephants can't be older than about 100 years.
You might say: "No programmer would ever write silly code like this!" This is true (for most programmers !!!). However, look at this code:
int age_of_elephant = utilities.get_initial_value
Now you can't tell if the assignment is ok by just looking at the source code. You would have to manually verify that utilities.get_initial_value actually returns an age_of_elephant value which can't be negative and can't exceed 100. It would be helpful if the compiler could check all this for you automatically, wouldn't it?
Without digging too deep in how it works, here is the solution in Obix. You would define a specific type age_of_elephant and declare a positive maximum value of 100. The source code for this type looks as follows:
type age_of_elephant
inherit simple_positive32
attribute value and_check: i_value <= 100~ end
end
endThen, you would declare a variable and assign it a value as follows:
var age_of_elephant age_of_my_elephant = ...
Now the Obix compiler ensures that the right side of the assignment actually returns an age_of_elephant value (and not a server_port value). And it is impossible to assign an invalid value such as -5 or 8080.
Many applications contain hundreds or thousands of integer variables with semantically different (and therefore incompatible) values. Compile-time and run-time checks like the above one are therefore very important and effective, because any incompatibilities and illegal values are immediately and automatically reported. The same observation can be made for other data types such as strings. For example, in Obix you would define different types with specific validation rules for customer_name, email_adress and ISBN_number.
All error-detection concepts are fully described in Obix's documentation and numerous examples show why they increase software reliability. To get an overview of the different techniques you can read part II of the Obix tutorial. This part guides you step by step in the development of an example application that creates a random picture based on data provided by people. Here is an example of such a picture, saved in a Scalable Vector Graphics (SVG) file:
Besides the number 1 goal (increased software reliability), Obix's web site also explains and gives examples of the two other main goals which are also pursued since decades in the software industry:
increase developer productivity
simplify the software development process
One example is the tight integration and support of Java software in Obix applications. You can use any existing Java software (.class or .jar files) in an Obix project and data can be easily exchanged between Java and Obix. The following Obix source code snippet shows an example of a variable declared and initialized in Obix, and then used in Java code:
var string name = "Lisa Simpson" // Obix code java System.out.println ( "Hello from Obix and Java, " + v_name.java_value() ); // Java code end java
Executing this code will display:
Hello from Obix and Java, Lisa Simpson
Part I of Obix's tutorial explains Obix's integrated support for easily creating different kinds of applications, ranging from executing a single instruction up to creating a complex web application using Java's servlet and JSP technology. For example, you can create a simple arithmetic calculator 'application' by using Obix's script file facility as follows:
After installing Obix, create file tests/calculator.osc in Obix's root directory and insert the following code:
const string input = system.console.ask_string ( "Please enter an arithmetic expression: " ) const any_type output = source_code_executer.evaluate_expression.result ( expression = input ) if output #r void then system.console.write ( "Result: " & output.to_string ) end if
Now execute the calculator by entering the following command in Obix's root directory:
on Windows, type obix tests\calculator.osc on Linux, type ./obix.sh tests/calculator.osc
When prompted, type any arithmetic expression such as:
( 1 + 2 ) * 3
After pressing <Enter> the result will be displayed:
Result: 9
Obix started as a one-man project. The author is currently looking for people interested to collaborate, in order to improve Obix, create and maintain an open-source community and finally make Obix a mainstream programming language that helps to write reliable production code in less time. You are very welcome to participate. Thank you!
The author appreciates any comments, suggestions or other feedback sent to christian {at} rps-obix {dot} com.