• 0 Posts
  • 8 Comments
Joined 1 year ago
cake
Cake day: July 3rd, 2023

help-circle



  • I’m really surprised to see Java ranked as less-verbose than OCaml.

    Here’s an equivalent code sample in Java 17 vs OCaml:

    Java:

    abstract sealed class Expr permits Value, Add, Subtract, Multiply, Divide {
      abstract long eval();
    }
    record Value(long value) extends Expr {
      @Override
      long eval() { return value; }
    }
    record Add(Expr left, Expr right) {   
      @Override
      long eval() { return left.eval() + right.eval(); }
    }
    record Subtract(Expr left, Expr right) {
      @Override
      long eval() { return left.eval() - right.eval(); }
    }
    record Multiply(Expr left, Expr right) {
      @Override
      long eval() { return left.eval() * right.eval(); }
    }
    record Divide(Expr left, Expr right) {
      @Override
      long eval() { return left.eval() / right.eval(); }
    }
    

    OCaml:

    type expr = 
      | Value of int
      | Add of expr * expr
      | Subtract of expr * expr
      | Multiply of expr * expr
      | Divide of expr * expr
    
    let rec eval = function 
      | Value value -> value
      | Add (left, right) -> (eval left) + (eval right)
      | Subtract (left, right) -> (eval left) - (eval right)
      | Multiply (left, right) -> (eval left) * (eval right)
      | Divide (left, right) -> (eval left) / (eval right)
    

    …Java has so much more syntactical overhead than OCaml, and that’s even with recent Java and being pretty aggressive about using boiler-plate reducing sugars like Records. And F# has even less, since it doesn’t require you to use different operators for numerics or do as much manual casting between strings/numerics




  • Knee surgery that wasn’t on his radar, his team’s radar, or his agent’s radar until he was told that the rookie was gonna get a shot to start next game.

    Sure, fine, take your elective season-ending surgery, but don’t try to play it like you had to leave, or like the team and coach that covered for you all season long and gave you a wildly-improbably second chance at being a starter when the rest of the league already knew you were broken somehow owed you something. You got paid millions to live every backup’s dream – a shot at becoming the guy – and your coach stuck by you long after you blew that chance.

    Then you go and make yourself totally unavailable even to be on the bench for the new kid who got comp’d to you and looks up to you?

    I really don’t understand how Mariota got his “he’s a nice guy” reputation, except maybe by contrast to Jameis because they were in the same draft class.