News for hackers. Stuff that matters.
Re:Rob Pike: Go at Google by agentS on Friday October 26, 2012 @10:43PM (#4705155)
> Go codebases by non experts are peppered with magical incantation (sleeps, etc.) to avoid the dreaded "all goroutines are sleep".

I'm confused. This is indicative of a deadlock, where no goroutine can make progress. Sleeps would mask the symptoms, yes, but would never actually solve a deadlock, the program would just do nothing for a longer period of time. What Go codebase(s) are you referring to?

> A concurrent Go program will likely behave differently given 2 bits (just 2 lousy bits) of difference in the object binary. (runtime.GOMAXPROCS(1) vs runtime.GOMAXPROCS(2)). Imagine someone touching those 2 bits in a "large codebase". It is practically impossible to do the same thing in a large Java codebase and fundamentally change the programs runtime behavior. (Happens all the time in Go.)

If you are trying to find a low number of bits, you can just use 0. GOMAXPROCS can be set via an environment variable, the function is just to override that value.

More to the point, I am convinced that you are wrong. You are saying that in a Java class file, there are no 2 bits I could change that would impact the behaviour of a program, and that is plainly false.

> It is very difficult to reason about a Go routine's behavior in a "large codebase" without global view and a mental model of the dynamic system e.g. which go routine is doing what and who is blocking and who is not.

I guess this could be true if you engineer a system where every goroutine depends on every other goroutine. But it isn't true for code I've seen. As an example, the http library in Go has a goroutine that accepts TCP connections, and a goroutine for every accepted TCP connection. This knowledge is not necessary to use it, and is not necessary if a different part of your program is using it, because it is exposed behind an abstraction (http.Handler). To paraphrase the OP, Go enables simple programming. It doesn't forbid bad programming.

> There is nothing, absolutely nothing, that you can do in Go that you can not do via libraries in Java.

Depending on what you mean by "do", I believe Turing would have something to say on this matter: http://en.wikipedia.org/wiki/Turing_completeness

> On the other hand, there are plenty of things you can do in Java that are simply impossible to do in Go.

Depending on what you mean by "do", I either agree with you, or think you are mistaken. If you mean things that you can syntactically write down, like a Giraffe is-a Animal, or an Apple is-a Fruit, then yes, that is impossible to write down in Go. If you mean a problem that can be solved in Java that cannot be solved in Go, then I think you are mistaken.

> Once we factor in the possibility for bytecode engineering, then Java is simply in another higher league as far as language capabilities are concerned.

Why is this in another league? You can use assembly from Go, meaning you can generate code and jump to it if you really want to. Not sure why this would be considered a special feature of Java, or even why you think Java pioneered this. Bytecode is just a portable assembly, but its just as portable to build per-platform assembly emitters (like compilers do).

> Most people who rag on Java are clearly diletantes Java programmers.

Right. That makes sense to me; no one who knows anything about Java would ever criticize it. Sarcasm aside, this demonstrates a fallacy in reasoning.

> If Go actually manages to be as effective as Java for concurrent programming at some point in the future

It isn't more effective now? News to me.

> when they fix the somewhat broken runtime

Sorry, remind me what this is referring to?

> It just works. (But it is "boring" because it's not bling anymore. Oh well, kids will be kids.)

This is dangerous thinking. This is the cry that the native programmers raised when Java was born. Try and keep that in mind.

Re:Rob Pike: Go at Google by rat87 on Saturday October 27, 2012 @03:12AM (#4705633)
> > when they fix the somewhat broken runtime

> Sorry, remind me what this is referring to?

I think he may be talking about the conservative gc which causes memory to effectively leak a lot on 32 bit machines.

http://code.google.com/p/go/issues/detail?id=909

Re:Rob Pike: Go at Google by xyproto on Saturday October 27, 2012 @10:42AM (#4706210)
Perhaps most people use 64 bit on their servers nowadays.

Judging by the rate of releases of minor versions of Go, I bet it will be fixed in about two months from now. They are certanly aware of the issue.

Re:Rob Pike: Go at Google by OceanSpray on Sunday October 28, 2012 @05:18PM (#4710014)
The issue is actually impossible to fix without overhauling the entire language. It's impossible to garbage collect unboxed objects without being conservative.
Re:Rob Pike: Go at Google by ralfn on Sunday October 28, 2012 @06:11PM (#4710162)
Exactly. But conservative GC sounds like a dumb idea in the first place. Im not the expert these people designing these languages are, but i can not understand how memory leaks can ever be acceptable just because the probability of it seriously affecting you, is low (when on x64). Doesnt that just imply you can not use these types of languages in any mission critical context.

I must be wrong though: it seems Google is using it for parts of their infrastructure, and im assuming those are long running procceses. But what if the worst case scenario does happen? Are there workarounds? Monitor memory usage, and just restart? Can we force the runtime to free a certain resource?

What am i missing? How does this not completely destroy anu utility of these languages? Why do people put conservative gc in languages outside of the esoteric or academic context?

Re:Rob Pike: Go at Google by agentS on Sunday October 28, 2012 @07:01PM (#4710284)
> Doesnt that just imply you can not use these types of languages in any mission critical context.

No more so than with C++. There is a relatively high probability of you having left a memory leak in an average C++ server.

> Monitor memory usage, and just restart?

That would work, and is probably a good idea for all servers anyways. I've seen apache take upwards of 60 gigs due to some misconfiguration, so monitoring memory utilization of your programs and alerting or automatically restarting is a good idea.

> What am i missing? How does this not completely destroy anu utility of these languages? Why do people put conservative gc in languages outside of the esoteric or academic context?

There isn't really a good reason as far as I can tell. The only advantages are that its much simpler to implement, particularly when you have C interop. You can annotate Go objects with types to do precise collection, but as soon as you pass them to C, a lot of guarantees the Go typesystem makes go out the window. Other than that, can't think of anything.

Re:Rob Pike: Go at Google by ralfn on Sunday October 28, 2012 @06:22PM (#4710187)
It is my understanding the chance of complications is lower on a 64 bit system. But it is very likely, that well crafted requests can make any server application written in Go, trigger this complication, and essentially result in a DOS attack.
Re:Rob Pike: Go at Google by agentS on Sunday October 28, 2012 @07:06PM (#4710296)
I think it would be mindblowingly difficult to cause this DOS. If you think it possible, you can setup a demo on appengine. You even get to upload the source code, so you have that advantage, that you wouldn't ordinarily have.

Gist of the task at hand: you'd have to arrange for data passed into your target application to point to structures in memory, causing them to be pinned. Ideally, these structures should be big, to maximize impact of the attack. Further, you'd have to ensure that the data you passed in isn't garbage collected, as this would allow the target structures to be collected.

Re:Rob Pike: Go at Google by xyproto on Saturday October 27, 2012 @10:38AM (#4706199)
Can't upvote you enough.
Re:Rob Pike: Go at Google by 0xABADC0DA on Saturday October 27, 2012 @07:28PM (#4707579)
> > On the other hand, there are plenty of things you can do in Java that are simply impossible to do in Go.

> Depending on what you mean by "do" ...

Oh, I don't know, maybe dynamic code loading or secure sandboxing of code? For instance you can compile a custom Google Go without disk IO, but you can't have an app that loads plugins much less one where the app can do IO but the plugin can't.

These may not be the wisest or most useful of features for "systems" programming, but you have to admit that there are real things Java can do that Google Go cannot.

I think Google Go advocates put blinders on like agentS because if they actually objectively looked at the situation they would have the same thing to say as others do about Google Go: "meh".

Re:Rob Pike: Go at Google by agentS on Sunday October 28, 2012 @03:22AM (#4708360)
> Oh, I don't know, maybe dynamic code loading or secure sandboxing of code? For instance you can compile a custom Google Go without disk IO, but you can't have an app that loads plugins much less one where the app can do IO but the plugin can't.

Sure you can. Spawn a child process with lower security privileges, and communicate over a pipe. It might require you to restructure to reduce chattiness, but on the other hand, you will be much less likely to expose yourself to security vulnerabilities than the Java "sandbox".

If the child process is written in Go, you can even use the -u compiler flag to only allow safe packages (i.e. no assembly, C, only packages explicitly marked as safe and pure Go). You can go even further, and mark package os unsafe, disallowing file system access altogether. Or do what (I suspect) Appengine does, and provide your own neutered implementation of package os/time/net/etc, and mark those as safe.

The Go playground is an example of this, btw. It merely streams stdout and stderr, but you could imagine doing other things with the sandboxed program.

> I think Google Go advocates put blinders on like agentS because if they actually objectively looked at the situation they would have the same thing to say as others do about Google Go: "meh".

I think you are falling prey to the same fallacy of false cause as your GP. "agentS likes Go, so he must not be objectively looking at the language". It is possible to objectively look at the language, and think it useful.

Re:Rob Pike: Go at Google by 0xABADC0DA on Sunday October 28, 2012 @07:50AM (#4708733)
> Sure you can. Spawn a child process ...

This is exactly what I was talking about. You can't even admit facts like that Java has dynamic loading and a security model and that Google Go does not. You're simply delusional in this respect.

Re:Rob Pike: Go at Google by agentS on Sunday October 28, 2012 @08:33AM (#4708776)
It seems I wasn't clear enough; I apologize for the confusion. I fully admit that Java has dynamic loading and a security model and the Go does not.

I was responding to "you can't have an app that loads plugins much less one where the app can do IO but the plugin can't."; that is, I was merely providing a way to implement what you wanted (plugins that cannot do IO, in a host that can).

Like I said in my original post, "If you mean things that you can syntactically write down, like a Giraffe is-a Animal, or an Apple is-a Fruit, then yes, that is impossible to write down in Go." Similarly, it is impossible to dynamically load code, or enforce permissions at the runtime level (although implementations of this enforcement has historically been... buggy, to be charitable). I was attempting to show that the problem of having sandboxed plugins is solvable in Go.

Re:Rob Pike: Go at Google by eternalban on Sunday October 28, 2012 @09:29AM (#4708871)
The child process approach is viable, but in fairness you should note that shared address space provides efficiencies that the RPC approach does not. This approach is IMO quite interesting in context multi-core and certain problem domains, but as a general mechanism it is a 'hack'.

And then:

- A full featured runtime reflection mechanism that does not drop "static info" on the floor: http://stackoverflow.com/questions/10210188/instance-new-typ... (Yes, there is a workaround but it is in 'hack' category of system engineering.)

- Class.forName(cname).

- @MetaInfo() ... Arguably not easy on the eye but necessary and enabling.

- Bytecode injest (beyond dynamic linking) -- the JVM is your oyster.

- and related Instrumentation and AgentS (pi) : http://docs.oracle.com/javase/6/docs/api/java/lang/instrumen...) -- this is a very powerful feature.

It is borderline fanaticism to insist on comparing Go to Java, and unfair to Go. Effective advocacy of Go should focus on its strengths (syntax) and not attempt to gloss over its inherent limitations. It is a capable and viable language within well defined limits. Java and JVM are in another league. Accept it and move on.

If a new 'headius' feels up to it, Go on JVM would be a very interesting new language for the JVM ...

Re:Rob Pike: Go at Google by agentS on Sunday October 28, 2012 @06:53PM (#4710265)
> The child process approach is viable, but in fairness you should note that shared address space provides efficiencies that the RPC approach does not. This approach is IMO quite interesting in context multi-core and certain problem domains, but as a general mechanism it is a 'hack'.

As to the lack of a shared address space, I thought I had communicated that when I said "It might require you to restructure to reduce chattiness", but yes, there are performance advantages to having a shared address space.

You should note that there are security disadvantages to having a shared address space with a sandboxed plugin written in a relatively low-level language (bytecode). I won't post several links to exploits of the Java sandbox in the last year alone, but I am sure you can google for them.

This mechanism is most certainly not a hack. This is the approach that Chromium and the other multi-process browsers (all the modern ones?) use for sandboxing. It seems far more effective to me to push responsibility for security to the OS, rather than the language runtime.

> A full featured runtime reflection mechanism that does not drop "static info" on the floor

Package reflect is fully featured. It just requires you to have a value, or type to actually reflect upon. The tradeoff being that Go can do dead-code elimination and Java cannot. Same thing for Class.forName.

> @MetaInfo() ... Arguably not easy on the eye but necessary and enabling.

I think you are referring to annotations. Yes, Go doesn't have these on methods, functions, or types. But it has these for struct fields (tags); this gives you 90% of the functionality, without muddying up the syntax.

> Bytecode injest (beyond dynamic linking) -- the JVM is your oyster.

Sure. See my note about all of these points below.

> and related Instrumentation

Go has a CPU profiler, a memory allocation profiler. In tip, it has a data race detector. It can expose this data over an HTTP interface so you can profile a running server http://golang.org/pkg/net/http/pprof/.

> It is borderline fanaticism to insist on comparing Go to Java, and unfair to Go. Effective advocacy of Go should focus on its strengths (syntax) and not attempt to gloss over its inherent limitations. It is a capable and viable language within well defined limits. Java and JVM are in another league. Accept it and move on.

You continually give me solutions that are impossible to implement in Go, but not the corresponding problems. Like I said, there are things that are syntactically impossible to write down in Go. If you want me to give you a list of things that are impossible to do in Java, I can do that (structural typing, value types, methods on values, multiple top level definitions in a single file, first class functions, efficient array slicing come to mind). I have not done that because it is a nonsensical thing to do. That would be like me saying Javascript is superior to Java because Java does not have prototypical inheritance.

The only useful example I've heard is sandboxed plugins. That is a problem, not a solution. All the things you've listed are solutions. If you actually want to have a conversation about how to solve problems in Go, then list problems, not a laundry list of features that Java has that Go does not.

> If a new 'headius' feels up to it, Go on JVM would be a very interesting new language for the JVM ...

Why? If I want more performance than gc gives me, then I use gccgo. What would Go on the JVM give me?

Also, on an unrelated note, I find it a little sad and pathetic how both you and 0xABADC0DA have to resort to insults to get your point across.

Re:Rob Pike: Go at Google by eternalban on Sunday October 28, 2012 @08:18PM (#4710448)
>> and related Instrumentation > Go has a CPU profiler, a memory allocation profiler. In tip, it has a data race detector. It can expose this data over an HTTP interface so you can profile a running server http://golang.org/pkg/net/http/pprof/.

It is canonically called "instrumentation" but that is not all that it is capable of doing. Have you actually ever used this feature of Java?

> Also, on an unrelated note, I find it a little sad and pathetic how both you and 0xABADC0DA have to resort to insults to get your point across.

?? When and where did I insult you? Pathetic, on the other hand, is an insult. I strongly take exception to that.