Lack of generics seems to always be the argument against Go. I have been coding in Go for over a year now nearly every day and it really became an annoyance only once: CRUD operations in a web-service expecting JSON-objects.
That's literally the only time where the code-duplication was a problem for me.
Now, not everything else has been all good (mostly minor issues with community libs), but the one thing that never ceases to amaze me with go is that: You hammer out a few hundred lines of code, compile, fix those few syntax errors, compile again and 9 out of 10 times your code just works.
The simplicity of the language is the key. It's a tool that feels right and gets the damn job done.
The funny thing is that adding generics will also improve error handling as you would be able to make that Result<T> generic from Swift and implement flatMap for it. This would be as good as exceptions, if not better because its very explicit and can be made compatible with the existing mechanism.
This is why I find it unbelieveable when Go users tell me "I never need generics". I look at their code and see
Also, the "I never need generics" made me smile. Sure, one can get by without them, but sometimes, as I said above, it would be really nice to have them.
Getting used to it is not the point. What I find cringe-worthy is that that's a bewildering amount of noise. It actually makes it harder to figure out what a specific piece of code does.
Admittedly the error pattern is so common that I can imagine people getting very much used to it, but thats not the issue here. The problem is indicative of Go's lack of abstraction power, and its pervasive. There is no difference between `filter`, `map` and a regular foreach - every piece of code that wants to do things like that must re-implement the mechanics of creating new slices and assigning things to members which are accessed using a specific index. So many details - I can't see the forest from the trees!
I see the same kind of noise in legacy messy projects where a piece of code works on multiple abstraction levels and its impossible to think about what a it does without thinking about the mechanics of how it does it.
Given all this I really can't understand how someone can call Go code beautiful and clean. My gut reaction is "this will cause a mess couple of years down the line".
The cost of not having generics in Go is really understated, and it saddens me greatly. With them, Go would be an extremely interesting language. But apparently, the language designers believe that you (the user) are not to be trusted with writing sensible abstractions and therefore are forbidden to do it.
Getting used to it is not the point. What I find cringe-worthy is that that's a bewildering amount of noise. It actually makes it harder to figure out what a specific piece of code does.
I find that so bizarre. That's on a personal level, I'm not throwing stones.
My two favorite languages before Go came along were Objective-C and Python. Different tools for different problem-sets of course, but Objective-C can quite easily be called insanely noisy.
Go is obtuse, but I find its readability on par with Python in that there's one way to do something, and that way is repeated over and over. I don't have to worry too much about stylistic preferences between programmers, people trying to get fancy while writing code (or trying to show off). Our server code serves thousands of requests per second - I need that code to be rock-solid, not fancy or overtly minimalistic.
You're right, people do get used to the error pattern. I can either handle it, ignore it, or toss it up the stack, and I get to make an explicit decision about that every time.
We've been rewriting critical systems code in Go (from mostly Python) and it's a joy. I am, of course, the (unintended) target audience for Go - a dynamic language dev looking for speed, concurrency, and compile-time safety, along with the simplistic beauty of gofmt, goimports, and so on. But I do find it beautifully simple, if not entirely "beautiful."
Seriously, in good faith, I attempted to learn and write a simple web application in go.
I found it hard coming from a world where IDE support was available in other languages that do autocompletion and things like that and development just moves faster. In go, there is some level of support in sublime text, go for vim etc, but it is not nearly as full featured as say, IntelliJ. Want to learn about the javadoc - Command + J. Want to refactor code, much easier than in go. So tooling is a big problem I encountered.
Next in line is lack of reusable data structures. Sure, embedding of structs is supported, but lets see...what will you do with a person struct (name, age, gender) that should be part of a employee struct and also the executive struct. You have 2 options 1) copy paste the person struct fields into each of the other structs or 2) you have interfaces and implementations of those interfaces so you can only deal with it through interfaces using embedded structs. What we really want is a flattened struct (just like inheritance). Most time people use inheritance not because its the right thing to do for that piece of functionality, but because it allows easily flattening out a data structure so you have reuse of a common data structure with common properties across other data structures. This one killed it for me with go. I can't reuse. I am not google to have loads of dollars and when I try to make things work, I need to be able to keep an eye out for bugs that can creep in with go where re-use is artificial or takes excessive work to get.
All in all, maybe go has its niche, but for a small shop that runs on scanty resources and needs to build robust and reliable applications, a heavy weight like Java or .Net is still ruling the roost.
That's funny, because I'm also a Go skeptic but your 2 points are literally exactly the opposite of mine. On the top 2 of the things I like about Go they are tooling and removed inheritance.
Being able to fire up a fully formed, non-handicapped environment consisting of only vim and some command line tools is great. I've tried repeatedly on the JVM to accomplish this and always end up back with bloated IntelliJ and the vim plugin as my only option.
I would say that in the last 15 years I've used inheritance correctly a handful of times, embedded structs are nearly always the correct solution to data structure reuse problems. That Go prioritizes composition over inheritance for data structure reuse is one of its fundamental value propositions, that anyone that has used Java extensively thinks otherwise is baffling to me.
If Go had a longer history I'd probably argue the exact opposite conclusion of you. If you are a small shop with scanty resources and need to build practical business solutions Go seems like a great choice. Conversely, if you are able to afford the best developers and have massive enterprise software needs, maybe Java or .Net makes more sense.
>> bloated IntelliJ and the vim plugin as my only option
Bloated it may be but helps me get the job done faster...much faster than I can do it in vim. I work on a mac with 16 GB RAM and thats sufficient for lots of processes. Every bit of the way, I have documentation I can lookup right within as I type, I have autocomplete that always works, I have debugger support to catch little things I missed, tons of libraries and plugins that have stabilized over the years...whats not to like? The downsides (and the reason I looked at go) are both Java and .Net are memory hogs. I needed something more lighter that would offer the same level of productivity during development.
But that's the beauty of the go tool chain. I have a source browser (godef), a documentation browser (godoc), a code style formatter (go fmt), code vetting (vet), unit testing (go test), a linter (golint) etc. and they are all fast command line programs. This means that it is trivial to setup a vim/command line environment the way I like.
In my vim setup with simple key strokes, I can go to the source of, see the type definition of, see the documentation for the call under the cursor. I have formatting, vetting, and if you want compiling on save of the file (and it's super fast). I have autocomplete that behaves exactly as I want it to.
I wish there was better ctags support for go, and the go oracle tool is more prototype than production software, but on the whole I am much happier with my development chain in go than I've ever been on the JVM or .NET.
Embedding won't give you a flattened structure with transparency you expect. In other words struct B embedded in struct A will only create a syntactic sugar so that you can access properties of B through A. It won't work in other cases .Check this out - http://stackoverflow.com/questions/24333494/golang-reflectio...
This is not to say inheritance is better. I am just illustrating how reuse is harder with go because it expects a lot more code to do a simple thing.
I attempted not to. What pulls me back is the fact that I am trying to force go to help me reuse data structures I already have (without turning to reflection everytime or manually typecasting).
I've tried Go some too. I disagree with your assessment of the data structures (inheritance isn't always great), but the tool thing I strongly agree with.
I'd note that all the replies at this time argue the point about data structures, but none address the tooling.
I want my autocompletetion, dammit! And I don't want to use Emacs or Vi to get it.
The lack of refactoring support was what ended up making me switch back to Java+Dropwizard. I'm just much quicker at evolving services because of the better tooling.
Struct embedding is just syntactic sugar. Have you tried using reflection to look at the fields of the struct? You don't have a chance of looking that the embedded field properties as if they were truly embedded (flattened out as in inheritance) using reflection. Now put that opposite inheritance. No matter what you do (reflection, direct access what not), you still can get to those properties. See why I am saying go is making it harder? Its those cranny little details that you experience that drop your productivity.
> a small shop that runs on scanty resources and needs to build robust and reliable applications, a heavy weight like Java or .Net is still ruling the roost.
That seems to be the opposite usual scenario for "heavyweight" enterprise frameworks.
I actually think Go hits the sweetspot - faster to develop in than Java/.NET, but much more robust, reliable and faster than the scripting languages.
Here is a competition. I'd write in Java and you can write in go. Lets crank out a simple ToDo CRUD application. Any bet who will finish faster?
This is not to say go is bad at all. Its been designed by people 1000x smarter than me. But it isn't helping small shops go any faster or be more productive than they are with current setup. Talk about progress of the 21st century programming language...can't find much.
> Lets crank out a simple ToDo CRUD application. Any bet who will finish faster?
Well I haven't done much web programming in Go, so I would not be very fast. I have done a lot in Python, and I usually finish prototype apps within days while the Java teams are still stuck in meetings with the Oracle DBAs trying to work out why Hibernate is generating shitty SQL again. And I believe Go is comparable to Python as far as productivity is concerned, but with type-safety and speed.
I think there is a lot to commend of Java, well at least the JVM, and the tooling and libraries are great, as is the performance. But I rarely hear anyone argue it is a fast, agile language to develop in.
Well, I was just comparing Java - a complied, strictly typed languages to another in the same domain - Go. Scripting and interpreted languages like python, ruby are a different thing altogether. I agree with you that ruby/rails or python/django get it done a lot faster. On the JVM, we get close but not quite - with Grails and Play. Spring Boot seems to be getting up there as well in terms of productivity. They still have some way to go.
> Scripting and interpreted languages like python, ruby are a different thing altogether. I agree with you that ruby/rails or python/django get it done a lot faster. On the JVM, we get close but not quite - with Grails and Play
Play doesn't use a scripting/interpreted language, it uses Scala, a statically-typed one, but with type inference which you may have confused with dynamicity. As for Groovy/Grails, they seem to be dying off lately.
This piece reminded me of "Zen and the Art of Motorcycle Maintenance", with its talk of the practical qualities of the language through analogy to a shop-built gig.
Notice the author would still rather use Swift when he's doing fun stuff. I get this sentiment and more than once I've wished there were more constraints in the language to mitigate the damage some kid with a chip on their shoulder could do but it says something about the psychology of programmers, "I know personally I'm good enough to do magical, wizardly stuff with all the cool stuff that Swift gives me but you, well, you need some training wheels so we're gonna use Go for this project".
I don't know about you but I'd rather work with people that understand the tools they are using and when it's OK to do fun stuff and when it is important to exercise restraint and "dumb it down" for the good of the team. Using the language to solve the problem of uneven programmer ability feels a bit off. It's something out of 1984. You can't say "great" in Go you can only say "good++".
I have a rule when I make project technology decisions:
If we understand the domain and understand what we are building then we can afford to be innovative on the technology. If we are trying to be innovative in what we are building then we need to choose proven (aka boring) technology.
I liken this to Intel's "tick tock" development approach. If they're moving to a new microarchitecture they stay on the same process, and if they're doing a process shrink they use the same microarchitecture. Working out the kinks of a new process can be done with a microarchitecture that's solid, and vice versa.
I think by "proven" he's implying that it's proven to himself, that is, that he's familiar with it.
I kinda like that philosophy, and didn't realize that I somewhat adhere to it: I tend to try to keep to tools I'm familiar with when I'm solving problems that I know are new to me. It lets me focus on the problem and avoid thinking too much about the tools. But if I'm in learning mode or need to implement something I understand well, I'll often reach for a new tool just to play around with it or try something different.
Yes, this is another aspect: I think there is only a certain amount of "new stuff" the brain can absorb in a given time period. You need to choose what to use that learning budget on.
I don't think it's necessarily about mistrust of other programmers. It's more that we all have tendencies to over-engineer the small stuff, so with Go giving you fewer ways to do things you spend more time thinking about the job you're getting paid to solve.
"I know personally I'm good enough to do magical, wizardly stuff"
In my experience really good developers don't see it like that, they see it more like the Brian Kernighan quote:
"Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it?"
It isn't that they are worried that "lesser" programmers will make a mess using "clever" code, but rather they are worried how long it will take them to debug their own "clever" code, or just decipher such code they produced themselves in the future after they haven't looked at it in 6 months.
True, but what makes Go different than a lot of languages is that it basically guides you into doing things in the most straightforward way possible by making it a PITA not to do so (see: the unsafe package).
If you have an infallible sense of discipline then you don't need this sort of guidance, but given unlimited flexibility a lot of developers can easily lapse into fat-kid-in-a-candy-store mode regardless of their knowledge and skill level.
So you're saying you want programming to be hard because that means you get to work with smarter people? I think what Go is striving for is simplicity, not elegance. And that change makes the code easier to write and maintain for everybody involved. At 10AM I might feel like writing Swift, but at 3AM I'm sure as hell glad I used Go.
Or, less anecdotally, I maintain about twelve services in Go, including web services, proxies, and an analytics engine, and I have never been woken up in the middle of the night with a failure. That was certainly not true when I was writing Python or Javascript. Erlang or Swift might offer comparable reliability, but it comes at the cost of a lot of complexity.
When things get serious, I think you'll discover that Go provides far less reliability, and is far more complex. (What's simpler than "it's already handled for you with OTP and battled tested for 2 decades"? That's a lot more simple than "you can't do it in this language and you'll end up with a poorly implemented half version of OTP in Go."
Of course for toy or small services, go is fine. Erlang certainly could use the "build a binary run it anywhere" distribution model of Go tool.
But reading all these pro-go articles, it strikes me that none of them seem to be written by people who really understand concurrency.
Believe me, I wish Go was written by people who had understood erlang. There's a lot to like about it and it has momentum.
I'm not sure YouTube or dl.google.com qualify as "toy or small services", nor the handful of other relatively large businesses building on top of Go (CloudFlare, Iron.io, etc).
I don't think anyone disagrees that Go is an improvement over Javascript, or more reliable than Python. But I've been working in Scala for several years and could say the same thing about never being woken up.
Look at the examples on the page. Would you really rather see the Go one at 3AM? It's twice as long, and the superficial similarity of each if(err...) stanza obscures the important differences. On a large codebase that adds up. Maybe the "complexity" meant the Swift took longer to write (though I'd dispute that too) - but if it's more readable and more maintainable, that's a positive tradeoff.
Define what you mean by hard and then I can say whether you're correct or not. Otherwise you're putting words in my mouth. I didn't say I want programming to be "hard" but I did say I'd rather work with smarter people. That doesn't mean smarter programmers exclusively program in Haskell, Erlang, Clojure, Scheme, Racket, SmallTalk, etc. I find programming overall to be quite easy in any language once you're used to thinking with the abstractions the language offers. The hard part is communicating with other people.
Also, your "less anecdotally" is by definition pretty anecdotal.
> "I know personally I'm good enough to do magical, wizardly stuff with all the cool stuff that Swift gives me but you, well, you need some training wheels so we're gonna use Go for this project".
It could also be that he realizes that he is a PL snob/geek, and that makes him more likely to pick up and learn weirder/'more powerful' languages/paradigms. Other programmers (arguably most programmers) aren't PL geeks, not for a lack of ability, but for a lack of interest. Choosing to use more advanced languages may be great for him, but may just cramp the style of other people that aren't PL geeks.
The lack of generics is definitely a problem. You can't write generic code, and end up having to write your own thunks for each type you want to use. The standard library can't expose generic facilities that work on any type.
This should be evidenced by the fact that Go is the only mainstream statically typed language without parametric polymorphism. Worse, trying to bolt it on after the fact has generally lead to ugly solutions, like C++ templates or Java's generics.
I expect Go will eventually follow Java's lead and bolt on generics awkwardly.
I guess you're a fan of rewriting type thunks over and over and over again, and don't care about the standard library implementing functionality or reusably. Whatever floats your boat, but in both C++ and Java people got tired of writing type-thunking boilerplate over and over again and eventually got features added to the language to fix the problem.
At this point I'm not sure how Go can do generics well, so if "right or not at all" is really the bar, then Go will probably never get them.
As he said in the article, neither seem to be problems which come up in practice. I maintain about twelve Go services running in production, and neither failure has cost me any significant amount of time.
What kills me is that generics (or any other programming language abstraction) are not problems, but problem-solving tools. Technically speaking, they are never needed, if your definition of "not needed" is "I can work without them".
You don't need anything beyond assembly language, really.
The thing with most tools and abstractions is that you don't appreciate them until you use them -- when you truly use them, not merely when you learn about them. Then you wonder how you ever lived without them. You don't know if failing to use an abstraction hasn't cost you a significant amount of time until you've embraced their use.
To me, this is a variant of the Blub paradox at work.
You can still send mutable state across channels, at which point it is shared and potentially racy. Race detectors only help you catch data races in the act (e.g. in production), they don't prevent them from happening in the first place.
Props to whoever built this presentation software. With Javascript disabled, it gracefully degrades to a basic HTML page. Most others leave you with a single broken slide.
What is with Go supporters ? I don't understand why if I don't use Go then I am not solving real world problems and instead building over engineered monstrosities. Working in the enterprise features like exceptions and generics makes it easier to ensure consistency across the platform and our 20+ developers.
> What is with Go supporters ? I don't understand why if I don't use Go then I am not solving real world problems and instead building over engineered monstrosities.
What is with you?
The article is talking about languages, not the category of problems people are trying to solve using those languages. (In principle, NASA could have written the Mars rover code in brainfuck).
> enterprise features like exceptions and generics
What is an "enterprise feature"? Sounds like a Java-world word though.
I also don't understand how generics and exceptions "ensure consistency across the platform".
"Go feels under-engineered because it only solves real problems"
"and so you build real solutions rather than finding excuses to use your beautiful tools"
The implication from reading the article is that those of us that rely on those so called exotic features aren't doing so for serious business and technical reasons. And it seems to be a common thread amongst many Go users.
And generics allow you to reuse existing components much cleaner and exceptions allow you to handle errors in a consistent way across the system. You can build error handling classes but often handling errors explicitly doesn't scale.
I read that to mean that other languages can solve both real and "non-real" problems, those where one can try ones tools for the inherent joy of using them, but that Go probably doesn't inspire one to do the latter and focuses solely on the real problems.
> The implication from reading the article is that [...]
The implication you inferred from reading the article is that...
I think there reason is that there a misunderstanding here caused by a cultural gap. The Practice of Programming is a very good read which I feel like recommending to every programmer.
> And generics allow you to reuse existing components much cleaner and exceptions allow you to handle errors in a consistent way across the system.
Although I don't think "exceptions allow you to handle errors in a consistent way" (based on my long and still on-going experience with C++), I still don't see how exceptions and generics "ensure consistency across the platform".
> You can build error handling classes but often handling errors explicitly doesn't scale.
I've encountered people doing this. When I said "If I had Maybe here then I could write 1/5 as much code," someone showed me a class that maintained whether it had encountered an error, and each method would do nothing and return the previous error if so. This allowed him to write 1/5 as much code in the method that actually does stuff, just as he would in Haskell or Swift. Unfortunately the approach of reducing every function full of noisy error checking to a bunch of calls on one object is pretty bad in general...
There are plenty of go fanboys out there who will rage about go getting any kind of criticism, but this was a really thoughtful take on why go is a good practical language despite the problems.
They probably mean that you are solving problems, real world and other, but you don't really need features like generics to do the "real world" part. Their proof is in things they have done, projects they have completed. If more projects and developers tried to use Go they might also find that a lot of projects can work with Go.
Regarding the 20+ developers I am pretty shure Google has Go projects with many developers. I also think they were clearly targeting enterprise projects. Google is a huge enterprise with huge programming projects.
I can give you insight into my perspective. Go has made programming better. It is genuinely easier to build reliable things in Go than in Java or C or Python (from my experience). I didn't know that, until I invested a good amount of time building things with it, souly because everyone seemed so enthusiastic.
It's fine to say for economic or organizational reasons you're not moving to Go, but don't say it's because you need exceptions or generics unless you've spent a serious amount of time trying it the other way.
But you can't deploy your Go to iOS. Or your Swift to Linux.
I'm getting interested in Nimrod (or Nim as I think it's planning to become). Compiles to native binaries via C, C++ or ObjectiveC. Even compiles to JavaScript. So it will run on all consumer and server platforms, on microcontrollers and in browser.
And it has generics, exceptions, macros, inheritance, and (optional, time-boxed) garbage-collection.
It's a tiny community which hasn't even managed to get a Wikipedia page to stay up, but I'm barracking for it.
And?
iOS and Android supports are on their way in case you're not following recent developments. In case you're interested in writing programs for mobile devices, there's already a supporting go.mobile repository with (mainly targeting Android at the moment).
> And it has generics, exceptions, macros, inheritance, and (optional, time-boxed) garbage-collection.
Sigh... this "where's my feature!" argument almost always comes up.
It is not reasonable to expect that feature X that is very important to you has to carry the same weight for other people.
Some people think that it is unthinkable to write programs without feature X. If you think that way, then Go is probably not a language for you. Note however that there are many people who do not think that absence of feature X is a crippling thing, and do enjoy writing programs in Go.
> Sigh... this "where's my feature!" argument almost always comes up.
I'll make it simple. Nimrod has one feature - only ONE - which differentiates it from Go. It's not generics, it's not inheritance, it's not proper error handling (cos they're all just fancy features which nobody really needs, right?), it's not even optional garbage collection (although that's a part of it, Go is not suitable for constrained real time applications because of its opinionated lack of optionality in this space).
It's REACH.
You know, the thing that has made JavaScript the most widely used language on the planet - and nobody's claiming THAT's got the greatest feature set.
> iOS and Android supports are on their way in case you're not following recent developments.
Yes I am, and the closest I came up with was this:
Seriously? I mean, have you tried this? Have you even tried to make sense of the build instructions?
If you have the inside line on some secret Google plans for Go then good on you. But if you're going to make public claims like this - in a forum where people might be interested to hear about tools that help them DO cross-platform development rather than just dream about doing it one day - you should be prepared to back them up.
Challenge: you implement a cross platform library in Go, I'll do one in Nimrod, we'll upload working XCode and Android projects that use our shared library and that compile to App Store / Play Store eligible apps to Github. I'm up for it - are you?
> OS and Android supports are on their way in case you're not following recent developments.
Yes, but it remains to be seen how Go's view on data structures map Objective-C and Java APIs.
As for Android support, the Android team doesn't seem to care any little bit about it, given their statements on Google IO.
So you have developers of a Google language trying to target a Google platform, where the platform owners just want to support Java (NDK is a kind of stepchild).
Why do you want to see Go on Android? Yesterday, on the C++14 thread, you told me about why you gave up Turbo Pascal for C++ when you started programming for Windows 3.0 because you wanted to use a language officially supported by the OS vendor. If we apply that logic consistently, it seems to me that it would be best to just use Java on Android, unless you want to share code between platforms.
I agree, but sharing code between platforms is what I do, as I want to target both Android and Windows Phone on my hobby coding. So the common language winner to both SDKs is C++.
The ticket was created back when I was still into Go and was wishing for first level support on Android.
Still I think it would be nice if it would be supported for those that like the language.
Have you looked at RemObjects Elements (http://www.remobjects.com/elements/)? With that (commercial) toolchain, you can write in either C# or Oxygene (an Object Pascal-derived language), and compile to .NET IL, JVM bytecode (and from there to Dex bytecode for Android), and even native code running atop the ObjC runtime for iOS and Mac.
I know then from the time they used to collaborate with Embarcadero. Although I left Turbo Pascal/Delphi when Windows 3.x was still actual, I kept on following Borland.
What I am doing are very basic hobby projects, when private life allows for, which is seldom the case nowadays. You can check some of them with my nick at GitHub.
If I would be doing a commercial app, I would be buying either Qt or Xamarin, mainly because they are better known and using Pascal like languages (except maybe Ada) is no longer relevant on my CV.
Am I the only one who is very confused by these examples?
A function named "frobulate" - what is frobulate? I dunno. The function calls: thingsToFrobulate, logit, cleanupOldest, processOld, doNewThing, cleanup and somehow FrobulatingMessage is set on the way.
Honestly; you can do the most clever functional programming in the world but if you naming is like this then your code is just going to be bananas.
And BTW: both Swift and Go are missing exceptions; I think those would be very helpful here.
Ok. Maybe I am not getting the joke then. So thingsToFrobulate, logit, cleanupOldest, processOld, doNewThing, cleanup and FrobulatingMessage are "metasyntactic variables" too?
It just comes down to a habit of giving a name to something as an example of something that isn't meant to map to any problem domain. E.g. when a manufacturer is in the business of making "widgets," we know they're not actually making products that are widgets (whatever those are.)
Once you know that the names being used are not considered to be "important", the other names aren't as important as well, only the syntax. These metasyntactic variables are useful for avoiding situations like "Who's on First?" (e.g. https://www.youtube.com/watch?v=kTcRRaXV-fg ) which is humorous to native-English speakers, but probably incoherent to non-native English speakers.
I've spent a solid amount of time with both Python and Go, and I encourage you to make the jump. Services I write in Go are just much simpler and easier to maintain than in Python (or Javascript).
I haven't had an issue with code duplication at all. If you do, you might just not have gotten deep enough into how interfaces work yet.
When you use the standard library it's clear it was designed by people who have been programming computers since the Plan 9 days, I consider it much more mature than Python's equivalents.
In terms of tooling, having go fmt run on every save is wonderful, your code is always and instantly formatted perfectly. Beyond that, I haven't needed much.
Tooling? I am not sure about that one. Go tooling is pretty nice. The one area lacking a bit is, for want of a better word, "package management". However, I have been using gpm with success, and others are happy with godep.
For me, the biggest pain point is, to be honest, dealing with json. json in Go is not as fast as you would expect, due to the overhead of runtime reflection. Parsing "loose/dirty" json is also painful. If you cant be sure ahead of time if a value is `"1"` or `1` (int or string of int), and have to support both, you are going to have a bad time.
Well, these are B2B customers, who are huge companies. We have actually had customers say they can't even find which servers are running the code, so could we "pretty please with money on top" just make it work anyway....
Sometimes you actually have to deal with what you get, and can't just "fix the other end".
It might be a bit more painful, but it is totally doable. You could parse that field into a generic interface, and check the type in your code, or you could create an interface which requires an `AsInt` method, and implement it for both options.
I personally struggled with the json parsing issue a fair bit, but persevering resulted in me having a mostly static typed setup which has ended up being much better than when I've used JS or Python.
Yeah. It is indeed possible, just painful. I am thinking of wrapping json or even go-simplejson to add support for attempting to coerce strings to ints, where the target is an int and you happen to get a string(int) via json. Haven't gotten around to it yet though.
That isn't the case at all. The problem is that the types restrict your functions, so you either have to write a Mao function for every type you want to support, or drop the types altogether.
The situation where you drop the types is the equivalent to Python isn't it?
So, you don't write the map function in Go; you use a plain for loop. Again, Go only focuses on solving real problems, and does so in a mostly imperative style.
Map is solving the real problem of code duplication for the scenario "create a new list whose elements are the elements of the original list to which f was applied". Not only does it reduce boilerplate but when you read map(f, list) you know that the result is gonna be a new list of the same size, that if f = id you're gonna get the same list, etc. In other words, map has invariants. It captures a tiny subset of all the for loops you can write.
Saying "we don't need map, we have for", is akin to saying "we don't need toUpper, we have for loops" or "we don't need functions, we have goto".
- Designers of the language forced their where-braces-go religion on everyone by building it into the language.
For me, that means every time I attempt to write code in Go my nose is rubbed in the "this language was built by assholes who have no respect for you".
Oh really? I can see that I suppose, but I always found it kind of nice that they enforce a very specific style. It makes it so that all Go code I see is consistent and clear. Same with the way they do documentation.
I guess it does take some of the aesthetic or artistic quality out of it, but in practice it's never bothered me. On the contrary, not having the option removes quite a bit of mental overhead on what (to me) comes down to a fairly religious but ultimately inconsequential viewpoint.
Are you being ironic? I guess it wouldn't overly bother the OP, considering he's switching from python, where "the designers of the language forced their mind-your-indentation religion on everyone blah blah blah".
Now, not everything else has been all good (mostly minor issues with community libs), but the one thing that never ceases to amaze me with go is that: You hammer out a few hundred lines of code, compile, fix those few syntax errors, compile again and 9 out of 10 times your code just works. The simplicity of the language is the key. It's a tool that feels right and gets the damn job done.