I both love and hate writing Bash. I love that it\'s so streamlined for operating on files and working with processes (I agree with this popular question that it\'s way
I recently developed a language called BashClass which is Object Oriented, has type checking and allow multi-dimensional arrays. The language syntax is inspired by different programming languages.
Here's an example on how a List
class is implemented (Full example here):
class List extends Object {
var Object[] data = new Object[];
var int size = 0;
constructor List(){
super_constructor();
}
function void add(var Object object) {
data[size] = object;
size = size + 1;
}
function void pop() {
if(size == 0) {
exception("Cannot remove element from an empty list");
}
size = size - 1;
data[size] = null;
}
function int size() {
return size;
}
function Object get(var int index) {
if(index < 0 || index >= size) {
exception("Cannot access element out of bound");
}
return data[index];
}
}
Classes and multi-dimensional arrays in BashClass are converted to Bash 4.4 associative arrays. The language is at its first release and is open source on Github. Feel free to contirbute and suggest features.