Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
I am just learning Go and the fact that it gets so many things right are what make the things that seem 'less right' so frustrating. The type system feels like more of a straight jacket than an actual tool. A good type system can be expressive and powerful in addition to just making your code typesafe.

Adbot
ADBOT LOVES YOU

sarehu
Apr 20, 2007

(call/cc call/cc)

mdxi posted:

It may also be illuminating to remember that it was designed and written by people who are already titans in their field and have absolutely nothing to prove to anyone.
The problem with this explanation is that it has decent explanatory power for some of the ways that Go sucks, but not all the ways. So consider me unilluminated.

Bozart
Oct 28, 2006

Give me the finger.
can we stop with the dumb language wars and get back to dumb programs Sheesh

blorpy
Jan 5, 2005

Most of my complaints with Go are with the hype surrounding it anyway. It's fairly palpable. Go is not the saviour.

Karate Bastard
Jul 31, 2007

Soiled Meat

Bozart posted:

can we stop with the dumb language wars and get back to dumb programs Sheesh

Nah that's all good, as long as it can be kept to the concrete. For example, I'd really like to hear why you think the type system is bad and how it hinders you in your day-to-day work, and what you propose should have been done instead, and why you'd expect that to improve things, and what other language you consider has done this right.

e: and that's "you" in the general sense, not specifically directed at "you" in the specific sense.

blorpy
Jan 5, 2005

Karate Bastard posted:

Nah that's all good, as long as it can be kept to the concrete. For example, I'd really like to hear why you think the type system is bad and how it hinders you in your day-to-day work, and what you propose should have been done instead, and why you'd expect that to improve things, and what other language you consider has done this right.

e: and that's "you" in the general sense, not specifically directed at "you" in the specific sense.

Most go projects I've seen go to type assertions at some point and some even have to resort to using reflect. Moving your type system to the runtime is a pretty good concrete example of it not being expressive enough.

sarehu
Apr 20, 2007

(call/cc call/cc)
I could tell you how the type system would hinder me but that's why I'm not using Go for that sort of stuff. But just to pick an example, I'd badly want generic stream resequencing logic and generic stream throttling logic in a project I recently worked on. Also a bunch of stuff for performance reasons (because Go slices and maps would be wrong). C# gets this relatively "right", in particular with respect to boxing.

Coffee Mugshot
Jun 26, 2010

by Lowtax

Markov Chain Chomp posted:

Most go projects I've seen go to type assertions at some point and some even have to resort to using reflect. Moving your type system to the runtime is a pretty good concrete example of it not being expressive enough.

What's wrong with type assertions? That's not a strange thing to do when you're using interfaces anyways. I also really doubt many projects have to resort to using reflect unless you're dealing with protocol buffers or something.

Deus Rex
Mar 5, 2005

Voted Worst Mom posted:

What's wrong with type assertions?

They fail at run time, superior type systems don't need them (or even have them), maintaining and accessing type information at run time is prohibitively expensive for some cases.

Karate Bastard
Jul 31, 2007

Soiled Meat
What do you catch with asserts that interfaces don't?

blorpy
Jan 5, 2005

Voted Worst Mom posted:

What's wrong with type assertions? That's not a strange thing to do when you're using interfaces anyways. I also really doubt many projects have to resort to using reflect unless you're dealing with protocol buffers or something.

It's actually pretty loving strange when all of your type information is known at compile-time. It makes your project more brittle and it's unnecessarily verbose. And gently caress it, why should I have to do it? Why can't it just have a good type system instead?

blorpy
Jan 5, 2005

MALE SHOEGAZE posted:

I am just learning Go and the fact that it gets so many things right are what make the things that seem 'less right' so frustrating. The type system feels like more of a straight jacket than an actual tool. A good type system can be expressive and powerful in addition to just making your code typesafe.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
why does that movie gif have some random guy's name in the left corner

KaneTW
Dec 2, 2011

the act of putting text over somebody else's work is a very hard and arduous process. it's only natural to take credit

ATM Machine
Aug 20, 2007

I paid $5 for this

Suspicious Dish posted:

why does that movie gif have some random guy's name in the left corner

because tumblr is a thing that exists

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder

ATM Machine posted:

because tumblrthe internet is a thing that exists

sarehu
Apr 20, 2007

(call/cc call/cc)
Here is what annoyed me about Go's type system yesterday. I had several types of slice, and for each of them, I wanted to find the index of the element that matched a given player. In other languages I could just write func[T] lookup(elems []T, f func(T)bool) (index int, found bool) { ... }, or actually it would be a utility written for me, but instead I had to rewrite the same for loop several times. And the same again when I wanted to make a new slice with the matched element removed. I guess it doesn't matter though because Go is made by titans in their field, just like Git, a perfect version control system that is also above criticism.

WHERE MY HAT IS AT
Jan 7, 2011
The lack of function overloading irks me a lot of the time. Like sarehu's post above, you can't just do lookup(whatever []type) int {...} for each type, you'd have to have a different function name for each. It's not like it's a bunch of extra typing, but why the hell did they design a modern language this way? If you won't give me generics at least give me overloading so I can sort of simulate it.

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
Overloading or dynamic dispatch or really any number of things. (I don't quite understand the meaning of overloading in a language without classes, though, care to elaborate?)

Or like the example here with the linked list:

http://yager.io/programming/go.html

You can sorta simulate something this with interfaces (I guess?) but now you've lost any meaningful type safety.

I dont know why go is this way aside from the compilation speed thing maybe? I'm an idiot so I can only speculate. It's a Bad Type System.

Bozart
Oct 28, 2006

Give me the finger.

sarehu posted:

Here is what annoyed me about Go's type system yesterday. I had several types of slice, and for each of them, I wanted to find the index of the element that matched a given player. In other languages I could just write func[T] lookup(elems []T, f func(T)bool) (index int, found bool) { ... }, or actually it would be a utility written for me, but instead I had to rewrite the same for loop several times. And the same again when I wanted to make a new slice with the matched element removed. I guess it doesn't matter though because Go is made by titans in their field, just like Git, a perfect version control system that is also above criticism.

Just curious, why isn't a map appropriate in this case?

blorpy
Jan 5, 2005

sarehu posted:

Here is what annoyed me about Go's type system yesterday. I had several types of slice, and for each of them, I wanted to find the index of the element that matched a given player. In other languages I could just write func[T] lookup(elems []T, f func(T)bool) (index int, found bool) { ... }, or actually it would be a utility written for me, but instead I had to rewrite the same for loop several times. And the same again when I wanted to make a new slice with the matched element removed. I guess it doesn't matter though because Go is made by titans in their field, just like Git, a perfect version control system that is also above criticism.

Don't worry, `go generate` will allow you to fix this by building the world's most simple build system. Any .go file in your repo may bear a `//go:generate` on any line, and go will happily call out to your shell to perform whatever you've put there.

Simple!

sarehu
Apr 20, 2007

(call/cc call/cc)

Bozart posted:

Just curious, why isn't a map appropriate in this case?

The order of the slice elements mattered, one represented a waiting list, the other was similar.

Khorne
May 1, 2002
In case anyone runs into this issue, the 1.4.2 msi installer is broken. Use the archive to install instead.

Khorne fucked around with this message at 17:14 on Mar 11, 2015

Bozart
Oct 28, 2006

Give me the finger.

Khorne posted:

In case anyone runs into this issue, the 1.4.2 msi installer is broken. Use the archive to install instead.

I just used it yesterday, no problem.

Khorne
May 1, 2002

Bozart posted:

I just used it yesterday, no problem.
I downloaded it today and redownloaded it and kept getting bytes.[various things] errors on most standard library files when I attempted to build anything. Installing from the archive allowed everything to build/run fine.

Google turned up no one else having the issue.

edit: I just downloaded and installed it on my laptop and it was doing the same thing.

Khorne fucked around with this message at 17:41 on Mar 11, 2015

duck monster
Dec 15, 2004

Is it just me or do a lot of Go's libraries have utterly garbage documentation. Maybe I'm spoiled by python, but I'm coming across so many libraries that have at best a minimal API documentation and no context at all.

blorpy
Jan 5, 2005

duck monster posted:

Is it just me or do a lot of Go's libraries have utterly garbage documentation. Maybe I'm spoiled by python, but I'm coming across so many libraries that have at best a minimal API documentation and no context at all.

I think they're pretty good but assume some familiarity with C.

I wasted half an hour the other day trying to get the binary package's thing to pack my int into bytes, but it turns out its packing is set up for protobufs. D'oh!

sarehu
Apr 20, 2007

(call/cc call/cc)
I have a question for you Go people. Suppose you write a web application in Go. What do you do to get it running in actual production?

Right now I ran it with nohup and proxied it with nginx so that it'd run on port 80 after reading a tutorial. I hope it doesn't go down!

But like, seriously, what do you do? This is not really a Go-specific question, sorry that it's in the wrong place.

Ferg
May 6, 2007

Lipstick Apathy

sarehu posted:

I have a question for you Go people. Suppose you write a web application in Go. What do you do to get it running in actual production?

Right now I ran it with nohup and proxied it with nginx so that it'd run on port 80 after reading a tutorial. I hope it doesn't go down!

But like, seriously, what do you do? This is not really a Go-specific question, sorry that it's in the wrong place.

Just throw the binary on your server and run it. Nginx is an option if you need any benefits from a reverse proxy. It doesn't get much easier.

Urit
Oct 22, 2010

sarehu posted:

I have a question for you Go people. Suppose you write a web application in Go. What do you do to get it running in actual production?

Right now I ran it with nohup and proxied it with nginx so that it'd run on port 80 after reading a tutorial. I hope it doesn't go down!

But like, seriously, what do you do? This is not really a Go-specific question, sorry that it's in the wrong place.

Yeah, you don't even need nginx really if you want to give it access to lowports.

code:
setcap cap_net_bind_service=+ep /opt/magicalgoadventures/bin/magicalsite
That's the beauty of the whole thing, it's just an executable that runs. It's no different than a completely statically linked C executable. If you're using systemd an example unit file for your Go Web App looks like:

code:
[Unit]
Description=My Wonderful Web App
After=network.target

[Service]
User=nobody
Group=nobody
Type=simple

CapabilityBoundingSet=CAP_NET_BIND_SERVICE

ExecStart=/opt/magicalgoadventures/bin/magicalsite -config=/etc/magicalsite.toml
Restart=always

[Install]
WantedBy=multi-user.target
There's nothing special to do with it other than run it.

Urit fucked around with this message at 03:23 on Mar 15, 2015

good jovi
Dec 11, 2000

'm pro-dickgirl, and I VOTE!

sarehu posted:

I have a question for you Go people. Suppose you write a web application in Go. What do you do to get it running in actual production?

Right now I ran it with nohup and proxied it with nginx so that it'd run on port 80 after reading a tutorial. I hope it doesn't go down!

But like, seriously, what do you do? This is not really a Go-specific question, sorry that it's in the wrong place.

Running the Go process on a higher, unprivileged port and proxying is the way to do it. Look into something more powerful than nohup for running your code, though. I use daemontools at work and it's fine, but I think supervisor is a bit more reasonable to set up. You want something that will handle stdout/stderr redirection, restarting the process when it crashes, and reporting on process status.

duck monster
Dec 15, 2004

good jovi posted:

Running the Go process on a higher, unprivileged port and proxying is the way to do it. Look into something more powerful than nohup for running your code, though. I use daemontools at work and it's fine, but I think supervisor is a bit more reasonable to set up. You want something that will handle stdout/stderr redirection, restarting the process when it crashes, and reporting on process status.

Honcho (A python heroku like thing that does Procfiles and .env files) can export out to supervisord. Its really handy for turning 12 factor type apps into non retarded systemd apps.

Urit
Oct 22, 2010
Is there a consensus on the most viable embedded scripting language for Go? I'm writing something that I'd like to allow (friendly - as in written by internal users and stored on disk with the program) arbitrary code execution in. Lua seems to be vaguely incompatible with Go on Windows due to longjmps for error handling which causes straight up crashes, plus it's playing with CGo. Otto looks neat but it's Javascript which no one wants to write, and it's not really fast for string processing. I found a random project on Github called Agora but it hasn't been maintained for a year and it's somone's toy scripting language, though it looks pretty neat.

sarehu
Apr 20, 2007

(call/cc call/cc)
go fmt is changing a * b to a*b on me.

I'm getting really hatey right now.

Linear Zoetrope
Nov 28, 2011

A hero must cook

sarehu posted:

go fmt is changing a * b to a*b on me.

I'm getting really hatey right now.

It bundles operators by binding/precedence. It's to make expressions like a * b + c * d easier to read by grouping them as a*b + c*d. It's kind of dumb when it does it on standalone expressions though, yeah.

sarehu
Apr 20, 2007

(call/cc call/cc)
No it's dumb in general.

Karate Bastard
Jul 31, 2007

Soiled Meat
This is something I'd bikeshed the gently caress out of and I agree with you.

Coffee Mugshot
Jun 26, 2010

by Lowtax
It doesn't matter what gofmt does because it does it consistently and that's the point. There are some bugs but that's not one of them.

NickPlowswell
Sep 14, 2014

The exoplanet has failed :qq:

Urit posted:

Is there a consensus on the most viable embedded scripting language for Go? I'm writing something that I'd like to allow (friendly - as in written by internal users and stored on disk with the program) arbitrary code execution in. Lua seems to be vaguely incompatible with Go on Windows due to longjmps for error handling which causes straight up crashes, plus it's playing with CGo. Otto looks neat but it's Javascript which no one wants to write, and it's not really fast for string processing. I found a random project on Github called Agora but it hasn't been maintained for a year and it's somone's toy scripting language, though it looks pretty neat.

There's
go-lua Which is all native Go so no cgo BS
otto V8 JS all in native Go.

I've used both of them with great success. Pretty decent in terms of performance for what it is, as well.

Pretty much everything else is trash/a toy language that you shouldn't expect users to learn or uses cgo

e: If it matters, I prefer otto. It's much easier to interface with.

NickPlowswell fucked around with this message at 08:07 on Apr 16, 2015

Adbot
ADBOT LOVES YOU

Urit
Oct 22, 2010

NickPlowswell posted:

There's
go-lua Which is all native Go so no cgo BS
otto V8 JS all in native Go.

I've used both of them with great success. Pretty decent in terms of performance for what it is, as well.

Pretty much everything else is trash/a toy language that you shouldn't expect users to learn or uses cgo

e: If it matters, I prefer otto. It's much easier to interface with.

Awesome, thanks a ton. Those were the two I saw as well but I was seeing if there was something else out there that was better that I just didn't know about. CGo is cool and all but I'm running in a mixed Windows/Linux environment so the cross-compilation of Go is a huge plus for me, and having to hope that MinGW is going to work today and/or the C portion won't segfault is a pain in the rear end.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply