JMUC is a cross-platform compiled Java-based high-level programming language and
IDE package made by Daniel Williams.
I programmed JMUC without any formal compiler class and without any research.
So the final product, I'm proud to say, is a 100% original compiler.
Features
- Cross platform
- Compiled language
- Clean and simple syntax
- High level built-in functions
- Automatic indentation
- Syntax highlighting
- Autocompletion
Example of selection sort:
JMUC requires Java to run.
You can download the latest version of Java here.
JMUC, editor, and
example programs
Introduction to JMUC
Variable types
Variable and array keywords are highlighted in pink.
int
Stores a 64-bit integer in the range
-2^63 to 2^63-1.
An int
can always be used in place of a real
if decimal places are not needed.
real
Stores a 64-bit real number in the range
±1.7976931348623157E+308
with about 15 decimal digits of accuracy.
string
Stores a string of characters of unlimited length.
Like arrays, the characters in a string
are indexed starting at the zeroth index.
boolean
Stores either
true or false
and can be used in boolean logic expressions.
Examples:
int num = 12345
print("An integer: " + num1)
real realNum = 3.14
print("This has decimal places: " + realNum)
boolean aBool = true
print("Only two options: " + aBool)
string s = "This is a string"
print(s)
Operators
The order of operations is:
1 |
^ |
exponentiation |
2 |
*, /, % |
multiplication, division, modulus |
3 |
+, - |
addition, subtraction |
4 |
<, >, <=, >= |
less than, greater than, less than or equal to, greater than or equal to |
5 |
==, !=, === |
equal, not equal, type equal |
6 |
&, | |
AND, OR |
7 |
!(...) |
NOT (requires parenthesis) and other functions |
Examples:
// Initialize an array with values
int[] arr = {1, 8, 3, -45, 0}
// Access array values
print(arr[0]) // 1
print(arr[1]) // 8
print(arr[2]) // 3
// Get the length of an array
int length = #arr
print(length) // 5
// Initialize an array by length only
int[] arr -> 100
// Assign array values
arr[0] = 16
arr[99] = -35
// Access array values
print(arr[0]) // 16
print(arr[50]) // 0
print(arr[#arr - 1]) // -35
Arrays
int[],
real[],
string[],
boolean[]
Each array type holds its respective data type.
Arrays can only hold mixed data types.
Once an array is initialized, it cannot be resized.
Arrays are passed by reference, so modifying an entry in one array
will modify the same entry in any copy of that array.
// Initialize an array with values
int[] arr = {1, 8, 3, -45, 0}
// Access array values
print(arr[0]) // 1
print(arr[1]) // 8
print(arr[2]) // 3
// Get the length of an array
int length = #arr
print(length) // 5
// Initialize an array by length only
int[] arr -> 100
// Assign array values
arr[0] = 16
arr[99] = -35
// Access array values
print(arr[0]) // 16
print(arr[50]) // 0
print(arr[#arr - 1]) // -35
Type casting and checking
Integers can always be used in place of real numbers.
In most cases, if a real number returned from a function is
an integer, it will be automatically cast to an
int.
The types of two variables can be checked using the '==='
operator.
int num1 = 78
int num2 = sqrt(4) // Automatically returns an int
real num3 = sqrt(5) // Returns a real number
print(num1 === num2) // true
print(num2 === num3) // false
print("Hello" === "Goodbye") // true
Branching structures
JMUC provides the
if,
else if, and
else
keywords for branching between different pieces of code.
These keywords are highlighted in dark blue.
int num = 5
if (num == 3) {
---print("Not this one")
}
else if (num < 4) {
---print("Not this either")
}
else {
---print("This one")
}
int num = 100
// Nesting works too
if (num % 2 == 0) {
---print("This is even")
---
---if (num == 4) {
------print("It's 100");
---}
---else {
------print("Nope")
---}
}
Loops
JMUC provides the
while and
repeat
loops for iterating the same code many times.
These keywords are also highlighted in dark blue.
while
The while loop takes an
boolean parameter and will repeat
as long as the condition is true.
repeat
The repeat loop takes an
int parameter which determines how
may times the loop will execute. Once the loop is entered,
the number of repetitions cannot be changed.
int numRepeats = 5
// Repeat five times
repeat (numRepeats) {
---print("In the repeat loop")
}
// Equivalent, but with while loop
int i = 0
while (i < numRepeats) {
---print("In the while loop")
---i = i + 1
}
real[] nums = {4.5, 5.5, 6.5, 7.5, 8.5}
// Iterating through an array
int index = 0
repeat (#nums) {
---print(nums[index])
---index = index + 1
}
Built-in functions, math, and constants
JMUC provides a number of common functions such as
print,
sleep,
min,
max,
sin,
cos,
roundTo, and
randInt.
It also has higher level functions such as
stdev,
inputInteger,
isPrime,
interpret, and
describe.
Functions that return values are highlighted in dark red.
Functions that do not return values are highlighted in cyan.
The details of these functions are described in the function reference section.
Math expressions and examples
Functions that return values must be evaluated as part of expressions.
Functions that do not return values must be evaluated as part of expressions.
That is, these functions cannot exist alone on a line.
real someTrig = sin(1.6) / atan(1)
int roundedNum = roundTo(47.234, 5) // Round to the nearest 5, returns 45
real logs = log(2.718) + log2(512) + log10(100) + logN(1331, 11); // 0.999, 9, 2, 3
real distance = mag(3, 4) // Pythagorean theorem, returns 5
int millis = getMilliTime() // Time since epoch in milliseconds
boolean primeCheck = isPrime(32410291) // true
real randNums = randInt(0, 100) + rand() + randGauss()
int aSummation = nTriangle(10) // returns the nth triangle number
int max1 = max(49, 10, 90, 65)
int max2 = max(53, 15, 49, 30,-4, 19) // variadic functions
string answer = describe("newton") // returns 'Isaac Newton, English scientist'
Built-in constants
JMUC has the following built-in mathematical constants:
pi = 3.141592653589793238
e = 2.718281828459045235
phi (golden ratio) = 1.618033988749894842
max = 2^63-1
min = -2^63
Gd (deep-gauss constant) = 0.753089164979674816
real answer = log(e ^ 4.5) // Returns 4.5
real radius = 2.0
real area = pi * radius ^ 2 // Returns 12.56637
real scaled = 10 * phi // Returns 16.18034
int bigOne = max(max, 99999999); // max is always bigger
int smallOne = min(min, -99999999); // min is always smaller
real val = e ^ (-Gd ^ 2 / 2)
print(val == Gd) // Mind blown
String manipulation examples
// Concatenation of strings
string s1 = "Hello "
string s2 = "World!"
string s3 = s1 + s2
print(s3) // Hello World!
// Reverse a string
s3 = reverse(s3)
print("Reverse: " + s3) // !dlroW olleW
// Isolate parts of a string
string s4 = substring("ABCDEFG", 0, 3)
print(s4) // ABC
// Length of a string (same as array)
print("Length is " + #s3)
// Change to upper case
print(upperCase(s1)) // HELLO
// Separate string into array
string str = "Hello World!"
string[] chars -> #str
// Fill the array
int i = 0
repeat (#str) {
---chars[i] = charAt(str, i)
---i = i + 1
}
// [H, e, l, l, o, , W, o, r, l, d, !]
print(chars)
User input examples
The functions
inputInteger,
inputReal,
inputBoolean, and
inputString
are used to get input from the user.
Program execution is stopped until a valid value
is entered.
int myInt = inputInteger()
real myReal = inputReal()
string myStr = inputString()
boolean myBool = inputBoolean()
print(myInt + ", " + myReal + ", " + myStr + ", " + myBool)
Function reference
Functions that return values such as
sin and
rand
must be evaluated in expressions.
Functions that do not return values such as
print,
sleep, and
info
must exist alone on a line.
Return
|
Name and parameters
|
Description
|