News for hackers. Stuff that matters.
Re:Golang at CloudFlare by Strom on Tuesday July 03, 2012 @02:27PM (#4195453)
Static linking is easily available with C/C++ as well. The main trade-off is how critical bugs in some library your program uses can be solved.

With dynamic linking it's possible for the library author to publish an API-compatible update, which when deployed fixes the issue in all programs that use this library. With static linking you need to recompile the whole program and publish the update.

For real world examples you could look at the Microsoft C run-time. When a security vulnerability is found & fixed, Microsoft pushes the dynamic link version of the update via Microsoft Update and millions of programs are no longer affected by this issue. However when you linked statically, you need to update your program as well. Many programs do not have good automatic update systems, and many programs aren't even under continued maintenance and remain forever vulnerable.

Re:Golang at CloudFlare by Splines on Tuesday July 03, 2012 @04:15PM (#4195971)
I wonder if there's a way to have your cake and eat it too.

Publish your app as a dynamically linked binary to an app publisher, the publisher takes your dll and mashes it with its dependencies into a single dll that they deliver to the customer.

When there is a security update in a dependent dll, a new binary can be delivered by the publisher to the customer with no need for the original author to push a button.

I'm guessing something like this exists already?

Re:Golang at CloudFlare by jkn on Tuesday July 03, 2012 @03:43PM (#4195825)
Static linking is not easily available with C/C++ in the general case. Some libraries support it, some important ones like Glibc and GTK+ do not.
Re:Golang at CloudFlare by pjmlp on Tuesday July 03, 2012 @04:31PM (#4196045)
The only reason this is not an issue with Go is that the language is too young and the reference compiler only supports static linking fot the time being.

The moment the compiler starts supporting dynamic linking the same will happen to Go.

Re:Golang at CloudFlare by koenigdavidmj on Tuesday July 03, 2012 @04:55PM (#4196151)
The Plan 9 people (basically the same group as the Go people) have some philosophical problems with dynamic linking. Read http://harmful.cat-v.org/software/dynamic-linking/ for their arguments.
Re:Golang at CloudFlare by 4ad on Tuesday July 03, 2012 @04:54PM (#4196146)
Static linking of Go code is a conscious design decision, not some artifact of toolchain immaturity. It will never change.
Re:Golang at CloudFlare by pjmlp on Wednesday July 04, 2012 @01:26AM (#4197760)
You can make use of dynamic linking with gccgo, as far as I am aware.
Re:Golang at CloudFlare by reddit_clone on Tuesday July 03, 2012 @05:22PM (#4196251)
On a related note, using Go can one develop DLLs that can be dynamically consumed from other applications?

Or you can only produce statically linked exe's?

Re:Golang at CloudFlare by zimbatm on Tuesday July 03, 2012 @06:40PM (#4196581)
Only exes at the time being. Go is the main loop and needs to have control of the execution flow for concurrency.

If you think of it, DLLs are a bit like separate programs that you communicate with trough the C call stack instead of another structured protocol. In Go you would spawn different processes and use something like protobuf to exchange messages.

Re:Golang at CloudFlare by 1amzave on Tuesday July 03, 2012 @06:38PM (#4196577)
Huh? Perhaps you mean Glib? Static linking works just fine with glibc:

  [me@host: tmp]% cat > hello.c
  #include <stdio.h>
  int main(void) { printf("hello world\n"); return 0; }
  [me@host: tmp]% gcc -o hello -Wall hello.c -static
  [me@host: tmp]% file hello
  hello: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 2.6.32, not stripped
  [me@host: tmp]% ldd hello
  	not a dynamic executable
  [me@host: tmp]% ./hello 
  hello world
Re:Golang at CloudFlare by saurik on Tuesday July 03, 2012 @06:44PM (#4196598)
I largely agree with you, but for what it's worth, that doesn't "just work": there are places in glibc that use dlopen to pull in modular code; one example is the DNS resolver.
Re:Golang at CloudFlare by tedunangst on Tuesday July 03, 2012 @08:34PM (#4197000)
As mentioned, if you try that it works less than 100%. Trying to run a 32-bit program on a 64-bit host will fail in weird ways unless some of the expected bonus libraries are available.
Re:Golang at CloudFlare by gillianseed on Tuesday July 03, 2012 @07:29PM (#4196807)
Although I've never tried it myself I've read that gtk supports static linking, iirc you have to build gtk with --disable-modules.

Also, Go has gtk bindings, how does that work?

Re:Golang at CloudFlare by jkn on Wednesday July 04, 2012 @02:05AM (#4197864)
Ah you're right, it seems you can get a static build by recompiling GTK+ and its dependencies with the appropriate flags and some extra manipulation... See http://wiki.inkscape.org/wiki/index.php/CompilingStatic for an outdated example. I don't know if that would work on Windows, it used to be not supported: http://readlist.com/lists/lists.sourceforge.net/mingw-users/...
Re:Golang at CloudFlare by tedunangst on Tuesday July 03, 2012 @08:31PM (#4196990)
Go can dynanmically load C libraries I believe, but there is no support for native shared go code.
Re:Golang at CloudFlare by 4ad on Wednesday July 04, 2012 @07:44AM (#4198957)
That is correct.
Re:Golang at CloudFlare by johnm on Tuesday July 03, 2012 @05:00PM (#4196165)
Makes the choice of using them that much easier. :-)