Live data from Hacker News

Four years of Go

blog.golang.org

141–150 of 202 posts

Re: Four years of Go

#141
post #82
post #67

Earlier quoted context omitted.

That was my initial struggle as well coming into Go (I have worked for several years in C# & Java). You learn to work around this limitation using interfaces for both function parameters and return types. Frankly, I have had to do a little more explicit typecasting that I would have liked (going from interfaces to the actual type) but it is ok.

Are you saying that making sure the type is correct (just before the cast) becomes the programmer's responsibility? How often does this happen?

Nope. This mostly becomes a problem if you like to be DRY and try to replace generics (type T) kind of functionality with interfaces. For e.g., I have a method, which does the classic, lookup from cache first before hitting the actual db. In C#, you can use

  public T Get(int id, string cacheKey) {

  }
When I consume it and say Get for User object, I expect an User object as I already know it's type.

In Go, you have to return an interface (and ideally an error)

Here would be the equivalent,

  v, err := s.Get(id int, cacheKey string)
  if err != nil {
           //Handle error here
  }
  if v == nil || v.(*models.User) == nil {
		return nil, http.StatusNotFound
  }
Its a bit more code, but on the flip side, it gets you thinking as a client of all the things that can go wrong with your code

Re: Four years of Go

#142
post #136
post #11

Earlier quoted context omitted.

It will - it's too compelling a proposition.

I doubt it will ever make a dent on the enterprise over the JVM/.NET/C++ stacks, unless a compelling library requiring its use shows up.

It will tend to make a dent one program at a time - like etcd, docker, nsq. Soon, a significant fraction of your installables will have to be compiled with Go.

This was reason enough for C to get popular.

Re: Four years of Go

#143

Earlier quoted context omitted.

My experience with Go was bizarre -- I loved programming in it, but I don't understand why! For example, Go has no REPL. (It's difficult for statically-typed languages to provide one.) It's commonly believed that a REPL is valuable and increases productivity. So if you were offered the choice, is there any circumstance in which "no REPL" is equally powerful as having one? Well, the vast majority of great hackers seem…

> It's difficult for statically-typed languages to provide one. No, it's not. As long as you have a way to polymorphically print a return value, which there are ways around (in Go, with reflection; in Haskell, with typeclasses; in Java, with Object's toString), there is nothing semantically difficult about a REPL for statically typed languages. > there's no dynamic typing Yes, there is, through `interface{}`.

The main thing stopping Go having a REPL (when there are ones for C, for example) is that Go can't yet compile to, or load, dynamic libraries. This stops each bit of REPL being compiled up and executed, which would otherwise be simple.

Re: Four years of Go

#144
post #136

Earlier quoted context omitted.

I doubt it will ever make a dent on the enterprise over the JVM/.NET/C++ stacks, unless a compelling library requiring its use shows up.

It will tend to make a dent one program at a time - like etcd, docker, nsq. Soon, a significant fraction of your installables will have to be compiled with Go. This was reason enough for C to get popular.

> It will tend to make a dent one program at a time - like etcd, docker, nsq. Soon, a significant fraction of your installables will have to be compiled with Go.

Only if commercial UNIX and Windows also get rewritten in Go.

> This was reason enough for C to get popular.

C got popular because UNIX was adopted by the enterprise and C was the system language.

I doubt C would ever been popular without UNIX.

Re: Four years of Go

#146
If hacker news is any indicator of success than go will become the most used programming language soon.

Yeah I was been ironic but go is quite a nice language =)

Re: Four years of Go

#147
post #86

Earlier quoted context omitted.

My experience with Go was bizarre -- I loved programming in it, but I don't understand why! For example, Go has no REPL. (It's difficult for statically-typed languages to provide one.) It's commonly believed that a REPL is valuable and increases productivity. So if you were offered the choice, is there any circumstance in which "no REPL" is equally powerful as having one? Well, the vast majority of great hackers seem…

> Or do you believe in the other possibility: having a REPL doesn't matter as much as everyone thought? The importance of REPL is very exaggerated. Neither Java, C#, C++ nor C have one (and together, these four languages probably make up for 95% of programming languages). There is nothing that prevents any of these languages to get one (Scala has one, a bunch of these exist for other statically typed languages), it's…

> The importance of REPL is very exaggerated.

I constantly use REPLs to experiment, verify output of functions, etc. In the case of Go I open the Go Playground at least once a day, often much more.

Re: Four years of Go

#148
post #97

Earlier quoted context omitted.

I see that as an obvious mistake. C++ is so different than C, and I imagine most C purists despite it. Go created a smarter C, and presented it as the solution. The problem though is that C++ people likely aren't C purists to begin with, or that C purists are too into C. Compounded by those who only drop to C when needed, you begin to see why it failed initially in this segment. I do think it will continue to gain ad…

> C++ is so different than C, and I imagine most C purists despite it. Go created a smarter C, and presented it as the solution. I think it has nothing to do with the difference between C and C++ and everything to do with the reasons why people use C and C++: extreme performance, zero-cost abstractions, and integration with native libraries.

I think you are right, and I tried to convey that in my last two sentences but in retrospect worded it poorly. I guess what I was trying to say there is that people who "drop to C"(or for that matter, start in C) for performance reasons or compatibility reasons aren't going to consider a slower and less integrated language. This is probably most people, I'm not sure many people write everything in C regardless of task anymore(such as say, webapps).

I still think the initial part stands. C and C++ are not visually or mentally similar languages. Go is very similar to C in logic, so I'm not sure why it was expected that C++ people would flock to it(unless of course they weren't happy with C++, which brings us back to the first condition in that they were probably only using it for performance).

Re: Four years of Go

#149
post #60

When I look at the Google Trends for "golang", China is the top region by a huge margin (the next highest region after China is Sweden at 30) [ http://i.imgur.com/XHW40kp.png ]. And the rise of interest in "golang" in general seems to correspond to the massive spike in China [ http://i.imgur.com/Y3oO2jf.png ]. I'm not really sure what that means...

China is the world's most populous country, with a population of over 1.35 billion. That's 19% of the world population.

The population itself doesn't matter that much. According to this: http://en.wikipedia.org/wiki/Poverty_in_China#Poverty_reduct... ~950 million live on less than 5$ per day. I doubt you can get a decent PC and a decent Internet connection on that kind of money. I'd bet that the US has more programmers than China right now, even though China has 4x the population.

Re: Four years of Go

#150
post #144

Earlier quoted context omitted.

It will tend to make a dent one program at a time - like etcd, docker, nsq. Soon, a significant fraction of your installables will have to be compiled with Go. This was reason enough for C to get popular.

> It will tend to make a dent one program at a time - like etcd, docker, nsq. Soon, a significant fraction of your installables will have to be compiled with Go. Only if commercial UNIX and Windows also get rewritten in Go. > This was reason enough for C to get popular. C got popular because UNIX was adopted by the enterprise and C was the system language. I doubt C would ever been popular without UNIX.

I might be off, but I think C still would have been popular. It's such a simple language, very easy to learn, easy to reason about, close to the machine but provides enough abstraction to easily write complicated code. C's merits as a language are self-evident beyond its usage in Unix. Of course, some other language with this set of properties might have taken C's role if it had not been for unix, so maybe that's what you meant.
Post reply on HN