Hello World!
This program speaks for itself.
letMeLearnYouSomething("Hello, world")!
Variable Declarations
John Lang provides many variables to declare.
switcheroo x: youBetcha!
handful y: 2!
switcheroo isPositive: y >= 0!
chitchat message: "Eat the rich"!
Function Declarations
Functions are incredibly functional in John Lang
gitErDone isEven(handful x): switcheroo {
betterGetGoin x % 2 == 0!
}
Conditionals
Conditionals are conditioned in John Lang.
ope x > 50 {
betterGetGoin 2!
} welp ope x > 25 {
betterGetGoin 1!
} welp {
betterGetGoin 0!
}
Loops
Even John Lang provides many ways to loop.
tilTheCowsComeHome handful x: 0, x < 10, x: x + 1 {
letMeLearnYouSomething(x)!
}
holdMyBeer x < 10 {
x: x + 1!
}
Classes
You want classes? John Lang has them.
doohickey Rectangle {
slapTogether(handful h, handful w) {
handful height: h!
handful width: w!
}
}
Rectangle r: whipUp Rectangle(4.0, 8.0)!
letMeLearnYouSomething(r.width)!
r.width: 5!
Data Structures
Collections are an easy feat for John Lang.
todo fruits: ["apple", "banana"]!
almanac fruitPrices: { "apple": 2, "banana": 1 }!
Example Program
Here is an example program, courtesy of John himself.
handful x: 0!
holdMyBeer youBetcha {
x: x + 1!
ope x < 5 {
letsNotGetCarriedAway!
} welp {
letsBlowThisPopsicleStand!
}
}
letMeLearnYouSomething(x)!