Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Language Syntax

Name: Anonymous 2012-01-31 16:18

So, /prog... which is the superior syntax for a statically typed language? Do you have a cleaner syntax I did not show? If so, ENLIGHTEN ME!



def fib(a: int): int
  if a < 2
    a
  else
    fib(a-1) + fib(a-2)
  end
end

(define (fib:int a:int)
  (if (< a 2)
    a
    (+ (fib (- a 1)) (fib (- a 2)))))

def fib(a int) int:
    if a < 2:
        return a
    else:
        return fib(a-1) + fib(a-2)

fib :: int -> int
fib a = if a < 2 then a
        else fib (a - 1) + fib (a - 2)

fib: method(a int,
  if(a <(2), a)
  else(fib(a -(1)) +(fib(a-(2)))))

procedure fib(a: int): int;
begin
  if a < 2 then
    return a;
  else
    return fib(a-1) + fib(a-2);
  end;
end;

int fib(int a)
{
    if (a < 2)
        return a;
    else
        return fib(a-1) + fib(a-2);
}

func fib (a int) int {
    if a < 2 {
        return a;
    } else {
        return fib(a-1) + fib(a-2);
    }
}

Name: Anonymous 2012-01-31 21:00

Haskell and ML don't look too bad (look the best) because they have type inference. Expect stuff to look much more scarier for larger programs.

Overall I prefer dynamicly typed languages more, so I can't judge. I didn't choose the Scheme-like because of syntax abuse - it wasn't homoiconic enough with the type declarations (CL does let you declare types as well, but it ain't that pretty either, because you usually don't declare types that often, unless you really want to overoptimize.)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List