[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Golang thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 68
Thread images: 8

Redpill me on golang, /g/. Let's say I'm coming from Rails. Is it worth learning? Can it replace Ruby in general?
>>
>>57853479
A lot of people use Rails 'front end' and Go for the backend/systemy shit. For example the site memorycorruption.com is done this way.

Go is really good tool for specific things. Depends what you want to do, get the Kernighan book http://www.gopl.io/
>>
Go is one of the best programming languages out there. For every criticism of Go, there are ten more criticisms for the alternatives to Go.
>>
It's a meme
>>
>>57853669
Assume I've only ever used Rails and nothing else. What's the canonical way of building a basic website that just lets you add to and display stuff from a database?
>>
>>57853479
>Is it worth learning?
yes
>Can it replace Ruby in general?
yes

It'll take you a weekend to learn you a Go if you're coming from another language.

https://gobyexample.com
https://golang.org/doc/effective_go.html
>>
>>57854113
You've probably never even used it.

Go is the best language of this generation.
>>
>>57854121
the standard library has quite a bit of good stuff for basic websites. there are some very good third party libraries that are amazing for creating scalable web applications.

Go really is quite good.
>>
Go is great If you wanna replace ruby on rails
Its alright for making small automation scripts
Thats pretty much all of its use case
>>
>>57855237
/thread

>>57853479
Then again, once Crystal rises - if Crystal rises - it can't replace that one, because muh generics and macros and LLVM backend.
>>
What does it offer that Python or Java don't?
>>
>>57857103
Simplicity, speed, and easy concurrency.
>>
>>57857103
Both are achievable in Python or Java.
>>
>>57853479
Elixir is replacing Ruby

Go is retarded and dying
>>
>>57853479
>Can it replace Ruby in general?
Yes but don't expect being able to use magic libs that do 90% of your work like in Ruby.
>>
>>57857426
...but you can, with third party libraries.
>>
>>57857501
Yeah but they're not as "magic" as the Active Record's ORM for example.
>>
>>57853479
NO

GENERICS
>>
>>57857541
>muh generics
I bet you don't even know what this means.
>>
>>57857563
it means you will never be able to write a piece of reusable code in go.
>>
>>57857580
Spoken like someone who has never written anything in Go.
>>
>>57857580
Sounds like you don't know SHIT about programming.
>>
>>57857600
Spoken like someone who has never written anything of substantial size in their life.
>>
>>57857628
Spoken like someone who hasn't either.

Generics create needless complexity and take a fuckton of time either at runtime or compile time.
>>
>>57857647
t. someone who has never written anything of worth
>>
>>57858287
t. Someone who is grasping at straws.

Interfaces, reflection, and type assertions eliminate the need for generics. If you had half a fucking brain you'd know this.
>>
>>57858315
keep telling yourself that. Bad hacky implementations used for pseudo generics will never be the real thing and will never work like the real thing.
>>
>>57858336
>work like the real thing
Yeah, I enjoy the fact that I don't have to wait literal hours for my program to compile because someone though generics were a good idea. Keep living in the past, grandpa.
>>
>>57858344
Have you considered purchasing a computer built after 2006?
>>
>>57858397
>he thinks the solution to monumentally slow compile times is to just buy faster hardware.

buy all the fastest hardware you want, you'll still have horrendous compile times when dealing with generics*.


* in an actual production environment, which I'm sure you have no actual experience in, otherwise you'd know what I'm talking about.
>>
>>57858454
>i don't know how to use this feature or compile my programs properly
>ban generics

you the kinda nigga to create include loops.
>>
>>57858486
>well those straws aren't gonna grasp themselves!
>>
>>57857580
Generics allow you to do things like iterate through types that are considered "generic" arrays, even if that type isn't specified exactly within the functions. Generics can be unsafe and with a language like Go, you need lots of safety. Network programming requires lots of error checking and for code to be concise.
>>
>>57858336
Generics ARE hacky code generation you fucking retard. You're using generics as a crutch because you aren't a good coder.
>>
>>57858583
Look at Rust
>>
>>57853479
Woah back up, people are still using ruby?
>>
>>57858592
>"coder"
back to redd!t
>>
>>57858669
All that RoR shit written a few years ago aint gonna maintain itself.
>>
>>57853669
>Go is really good tool for specific things
Back-end.
>>
>>57859715
>>57853669

Is it advisable to write a web app using just the stdlib? I'm looking for something like Rails or even just Flask but I'm not sure what my options are in Go.
>>
>>57855119
Any suggestions on reading material?
>>
>>57853479
So I want to write a game server

would it be more fun to write it in C/C++ or Go?

>inb4 "you're posting in a Go thread"
>>
>>57860007
>>57859715
I thought GO was specifically good for micro services like API back ends
>>
>>57853479
The 'go' in golang stands for 'garbage-oriented'
>>
>>57860053
Do you want your server to lag and crash for no apparent reason every 5 seconds? If so, use go. Otherwise, go with literally anything else.
>>
>>57861161
>Go with literally anything else

That makes for a good slogan
>>
File: gophha.jpg (47KB, 599x483px) Image search: [Google]
gophha.jpg
47KB, 599x483px
Yes and yes.

>>57855237
Fucking stupid.

>>57857580
Reusable code is a meme. Write a fucking library.
>>
File: gobooks.jpg (152KB, 768x1024px) Image search: [Google]
gobooks.jpg
152KB, 768x1024px
>>57861161
What are you on about?

>>57860053
Go's networking package is beautiful, so you'll be fine.
>>
File: 1478417288777.jpg (51KB, 526x701px) Image search: [Google]
1478417288777.jpg
51KB, 526x701px
>garbage collection
>>
File: ken-besides-mig.gif (209KB, 640x426px) Image search: [Google]
ken-besides-mig.gif
209KB, 640x426px
>>57861277
>being a code ricer
>thinking you have better taste than the unix authors
>>
File: pike.jpg (19KB, 500x335px) Image search: [Google]
pike.jpg
19KB, 500x335px
>>57861310
enjoy your uncontrollable lag spikes
>>
Go > D > JavaScript > Rust > C > Python > Ruby > Perl > Lua > Bash > PHP > C++ > Java
>>
File: glendy.png (22KB, 641x678px) Image search: [Google]
glendy.png
22KB, 641x678px
>>57861337
actually go's gc has a time-bounded mark & sweep pause, and most mark & sweep pauses are less than a millisecond even for big heaps

you can use even use go in a real time system provided its pause constraint is within your own constraints
>>
golang? more like goylang.
>>
>>57861428
Hello rob pike. Come to rub someone's spike?
>>
>>57861443
The Go GC is optimized for latency, but not throughput. If you have hard constraints in both areas I don't think Go is the right tool for the job.
>>
>>57861568
Unfortunately, the rest of the language is so mindnumbingly retarded (taking all the bad parts of previous languages, with none of the good) that go is never the right tool, for any job.
>>
>>57861591
I don't think the design of the concurrency aspect was bad, as well as the choice to use OO with interfaces. That being said, there's obviously alot of pain points in the language which would not make me want to choose it for most potential uses.
>>
File: 1475529513481.jpg (43KB, 480x451px) Image search: [Google]
1475529513481.jpg
43KB, 480x451px
root@sv3 ~ $ cat hello.go
package main

import "fmt"

func main() {
fmt.Println("Hello World")
}
root@sv3 ~ $ go build hello.go
root@sv3 ~ $ ls -lh hello
-rwxr-xr-x 1 root root 1.5M Dec 6 00:07 hello


1.5 megs for a simple hello world...
>>
>>57861568
Solution: don't create garbage in your event loop or whatever. You wouldn't do it in C.
>>
>>57861657
Sure you can try to do stuff like memory pools and other optimizations to ensure that the GC performs exactly the way you want it to, but at that point are you really benefiting that much from it over just writing it in C/C++?
>>
>>57861617
>I don't think the design of the concurrency aspect was bad
That's really the best part of the language. That's the selling point of the language and also the reason that Rust initially looked very promising (but then Rust's designers fucked it all up).

>>57861591
>taking all the bad parts of previous languages, with none of the good
What are you even talking about? 0 examples.

>go is never the right tool, for any job.
Why, then, do I invariably reach for go when writing a new program? The one exception is writing GUIs, in which case I usually reach for Tcl/Tk or C with libiup.

>>57861623
It's unreasonable, yes. Pike's bug report of "binaries too large and still growing" is still active.
>>
>>57861693
>do stuff like memory pools and other optimizations
No, just use the compiler's escape analysis switch, which will tell you what code is incurring heap allocations. In most programs, heap allocations are rare, and you soon learn to identify patterns that incur heap allocations.

Don't do retarded things like returning pointers to objects that are local to functions, since that's a pattern which necessarily gets moved to heap.
>>
>>57860007
The stdlib is the "standard", but it's verbose.

Look at Gin. It is a lightweight framework for web servers.
It really lends to short code. There is middleware available for common needs like setting secure http headers, managing session cookie data, csrf protection, etc.

Writing your own authentication system is the norm.
>>
>>57861623
[anon@x220t /tmp] cat out.go                                                                                                                                                                                                ok
package main

import "fmt"

func main() {
fmt.Println("Hello World")
}% [anon@x220t /tmp] go build out.go ok
[anon@x220t /tmp] du -hs out ok
1.6M out
[anon@x220t /tmp] strip out ok
[anon@x220t /tmp] du -hs out ok
1000K out
[anon@x220t /tmp] ./out ok
Hello World
>>
>>57862122
Sadly strip breaks Go binaries on Windows. Go follows the PE standard more closely than Windows.
>>
>>57862167
so build with upx or dynamically linked with gccgo if filesize is such a concern, but I personally don't think it is. I work in c++, and would be happy to have go build speed in exchange for binary size
>>
>>57861623
it's statically linked.
Thread posts: 68
Thread images: 8


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.