Kaushik Sathupadi
Programmer. Creator. Co-Founder. Dad.
See all my projects and blogs →

Why You’ll like Fantom -part 1 – The compiler

The benefit of the compiler(and static typing) has always been a topic of hot debate. People love it, with passion. And people hate it, with passion. Have you thought about what is it with the compiler that brings people into a love/hate relationship with it?

Compilers. You can’t live with them.. You can’t live without them

Sounds familiar? That’s because compilers are like your wife. They complain .. let you know when you suck. And that’s a good thing. Wait.. is it?

(Compiler vs Your wife)!

What’s Jack’s solution?

How do you fix your wife? Here are a few suggestions

  1. “Honey, can you make sure you cut my nails every weekend”
  2. “Oh i am so careless baby.. Things will be way better if someone more dependable(looking at her) took care of all the bills”
  1. “When I am wearing a red T-shirt .. it means i am in a really bad mood, so you are not allowed to complain. Other days you can.”

 

Like that’s going to happen

Well who are we kidding. that’s not going to happen. In your dreams Jack. But James might try his luck with the Fantom Compiler..

Make the compiler do more work.

Here are a few examples

a := 3

instead of

Int a := 3

and then do a..

s  = "My color is $color and My age is $age"

instead of

String s = "My color is " + color + " and My age is " + age

Agree on signals that indicate the times when the compiler is not allowed to complain

blogOrAnimal := getEitherABlogOrAnAnimalFromDatabase()
blogOrAnimal->save

“getEitherABlogOrAnAnimalFromDatabase” returns either a blog or an animal. Both of them have a save method. You just want this time, this one time, to treat them equally and call the freaking save method instead of “ifs-and-casts-and-then-calls”

Blog b := getObject("blog")

instead of..

Blog b := (Blog) getObject("blog")

(assuming that getObject is “declared” to return “Object” but returns the correct type of object depending on a parameter at runtime)

So .. that’s the thing about the Fantom compiler. It provides the benefits of static type checking but shuts itself up when you ask it to. Go to fantom.org to learn more.. or play with it online

Post by Kaushik Sathupadi, Founder Cull.io - A platform to recruit web developers by having them develop a web application
 
blog comments powered by Disqus