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 550143
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[3]: Comment by Laurence
by Hiev on Wed 23rd Jan 2013 20:51 UTC in reply to "RE[2]: Comment by Laurence"
Hiev
Member since:
2005-09-27

Personally, I find the sintax cryptic and I would only use it as a last resource.

For example:

func fib() func() int {
a, b := 0, 1
return func() int {
a, b = b, a+b
return a
}
}

Some people may feel comfortable with that kind of syntax, I don't, It is as bad as the worse C++ IMHO, well not that bad.

Edited 2013-01-23 20:58 UTC

Reply Parent Score: 4

RE[4]: Comment by Laurence
by Laurence on Wed 23rd Jan 2013 21:00 in reply to "RE[3]: Comment by Laurence"
Laurence Member since:
2007-03-26

To be honest, that doesn't even look valid Go (though, as I said, I'm only a week in on the language).

However some of the weirder syntax I've read on the tutorials were purely demonstrations showing how the more advanced C++ routines would be ported (so not really your typical day to day functions).

But lets be honest, you can find extreme cases of bad code in any language, so if you're genuinely curious about the language then I'd recommend have a quick browse through the tour: http://tour.golang.org/

Reply Parent Score: 2

RE[5]: Comment by Laurence
by Hiev on Wed 23rd Jan 2013 21:09 in reply to "RE[4]: Comment by Laurence"
Hiev Member since:
2005-09-27

It is a valid Go code, I took it from one of golang.org examples, my point is, just like in C++, it can become unreadable with not much effort.

Edited 2013-01-23 21:09 UTC

Reply Parent Score: 2

RE[4]: Comment by Laurence
by Nelson on Wed 23rd Jan 2013 21:01 in reply to "RE[3]: Comment by Laurence"
Nelson Member since:
2005-11-29

It takes time to adjust, but Go's declaration syntax is novel and helpful, especially when dealing with complex types.

Go:
f func(func(int,int) int, int) int

C#:
var f = Func<Func<int, int, int>, int, int>

There is just no sane way to write the syntax generally. I'm scared to even think what this would look like in C++.

Reply Parent Score: 2

RE[5]: Comment by Laurence
by dagw on Wed 23rd Jan 2013 21:44 in reply to "RE[4]: Comment by Laurence"
dagw Member since:
2005-07-06

I'm scared to even think what this would look like in C++.

int f(int (*fnc)(int,int),int,int)

Reply Parent Score: 2

RE[5]: Comment by Laurence
by lucas_maximus on Wed 23rd Jan 2013 22:56 in reply to "RE[4]: Comment by Laurence"
lucas_maximus Member since:
2009-08-18

var f = Func<Func<int, int, int>, int, int>


Would probably want to be

var f = Func<Func<myObjectWith3ints>, int, int>

If I am understanding Func correctly.

Reply Parent Score: 2

RE[5]: Comment by Laurence
by Loreia on Thu 24th Jan 2013 09:35 in reply to "RE[4]: Comment by Laurence"
Loreia Member since:
2012-01-17

There is just no sane way to write the syntax generally. I'm scared to even think what this would look like in C++.


Sounds like you have an issue with C++.
C++ would require just one extra * char for function pointer. Hardly anything to be scared of.

Reply Parent Score: 2

RE[4]: Comment by Laurence
by satsujinka on Wed 23rd Jan 2013 22:19 in reply to "RE[3]: Comment by Laurence"
satsujinka Member since:
2010-03-11

You've been space butchered, but it's not that weird.

The anonymous function is simply a closure that captures the variables a and b, then modifies them both to produce the next Fibonacci number when called.

It's really quite standard. I mean compare to a similar Scheme function (mind you it's been awhile):

(define fib (let ((a 0) (b1))
(lambda () (begin (set! a b) (set! b (+ b 1)) a)))

But of course, until you share what language you think does this "better," it's impossible to address your complaint.

Edited 2013-01-23 22:19 UTC

Reply Parent Score: 3

RE[5]: Comment by Laurence
by Hiev on Wed 23rd Jan 2013 22:27 in reply to "RE[4]: Comment by Laurence"
Hiev Member since:
2005-09-27

I can read the code:

func fib() func() int {

declares a function that returns a function.

a, b := 0, 1

declares a and b as integer then initialized them with a zero.


return func() int {
a, b = b, a+b
return a
}
}


That's the closure, but the difference with its counterparts like Javascript and C# is that you can mix that example with pointers and a weird array initialization syntax that Go allows.

I said Go is a C like language, why do you keep comparing it with Javascript and C#?

Reply Parent Score: 2

RE[4]: Comment by Laurence
by saso on Wed 23rd Jan 2013 23:18 in reply to "RE[3]: Comment by Laurence"
saso Member since:
2007-04-18

Congrats, you've written shit code with no sense of style and taste. Hope you feel good that even automatic code formatting tools like "indent" are smarter than you. Writing unreadable code to make a statement about style is about as valid as criticizing car safety by driving down a mountain road at 200+mph, IOW nobody will take you seriously.

Reply Parent Score: 4

RE[5]: Comment by Laurence
by Hiev on Wed 23rd Jan 2013 23:24 in reply to "RE[4]: Comment by Laurence"
Hiev Member since:
2005-09-27

mmm, never mid, replied to wrong comment, I'm sorry for that.

Edited 2013-01-23 23:33 UTC

Reply Parent Score: 3