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

Pages: 1-4041-

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 16:27

>being concerned with syntax
>pessant

Name: Anonymous 2012-01-31 16:30

>>2
notation matters

>>1
haskell looks nicest there

Name: Anonymous 2012-01-31 16:32

Lisp, Python (for bracketless) and the last one (for C-style syntax) look the best and cleanest.

Name: Anonymous 2012-01-31 16:34

javascript syntax

Name: Anonymous 2012-01-31 16:37

>>3
Nu-uh!

Name: Anonymous 2012-01-31 16:45

>>5
You mean,

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

amirite? I like FIOC the best.

Name: Anonymous 2012-01-31 17:11

>>7
how about you go FIOC yourself!

javascript syntax is better

Name: Anonymous 2012-01-31 17:48

>>8
how is more syntax better?
face it, offside-rule syntaxes are the FUTURE!

Name: Anonymous 2012-01-31 17:50

I don't understand how anyone in his right mind can design a new statically typed language and not use haskell style type signatures. They're just so obviously superior to those c style abominations, especially if you add parametrized types and additional keywords like implicit that clutter the type signatures even more (e.g, scala).

Name: Anonymous 2012-01-31 17:57

Common lisp obviously

Name: Anonymous 2012-01-31 18:18


let fib n =
    match n with
    | n when n < 2 -> n
    | n -> (fib (n - 1)) + (fib (n - 2));;

Name: Anonymous 2012-01-31 18:50

>>1
static typing is an abomination

Name: Anonymous 2012-01-31 19:14

>>2`
>syntax doesn't matter
>Lisp has the best syntax because it's homoiconic

Name: Anonymous 2012-01-31 19:27

>>14
>homo
>best
no.

Name: Anonymous 2012-01-31 19:28

>>12 ocaml?

Name: Anonymous 2012-01-31 19:29

>>15
there's nothing better than homo touhous

Name: Anonymous 2012-01-31 20:55

You're doing Haskell wrong, cuntbaggot.


fib :: (Num a)=> a -> Integer --Infinite precision int
fib 0 = 0
fib 1 = 1
fib a = 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.)

Name: Anonymous 2012-01-31 21:39

>>18
>Num a
dude, that include Double, and Float.

it just Integer -> Integer.

Name: Anonymous 2012-01-31 22:08

>>16
Yes, it's probably the same in F# too. (It's great because the plebs can't tell it's statically typed.)

>>19
Satisfying types for the whole program really isn't that hard. If you know how to write in the various MLs, you will use the B&D nature of type system to enforce the correctness of your code in many areas. While satisfying types doesn't inherently make your program correct, being unable to satisfy your types does mean you can't write a correct program.

So what you said boils down to "writing larger programs is harder." The H-M type system is there to help you with that problem. Ignorance is not the solution.

Name: Anonymous 2012-01-31 22:26

Dubz.
Check 'em.

Name: Anonymous 2012-01-31 22:37

>>20
or (Integral a)

Name: Anonymous 2012-01-31 23:26

>>18
Didn't really mean to be HASKAL, just Haskell-like.

>>22
Nice dubs.

>>12
Looks pretty but I prefer the types to be annotated, even if it's obvious.

Name: Anonymous 2012-02-01 2:28

http://rosettacode.org/wiki/Yin_and_yang#ALGOL_68
I prefer ALGOL 68's style, where function definition syntax is the same as variable assignment syntax.
proc fib = (int a) int: (if a < 2 then a else fib(a - 1) + fib(a - 2) fi);

Name: Anonymous 2012-02-01 3:02

Lisp is UGLY
C is best

Name: Anonymous 2012-02-01 3:58

>>24
All `Haskell-like' languages have Pattern Matching; even Erlang, which isn't pure functional or Lazy.

Name: Anonymous 2012-02-01 11:57

C with 1TBS indent style
NO EXCEPTIONS

Name: Anonymous 2012-02-01 12:01

>>26
C is undefined shit.
x86 asm is best

Name: Anonymous 2012-02-01 13:35

>>21
typing is shit, everything is a cons cell, a lambda or an atom

Name: VIPPER 2012-02-01 13:38

>>30
A lambda is a cons cell.

Name: Anonymous 2012-02-01 13:47

>>30
it's not very efficient to only have data structures made of cons cells

Name: Anonymous 2012-02-01 14:17

>>32
I'm talking conceptually.

Name: Anonymous 2012-02-01 14:24

>>29
I opened a can of Zyklon B in this thread. Maybe you Haifa Jews can find somewhere else to troll while you're on break from figuring out how to integrate DEC's goyish ALPHA technology into your Jew chips.

Name: Anonymous 2012-02-01 14:26

C++
auto fib(int a) -> int {return
    a < 2 ? a : fib(a-1) + fib(a-2);}

Name: Anonymous 2012-02-01 15:40

>>35
It's cheated to use operator overloading.

Name: Anonymous 2012-02-01 15:57

>>34
your just butthurt cuz you know x86 implementations do and always will outperform your toy architectures nobody wants to invest in.

Name: Anonymous 2012-02-01 16:04

>>37
your just butthurt cuz you know your Jew chips only outperform Goy chips because Intel bought DEC's goyish ALPHA technology from HP.

Name: Anonymous 2012-02-01 16:09

>>37
your
You certainly have the kind of grasp of the English language I'd expect from an Intel employee. Let me guess: is your native tongue Hebrew?

Name: Anonymous 2012-02-01 16:12

>>39
go scrub another toilet you dumb goy

Name: Anonymous 2012-02-01 16:13

>>40
Go scrub another DEC patent you dumb Jew.

Name: Anonymous 2012-02-01 21:15

>>41
NO U

Name: Anonymous 2012-02-01 21:18

>>41
x86 SUPREMACY

Name: Anonymous 2012-02-01 21:30

>>43
Intel Jews ``innovate'' by copying/stealing/buying ideas goys invented 40 years ago and then striking monopolistic deals with computer manufacturers.

Name: Anonymous 2012-02-01 21:32

>>44
NO U

Name: Anonymous 2012-02-01 22:56

>>44
Why didn't the dumb goys strike any deals with computer manufacturers? Because they're dumb and asocial, unlike the master race which is smart and very social.

Name: Anonymous 2012-02-02 2:20

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

Is this supposed to be ..Pascal? Doesn't look like working Pascal code to me...

Name: Anonymous 2012-02-02 21:37

>>47
All of the examples were just general styles, not necessarily real  languages, as you can see in the typed scheme and typed FIOC.

Name: Anonymous 2012-02-03 9:23

>>48
Oh ok. Didn't quite get that. Don't know Scheme/Python. For me, a procedure just can't return a value.

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