News for hackers. Stuff that matters.
Re:Leaving Go by tptacek on Monday April 28, 2014 @12:55PM (#7661183)
If you're looking for a language that will enable "bottom-up development", where you gradually define, in Paul Graham On Lisp style, a language optimized for your problem domain, Golang is not the language for you.

Similarly, if you're looking for a language that will read and write like a specification for your problem domain, so that writing your program has the side effect of doing half the work of proving your program correct, Golang is also not a good choice.

What's worse, those two approaches to solving programming problems are compatible with each other. Lots of sharp programmers deeply appreciate both of them, and are used to languages that gracefully provide both of those facilities. If that describes you, Golang is a terrible choice; it will feel like writing 1990s Java (even though it really isn't).

There are two kinds of programmers for whom Golang will really resonate:

Python and Ruby developers who wish they could trade a bit of flexibility, ambiguousness, or dynamicism for better performance or safer code seem to like Golang a lot. Naive Golang code will outperform either Python or Ruby. Golang's approach to concurrency, while not revolutionary, is very well executed; Python and Ruby developers who want to write highly concurrent programs, particularly if they're used to the evented model, will find Golang not only faster but also probably easier to build programs in.

Systems C programmers (not C++ programmers; if you're a C++ programmer in 2014, chances are you appreciate a lot of the knobs and dials Golang has deliberately jettisoned) might appreciate Golang for writing a lot like C, while providing 80% of the simplicity and flexibility value of Python. In particular, if you're the kind of programmer that starts projects in Python and then routinely "drops down" to C for the high-performance bits, Golang is kind of a dream. Golang's tooling is also optimized in such a way that C programmers will deeply appreciate it, without getting frustrated by the tools Golang misses that are common to other languages (particularly, REPLs).

At the end of the day, Golang is overwhelmingly about pragmatism and refinement. If you're of the belief that programming is stuck in a rut of constructs from the 1980s and 1990s, and that what is needed is better languages that more carefully describe and address the problems of correct and expressive programming, Golang will drive you nuts. If you're the kind of person who sees programming languages as mere tools --- and I think that's a totally legitimate perspective, personally --- you might find Golang very pleasant to use. I don't know that Golang is a great language, but it is an extremely well-designed tool.

Re:Leaving Go by stiff on Monday April 28, 2014 @01:43PM (#7661599)
There is something to your description. I use Go sometimes, for pragmatic reasons, when I need more performance than I can get from Python or Ruby, but boy is it a ugly language!

There are just tens of little ugly things Go does and the result is, well, even uglier. Writing four functions for every collection to be sorted, writing x = append(x, foo) everywhere, shitty namespacing that prevents you from writing list := list.New() and so on and so forth. Even C is more elegant, and I would probably prefer to use C, if only C came with a library manager like rubygems or go get and a decent repository of libraries. I would even prefer Java if it produced native binaries and had an integrated library manager.

Re:Leaving Go by tptacek on Monday April 28, 2014 @01:51PM (#7661662)
x = append(x, foo) is a common C idiom too; in fact, it's been awhile since I had to work with STL containers, but I think it was common there too.

I love Golang namespacing rules. They do exactly what I need them to do to allow me to call into other people's code using the right function calls, and nothing else. I think Golang's namespacing is a high point of the language.

Re:Leaving Go by pcwalton on Monday April 28, 2014 @01:53PM (#7661668)
> x = append(x, foo) is a common C idiom too; in fact, it's been awhile since I had to work with STL containers, but I think it was common there too.

No, vector::insert() is the common idiom and mutates in place. It'd be written `x.insert(x.end(), foo.begin(), foo.end());` For single elements, vector::push_back() is the common idiom, and also mutates in place.

Re:Leaving Go by tptacek on Monday April 28, 2014 @01:54PM (#7661677)
Hrm. I've written about 100kloc of C++ code, around ~1999-2000. I'm going to have to go figure out why I thought this was the case.
Re:Leaving Go by webkike on Monday April 28, 2014 @02:02PM (#7661743)
vector::insert() is certainly not a C idiom. In can never be a C idiom because that is C++ code. the x = append(x, foo) idiom can be seen all over C, most obviously with the use of realloc, which is often called to resize an array via x = realloc(x, newsize).
Re:Leaving Go by mjdwitt on Monday April 28, 2014 @02:18PM (#7661860)
Indeed. Which is why pcwalton is answering Thomas' conjecture about C++'s STL containers.
Re:Leaving Go by stiff on Monday April 28, 2014 @01:58PM (#7661706)
I don't think simply having a separate symbol table for packages and a separate one for types and variables would hurt much, and I hate writing things like aList := list.New(). Having said this, I know many of those things are purported to have such and such super important reasons, it doesn't change the ugly "feel" of the end result. Another instance is the indication of visibility by case, they will go on and on about how it's a triumph of simplicity, I think it's simply an ugly notation.
Re:Leaving Go by tptacek on Monday April 28, 2014 @02:13PM (#7661821)
I honestly am not sure I follow what your concern is with that line of code. list.New() looks extremely clean to me.
Re:Leaving Go by stiff on Monday April 28, 2014 @02:23PM (#7661900)
You frequently have packages that are named after generic nouns, like time, host, file etc. There are many contexts where this same generic name makes for the best variable name: clear, short, and easy to type:

  func ReadFile(filename String) {
    file := file.Open(filename)
  }
In Go you have to invent a new name, so invariably you will see a lot of:

  theFile := file.Open(filename)
  aFile := file.Open(filename)
  readFile := file.Open(filename)
depending on who wrote the code.
Re:Leaving Go by tomp on Monday April 28, 2014 @03:00PM (#7662127)
Unless you're also frustrated by not being able to write `int int = 3` in C/C++/C#/Java/most other languages, I don't see the point of your concern.

    f = file.open("a.txt")
    out_file = file.open("b.txt", file.WRITE)
Re:Leaving Go by pcwalton on Monday April 28, 2014 @03:12PM (#7662199)
You can write that in C though.

    typedef int foo;

    foo main() {
        foo foo = 0;
        return foo;
    }
Re:Leaving Go by tptacek on Monday April 28, 2014 @03:26PM (#7662290)
You can do the same thing in Golang by renaming the import that clashes with your preferred variable name. Nobody does it, though, because it's not worth the trouble.
Re:Leaving Go by Locke1689 on Monday April 28, 2014 @03:59PM (#7662538)
In the C# language we refer to this as the 'Color Color problem'. You have some enum or type Color and then a member of an object which you, quite obviously, want to name 'Color'. It's so annoying for the programmer to work around this that we define special exceptions in naming rules so the programmer can do what they want.
Re:Leaving Go by dvirsky on Monday April 28, 2014 @06:14PM (#7663477)
the only place where I constantly find this annoying is the url package. url := oh wait, shit, already imported that.

a couple of times I just changed the name of the import, as you sometimes do in Python:

import (

  urllib "net/url"
)

url := urllib.QueryEscape(...)

tada!

Re:Leaving Go by monkey26 on Monday April 28, 2014 @10:59PM (#7664658)
I've hit this a few times in Python and it bugged me like crazy. But then I grew up and dealt with it.
Re:Leaving Go by pjmlp on Monday April 28, 2014 @04:01PM (#7662555)
> I think Golang's namespacing is a high point of the language.

Really?!? Available in modular languages since Mesa days (mid 70's).

Re:Leaving Go by m0th87 on Monday April 28, 2014 @01:14PM (#7661341)
You're right, Golang is all about pragmatism, and a very pragmatic thing for language designers to do is to listen to the marketplace on how the language should evolve. Lack of polymorphism must be the most common critique of Golang. It seems pretty practical to add it, as it would greatly reduce the amount of boilerplate. And it's not as if polymorphism is stuck in the ivory tower - languages used in industry have had them for decades.
Re:Leaving Go by tptacek on Monday April 28, 2014 @01:41PM (#7661578)
When I wrote that paragraph, I definitely did not think of "pragmatism" as "doing whatever people wanted them to do". Golang is also not Perl. If you're looking for Perl, Golang will disappoint you.
Re:Leaving Go by m0th87 on Monday April 28, 2014 @03:11PM (#7662193)
I'm not sure how you can create a pragmatic language while ignoring the most common complaints about it.

There's this common attitude of "if you want feature X and Go does not have it, Go is not for you." To some extent it's not surprising since there was confusion about what niche Go hit when it first came out. But when there's repeated patterns in critiques of Go coming from very smart people, it's probably worth paying attention rather than saying it just doesn't fall into the language's sense of "pragmatism".

FWIW, I'm a Python programmer who loves Go. Despite all its good stuff, though, we shouldn't remain content with what we have already.

Re:Leaving Go by tptacek on Monday April 28, 2014 @03:27PM (#7662298)
I wrote the comment you're replying to, so I'm probably in the best position to determine what I meant by the word "pragmatic". I didn't mean "implementing whatever feature people complained most about missing".

If there's a debate to have here, it's about what word better captures the point I was trying to make than "pragmatic". But that's an incredibly boring debate, so, I opt out.

Re:Leaving Go by m0th87 on Monday April 28, 2014 @03:50PM (#7662480)
I thought the debate was about polymorphism. It's apparently not worth including because...? It's not already in the language spec? Because the people who advocate it are using the wrong tool? Surely there's a better argument than this.
Re:Leaving Go by tptacek on Monday April 28, 2014 @03:58PM (#7662534)
Lack of polymorphism isn't even close to the most common objection to Golang. The most common objection is the lack of generics, which make it tricky to write reusable container libraries.

Golang comes pretty close to flat-out rejecting object orientation. It's only barely more object-friendly than C is. If you're the kind of programmer that wants to model a problem domain or build code with the Smalltalky feel that Gang of Four patterns give Java and C++, you will also hate Golang.

Generics might happen in the future (the more Golang I write, the less excited I am at the prospect), but a richer object model seems very unlikely. If you want to hang your argument on polymorphism rather than generics (I applied the principle of charity and assumed that's what you meant), the argument gets less valid, not more.

Re:Leaving Go by m0th87 on Monday April 28, 2014 @04:42PM (#7662865)
Apologies, polymorphism is a loaded term that could mean different things depending on your background. I mean parametric polymorphism, i.e. generics. What makes you unexcited about them?
Re:Leaving Go by tptacek on Monday April 28, 2014 @05:14PM (#7663126)
I surely see the value, but I'm also convinced by the idea that they will complicate the language, and, in practice, after a year or so writing fairly serious Golang programs (I wrote the emulator and debugger backend for Microcorruption in Golang, for instance, along with a pretty complicated web fuzzer) I haven't missed them.
Re:Leaving Go by bsg75 on Monday April 28, 2014 @01:43PM (#7661603)
If you are looking for X, Y will disappoint you.

-or-

If you are looking for X, use X.

Re:Leaving Go by pekk on Monday April 28, 2014 @02:27PM (#7661924)
Unless X is Python, then use Go (??)
Re:Leaving Go by bsg75 on Monday April 28, 2014 @02:28PM (#7661931)
When X is Python, and "time X" is too slow.
Re:Leaving Go by tptacek on Monday April 28, 2014 @02:30PM (#7661949)
Or "likelihood that program runs correctly if compiles correctly X" is too low, or "ability to write concurrent code in straight-line fashion rather than with callbacks X" is "too low".
Re:Leaving Go by bsg75 on Monday April 28, 2014 @02:38PM (#7661990)
Not sure I follow.

When single threaded top-down Python is too slow for a particular task, of late I find it easier/cleaner/faster to use Go routines than multiprocessing / threading in Python, because of the way concurrency was designed in Go, but added to Python.

> "ability to write concurrent code in straight-line fashion rather than with callbacks X"

Same concept or different point?

Re:Leaving Go by mseepgood on Monday April 28, 2014 @01:28PM (#7661471)
> languages used in industry have had them for decades

If languages used in industry have had something for decades it does not automatically mean that it's a good idea. Go reconsiders a couple of things that once were thought to be good ideas like class inheritance, exceptions, generics and questions their net benefits.

Re:Leaving Go by sanderjd on Monday April 28, 2014 @02:49PM (#7662064)
Yeah, and notably, you never hear grumbling about class inheritance, sometimes hear grumbling about exceptions, and constantly hear grumbling about generics. It seems like the amount of grumbling probably tracks the actual net benefits.
Re:Leaving Go by grey-area on Monday April 28, 2014 @01:45PM (#7661621)
They probably will add generics at some point in the future. In the meantime, lots of people are using and enjoying the language as it is.

If you want to write generic methods using your own types, you can define an interface to operate on, and then create types which conform (or wrap more basic types to conform) - as this article demonstrates after it sets up a straw man to criticise golang with. I quite like that approach, though it does depend what sort of libraries you're writing, and what sort of types you're operating on - a maths library might be painful for example but if you're operating on your own types anyway, using interfaces is no great burden.

Re:Leaving Go by coldtea on Monday April 28, 2014 @07:42PM (#7663890)
>In the meantime, lots of people are using and enjoying the language as it is.

I hear that a lot. That's not really an argument. People also enjoy stupid things, including things that hurt them, like drugs.

Re:Leaving Go by grey-area on Monday April 28, 2014 @07:57PM (#7663952)
I hear that a lot. That's not really an argument.

Well, it certainly isn't a convincing argument that it is the best of all possible languages, but it does lend weight to it being worth a look in its current form. Personally, compared to other languages I've been forced to think in (Java, C, C++, ObjC, Ruby), it comes out favourably, but I'm quite happy to accept that some people might think it is stupid, dangerously simple etc, etc. and listen to their reasons why - there's room for more than one language in the world.

Re:Leaving Go by jamra on Monday April 28, 2014 @02:14PM (#7661830)
Golang is a programming language that applies for readability over language features. Built in channels make it easy to break down your code into more granular pieces. It's like the unix approach to piping but in a program.

Reading a golang program is simple because you don't have to chase class hierarchies very far. I personally find polymorphic code to be a detriment to team projects. Anything that hides implementation is a hit on readability.

Re:Leaving Go by protomyth on Monday April 28, 2014 @01:17PM (#7661371)
"If you're looking for a language that will enable "bottom-up development", where you gradually define, in Paul Graham On Lisp style, a language optimized for your problem domain, Golang is not the language for you."

Sounds like he is looking for Forth or one of its decedents (e.g. Factor). That is pretty much the definition of how you do Forth development.

Re:Leaving Go by coolsunglasses on Monday April 28, 2014 @01:19PM (#7661386)
Bottom-up style works well for this ex-Lisper using Haskell.
Re:Leaving Go by DAddYE on Monday April 28, 2014 @01:00PM (#7661226)
> Systems C programmers

I don't know many (TBH none) c programmers that likes or actually uses go. The thing is that as for c++ if you are still writing in c is just for few reasons: portability (in terms of embedding your library) and speed. Especially the former seems very important.

EDIT: I know => I know personally or I follow.

Re:Leaving Go by kaib on Monday April 28, 2014 @01:06PM (#7661273)
Does Ken count as a Systems C programmer?

Most of the systems C programmers I know, who admittedly work on large distributed systems, like Go.

Re:Leaving Go by DAddYE on Monday April 28, 2014 @01:32PM (#7661502)
Edited, I meant: who I know or I follow.
Re:Leaving Go by myg204 on Monday April 28, 2014 @01:07PM (#7661278)
> I don't know many (TBH none) c programmers that likes or actually uses go.

I'll give you two, Rob Pike and Ken Thompson. Ha! :)

Re:Leaving Go by baruch on Monday April 28, 2014 @01:09PM (#7661292)
I prefer to work in C over C++ (did both at different jobs), mostly does C but where I don't care just that much about performance (specific allocations of memory and the like) than I'm likely to prefer Go over C++. It's far nicer and I really like the goroutines and channels concept. I like it that much that I copied it back to C in-fact.
Re:Leaving Go by kator on Monday April 28, 2014 @03:03PM (#7662150)
I'm a 30+ year Systems C programmer who is really enjoying Go.

Why do people make generalizations like this, Language wars are so much fun but we really do waste a lot of time on them.

Re:Leaving Go by mseepgood on Monday April 28, 2014 @01:08PM (#7661282)
The main reason why I used C over C++ was C's simplicity (actually C++'s complexity).
Re:Leaving Go by f2f on Monday April 28, 2014 @01:12PM (#7661319)
pleased to make your acquaintance.
Re:Leaving Go by georgemcbay on Monday April 28, 2014 @02:37PM (#7661986)
I'm a "C programmer" that loves working in Go.
Re:Leaving Go by tptacek on Monday April 28, 2014 @01:33PM (#7661521)
Nice to meet you.
Re:Leaving Go by mseepgood on Monday April 28, 2014 @01:04PM (#7661250)
> the tools Golang misses that are common to other languages (particularly, REPLs

A quick search for Go REPLs gave me many results, e.g. https://github.com/rocky/go-fish "Yet another Go REPL"

Re:Leaving Go by tptacek on Monday April 28, 2014 @01:33PM (#7661516)
There are C REPLs too.
Re:Leaving Go by mseepgood on Monday April 28, 2014 @01:43PM (#7661600)
I know, I didn't say otherwise.
Re:Leaving Go by chc on Monday April 28, 2014 @02:07PM (#7661773)
I think tptacek may have implying that, like all the REPLs for C, the REPLs for Go are more curiosities than anything anyone would want to use.
Re:Leaving Go by mseepgood on Monday April 28, 2014 @02:36PM (#7661977)
REPLs are for toying around and learning. The Go playground provides an alternative that seems to satisfy these needs for most people. If people really missed a Go REPL then the existing ones would not be "curiosities".
Re:Leaving Go by chc on Monday April 28, 2014 @02:46PM (#7662051)
People use REPLs for more than "toying around and learning." They can be very useful both for exploratory programming (which is different from toying around in that you're actually trying to accomplish something) and debugging. It seems more likely to me that Go doesn't have a good REPL because Go just isn't very amenable to general-purpose REPLs, which is the same reason C REPLs tend to be more trouble than they're worth.
Re:Leaving Go by mseepgood on Tuesday April 29, 2014 @01:12AM (#7665089)
> People use REPLs for more than "toying around and learning."

In all those years of Scheme, Ruby, Python, Haskell, Scala I have never used REPLs for anything other than tutorials or trying out something quickly.

> that Go doesn't have a good REPL

What makes you think that the Go REPL is not a good REPL? Have you actually tried it? Probably not, because you do not care as much about REPLs as you think do.

Re:Leaving Go by barrkel on Monday April 28, 2014 @05:49PM (#7663339)
REPLs are for interactive development, where you try out your code live on a command line, insert working snippets into an editor, and gradually build up a working program.

Really shines when the language / REPL has decent introspection, is able to break out into the REPL prompt in the middle of your code with in-scope identifier lookups, and you're dealing with lots of libraries that you don't necessarily have encyclopedic knowledge of, yet need to get the job done under time pressure.

At least that's how I use REPLs, most usually, pry in Ruby.

Re:Leaving Go by plorkyeran on Monday April 28, 2014 @02:54PM (#7662087)
Another possible explanation is that people who care about REPLs just use languages with good REPLs.