Slashdot Mirror


Interviews: Ask Alan Donovan and Brian Kernighan About Programming and Go

Alan Donovan is a member of Google’s Go team in New York and holds computer science degrees from Cambridge and MIT. Since 2005, he has worked at Google on infrastructure projects and was the co-designer of its proprietary build system, Blaze. Brian Kernighan is a professor in the Computer Science Department at Princeton University. He was a member of technical staff in the Computing Science Research Center at Bell Labs, where he worked on languages and tools for Unix. He is the co-author of several books, including The C Programming Language, and The Practice of Programming. Recently, the pair have co-authored a soon to be released book titled The Go Programming Language. Alan and Brian have agreed to give us some of their time to answer any questions you may have about the upcoming book, Go, and programming in general. Ask as many questions as you'd like, but please keep them to one per post.

50 of 185 comments (clear)

  1. OpenGL and LockOSThread by Anonymous Coward · · Score: 5

    Hi, I've stopped using Go when I saw the hacky stuff I need to do to get libraries like OpenGL to behave correctly. (see https://github.com/golang/go/wiki/LockOSThread) Are there any plans to fix this?

    1. Re:OpenGL and LockOSThread by genocitizen · · Score: 2

      Not sure there is anything to fix there... Have you given a look recently to https://github.com/go-gl ? The main issue here is that you need a specific goroutine to "sit" on a specific thread and process your OpenGL flow; it's already covered with some hacks, AFAIK.

    2. Re:OpenGL and LockOSThread by genocitizen · · Score: 3, Informative

      AC was referring to the fact you need to run all OpenGL code from same thread. Go's goroutines are not guaranteed to run on same thread (unless you do some black magic sorcerery).

    3. Re:OpenGL and LockOSThread by Anonymous Coward · · Score: 3, Informative

      Instead of linking your app to OpenGL you can instead create a separate process that will do that and communicate to it through a socket. You know, like X11 does. This way you are not putting driver guts in your process space like Win 3.1 used to do. See http://msharov.github.io/gleri... for an example.

    4. Re:OpenGL and LockOSThread by luis_a_espinal · · Score: 3, Interesting

      AC was referring to the fact you need to run all OpenGL code from same thread. Go's goroutines are not guaranteed to run on same thread (unless you do some black magic sorcerery).

      A deficiency that's not Go's problem to solve IMO.

    5. Re:OpenGL and LockOSThread by NostalgiaForInfinity · · Score: 2

      Yes, OpenGL is a big hack. Why is this Go's problem?

      The world is full of "big hacks" and shitty software, so languages that can't deal well with such systems aren't going to cut it. In different words, it's Go's problem because users aren't going to use Go if they can't get their work done in it.

  2. Wisdom of naming it "Go" by ZeroPly · · Score: 5, Insightful

    There's already a game called Go, which has about a gazillion articles on how to program it. Couldn't you come up with a name that would be less ambiguous? Now, when you see a user group for "Go programming", you have no clue which one it is.

    --
    Support microSD: in a post 9/11 world, it is unwise to carry your data on media that you cannot comfortably swallow.
    1. Re:Wisdom of naming it "Go" by JoshuaZ · · Score: 3, Interesting

      I agree. I saw the headline and thought I was going to see an interesting article about Go and computers, maybe something explaining in detail how Monte Carlo methods have made Go programs much more successful than the older brute force used to be. But nope. Maybe someone should write a program in Go to play Go for maximum confusion.

    2. Re:Wisdom of naming it "Go" by eldavojohn · · Score: 2

      There's already a game called Go, which has about a gazillion articles on how to program it. Couldn't you come up with a name that would be less ambiguous? Now, when you see a user group for "Go programming", you have no clue which one it is.

      In conversation, I refer to it as golang. You are right on your point about potential for confusion but I don't think your example is apt anymore. Googling for programming go appears to yield only results about golang. Also, it is not without tangential benefits like being able to call Go developers "gophers."

      I think when I first started programming Groovy long ago I stumbled upon a website promising that software development was groovy ... that's no longer the case when I google for groovy programming resources.

      In short the success of your language is a big enough concern than the name of your language is negligible (with the exception of negative words). The search results will follow.

      --
      My work here is dung.
    3. Re:Wisdom of naming it "Go" by McGruber · · Score: 2

      Couldn't you come up with a name that would be less ambiguous?

      Forth was already taken.

    4. Re:Wisdom of naming it "Go" by OrangeTide · · Score: 3, Funny

      why couldn't the name have been a SHA-256 hash of the initial specification document or a UUID. So instead of "Go" we could all say "one two three echo four five six seven dash echo eight nine bravo dash one two delta three dash alfa four five six dash four two six six five five four four zero zero zero zero". Then it wouldn't be ambiguous and unlikely to have search collisions if you search as "123e4567-e89b-12d3-a456-426655440000"

      --
      “Common sense is not so common.” — Voltaire
    5. Re:Wisdom of naming it "Go" by BadDreamer · · Score: 2

      The problem is for us who want to read about programming Go, the strategy game, and don't care in the least about some new, fancy programming language.

    6. Re:Wisdom of naming it "Go" by Anonymous Coward · · Score: 2, Informative

      Exactly. If I search for "C" only three of the top ten results are about the programming language.

  3. Why the hell would anyone use Go? by xxxJonBoyxxx · · Score: 5, Insightful

    Why the hell would anyone use Go?

    (Serious question, since our editors didn't tell us why Go was created, what Go's intended purpose was and whether or not anyone is actually using Go.)

    1. Re:Why the hell would anyone use Go? by eldavojohn · · Score: 2

      Why the hell would anyone use Go?

      (Serious question, since our editors didn't tell us why Go was created, what Go's intended purpose was and whether or not anyone is actually using Go.)

      As a software developer here that likes to fiddle with all languages, the second paragraph from Wikipedia seems to answer your question nicely: "It is a statically typed language with syntax loosely derived from that of C, adding garbage collection, type safety, some structural typing capabilities,[2] additional built-in types such as variable-length arrays and key-value maps, and a large standard library."

      So from the first few words someone might know C and desire garbage collection to be handled for them? Golang might be a better selection for them than Java.

      Personally for me, the built-in primitives for concurrency make it a great language for tinkering in realms of software design that were once onerous to me. But that's only one of a few of the language's goals.

      Maybe a better set of questions would be for an elevator pitch on why someone should use golang? Or perhaps if they have dropped some goals of golang for others as development went forward?

      --
      My work here is dung.
  4. C vs Go by claude.j.greengrass8 · · Score: 3

    How does 'The Go Programming Language' compare to 'The C Programming Language'?

    1. Re:C vs Go by fyngyrz · · Score: 2

      'go' is clearly exactly twice as difficult and complex to write as is 'c' - and there you have it.

      --
      I've fallen off your lawn, and I can't get up.
  5. Why was package versioning left out? by genocitizen · · Score: 5

    Why was package versioning left out? And are you guys still fond of this decision? As I use Go more and more I see this to be the weak spot; software has been around for many decades, and we all know that it is continuous evolution. Go's import system does not allow specifying or hinting a version, nor does the `go get` command (although it supports major VCSes), and that's how hacks like gopkg.in have been conceived. And it's not like package managers for other languages haven't already solved in a more or less elegant way the problem already...

    1. Re:Why was package versioning left out? by TopSpin · · Score: 3, Informative

      I'd be a Go programmer today except for this. Every major programming platform in use today has a module system to manage dependencies except Go. Go gives you "go get" to haul gobs of source into your tree, after which you get to build and maintain the mess.

      The Go folks cop-out and say this problem is one "for the community." Well, it has been six years and "the community" is still schlepping around, making messes with "go get" and inventing bad workarounds for the projects.

      Got a plan for this? You should.

      --
      Lurking at the bottom of the gravity well, getting old
    2. Re:Why was package versioning left out? by genocitizen · · Score: 2

      I've seen people not updating 'master' of their git repository because of this...utterly ridiculous. It makes new releases difficult to adopt and becomes soon detrimental to change in general. The package managers which have been developed (Godep, gb, glide) are not of the quality you would expect to professionally use Go...I've found issues with all of them (I know they're in high flux, but still).

    3. Re:Why was package versioning left out? by ewhac · · Score: 4, Insightful
      Because package versioning is not a language issue. It's a build issue, and should be part of your build system.

      "But go get ... reaches out and..." Stop. go get isn't part of the Go langauge; it's the default Go build environment. And yes, it lacks many features you'd want in a so-called "professional" build system (whatever that means this week).

      I get the impression that Go was perhaps intended to be used with repo, a tool principally used for managing the Android project, but also used elsewhere inside Google to manage large numbers of independent Git repositories. With repo, you establish a common branch or tag name across all the repositories that comprise your project, then "repo sync" to them. Poof! Build and version management. (Sorta.)

    4. Re:Why was package versioning left out? by ewhac · · Score: 2

      What if I want to use version 2? Or version 2.1?

      cd $GOPATH/src/myrepository/myproject
      git checkout release-2.0
      go build .

      Geez...

    5. Re:Why was package versioning left out? by NostalgiaForInfinity · · Score: 3, Insightful

      Because package versioning is not a language issue. It's a build issue, and should be part of your build system.

      In many languages, building code is a language issue. The fact that Go takes a fairly old-fashioned view of batch compilers and separate build systems is just a choice it makes, not a fundamental part of nature. Furthermore, language issue or not, the question simply becomes why are the commonly used build systems for Go so poor.

  6. Error Handling in Go by JPyObjC+Dude · · Score: 5, Interesting

    Go language differs from many other languages in how it handles Errors. Can you summarize the benefits and drawbacks to the Go language error handling approach when compared to Java for large scale applications.

  7. Why an un-googlable name? by bigsexyjoe · · Score: 2, Insightful

    Seeing as how it was created after the Internet was big, and one is constantly searching the Internet about the programming language one using, wouldn't you want a distinct name so search results are what the programmer wants? "Go" is the 35th most common word in the English language. When you search for "go" you get entries about games, movies, etc. Google, coincidentally gives the best results if the programming language is what you are searching for, but even Google gives you results for all sorts of things. The programming language isn't even a dominant result on other search engines.

    Obviously, if you use a search engine to find things about "JavaScript" or "Erlang" you get what you want. I can't imagine going through the trouble of creating a programming language and then failing to give it a distinctive name.

    1. Re:Why an un-googlable name? by Anonymous Coward · · Score: 2, Informative

      Seeing as how it was created after the Internet was big, and one is constantly searching the Internet about the programming language one using, wouldn't you want a distinct name so search results are what the programmer wants? "Go" is the 35th most common word in the English language.

      Try searching for "golang".

    2. Re:Why an un-googlable name? by __aaclcg7560 · · Score: 2

      Python brings up all kinds of interesting snake videos on YouTube.

  8. Usage by behrooz0az · · Score: 3

    For what scenarios and projects do You recommend it and for which you recommend against using Go?

    --
    Moderating "-1, Disagree" is simple censorship. Have the guts to post your opinion. -- Spazmania (174582)
  9. Why can't you mark a class with an interface? by bigsexyjoe · · Score: 3

    I can understand the convenience of not needing to mark a class as an implementer of an interface. But on the other hand, it would be nice if you at least had the option of marking a class as an implementer of an interface, so your IDE could tell you your class is not complete.

    1. Re:Why can't you mark a class with an interface? by Fwipp · · Score: 3, Informative

      I usually use the following method: https://play.golang.org/p/iF_d... - Attempting to run this will give a compile error. Once you implement MyType.Foo(); it will compile and run successfully.

      The only added part is line 10.

  10. Gos potential by Qbertino · · Score: 4, Insightful

    What serious long-term real-world potential do you see for Go?

    How do you see the potential of Go replacing existing open source webstacks such as Apache and PHP, Python or Ruby? Was Go built with a technology update of existing approaches in mind? How feasible is it in your opinion to try and replace the existing complex stacks with pure Go runtimes?

    --
    We suffer more in our imagination than in reality. - Seneca
  11. Official Go IDE? by Qbertino · · Score: 5, Insightful

    Is there an official cross-plattform Go IDE in the works? Experience shows that adoption is accelerated by offering a solid toolkit that is easy to pick up and get started with - such as the formidable Android Studio IDE Google offers to developers. Are there any plans similar to this for Go?

    I would like to see it take the place of C++ in the development of performant end-user applications with GUIs - are there any officially sanctioned projects that aim to provide a serious GUI toolkit and stack based on Go?

    --
    We suffer more in our imagination than in reality. - Seneca
    1. Re:Official Go IDE? by motorsabbath · · Score: 3, Informative

      Sorry, was late last night. LiteIDE is a go-centric ide with lots of great hooks for that language. I run it on Linux, OSX and Win10.

      https://code.google.com/p/liteide/

      --
      The heat from below can burn your eyes out
  12. tEoPS by M.+D.+Nahas · · Score: 2

    There many books on "how to program" but few on "how to program well". Brian, your book "The Elements of Programming Style" is a wonderful and a classic, but my students have a hard time reading the examples (Fortran 66 and PL/I).

    Is there any hope for an update?
    Is there any similar modern-language book that you recommend?

    Michael Nahas (son of Joe Nahas)

    P.S. I totally stole as much as I could from you when writing my tutorial for the language Coq. Sorry/Thanks!

  13. Re:Have we sunk this low? by trevc · · Score: 2

    I though this was funny "He is the co-author of several books, including The C Programming Language, Second Edition" Like somebody else co-wrote the first edition?

  14. Re:Why should I use Go? by OrangeTide · · Score: 2

    The main feature in Go is channels and the light weight threads you can use with them (goroutines). Go is for writing a certain style of concurrent program, and it does not intend to rival Common Lisp in language features. (I'd take ML over Lisp, I think the type inference in ML is a pleasure to use compared to Lisp)

    --
    “Common sense is not so common.” — Voltaire
  15. C's current place in the world by MountainLogic · · Score: 3, Interesting

    As the legend has it, C was created to support operating system development. As time has gone by C++ has slipped into OS development on larger platforms. It seems that much of the current core use of mother C is centering on embedded processors (all the way down to 8 bit micros with 256 bytes of RAM) and drivers in larger systems. For current use what design choices in C do you see as wise and what would you change given the current usage of C.
    PS: Thanks you for co-authoring the most wonderful, perfect, clear and concise technology document ever.

  16. Do you hate go fanboys as much as I do? by slashdice · · Score: 3, Funny

    Come on, be honest!

    --
    Copyright (c) 1990 - 2014 Dice. All rights reserved. Use of this comment is subject to certain Terms and Conditions.
  17. Comment removed by account_deleted · · Score: 3, Informative

    Comment removed based on user account deletion

  18. Re:I worry about autonomous language activities by Dutch+Gun · · Score: 2

    C has a lot going for it. It's simple, portable, ubiquitous. The language lets you do whatever you want with minimal fuss or overhead. Its generated assembly code is fast and efficient. Because it's the system language of choice for operating systems, nearly every other language can interop with C to some degree. C++ is largely backwards compatible with it. If you want a library to be portable with just about everything else, you write it in C. Great.. awesome so far.

    That being said, C requires that the programmer write code perfectly, or else you've got a potential security disaster. It's not theoretically impossible, but as we've seen from history, in a large body of complex code, it's nearly impossible. There are virtually no built-in mechanisms for the compiler to help the programmer catch obvious programming errors. As such, it seems like a rather terrible language to use for any sort of internet-facing API, where the code will be subjected to intense attacks. And that pretty much describes most of Google, doesn't it? So it's not too surprising Google would be looking for a safer C-like alternative.

    C is a fine language for what it is, but I don't understand people that seem to pick a single language, then infer that it's the end-all and be-all for every programming task on the planet. You CAN write secure, threaded code in C. Then again, you CAN build an entire house with nothing but hand tools. No carpenter doesn't have a basic hammer in their toolbox, but I'd imagine very few would purposefully eschew the use of a nail gun when appropriate.

    --
    Irony: Agile development has too much intertia to be abandoned now.
  19. Re:I worry about autonomous language activities by radish · · Score: 3, Insightful

    If your program runs on a machine which is connected to a network then it's an attack vector, even if it doesn't directly offer network services. Look at the huge number of vulnerabilities in things like file viewers or graphics rendering libraries.

    Sure, if you're writing an application which you know will only ever be run on airgapped machines with no removable storage then maybe you can not worry about security. Those applications are few and far between.

    --

    ---- Den ene knappen er powerknapp, den andre er Bender voice knapp "Bite My Shiny Metal Ass"

  20. Re:I worry about autonomous language activities by radish · · Score: 3, Interesting

    Why aren't you writing in assembler? Actually scrub that - how's your microcode? What always amuses me about the bare metal brigade is that they're often not actually that close to the metal.

    Different levels of abstraction work for different tasks, and it's always a trade off. Security vs Reliability vs Performance vs Resource Usage vs Developer Time vs Maintainability vs ... you get the picture. Anyone who tells me their tool of choice is appropriate for all tasks is telling me they have a very restricted view of the world. I write mainly in Scala these days but there are plenty of things I wouldn't try to use it for, and I sure as hell wouldn't write my services in C!

    --

    ---- Den ene knappen er powerknapp, den andre er Bender voice knapp "Bite My Shiny Metal Ass"

  21. Re:I worry about autonomous language activities by bobbied · · Score: 4, Informative

    Java is LICENSED by Oracle who doesn't give out the source code... Go is BSD licensed and has source code so you can build your own copy.

    Check with Oracle about the terms they use if you want to distribute their Java Virtual Machine in a commercial product. I can assure you it involves you providing them with cash before they will let you even distribute Java, unmodified, as part of your product. I know this from experience. I'll warn you, Java from Oracle does NOT come cheap if you wish to distribute it. Sure they will let you and your customer download it for free, but they want their cut if you download and distribute Java to a customer.

    With Go, there will be no such restriction. You can build and distribute Go to your hearts content w/o paying anybody even if you charge for it. You can embed Go in a project, modify it and sell it without having to give up your source code (as I read the license) as long as you leave the BSD license alone.

    --
    "File to fit, pound to insert, paint to match" - Aircraft Maintenance 101
  22. Go objects by StealthyRoid · · Score: 4, Interesting

    I'm curious as to the design decisions that led to the way that Go objects are implemented, which feel and seem to operate like C structs w/ function pointers. Yes, all objects are essentially structs with function pointers, but most languages provide a good deal of syntactic and functional candy on top of them to make them more useful. With Go objects, you get sortof-inheritance, sortof-polymorphism, and sortof-encapsulation, which requires re-thinking a lot of design patterns that people learn working with languages like C++, Java, and even PHP. That's not necessarily a bad thing, I can see arguments for forcing people to get out of their comfortable patterns, I'd just like to know why.

  23. Compiler hack guide by snadrus · · Score: 2

    Could the GoLang team produce a walkthrough on enhancing the compiler?
    Even something as simple as making the code more idiomatic (since it was translated) could garner huge increases in contributions.
    A guide to the structure would also be helpful.

    --
    Science & open-source build trust from peer review. Learn systems you can trust.
  24. Re:I worry about autonomous language activities by snadrus · · Score: 3, Interesting

    These statements come from experiences in other languages with obnoxious GCs. This is a performance-focussed language with great multiprocess primitives. The GC causes far less latency.
    https://talks.golang.org/2015/...
    Pauses average 1ms and will be halved again next release to 1/2000 of a second which is plenty workable for games & audio mixers
    Further, intelligently-written code can massively reduce GC frequency.

    A certain high-throughput web service I've built runs GC roughly once per hour (yet services 1000s of concurrent requests). And this is without any serious effort at tuning. This is because (unlike Java, Python, and JS) GC is avoided if possible for stack space (whenever provably-safe) which is freed when it leaves scope. The proving algorithms are improving too.

    --
    Science & open-source build trust from peer review. Learn systems you can trust.
  25. The future of Go by Serious+Callers+Only · · Score: 3, Insightful

    Now that Go has been in the wild for some time, which parts of the language would you change, and which bits have been an unexpected success?

    Are there any plans for Golang version 2, and what might that include?

  26. Re:I worry about autonomous language activities by psmears · · Score: 2

    Check with Oracle about the terms they use if you want to distribute their Java Virtual Machine in a commercial product. I can assure you it involves you providing them with cash before they will let you even distribute Java, unmodified, as part of your product. I know this from experience. I'll warn you, Java from Oracle does NOT come cheap if you wish to distribute it. Sure they will let you and your customer download it for free, but they want their cut if you download and distribute Java to a customer.

    OK, I checked with Oracle, and they said this:

    Can I distribute Java with my software?
    Yes, you can provide Java with your software provided you abide by the terms and conditions of Java binary code license.

    Go is great, and there are definitely advantages to Go's BSD licensing model, but this is not one of them :)

  27. Re:Runtime by Serious+Callers+Only · · Score: 3, Informative

    Sure, here's one from Russ Cox: https://news.ycombinator.com/i... Ultimately, those criticisms are not very interesting, because as a Go programmer these are tools you use as an end-user, not something which dictates how you program, and can and will be improved behind the scenes.

  28. Re:I worry about autonomous language activities by bobbied · · Score: 2

    You need to read the "Binary Code License Agreement" because that's where the terms are set. So YEA, you can distribute it, but if you distribute the "commercial features" (and my product does) you need a separate license. They charge for that license.

    --
    "File to fit, pound to insert, paint to match" - Aircraft Maintenance 101