Skip to content

Instantly share code, notes, and snippets.

@gavinking
Last active December 4, 2015 15:01
Show Gist options
  • Save gavinking/2fe376144dbfa2bd443d to your computer and use it in GitHub Desktop.
Save gavinking/2fe376144dbfa2bd443d to your computer and use it in GitHub Desktop.
silly verbosity comparison

Someone just told me that implementing an interface in F# is less vebose than in Ceylon. Let's see if that's true. Pick an example given on MSDN. (Yes, I know it's silly to make such trivial comparisons.)

F#

    type IPrintable =
        abstract member Print : unit -> unit

    type SomeClass1(x: int, y: float) =
        interface IPrintable with
            member this.Print() = printfn "%d %f" x y
    
    let x2 = new SomeClass2(1, 2.0)
    x2.Print()

Total: 10+26+15 = 51 tokens.

Ceylon

    interface IPrintable {
        shared formal void doprint();
    }

    class SomeClass1(Integer x, Float y) 
            satisfies IPrintable {
        doprint() => print("``x`` ``y``");
    }
    
    value x3 = SomeClass1(1, 2.0);
    x3.doprint();

Total: 11+24+16 = 51 tokens.

@renatoathaydes
Copy link

Sorry, tokens and characters are not the same thing :) so Ceylon has 51 anyway.

@gavinking
Copy link
Author

@renatoathaydes ah yes, oops.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment