Glava
Glava is an esoteric programming language, built on top of a Java base, that is designed to be effective in code golf competitions. It was designed and implemented by ZekNikZ in 2017.
Glava is not designed to be a separate language from Java, it is purely designed as a shorter, more feature-rich version. This includes a custom code page which allows all characters to be a single byte.
Features
Shorthands
Shorthands are single- or double-character shortcuts that are replaced by longer strings. Shorthands are what give Glava much of its power.
Type Shorthands
Type Keywords
β
→boolean
χ
→char
δ
→double
φ
→float
ι
→int
Type Classes
Π
→Boolean
Σ
→Character
Δ
→Double
Φ
→Float
Γ
→Integer
σ
→String
Type Classes w/ new
Keyword
ηΠ
→new Boolean(
*ηΣ
→new Character(
*ηΔ
→new Double(
*ηΦ
→new Float(
*ηΓ
→new Integer(
*ησ
→new String(
*
Casting
ζΠ
→(boolean)
ζΣ
→(char)
ζΔ
→(double)
ζΦ
→(float)
ζΓ
→(int)
ζσ
→(String)
Loop Shorthands
ε
→while(
closing character adds){
*Ξ
→while(true){
(infinitewhile
loop) *ω
→for(
closing character adds){
*Ω
→for(int i=0;i<
(pre-builtfor
loop) closing character adds;i++){
*
Command-line Arguments
String Arguments
⑴
→args[0]
⑵
→args[1]
⑶
→args[2]
⑷
→args[3]
⑸
→args[4]
⑹
→args[5]
⑺
→args[6]
⑻
→args[7]
⑼
→args[8]
⑽
→args[9]
Converted Arguments
The shorthands ①②③④⑤⑥⑦⑧⑨⑩
are replaced with their corresponding command-line arguments, after attempting to convert them to another native type. For example, if the first argument is 12.34
, ①
will be replaced with 12.34
in the code.
Converted Arguments Arrays
All of these arrays contain only the command-line arguments of that type.
Ⓑ
→glava_args_boolean[
*Ⓒ
→glava_args_char[
*Ⓓ
→glava_args_double[
*Ⓕ
→glava_args_float[
*Ⓘ
→glava_args_int[
*Ⓢ
→glava_args_String[
*
Output
π
→System.out.print(
*λ
→System.out.println(
*κ
→System.out.printf(
*
Misc
υ
→.length()
ύ
→.length
ϋ
→.size()
η
→null
ώ
→};
(also a group closer)
* This shorthand opens a group.
Automatic Code-Completion
Glava has the great feature of being able to auto-complete many parts of your code.
Automatic Group Closing
If, throughout your code, you open any groups ((
, {
, [
, etc.) but never close them, Glava will close them automatically when compiling. Note that this does not work the other way around.
Example: λ"Hello, World!
will be closed by λ"Hello, World!"
, and then by System.out.println("Hello, World!)
.
Automatic main
Method and class
Wrapping
Glava also has the ability to wrap your entire code in a main
method, assuming it does not have one. And then, if it does not have a surrounding class
, it will wrap the code in public class Main { ... }
.
Additionally, if Glava wraps the code in a class
, several other features are added as well. All of the following are added into/around the Main
class
as well:
Default Imports
java.util.*
static java.lang.Math.*
java.io.*
java.awt.*
javax.swing.*
java.text.*
java.util.regex.*
Default Class (Static) Variables
int m = 0
int n = 1
double d = 0d
float f = 0f
String s = ""
String t = "\n"
String u = "abcdefghijklmnopqrstuvwxyz"
String U = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
char c = 'A'
boolean T = true
boolean F = false
Command-line Converted Argument Arrays
Note: only the applicable arrays are created when the program is run. Also, note that all of these arrays also have shorthands.
int[] glava_args_int
double[] glava_args_double
float[] glava_args_int
char[] glava_args_char
boolean[] glava_args_boolean
Miscellaneous Features
On this wiki page you can find a list of all of the miscellaneous features of Glava that do not fit in another category.
Multi-line Strings
Instead of using \n
for linefeed characters in strings, in Glava, you can use literal linefeeds.
Shorter char
Literals
Not as important, but all char literals in Glava
no longer use and ending single quote ('c
is a char
literal in Glava but 'c'
is not).
Custom Code Page
To be able to use more characters in programs, Glava has a custom code page which can be found here.
Examples
Hello, World!
λ"Hello, World!
FizzBuzz
λ(①%3<1?"Fizz":s)+(①%5<1?"Buzz":①%3<1?s:①
99 Bottles of Beer
n=99;A=new String[]{" bottles of beer on the wall"," bottles of beer. Take one down, pass it around, ","Better go to the store and buy some more."ώwhile(n>0){λn+A[0]+", "+n+A[1]+(--n)+A[0]+". ");}λA[2]