Linked by kragil on Wed 23rd Jan 2013 20:26 UTC
Google "Native Client enables Chrome to run high-performance apps compiled from your C and C++ code. One of the main goals of Native Client is to be architecture-independent, so that all machines can run NaCl content. Today we're taking another step toward that goal: our Native Client SDK now supports ARM devices, from version 25 and onwards."
Thread beginning with comment 550195
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[15]: Comment by Laurence
by Hiev on Wed 23rd Jan 2013 23:07 UTC in reply to "RE[14]: Comment by Laurence"
Member since:

I can show you the Vala version:

fib = (i) => (i <= 1) ? i : (fib (i - 2) + fib (i - 1));

Reply Parent Score: 2

RE[16]: Comment by Laurence
by Laurence on Wed 23rd Jan 2013 23:28 in reply to "RE[15]: Comment by Laurence"
Laurence Member since:

Nice code, even though it does look really alien to me.

It's a pity you didn't open your comments with that example as it demonstrates your point well.

For now, I'm really enjoying Go, so I'm going to keep at it. Particularly as its the first time in ages that I've felt inspired to code rather than just coding to get paid. But it's always good to see how other languages handle things.

Reply Parent Score: 2

RE[17]: Comment by Laurence
by ssokolow on Thu 24th Jan 2013 00:02 in reply to "RE[16]: Comment by Laurence"
ssokolow Member since:

The only thing that's really alien about it is the function definition syntax.

The rest is just a recursive algorithm implemented using a ternary operator which uses the familiar C-style syntax.

Reply Parent Score: 2

RE[16]: Comment by Laurence
by satsujinka on Thu 24th Jan 2013 03:32 in reply to "RE[15]: Comment by Laurence"
satsujinka Member since:

That definition doesn't do what your Go example does. That example also requires a parameter which the Go example does not.

A similar Go function would be:

func fib(i int) int {
if i <= 1 {
return i
} else {
return fib(i-2) + fib(i-1)

That said, IMHO, the most readable Fibonacci function is Haskell's:

fib 0 = 0
fib 1 = 1
fib n = fib (n-2) + fib (n-1)

Though an encoding similar to what you provided is also possible:

fib n = if i <= 1 then i else fib (n-2) + fib (n-1)

Not as terse, but that's simply the lack of ?:, but a simple replacement would make Haskell more terse than your Vala example:

fib n = (n <= 1) ? i : fib (n-2) + fib (n-1)

Reply Parent Score: 3