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

(# “Honey, can you make sure you cut my nails every weekend”
(# “Oh i am so careless baby.. Things will be way better if someone more dependable(looking at her) took care of all the bills”

(# “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

pre. a := 3

instead of

pre. Int a := 3

and then do a..

pre. s = “My color is $color and My age is $age”

instead of

pre. 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

*( “When I use a ‘->’ instead of “.” to call a method, just don’t check if the method actually exists or do any sort of type checking”. check an example

pre. 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”

*( ” When I declare a type, I mean I want that type, don’t need to me cast”. so..

pre. Blog b := getObject(“blog”)

instead of..

pre. 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

Please check out my app Slow & Incremental - Personal Productivity by working on one step at a time
 
blog comments powered by Disqus