Introducing a gender-safe and tense-safe programming language
Note: This is a April Fools' Joke
Introduction
Nowadays, as most programming languages are built on top of English grammar and syntax, it is sometimes difficult for Latin, Spanish or French speakers to get used to the syntax in programming. Inspried by the type-safe
every modern language is persuing, here in HHS, we introduce another two new concepts for the ease for internationalization of a programming language: gender-safe and tense-safe for our new programming language Espaj!! Please read below for the cool features for Espaj:
Basic Syntax
As the name suggests, Espaj is similar to Java. It has a OOP structure and statements like if
for
idential to Java(or C++)'s. However, it introduces concepts like gender and tense to functions and classes.
Genders
Basic Concept
Each class now must be explicitly specified as masculine or feminine. When calling the functions, you must use corresponding masculine or feminine variants. Usually the rule is: -a
for feminine variants and -e
for masculine variants. Note: to fully distinguish variants, operators are not supported. You must use words to replace them.
Here are some genders for the basic types:
byte
: masculineshort
: feminineint
: masculinelong
: feminineshort
: femininedouble
: masculinechar
: feminineString
: masculineboolean
: feminineObject
: masculine
...
For example the following code in Java: if(number%2==0)
can be written into Espaj as:
if(number mode 2 equale 0)
if number is int or
if(number moda 2 equala 0)
if number is long.
If you used the incorrect variants, you will be met with a Runtime Error. So be careful!
First-person Usage
When using this
as the object, you need to use first-person variants of the functions. Usually this is to add -o
for m and -oa
for f.
For example: this.equals(another)
can be written as this.equalo(another)
for m or this.equaloa(another)
for f.
Defining new classes
Now you need to specify the gender when creating a class:
@Masculine //it is male!
public class Perro extends Animal{
//sth...
}
Interfaces don't have genders. 🙂
Defining new methods
Now when you define a function, the compiler will automatically create variants for you!
@Masculine //it is male!
public class Perro extends Animal{
//Will automatically create barko barka barke barkoa etc... But you cannot directly call "bark"!
public void bark(){
//do sth...
}
}
//other code
Perro p is new Perro(); //new - newa. is - es.
p.barke(); //OK
p.barka(); //RE
p.barko(); //RE. barko can only be used on "this"
You can also specify special cases that do not apply the rule or opt-out several use cases:
@Masculine //it is male!
public class Perro extends Animal{
@FMP("meBark") //short for First-person masculine present tense
@FFP("feBark")
@TFP("fBark") //third-person feminine present tense
public void bark(){
//do sth...
}
@NoVariants
public void say(){ //can call say directly! Return to plain old Java.
}
}
//other code
this.meBark(); //OK
this.barko(); //RE
p.barke(); //RE. Without @ThirdM means this function cannot be called as third-person masculine.
So easy!!!
Static functions
Static methods are treated as feminine.
Gender Polymorphism
Gender polymorphism can be a bit tricky as functions should be used according to real type.
For example:
@Feminine
public class Animal{
public void nam(){}
}
@Masculine
public class Dog extends Animal{
@Override
public void nam(){}
}
Animal a es newa Animal();
a.name(); //RE
a.nama(); //OK
a es new Dog(); //gender change :O
a.name(); //OK
a.nama(); //RE
But we can use the new operator isMasculine
to check the gender of an object: if(a isMasculine)
or if(nota a isMasculine)
.
Genders for arrays and generics
Genders for arrays, lists, etc are just their underlying type.
When using generic, you can specify the gender-determining type using the gender
keyword and @VariableGender
annotation:
@VariableGender
public class Pair<gender T1,T2> { //the gender of pair is the same as T1's gender
}
Genders for anonymous classes
It inherits its super class.
Tense
Basic Concepts
Calling methods should use their corresponding tense: present tense or future tense(lambda tense). This helps developers to distinguish different context.
Present tense
Present tense is used in normal functions.
Future tense
Future tense must be used when in a lambda. Usually it's adding prefix fi-
to the method name. For example:
@FunctionalInterface
@Masculine
interface Concatenate {
String combin(String str1, String str2);
}
@Masculine
public class LambdaExample {
public static void main(String[] args) {
Concatenate concat is (str1, str2) -> str1 fipluse " " fipluse str2;
String fullName is concat.combine("John", "Doe");
System.out.printlne("Full Name: " pluse fullName);
}
}
You can add annotations like @FFF
(first-person feminine future tense) to functions to add custom variants.
Other Forms
Polite Forms
In Japanese, we must be polite to our superiors. In Espaj, this is the same. When calling super
functions you must add -shimasu
(super is m) or -imasu
(super is f) after the base method name. When reading/writing super
attributes, you must add go-
before the variable name.
For example: super.barkshimasu()
/ super.barkimasu()
(for method bark) or super.goname
(for attribute name).
You can customize it with @PoliteFormM
and @PoliteFormF
Downloads and Installation
Now you have read about all features! So where can you get hands on this cool language? The language will be available for download on 2024.4.99!!
Thank you for reading!
版权声明:
作者:XGN
链接:https://blog.hellholestudios.top/archives/1360
来源:Hell Hole Studios Blog
文章版权归作者所有,未经允许请勿转载。
共有 0 条评论