It’s Friday – time to kick back and relax with two fun Scala programs we put together for your amusement.
Scala has a pretty flexible syntax (although not as flexible as Racket’s, of course) that makes it popular amongst proponents of DSLs. Not all DSLs have to be serious, however, as I’m about to prove.
First up is Noel’s original concept – proof of his love for DSLs, expressed in purest code:
class A(num: Int) { def Scala = "It's s" + ("o" * num) + " much fun!" } object I { def <(num: Int) = new A(num) } I <3 Scala // ==> "It's sooo much fun!"
Second is a simpler work that I call “The Startled Lolcat”:
object O { def o = "What has been seen, cannot be unseen." } O.o // ==> "What has been seen, cannot be unseen."