News for hackers. Stuff that matters.
Re:Moving from Go to PHP Again by Xeronate on Friday February 08, 2019 @12:40AM (#19111828)
Why do so many companies keep moving to go? I tried to like it, but it was just so painful to write.
Re:Moving from Go to PHP Again by 12298765 on Friday February 08, 2019 @01:49AM (#19112086)
I'm curious, what is painful about it?

I came to Go from mainly C++, Java, and Python background, and I feel like it's the best of all 3 (to me). It's compiled and really fast (like C++), it has a great set of libraries and community interaction/support (like Java), and it has simple syntax that is clear and quick to understand (like Python).

It's not a perfect language (nothing can ever be), but it's become my favorite to use for back-end web services and even taken over some of my scripting workflow.

I can see it being painful if you're trying to render websites server-side though. That's a bit outside of what it's made for

Re:Moving from Go to PHP Again by sam0x17 on Friday February 08, 2019 @02:10AM (#19112149)
On the topic of web frameworks, though, I firmly believe it is possible to write a delightful web framework with mass appeal (like Rails) in any language, you just need the right influences and conventions, but this seldom happens because the people who could write it are already busy enjoying their framework in the language that they enjoy most.
Re:Moving from Go to PHP Again by k__ on Friday February 08, 2019 @07:57AM (#19113691)
I talked with a few people who wrote Go servers and while they loved almost everything about the language and ecosystem, they hates the missing generics so much, they still switched to other languages later.

Writing code-generators for everything wasn't fun.

Re:Moving from Go to PHP Again by w8rbt on Friday February 08, 2019 @08:35AM (#19113941)
I don't miss generics in Go and I have used generics in C++ a good deal. I think the whole generics argument against Go is largely parroted by people who may not even know what generics even are. C doesn't have Generics either. It's doing OK.
Re:Moving from Go to PHP Again by ryeguy on Saturday February 09, 2019 @05:58PM (#19125242)
Any language that doesn't have generics, including C and Go, have to work around that limitation. In C, people get around this by using void* (equivalent to using interface{} in Go) or code generation via macros.

I'd flip what you said and say that most of the people arguing against generics in Go don't have much or any experience with them. Which makes sense because a large number of users came from dynamically typed languages.

Re:Moving from Go to PHP Again by throwaway2048 on Saturday February 09, 2019 @05:07AM (#19121635)
that isn't true at all, function macros serve as the moral equivalent of generics.
Re:Moving from Go to PHP Again by hazz99 on Friday February 08, 2019 @05:55AM (#19113082)
Personally, I find the concurrency support quite lacking. Compared to Java/Javascript/Python/etc, it's great, but nothing compared to languages like Ada or Elixir.

I wish we could use more than channels - for me, I often feel like I'm shoehorning them in because there's no support for protected objects (native queues, conditional variables etc).

Perhaps I'm just using them wrong. Sometimes I have to use locks, and I don't think we should be forced to use locks in 2019. We've had better solutions since the 80s.

Re:Moving from Go to PHP Again by grumpydba on Friday February 08, 2019 @09:52AM (#19114653)
> Sometimes I have to use locks, and I don't think we should be forced to use locks in 2019. We've had better solutions since the 80s.

Absolutely not. Locks/spinlocks are found in pretty much every significantly parallel software project. It is pretty arrogant to criticize almost all software architectures on earth.

Re:Moving from Go to PHP Again by hazz99 on Friday February 08, 2019 @07:53PM (#19119982)
> It is pretty arrogant to criticize almost all software architectures on earth.

Almost all software is programmed with modern languages, which all (imo) have extremely lackluster support for concurrency. It's not a symptom of the programmers, but the tools they work with. Who uses Ada these days?

Locks should only be used when other protection mechanisms are too slow.

Semantically, the critical region protected by a lock is not connected to the lock in any way. This can make debugging races super difficult, and you have to rely on everyone to lock everything at the right point.

Juggling multiple locks in complex concurrent processes is difficult, and prone to bugs.

I struggle to think of where a lock is required, barring the extremely hyperoptimised hot paths within operating systems, or similar applications.

Re:Moving from Go to PHP Again by sethammons on Friday February 08, 2019 @09:22AM (#19114319)
I find waitgroups to be similar to condvars
Re:Moving from Go to PHP Again by apta on Friday February 08, 2019 @11:08AM (#19115511)
Re:Moving from Go to PHP Again by jashmatthews on Friday February 08, 2019 @05:09AM (#19112887)
Go has GC and a runtime so you can argue it's not really close to C/C++/Rust at all and much closer to AOT Java.
Re:Moving from Go to PHP Again by oconnor663 on Friday February 08, 2019 @02:12AM (#19112153)
Personally I found it too easy to accidentally forget to check an error, or to shadow a named error return, or to create a nil error that doesn't compare equal to nil. Also to write a method that appears to mutate the receiver but which in fact copies it.
Re:Moving from Go to PHP Again by agnivade on Friday February 08, 2019 @03:04AM (#19112337)
> I found it too easy to accidentally forget to check an error

Use https://github.com/kisielk/errcheck for that.

Or prefer https://staticcheck.io/ for a larger set of checks.

Re:Moving from Go to PHP Again by apta on Friday February 08, 2019 @11:09AM (#19115520)

    fmt.Println("foo")
I don't see errcheck complaining there

how about (taken from here: (https://www.reddit.com/r/programming/comments/ak305l/goodbye...):

    r1, err := fn1()
    r2, err = fn2()
    if err != nil {
      return err
    }
err check doesn't complain either
Re:Moving from Go to PHP Again by oconnor663 on Friday February 08, 2019 @01:47PM (#19117389)
That second example is really surprising. This sort of thing happens all the time in production when lines get moved around. Does anyone know why errcheck misses it?
Re:Moving from Go to PHP Again by agnivade on Tuesday February 19, 2019 @12:20AM (#19196794)
Not sure about that. But https://github.com/gordonklaus/ineffassign catches that.
Re:Moving from Go to PHP Again by spdionis on Friday February 08, 2019 @04:19AM (#19112648)
use an IDE
Re:Moving from Go to PHP Again by rnvhhynr on Friday February 08, 2019 @06:46AM (#19113353)
What's a good IDE for Go? Something that's snappy and fast, no Java dinosaurs please
Re:Moving from Go to PHP Again by 12298765 on Friday February 08, 2019 @09:11AM (#19114232)
I mean GoLand is pretty good, but I do also like IntelliJ, so YMMV if you don't like the JetBrains products. And it isn't free.

VSCode is also really good for Go, I was surprised. There are plugins that massively help with testing, syntax checking, error handling, etc. I think it actually catches more issues than GoLand!

Re:Moving from Go to PHP Again by rnvhhynr on Friday February 08, 2019 @09:18AM (#19114289)
I've tried VSCode but it seems to require you to install Go... It can't even find the declaration of a variable or the definition of a function without Go, while Sublime can.
Re:Moving from Go to PHP Again by xdfgd0ig0dg on Friday February 08, 2019 @09:17AM (#19114274)
Visual Studio Code with the official go extension is really great and snappy
Re:Moving from Go to PHP Again by geoka9 on Friday February 08, 2019 @11:47AM (#19116041)
Emacs with go-guru.
Re:Moving from Go to PHP Again by sam0x17 on Friday February 08, 2019 @02:04AM (#19112127)
In all honesty, indenting with more than 2 spaces (or, gasp, with tabs) is enough to kill a language for me these days. There are so many competing "new age systems languages" as I call them (crystal/rust/go/nim/d/julia/etc) that you really can pick the one that suits you the most. Crystal is more my speed. Yes go is way more mature, and has all the features I want, but it just isn't set up how I want things to be set up, whereas Crystal is. Is Crystal perfect? No, but it's the closest thing to what I want, and has all the appearances, trappings, etc., that I would expect of a language sent by the gods. The way go code looks just doesn't do that for me, but I'm sure it does for the people who created it.
Re:Moving from Go to PHP Again by joshmn on Friday February 08, 2019 @12:44AM (#19111856)
What do you usually write? That might answer some questions.
Re:Moving from Go to PHP Again by cloverich on Friday February 08, 2019 @09:54PM (#19120394)
Because it works well at various levels and is good at producing low error maintainable code. It's also very stable and has a good stdlib so what's written five years ago is still working and makes sense. It's not really fun for me (yet?) and I think something like Django is more suitable in many cases, but choosing a core competency go is a pretty safe bet for medium or large company.
Re:Moving from Go to PHP Again by aikah on Friday February 08, 2019 @05:48AM (#19113056)
Go's a language for managers that don't trust their developers with their own intelligence. It's either a good thing or a bad thing.

Go is actually simpler than PHP as a language, once one understands "explicit" pointers (though PHP does expose pointers for a few things, arrays for instance since they are copied by default).

As for PHP, it's useful IN SPITE of itself, and that's the issue, the language works against the developer and only the tooling, frameworks and rigorous security practices can mitigate its flaws.