Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
The CORA Programming Language Jörn Fischer Faculty of Computer Science University of Applied Science Mannheim 68163 Mannheim, Germany j.fischer at hs-mannheim.de Abstract— CORA is a short form of “Compile Once Run Anywhere“. The programming language is object orientated and compiler based, running on a virtual machine called the “Minimal Virtual Machine“(MVM). Due to the tiny size of the MVM’s kernel, the virtual machine may be ported to any platform within a few hours. The language is highly inspired by JAVA [1] and C/C++ [2] and tries to include large parts of the syntax of both languages. The following article summarises, what functionalities are covered in the actual version. void sort(double numbers[]){ // bubble sort algorithm int N = numbers.length; for (int i=0; i<N; i++){ for (int j=0; j<N-1; j++){ if (numbers[j]>numbers[j+1]){ double help = numbers[j]; numbers[j] = numbers[j+1]; numbers[j+1] = help; } } } I. I NTRODUCTION The name CORA, “Compile Once Run Anywhere“implies that the code is compiled to an intermediate code, which then runs on a virtual machine called the CORA MVM (Minimal Virtual Machine). The MVM kernel covers about 2-3 pages of C/C++ code and therefore is easyly ported to any platform. The MVM is also ported to JAVA and JavaScript, languages which are highly disposable. II. K EYWORDS The following table shows the keywords which are actually implemented in CORA. All keywords exist in JAVA, C++ or even in both of these languages. break goto return void class new if double case static float asm private public extends char switch boolean byte int long const do else short while for III. L ANGUAGE AND S YNTAX As the code example in Fig.1 shows, the code is widely compatible with the JAVA and C/C++ syntax. There are “for“-loops, “while“- and “do-while“-loops. The “for-each“-loop is NOT implemented yet! Please always use curly brackets {} for the block to be repeated. The “if-else“expression should also contain curly brackets for the if-blocks and for the else-block. Please do not use the “else-if“expression, but “else{ if(condition){...block...} }“instead. The “switch-case“expressions should work fine. Arrays are implemented as one dimensional arrays and may be declared using the new operator. The declaration of an array by assignment of multiple numbers in curly brackets is NOT supported yet. } Fig. 1. A simple bubble sort example method. IV. DATA T YPES The following elementary data types are defined: char, byte, short, int, long, float, double. Because the actual MVM is based on floating point operations, “double“variables are always treated with the precision of floats. Declarations may be made outside of methods, but variable initialization must always be done in methods. V. O PERATORS The following Operators are implemented: Name brackets negate increment decrement Arithmetic Operators shift operators compare operators Symbol () [] ! ++ −− ∗/% +− << >> > >= < <= == ! = Priority 13 12 11 10 9 8 7 The priority of the operators should be the same as in JAVA. Brackets always have the highest priority. VI. F UNCTIONS /M ETHODS As in JAVA methods are declared with an optional “public“or “private“, then the data type of the return value, the name of the method and in brackets the arguments of the method. The return statement or the closing curled bracket ends the method. As in C++ the public: or private: statement defines the following functions and variables as public or private. VII. O BJECT O RIENTED C OMPONENTS All declarations, functions, assignments and commands are organized in classes. From these classes, objects may be generated with the new operator. Until now it is possible to call functions with the dot operator, while for the moment variables have to be manipulated via setter and getter functions. Objects are generated as references. Assigning objects will only change the reference, not the object itself. For the moment there is neither a copy constructor nor a clone() method. Even interfaces are missing. Using the JAVA-keyword extends or the C++ way “class Name :public Basename“enables inheritance. VIII. L IBRARIES There are no C/C++ or Java libraries implemented. IX. F UTURE WORK First goal is to get a stable programming language, where bugs are recently reported and corrected in a short time. Second goal is to implement the main kernel functionality of Java and C/C++. Third goal is to implement a minimum of libraries and documentation, which help the programmer to write simple programs. ACKNOWLEDGEMENT Special thanks to Thomas Ihme and Robert Kettler who helped with fruitful discussions. R EFERENCES [1] K. Arnold and J. Gosling. The Java Programming Language. The Java Series. Addison-Wesley, Reading, Massachusetts, 1996. [2] Brian W. Kernighan and Dennis M. Ritchie. The C Programming Language. Prentice-Hall, 2nd edition, 1989.