Official Go support
stripe.com
stripe.com
I'm a big fan of C and python and I've never used Go. My initial impressions from readings were that Go is a better C. But then I came across a Go person who was lamenting that misunderstanding and that Go is python but with better performance. What's it all about?
Also even if we compare it to C I don't like the garbage-collection thing at system level. Also what does Go let you do in terms of garbage collection that cannot be done with a C gc library (which anyone can use if they want but then also have the choice to do raw/manual memory management if they want too).
Many people, myself included, find it a wonderful language suitable for all sorts of service development whether it's data processing systems or web APIs.
Given that it was co-created by Ken Thompson (of Unix/C/Plan9 fame), I think the comparison is justified.
And regarding semicolons: you don't use them as much while coding, but the lexer puts them in for you, so they're there on some level.
You still have access to memory/pointers/unsafe, it shares a C-style syntax (go ahead, put in the semicolons if you want!), is compiled but offers the gentle, elegant watchfulness of a Python-like scripting language.
In most cases it can be a relatively drop-in replacement for C++ or Python as a binary. It will never be like C in that there's a lot of overhead and lack of memory control for embedded systems, so you probably can't treat it as a C competitor in any way.
Specifically about garbage collection, I'd recommend taking a look at what's coming up in 1.4:
https://docs.google.com/a/stripe.com/document/d/16Y4IsnNRCN4...
If you want a better C, better to look into Rust: http://www.rust-lang.org/
Unless Management forces the team to change their mind, that is.
:| really? Got a link to that?
I really thought that they'd finally gotten over themselves and realized that lots of people want and use the NDK.
https://www.youtube.com/watch?v=K3meJyiYWFw#t=1566
- Java is the official language, that is what the team has invested into
- You can use the NDK for your favorite language, but beware that you are required to use JNI anyway for Android APIs
- Not possible to do any comment regarding Java 8 support.
- Only use Scala for business logic, no tooling support plans
It's unclear what the big missing feature is after lambdas. I think there will be little incentive for further change, so large companies will keep on running it.
I agree. I think Java pretty much is what it is by now. As someone said, "For those who like this kind of thing, this is the kind of thing they like."
Java-the-language is pretty complete. (Even though Haskell people complain about the lack of a decent type system, and Lisp users complain about the verbose syntax, and C++ folks wish they had destructors.) Java-the-platform is in fine shape (the library is Java's unsung best selling point.)
Java-the-enterprise-bloatware-behemoth... well, it really needs to be shot in the head and the body incinerated, but it may actually do the jobs it's given to do about as well as anything that might replace it.
- Value types, GPGPU, replacing JNI with an improved JNR, reified generics, making Unsafe an official package, modularity, AOT compilation, replacing Hotspot by Graal...
Some things discussed here,
http://www.oracle.com/technetwork/java/javase/community/jlss...
http://openjdk.java.net/projects/panama/
http://openjdk.java.net/projects/sumatra/
http://openjdk.java.net/projects/valhalla/
https://wiki.openjdk.java.net/display/Graal/Publications+and...
Thanks for the links.
Specially for people doing big data analysis in JVM languages or jumping out of Java to languages like C and C++ for the last performance increase.
https://github.com/google/auto/tree/master/value
I'm honestly not seeing as big as lambdas (or generics in Java 5). If you think they really are that big, perhaps you could explain why?
(Well, you get some help: the compiler inserts (arbitrarily expensive) copies of your data for you.)
I actually hope that Rust does not become that kind of a language. I think it has a lot going for it, but I do agree that it's a pretty dense language, and that will cause problems in uptake for real projects.
Not targeting any specific language, as I imagine all of us that went through this, have own hard earned war scars.
There's plenty of off-shore C++ programmers, and I doubt anyone would say that's an easy language.
And yes, offshored work is almost always of poor quality, but I actually think this is due to the inherent problem with paying people to write a product that they are not fully invested in. The same thing happens with contract work done in your own country. If the developers don't work for your company, they don't have your culture and they don't know your business. This is compounded by the communication inefficiencies from being outside your trusted mediums.
I have seen pay-for-code (contracting, offshore or not) fail many times. The only times I have seen it succeed is when the contractors are hired to work for the company directly, are taken inside its boundaries, and given full access to the company communication facilities and culture. But then, they may as well be regular employees.
None of this has anything to do with the language being used. As they say, you can write bad code in any language, and even the best code doesn't help if it's not doing the right thing.
The nice thing about go is that there's just a lot less to know. You can learn everything in a weekend. There just aren't many dark corners in the language.
> I actually hope that Rust does not become that kind of a language. I think it has a lot going for it, but I do agree that it's a pretty dense language, and that will cause problems in uptake for real projects.
Many of those real projects can't use anything easier than Rust. Sure, using a GC for everything is easier, allowing memory safety violations is easier, and allowing data races is easier (for some definition of "easy"). But for many projects, like browser engines, kernels, games, etc. neither of these are an option. In other words, avoiding new concepts comes at a price. The concepts in Rust aren't there for no reason; they're there because they're solving real problems.
(Incidentally, I don't think that "simpler" is the right term; I think there's a lot of confusion between "simple" and "easy".)
Unlike the dynamically typed languages, it doesn't trade speed for beauty of syntax. This means that sometimes syntax can be a little non-uniform, but there's always a reason. Unlike C and C++, it doesn't trade safety for speed of execution. There are no buffer overflow vulnerabilities in Go applications. It treads a fine line of where to let the language do the lifting and where to make you do it. In general, it does a really good job of finding the pragmatic side of the line to sit on in any particular situation.
I don't know of any widely used C garbage collection libraries. The benefit of it being a language-level is that everyone uses it, which means your code works the same as everyone else's, so you can easily just reuse other people's code, without having to restrict your search to some small subset of repos that use your particular GC Library.
Also, in Go, unlike most other garbage-collected languages, there is a stack, and you can pretty easily write code that only uses memory from the stack, and never needs to run GC.
Finally, Go's tooling is really phenomenal. Testing, doc generation, performance reporting, code coverage, linting, package distribution, code formatting, refactoring, cross-platform compiling, and soon, pre-processing, are all built-in and really well done.
When you start diving into it a a bit more, you'll see that Go has it's own ASM language[1] that your code is first compiled into (which then can be translated into specific os/platform asm).
This has it's own ups and downs. Debuggers don't work all that well on Go generated executables (gdb is the closest, even that one isn't all that great). You also don't have the years of optimizations that GCC and LLVM bring to the table. But the Go team has tight control of the tools, which allow for quick compilation and allow them to pick their own direction.
I like that fact that a lot of the tooling/editor support is not picking a winner nor demanding an IDE. Tools like errcheck, goimports, gorename (announced today), oracle, gocode, godef, godoc, gofmt, golint, gotags, ... (on and on) ... all can be leverage by IDEs, emacs, sublime, vim and others equally... or just used from a console or in your own stacks.
Actually there are in certain cases [1], but there's a good reason for that.
1. http://stackoverflow.com/questions/25628920/slicing-operatio...
[0] https://golang.org/doc/faq#What_is_the_purpose_of_the_projec...
[1] http://commandcenter.blogspot.com/2012/06/less-is-exponentia...
It was designed to compile fast, and compiles faster than most languages and still has near C-speed. It doesn't have a GIL so it has better concurrency (Java style memory model). It has no complicated features like generics, instead you just use type assertions when you need. It also has impeccable tooling.
That's not entirely true. Go 1.3 introduced pre-emptive scheduling, so now only the most trivial (useless) of infinite loops will hog the scheduler. But if you're doing real CPU-bound work you won't block other goroutines from executing.
package main
import "fmt"
func main() {
go func() {
for ;; {}
}()
for ;; {
fmt.Println("still here")
}
}
Even bigger pointless programs also freeze: package main
import "fmt"
func f(v int) int {
return v+1
}
func g(x int) int {
if (x > 100) {
return 1
}
return 0
}
func main() {
go func() {
for ;; {
if g(f(111)) == 0 {
break
}
}
}()
for ;; {
fmt.Println("still here")
}
}
This is of course by design, because Go was designed only to support useful programs. The programmer trying to figure out how the concurrency model works may whine that it's inconsistent and he can't figure it out, but that's only granted because threading is hard. Go makes it easier by only supporting useful cases.On platforms like Go and the JVM, the garbage collector acts like a GIL, which is why they'll never replace C/C++.
[citation needed] - the vast majority of Linux software is C or C++ and I can't immediately think of any with GC. It's not normally assumed, everyone does explicit deallocation, possibly ending up writing their own slab or pool allocators.
How about Go's syntax and semantics seem ad-hoc, hard to remember, and inconsistent because _they are_ ad-hoc, hard to remember and inconsistent? What does your thought leader have to do with your genuine opinion?
The crux of the matter is that there are inelegant parts to the language because they are usefully inelegant, and when you're actually writing software, useful is better than elegant.
This isn't true, you only get code points when you convert to []rune, I'm not aware of any situation where you would magically get codepoints.
>If any thread runs in an infinite loop that doesn't call built in functions, the entire runtime will freeze.
This is not true, since 1.3 all function calls can potentially yield. Also it only happened if you had as many goroutines running infinite loops as you had kernel threads.
I worked for about 2 years in Python and hated most things about it - from the whitespace sensitive indentation that led people to write really long lines and the limited expressive capabilities forcing people to do meta voodoo in their libraries leading to incomprehensible DSLs, to the legacy that sticks like "old-style vs new-style classes", to the performance problems and the sad state of libraries in the ecosystem, let alone the complete cluster-fuck that is dependency and deployment management on top of Python.
So you know, I want to hear about languages that are not like Python.
Go is actually quite different from python in a lot of ways. Most of the stuff you hate about python does not apply to Go in any way. You can't really make a DSL in Go - there's no operator overloading, no meta classes... no classes at all. The performance of Go is an order of magnitude faster than python and only a few times slower than C. Dependency management and deployment are trivial - Go compiles to a standalone binary with no dependencies (except sometimes libc depending on what you're using).
So... Go is nothing like Python. When people say it is, what they mean is, Go tries to make its syntax really obvious, and make life pleasant for experienced developers writing software in the language.
Stockholm syndrom is a builtin feature that comes with it and not much else. It doesn't provide basic stuff like generics, warnings, or exceptions because the authors want to make a bold statement about how they are in the Right and their potential users are wrong.
Meanwhile system software will continues to be built in C and C++ since Go addressed some real problems with system programming but created new ones.
Go was explicitely created for the average programmer like is said in videos talks. It is a dumbed down language to address the maintenance problem through tools instead of through better craftmanship. Go isn't very successful at Google but in startups who could do technically anything and still have the same outcome.
As always with the HN hype: Do. Not. Listen.
>Go isn't very successful at Google
Go is used heavily for networking and server stuff at Google. The entirety of dl.google.com runs on go (ported from C).
- dl.google.com
- vitess
- Google App Engine, that used to be maintained by someone on the Go team not the Google App Engine team, if the Google IO information is still valid.
Chrome is focusing on Dart support and Android team was very explicit at Google IO about Java being what really matters.
So any other very successful Go projects at Google that can be shared?
EDIT: For those that bothered to provide answers. Thanks.
Most of the places it is used are not public facing stuff they are low level network systems which is what it was designed to be good at.
- Various projects at github.com/google
Many new system projects at Google are using Go over C and the trend is such that more and more new projects are using it.
The reason so many Go advocates seem irrationally biased is because they're under near-permanent assault. Personal assault. The anti-Go crowd never lets a Go post fly by without arguing against it, but it's the "...and everyone who is using it is stupid, ignorant, a kid, or just doesn't understand programming" that leads to the kind of defensiveness that tends to crop up. Argue against the language, but please, stop assuming people who have made different choices and have different priorities or preferences are dumb.
Which isn't very exciting but it is generally what people want. Something that's a good enough multi-purpose language to cover normal use cases. And in the rare examples they need something more niche, then there's other languages that will serve those functions better.
Is blue/purple color blind less common? Can you differentiate between red/green?
And as Sanddancer points out, any colors that make use of red/green are going to be problems as well. (hence blue/purple being an issue as the difference is the red component).
In a given group of 5 men, you have a 50% chance that 1 is red/green color deficient.
Soooo, 1 in 10 men are red/green colour deficient?
Pc = Probability that someone is colorblind
(1 - Pc) = Probability they aren't colorblind
(1 - Pc)^5 = Probability that no one in group of 5 is colorblind
1 - (1 - Pc)^5 = Probability that someone in group of 5 is colorblind
Solve .5 = 1 - (1 - Pc^5): http://www.wolframalpha.com/input/?i=.5+%3D+1+-+%281+-+p%29%...You get .129449, which is approximately 1 in 8
It usually doesn't come up in conversation. Even when I was working on an image processing toolkit, it was several months before I realized my boss was red-green colorblind.
Of course without knowing the base we don't know how big usage it actually is, also we don't know if it's counting one-per-client or one-per-request. Still nice to see that nonetheless.
[0] http://movingfulcrum.tumblr.com/post/97624791473/critique-of...
There's a tradeoff space here, as that tweet indicates. Doing things generically makes the library less idiomatic, but means developers don't need to churn their library dependency as often. Go's a different language from Java, and it's less common to have to deal with casting, etc. As that tweet conversation indicates (particularly https://twitter.com/JimDanz/status/511732603884294145), we're also considering changing the Java library implementation in the future.
I'm currently doing a project that takes json, with no predefined structure, or at least very varying struct and transforms it. Dealing with checking for keys and doing type conversion it's that much fun. The same project need to parse an XML file, with a clear and defined structure, it took something like five minutes and work on my first try.
I don't think you would need to update the Go library in the case of just adding new parameters, not if the parameter can be excluded. The json parser should just skip that value, it won't be available to you of cause, but it should break the parser. Given that I haven't touched Java in 10 years I don't know how Java deals with unexpected parameters.
Most of the code we've been porting has been infrastructure: parsers, reverse proxies, and the like. We're still getting a feel for what it's like writing complex application logic in Go, but what we've seen so far has been promising.
You're probably already aware of this, but there are 3rd party[0] libraries, including one for Lua[1]
[0]: https://stripe.com/docs/libraries#third-party [1]: https://github.com/wsummerlin/stripe-lua
Is this the case here? Does lua have a lot of use elsewhere?
The majority of developers I know (across several camps) strongly oppose Go, often to the point of ridiculing it.
But then I see Go support being added to everything, usually by a few key people who strongly prefer it. In fact I hear Heroku is internally adopting Go pretty rapidly.
So every time I see an announcement like this, I look up whether Go has added some kind of generics yet. And as usual, they haven't.
But to me, the worst part of this is that the whole community has Stockholm syndrome, being perfectly content to instantly defend every position the Go team makes, no matter what.
...but you've got to admit: look at the graph. That's an exponential increase in people using go to access the service.
If you're a service based company you can't just ignore the people who use your service.
If people are using go? Provide a go library.
If you see an exponential curve of people accessing it using lua, write a lua library.
It's pretty obviously the right thing for them to do.
Missing generics is not a major problem. Yes, it means you can't write a generic red black tree in the language that doesn't require type-casting. However, for real software solving real problems, you don't often actually need generics. I work on Juju, which is a couple hundred thousand lines of code, consisting of a client and networked servers deployed across an arbitrary number of machines in the cloud. The number of times we might have wanted to use generics in the codebase is approximately 2... and only one of those pieces of code is actually used by more than one type.
Sure, some software really benefits from generics. But most of the time, generics just complicate the code with little to no benefit. Many things people do with generics can be accomplished with interfaces and just writing code that has fewer assumptions about the outside world.