News for hackers. Stuff that matters.
Re:Go best practices, six years in by nvarsj on Sunday May 01, 2016 @03:33PM (#11607535)
The stages of go enlightenment:

1. Holy crap, this is like coding in early Java days, what the heck were the language designers smoking?! They just ignored everything! Where's my testing framework! DI?! Build system, dependency management?! WTF.

2. Holy crap, this is like coding in the early Java days! This is awesome! I can understand all golang code I read! Everything is so simple and easy. I finally get "less is more", and "worse is better"!

3. (Many months later) Oh god, I'm getting so sick of writing this test assertion in 4 lines over and over, and writing 100s of lines of mock structs. My tests are 5% substance and 95% setup. Okay let's write a junit/mockito assertion library. Oh crap, I'm having to manually wire everything everywhere and it's such a pain. Let's write a DI library. Ugh my project is getting too big and `go get` just doesn't cut it - time to use a dependency management library. Ugh, makefiles only go so far, time to write a build tool. Ugh code generation and metacoding is nonexistent, let's write our own code generation tool so we don't have to hand build 100s of types. ETC.

4. (Distant future) As golang's stubborn designers finally accept some flaws in their original thinking, they add features to make the language look a lot like another widely used language at the Googplex. Mission accomplished?

P.S. This is somewhat tongue in cheek - I do enjoy using golang day to day. It is a refreshing change :).

Re:Go best practices, six years in by gtrubetskoy on Sunday May 01, 2016 @07:54PM (#11608420)
Java was:

1. Wow, this program runs on any platform!

2. Wow, no need to free memory!

3. Wow, threads and locks are so easy to do!

Then many years later

4. Who really cares about cross-platform code if all I do is on Linux?

5. Why does this program require 4GB of ram?

6. Must I really download and install the JVM all the time, and what is it good for anyway?

Go:

1. Wow, I can write stuff that previously could only be done in C/C++, and I can do it almost as easily as writing Python or Ruby.

2. Wow, I don't need anything installed for my program to run, it just runs!

Re:Go best practices, six years in by bad_user on Monday May 02, 2016 @02:52AM (#11609575)
> 4. Who really cares about cross-platform code if all I do is on Linux?

Deployment happens mostly on Linux, but development happens mostly on OS X and Windows. Having guaranteed behavior, compiling it only once, being able to deploy as a simple JAR file, the same JAR file that you tested locally, is awesome.

> 5. Why does this program require 4GB of ram?

Java is actually very memory efficient, all things considering. There are Ruby developers choosing JRuby for deployment because of that efficiency. By the time Go's GC will reach the same maturity, it will behave similarly.

> 6. Must I really download and install the JVM all the time, and what is it good for anyway?

The JVM ensures consistent behavior across all platforms and is able to do optimizations based on runtime profiling, with JVM bytecode acting as a very efficient ABI, making the JVM an efficient target for multiple languages, including Scala, Clojure, Groovy, Ruby, Kotlin, Ceylon and others, languages that have been able to bootstrap easily and have a huge ecosystem at disposal because of the JVM.

> 1. Wow, I can write stuff that previously could only be done in C/C++, and I can do it almost as easily as writing Python or Ruby.

Go is not a replacement for C/C++ because it has a GC. In fact it's impossible to use Go for the same use-cases where C/C++ is required. And if you can use Go, then you can use Java as well. And in fact, because Java is more mature and has alternatives like Azul's pauseless GC, it's more amenable for projects with soft real-time constraints.

> 2. Wow, I don't need anything installed for my program to run, it just runs!

That's cool sometimes, but Java is almost as ubiquitous as POSIX and HTML5. On Linux it's basically one "apt-get install" away, just like everything else. So the advantage of not requiring a runtime for me is, you know, meh.

Re:Go best practices, six years in by gizzlon on Monday May 02, 2016 @07:44AM (#11610611)
>> 5. Why does this program require 4GB of ram?

> Java is actually very memory efficient, all things considering.

Huh? Considering what? Compared to what?

> There are Ruby developers choosing JRuby for deployment because of that efficiency.

Yeah, Java !=JVM, and Ruby is not Go so this is kind of moot.

>By the time Go's GC will reach the same maturity, it will behave similarly.

Says who? You can't just state that as a fact without backing it up somehow.

Re:Go best practices, six years in by fauigerzigerk on Monday May 02, 2016 @04:39AM (#11610009)
>Java is actually very memory efficient, all things considering

That makes me wonder about your universe of things to consider. Java's terrible memory usage was set in stone the moment they decided not to include structured value types.

Re:Go best practices, six years in by pjmlp on Monday May 02, 2016 @06:50AM (#11610429)
Besides being planned for Java 10, there are AOT and JIT compilers for Java that are able to convert simple Java types that follow a specific value pattern into value types.

An example would be how the IBM J9 JIT converts a final Point class, just with getters and setters into a value type.

Also there are language extensions from JVMs like IBM Packed Objects or Azul Object layouts that are exploring how to involve the language into value types.

It sucks that they didn't follow the route of Mesa, Modula-3, Eiffel and Oberon in regards to value types, but they aren't holding still.

Re:Go best practices, six years in by fauigerzigerk on Monday May 02, 2016 @07:20AM (#11610510)
If the compiler can prove that an object is final and immutable and is never used in any other context that requires reference semantics, it could potentially use that optimization.

But then you also need data structures that can be parameterized to store such value objects as values. Otherwise you're back to square one.

Re:Go best practices, six years in by pjmlp on Monday May 02, 2016 @07:54AM (#11610643)
Which is the point of IBM and Azul's research.
Re:Go best practices, six years in by threeseed on Monday May 02, 2016 @06:30AM (#11610358)
Value Types are being worked on now for Java 10+.

https://en.wikipedia.org/wiki/Project_Valhalla_(Java_languag...

The Java language is definitely not set in stone.

Re:Go best practices, six years in by fauigerzigerk on Monday May 02, 2016 @06:48AM (#11610427)
No, the Java language is not set in stone. Its terrible memory usage is set in stone as long as the language doesn't have value types.

If (and that's a big if) they introduce value types in 2018, it will have been almost 25 years since that fateful decision that has done so much damage.

Re:Go best practices, six years in by pjmlp on Monday May 02, 2016 @07:13AM (#11610488)
While it sucks that Java does not support value types like other GC enabled languages, apparently Go owner's are fine with that decision, to the point of fighting to keep using it on their products instead of replacing it with Go.
Re:Go best practices, six years in by fauigerzigerk on Monday May 02, 2016 @07:38AM (#11610586)
That's like saying you're fine with every decision taken by a government you voted for.

Go owners have millions and millions of lines of existing Java code and they employ many people whose entire careers were made on top of Java.

I'm not saying there are no rational reasons to prefer Java over Go. But Google is hardly the yardstick for that.

Re:Go best practices, six years in by geodel on Monday May 02, 2016 @08:49AM (#11610881)
With >3 years release cycle by mid 2017 we are hoping to get Java 9 so to me Java 10 seams 2020 at the earliest.
Re:Go best practices, six years in by peteretep on Sunday May 01, 2016 @08:16PM (#11608495)
You're in stage 2, then.
Re:Go best practices, six years in by catnaroek on Monday May 02, 2016 @02:21AM (#11609488)
> threads and locks are so easy to do!

I don't think concurrent programming was ever particularly easy in Java. If you're talking about `synchronized` methods, well, they are of limited usefulness (to put it mildly) when you need to lock objects in an interleaved fashion: "lock A, lock B, unlock A, lock C, unlock B, lock D, unlock C, etc.", which isn't too uncommon a user case.

> stuff that previously could only be done in C/C++ (...) almost as easily as writing Python or Ruby

Metaprogramming, any? C++ has templates. Python and Ruby have metaclasses. What does Go have?

Re:Go best practices, six years in by spriggan3 on Monday May 02, 2016 @05:35AM (#11610190)
> What does Go have?

Go generate AKA C Macros but even worse since there is no macro syntax , you have to code you own code generator yourself .

Re:Go best practices, six years in by dig1 on Sunday May 01, 2016 @09:22PM (#11608687)
2. Yea, right. Obviously you haven't run enough Go binaries
Re:Go best practices, six years in by gizzlon on Monday May 02, 2016 @07:40AM (#11610598)
Really? I also find that to be true for the go stuff I run.

The last example is nsq[1]: Download, unzip and run the binaries .. aahh :)

Obviously this can be true for non-golang programs as well, but I can't think of any right now.

1: http://nsq.io/deployment/installing.html

Re:Go best practices, six years in by spriggan3 on Monday May 02, 2016 @05:30AM (#11610172)
> 5. Why does this program require 4GB of ram?

The biggest issue with Java IMHO , 6 not so much since deployment is automated.

> 1. Wow, I can write stuff that previously could only be done in C/C++

Not true, like at all. Every Go does can be done with Java.

Re:Go best practices, six years in by incepted on Sunday May 01, 2016 @11:44PM (#11609091)
> 4. Who really cares about cross-platform code if all I do is on Linux?

Most developers write their code on Windows and MacOS and then deploy on Linux. I'd say this "Write once run anywhere" thing was and still is a pretty big deal.

> 5. Why does this program require 4GB of ram?

Oh no! I need to buy a $5 piece of hardware to run this Java code? What kind of nonsense is that?

> 6. Must I really download and install the JVM all the time, and what is it good for anyway?

Once or twice a year, if you really want to. You update your browser much more often.

Re:Go best practices, six years in by throwaway_exer on Monday May 02, 2016 @01:04AM (#11609285)
> Oh no! I need to buy a $5 piece of hardware to run this Java code? What kind of nonsense is that?

4 GB per program absolutely destroys VM consolidation. I love the look on managers' faces when they ask for a 1 GB VM and I ask them, "Is this for a Java program?" :)

Re:Go best practices, six years in by nixusg on Monday May 02, 2016 @01:44AM (#11609396)
Just adding some ram is also not so easy in an embedded system.
Re:Go best practices, six years in by Hydraulix989 on Monday May 02, 2016 @02:39AM (#11609537)
But the Java JRE update installer wizard for Windows touts the fact that Java is "in" thousands of embedded systems -- parking meters, toasters, etc.
Re:Go best practices, six years in by threeseed on Monday May 02, 2016 @06:31AM (#11610363)
There are dozens of Java VMs some of which are optimised for embedded systems:

https://en.wikipedia.org/wiki/List_of_Java_virtual_machines

Re:Go best practices, six years in by dig1 on Monday May 02, 2016 @04:34AM (#11609984)
Imagine, Java is run on your phone's SIM card. Enough?

On other hand, on truly constrained embedded systems where real time is essential, no GC-based language has any business, no matter how GC is good. Even C++ is sometimes avoided.

Re:Go best practices, six years in by pjmlp on Monday May 02, 2016 @07:10AM (#11610481)
You mean like missile radar control systems?

http://www.pr.com/press-release/136232

Or do you prefer Aegis battleship Weapons System ?

http://dl.acm.org/citation.cfm?id=2402699

These are my favorite examples for Java being used in life critical situations.

Re:Go best practices, six years in by geodel on Monday May 02, 2016 @09:44AM (#11611230)
Well 2 thing stand out for me from links you mentioned:

> The applications use a combination of Thales proprietary middleware written in C combined with Java code enabled by the Java™ Native Interface (JNI).

> AONIX has additionally delivered professional services to help PERC Ultra users at Thales optimize their applications and improve execution performance including, a customer-specific training course handled the needs of coding in Java™ with hard real time constraints.

Seems like with helping of C and Consulting on 'How to do Java right' they made it work.

> End-to-end distributed thread timing constraints measured from stimulus to response are typically under 100 ms.

Since it is slightly faster than typical (per char) typing speed on keyboard. It appears nice but terribly impressive real time Java use case.

Re:Go best practices, six years in by pjmlp on Monday May 02, 2016 @10:26AM (#11611609)
For me it is impressive, because if the system doesn't work, the wrong guys die.
Re:Go best practices, six years in by frankzinger on Monday May 02, 2016 @09:51AM (#11611291)
> Imagine, Java is run on your phone's SIM card. Enough?

Not Java, not even close. JavaCard is an extremely stripped-down version of Java. I've used it and it feels like C.

From https://en.wikipedia.org/wiki/Java_Card#Java_Card_vs._Java:

> However, many Java language features are not supported by Java Card (in particular types char, double, float and long; the transient qualifier; enums; arrays of more than one dimension; finalization; object cloning; threads). Further, some common features of Java are not provided at runtime by many actual smart cards (in particular type int, which is the default type of a Java expression; and garbage collection of objects).

[EDIT] But I am not arguing with the overarching argument that Java proper can run efficiently on very constrained devices. It all depends on the implementation.

Re:Go best practices, six years in by m_mueller on Sunday May 01, 2016 @11:49PM (#11609104)
> What kind of nonsense is that?

.. and then someone gets the idea that your application should now run natively on Android phones, since they all run Java anyway, right?

Re:Go best practices, six years in by incepted on Sunday May 01, 2016 @11:51PM (#11609112)
Yes, they all run Java.

What's your point?

Re:Go best practices, six years in by frankzinger on Monday May 02, 2016 @12:03AM (#11609139)
I'm guessing his point is that "4 GB" is a big problem on a phone.
Re:Go best practices, six years in by incepted on Monday May 02, 2016 @12:07AM (#11609150)
Yes it is, but his number was an exaggeration in the first place.

There are hundreds of millions of phones running Java today, what does that tell you?

Re:Go best practices, six years in by m_mueller on Monday May 02, 2016 @01:28AM (#11609346)
The point is that memory still matters, not that Java is inherently a problem. You're shifting the goalpost here - earlier your claim was that 4GB is not a big deal since we can just buy more memory, now it's that 4GB is a ridiculous number anyway.

It's not if you meet one of these typical "don't do any premature optimisations (even in the design phase of my data structures), because some important CS person said so"-designs. There's all too many programmers who think they should never have to care about hardware anymore.

Re:Go best practices, six years in by viraptor on Monday May 02, 2016 @01:30AM (#11609349)
> Once or twice a year, if you really want to.

I really hope you actually mean 7+ times a year. https://en.wikipedia.org/wiki/Java_version_history#Java_8_up... - most versions contained security updates.

Re:Go best practices, six years in by incepted on Monday May 02, 2016 @02:51AM (#11609571)
None of these updates are mandatory. You don't have to upgrade anything if you don't want to.
Re:Go best practices, six years in by viraptor on Monday May 02, 2016 @03:06AM (#11609624)
If you looked at the issues and verified they're either not applicable in your case or don't affect your application, you already spent a lot of time on it. If you do install, you should verify your app still works. If not, you already spent time on analysis. The actual installation time is next to nothing compared to everything else around the "new jre came out" event.

What I'm saying is - you should care 7+ times a year. Doesn't matter if you only update twice.

Re:Go best practices, six years in by goodplay on Monday May 02, 2016 @12:15AM (#11609166)
> Oh no! I need to buy a $5 piece of hardware to run this Java code? What kind of nonsense is that?

Funny. That's Microsoft line of thought with Vista.

Re:Go best practices, six years in by tptacek on Monday May 02, 2016 @08:12AM (#11610704)
I'm sure this comment was written in good faith, but it doesn't belong at the top of this thread. It could be attached to virtually any post about Go. It barely engages with the actual post at all. Practically every other top-level comment below it is better.

And, of course, it spawned a completely useless thread litigating Java vs. Go. Perhaps that's why it's at the top of the thread --- which means voting had a perverse effect for this topic.

I don't know what to do about this tendency in language threads on HN, but it's a real problem.

Re:Go best practices, six years in by raould42 on Monday May 02, 2016 @03:55PM (#11614978)
I think having a ui widget to let us fold sub threads would be great. I really don't enjoy trying to scroll past some giant thread I think is not interesting to me.
Re:Go best practices, six years in by setheron on Monday May 02, 2016 @04:29PM (#11615293)
There are chrome extensions that do this :)
Re:Go best practices, six years in by askyourmother on Sunday May 01, 2016 @04:38PM (#11607764)
Appreciate it was written as tongue in cheek, but I am glad that today a developer can start with Go, test, write code, build, deploy all with Go, whereas nearly every other ecosystem requires additional tools, often external competing tools. Then life becomes about having to learn whole new toolbekt before even coding.

Go still keeps it lean, and is great.

The fact it does not have hipster dev approved status is also an added bonus. The minute we see a bloated testing suite with yet another DSL, for Go, we are in trouble.

Re:Go best practices, six years in by spriggan3 on Sunday May 01, 2016 @04:47PM (#11607799)
> The fact it does not have hipster dev approved status is also an added bonus.

What are you talking about ? the hype is strong with Go. So strong devs are persuaded they need to use Go at all cost then complain Go has a garbage collector ( just go go-nuts mailing list).

So strong there are countless articles on the net about "How we moved from X to Go..." just like in 2007/8 with Rails.

> The minute we see a bloated testing suite with yet another DSL, for Go, we are in trouble.

GoConvey and co ...

Re:Go best practices, six years in by jkarneges on Monday May 02, 2016 @04:53AM (#11610054)
> So strong there are countless articles on the net about "How we moved from X to Go..."

Writing about Go is a great way to hit the front page of HN. I once saw 5 articles about Go on the HN front page at the same time!

Re:Go best practices, six years in by gizzlon on Monday May 02, 2016 @07:47AM (#11610617)
I don't think that's true anymore (?). HN has a well defined, very short, hype cycle.
Re:Go best practices, six years in by ddw on Monday May 02, 2016 @12:09AM (#11609154)
Except you can not use GoConvey and still write a quality test suite.

Plus GoConvey wisely separated the UI visualizer from the BDD, we use the former and not the latter.

Re:Go best practices, six years in by eternalban on Sunday May 01, 2016 @06:46PM (#11608198)
> just like .. Rails

Uncanny, isn't it?

Re:Go best practices, six years in by daurnimator on Sunday May 01, 2016 @08:05PM (#11608470)
> The fact it does not have hipster dev approved status is also an added bonus

Huh? In my experience Go is the most hipster dev language around at the moment.

Re:Go best practices, six years in by skj on Sunday May 01, 2016 @09:07PM (#11608636)
The insight here is that the "hipster" devs are always the ones who have strong opinions that you do not share.
Re:Go best practices, six years in by cikey on Monday May 02, 2016 @03:46AM (#11609795)
Seems more like Rust is the new hipster target if i count the recent hn posts about it...
Re:Go best practices, six years in by daurnimator on Monday May 02, 2016 @04:21AM (#11609938)
I don't think you can equate press coverage with hipster-ness.
Re:Go best practices, six years in by spriggan3 on Monday May 02, 2016 @05:36AM (#11610195)
How many articles a day about Rust on HN ? that's right, not as much as Go.
Re:Go best practices, six years in by takeda on Sunday May 01, 2016 @08:48PM (#11608584)
I would say it is second after node.js
Re:Go best practices, six years in by MichaelGG on Sunday May 01, 2016 @05:09PM (#11607875)
Rust has that built in, but managed to be a much more solid language (feature wise).
Re:Go best practices, six years in by weberc2 on Sunday May 01, 2016 @05:27PM (#11607922)
I don't know, I want to like Rust, but every time I pick it up I feel like I'm relearning C++. It's learning curve is steep, the sorts of applications I write benefit more from solid development velocity and a good concurrency story. I might be wrong, but I get the feeling that Rust really only shines where performance and meticulous control are paramount. I want to like it, but it feels ill-suited to the applications that interest me. :(
Re:Go best practices, six years in by ntonozzi on Sunday May 01, 2016 @05:56PM (#11608040)
I don't think there's anything wrong with that. Rust is designed for a specific market, and it sounds like you aren't part of it.
Re:Go best practices, six years in by weberc2 on Monday May 02, 2016 @04:48PM (#11615460)
I agree; but I think I'm still allowed to be disappointed that my use cases aren't a good fit for so thoroughly-heralded a language. :)
Re:Go best practices, six years in by MichaelGG on Monday May 02, 2016 @04:51PM (#11615484)
Don't be disappointed. If you don't need the performance Rust offers, then use another ML-ish language. More expressiveness, none of the ownership issues (just GC).
Re:Go best practices, six years in by weberc2 on Monday May 02, 2016 @04:59PM (#11615558)
Which would you recommend for someone who prefers a C-like syntax, a good concurrency story, a comprehensive standard library, Java-esque speed, and dead-simple tooling (e.g., Go's tooling), and compilation to a static binary?
Re:Go best practices, six years in by MichaelGG on Monday May 02, 2016 @05:43PM (#11615929)
C# and F# can both compile to a static binary (Mono's AOT compiler), and meet your other requirements. I find it curious that "safety" wasn't one of the points.

If you're looking for C-like though, you are probably not in any modern-featured language designer's aim.

Re:Go best practices, six years in by weberc2 on Tuesday May 03, 2016 @09:44AM (#11620533)
> I find it curious that "safety" wasn't one of the points

It was implied by the context of "ML" languages. That was my intention at least; I thought ML languages were characteristically safe.

Regarding "C-like", I mostly mean syntax. I'm not too familiar with the ML family, but many FP languages have bizarre syntax which amplifies the difficulty of learning new concepts IMO.

Re:Go best practices, six years in by valarauca1 on Sunday May 01, 2016 @07:45PM (#11608381)
>I feel like I'm relearning C++

Because you are. You likely wrote widly unsafe things which are perfectly legal in C++. Rust is really just enforcing RAII which C++14 already has, and you've likely avoided.

Re:Go best practices, six years in by catnaroek on Monday May 02, 2016 @01:40AM (#11609383)
C++has had RAII for decades already. Actual Rust innovations are the borrow checker and dynamically sized types.
Re:Go best practices, six years in by pjmlp on Monday May 02, 2016 @02:21AM (#11609487)
Yes, we were already using it on Windows to program COM in the mid-90's.
Re:Go best practices, six years in by cwzwarich on Monday May 02, 2016 @03:39AM (#11609775)
The borrow checker is predated by Cyclone and other work on region systems. Rust added more polish, but none of the basic ideas are new.
Re:Go best practices, six years in by catnaroek on Monday May 02, 2016 @03:53AM (#11609823)
Of course, I'm aware that work on region systems dates back to the mid 90's, which is why I called Rust's borrow checker an “innovation” (the first time a product form factor or feature successfully makes it into a market) rather than an “invention” (coming up with a product concept that didn't exist before).
Re:Go best practices, six years in by MereInterest on Sunday May 01, 2016 @09:07PM (#11608637)
Wait, people avoid RAII? With how useful it is in every circumstance, I can't imagine C++ without it.
Re:Go best practices, six years in by weberc2 on Monday May 02, 2016 @04:57PM (#11615541)
It's not just the safety features; it's the syntax, the build system, the numerous kinds of strings, the difficulty of finding up-to-date documentation, etc. Rust just has a steeper learning curve than many newer languages. This is not to say that the learning curve is unjustified; only that it exists and is significant.
Re:Go best practices, six years in by weberc2 on Monday May 02, 2016 @09:35PM (#11617202)
Regarding safety, we don't even need to call into question my competence with writing safe code :) ; Rust's borrow checker currently precludes a swath of perfectly safe programs. This isn't a knock on Rust; it just means it's not yet intuitive.
Re:Go best practices, six years in by catnaroek on Sunday May 01, 2016 @06:17PM (#11608106)
It's not just about performance, but also (perhaps primarily!) correctness: making sure that resources (not just memory) are freed in the right places, that your code won't try to use resources that have already been freed, that the same object can't be mutated by two or more parties at any single point in time, etc.
Re:Go best practices, six years in by takeda on Sunday May 01, 2016 @08:46PM (#11608582)
Rust really aims to be replacement for C. It allows you to program in low level, but you have much more powerful type checking and keeps track of ownership which reduces number of errors that plagued C language.

Yes go also claims to be C replacement, but probably the only similarity is its simplicity, but unlike C it is not as expressive.

Re:Go best practices, six years in by BuckRogers on Sunday May 01, 2016 @09:47PM (#11608758)
I haven't used Rust extensively, more Go for sure. But it seems to me that Go was aiming for simplicity more than being a true innovation. It's basically a compiled Python with type annotations and unfortunately a GC to spoil it all.

Rust was aiming at innovating and advancing the PL space with meaning. I can't say looking back the time I invested with Go was well-spent.

Rust is probably worth the effort if you have the need for what it offers. It just requires more out of you than Go does.

Re:Go best practices, six years in by MichaelGG on Sunday May 01, 2016 @08:25PM (#11608522)
I don't know a whole lot about C++, but I've worked on projects using C. Seems to me Rust is straightforward and just enforces what you have to do in your mind otherwise.

Once IDEs start coming around it should be quite competitive. I'll admit to thinking the same thing: I'll use Rust for the absolute critical parts, then F# for the rest. But more and more parts I'm writing are easy enough to do in Rust, and I get the perf as a bonus.

Re:Go best practices, six years in by twic on Sunday May 01, 2016 @07:47PM (#11608387)
> The minute we see a bloated testing suite with yet another DSL, for Go, we are in trouble.

https://github.com/onsi/ginkgo

Re:Go best practices, six years in by Mahn on Sunday May 01, 2016 @07:19PM (#11608285)
You forgot 5. (In a more distant future) After a plethora of features, long time Go developers become disappointed with how much bloat the language acquired over the years, decide to start from scratch and design the definitive language to replace it. Go to 1.
Re:Go best practices, six years in by zzzcpan on Sunday May 01, 2016 @05:44PM (#11607993)
Well, hundreds of lines of mock structs is probably a sign that there is something very fundamentally wrong with the code. Go, as a language, has nothing to do with it. Testing is one of its nicest features. I only had to improve my testing experience just a bit, like stringifying complex outputs to compare them easily, comparing all of outputs with expected outputs in a single if statement and issuing a single verbose t.Errorf on failure, showing what functions produced what outputs on what inputs and what was expected.
Re:Go best practices, six years in by nvarsj on Sunday May 01, 2016 @06:13PM (#11608097)
100s of lines. It feels very much like mocking objects in Java before mocking libraries came about. The explicitness is nice, but the verbosity increases very quickly as you start adding state to your mocks.
Re:Go best practices, six years in by brightball on Sunday May 01, 2016 @06:46PM (#11608197)
At some point mid #3 I finally hit the "I think it's time to just learn Elixir for every situation where I don't need a portable binary..."

So far, looking like a solid decision.

Re:Go best practices, six years in by pjungwir on Sunday May 01, 2016 @11:57PM (#11609129)
I'm looking to transition from Rails to something more performant. Phoenix is at the top of my list, but these benchmarks worry me:

https://www.techempower.com/benchmarks/#section=data-r12&hw=...

https://www.techempower.com/benchmarks/#section=data-r12&hw=...

In both Phoenix has very high error rates, and in the first it seems really slow. Here is their Phoenix test app:

https://github.com/TechEmpower/FrameworkBenchmarks/tree/mast...

So what is going on there? Is it less of a perf win than I've heard? Is there something bad with their code?

Re:Go best practices, six years in by learc83 on Monday May 02, 2016 @02:50AM (#11609570)
Re:Go best practices, six years in by brightball on Monday May 02, 2016 @06:47AM (#11610420)
Yea, I had the same concern until I heard the reason. There are other benchmarks out there that compare to Go/gin that are more accurate.

Edit: Here.

https://gist.github.com/omnibs/e5e72b31e6bd25caf39a

Re:Go best practices, six years in by jake_morrison on Monday May 02, 2016 @01:56AM (#11609424)
The benchmark for Phoenix was done at the last minute, and had a lot of problems which they didn't have opportunity to fix. The next round will be better.
Re:Go best practices, six years in by asdf1234 on Monday May 02, 2016 @09:14PM (#11617123)
There were problems with the benchmarks and nobody had time to fix them. This is usually the case when the benchmarks have high error rates and this has also happened in the past with Haskell, C# and F# libraries.
Re:Go best practices, six years in by honua on Sunday May 01, 2016 @09:02PM (#11608626)
This is helpful to read because I've been debating between learning Elixir vs Go
Re:Go best practices, six years in by twic on Sunday May 01, 2016 @07:54PM (#11608415)
Counterfeiter is a pretty serviceable mock generator:

https://github.com/maxbrunsfeld/counterfeiter

Re:Go best practices, six years in by pacala on Sunday May 01, 2016 @08:57PM (#11608611)
What do people use mocks for?
Re:Go best practices, six years in by RyanZAG on Sunday May 01, 2016 @03:39PM (#11607561)
It will get extremely meta when golang's infrastructure gets good enough for other languages to want to use. Then they'll split it out into a 'GoVM', or I guess 'GoRT', and then you'll have a 'GoVM' competing with the JVM...