484 points · by enneff · 13y ago · 290 comments
But OTOH it really "just works" out of the box.
But, that output / work product is -- and a huge part of Go's value is around the EDGES of a system (build, standard formatting, deploys, etc)
WRT generators: have you tried using channels? "The tour of Go" seems to instill you with the idea that you should not iterate over lists and use channels instead.
I also miss list comprehensions and, for that matter, type-parametrized functions.
OTOH, static duck typing is brilliant: best of both worlds.
[1]http://help.duckduckgo.com/customer/portal/articles/216392-a...
Sarcasm doesn't belong on HN.
There's a few, but I think it's still too early to really call out a "defacto" framework.
Revel, as mentioned, is a popular "full stack" framework, but it can be pretty heavy. web.go[1] gets a lot of use (it sits at a Flask/Sinatra level), and beego[5] looks good but it's also totally acceptable to plug a few libraries together without much work on top.
For example, I'm using:
- mux, sessions, schema & context from Gorilla[2]
- go.auth for social sign-in [3]
- the RethinkDB driver [4]
... and that's about it. Write your routes with mux, set up your handlers with auth/sessions/schema, and generate your models & queries with whatever DB you want. The standard html/template library is good enough (and there's a Mustache library if you need it), and the standard http library covers everything in between.
TL;DR: If you enjoy writing Flask/Sinatra apps, you'll enjoy writing Go web apps. If you're coming from a full-stack framework (like me), there is definitely a learning curve, but I feel that Go's documentation and std. lib flatten that out a little.
[1]: https://github.com/hoisie/web
[2]: http://www.gorillatoolkit.org/
[3]: https://github.com/bradrydzewski/go.auth
That being said, right now the dominate Go web library is "net/http" from the Go standard library, supplemented by Gorilla (as needed): http://www.gorillatoolkit.org/
If what you are looking for is really a Go web framework however, there are a few in development including Revel: http://robfig.github.io/revel/
And for those who missed my attempt at humor: http://slashdot.org/story/01/10/23/1816257/apple-releases-ip...
You, sir, are a risk taker. Kudos.
That said, it's fun to read the old thread. I like this comment from dbrutus:
Do you want revolutionary? Ask yourself, what chip is this running? Ask yourself, what is the OS on this thing? This is v0.8 of Apple's PDA folks. They're just waiting for the hardware and the economy to get a little better.
I assume he is jokingly suggesting that the detractors are wrong.
Yes, I believe the detractors are wrong. And I believe they are especially wrong about generics. One of CloudFlare's most hard core C++/Boost guys 'tried out' Go to see how he liked it and is rewriting everything that needed redoing in Go.
The combination of a 'small, powerful' language that supports multicore machines and the good standard library means people can _get things done_.
Chet: "Get out the drool cup!" Erik: "In use, my friend! Drooool!" Chet: "Then break out the scraper, because someone's gonna have to scrape my jaw off the floor!" Erik: "That's also in use, to scrape my spooge off the monitor! Spoooge!" Chet: "Ouch! Fetch me my eye medicine, because I have an eyeache from watching a whole mixed bag of eye candy!" Erik: "All of the eye medicine's already in my eye! I'm done with the scraper, though."
[1] - http://benchmarksgame.alioth.debian.org/u64q/benchmark.php?t...
* - To the extent that you may find micro-benchmarks a useful measuring stick.
var service map[string]net.Addr
When I read this it's easy to skip seeing string, aside from the fact that ] as a delimiter also looks like net.Addr was accidentally combined with the previous line. func ParallelWrite(data []byte) chan error {
res := make(chan error, 2)
f1, err := os.Create("file1")
if err != nil {
res <- err
} else {
Here we see no parenthesizes used in if statements, yet we retain {. In skimming it's easy to miss the if in the first place. Yet everywhere else they're happy to use parenthesizes. We also see that "make" is lowercase yet a method, but os.Create and ParallelWrite has caps for a method.There's also the fact that the array (I'm guessing) of bytes diverges from every other language to put them in front of the type which looks like crap. We see the same poor choices of delimiters as with map value types.
Then there's this
func main() {
c := make(chan bool)
m := make(map[string]string)
go func() {
m["1"] = "a" // First conflicting access.
c <- true
}()
m["2"] = "b" // Second conflicting access.
<-c
for k, v := range m {
fmt.Println(k, v)
}
}
<-c looks like its just dangling, and if this is meant to say there's some kind of stream or assignment then does it just go to /dev/null? Yet "c <- true" is also correct? I'd argue for either void <- c, _ <- c, or c.read() if wanted to support something like that.It's also difficult to tell in the for loop if v is being assigned as "range m", or if "k, v" are a tuple resulting from "range m"
It's too bad because the goals of the language are quite nice from a CS perspective.
As any Go programmer will tell you, Go is a very readable language. It's one of the design goals. It is _not_ a design goal to impress people making superficial judgements.
Also, LOL: https://news.ycombinator.com/item?id=5327478
Yes I did just post that. Should I wait until there's an article on coding aesthetics first? I'm a seasoned programmer with experience in many languages. Reading a new language should make me want to use it because it's an improvement in many ways, particularly around expressivity and clarity. IMHO Go isn't as good as it could be. I wasn't saying Go as a whole is bad or not worthwhile.
Like I said, Go isn't designed to impress superficially. It's a pragmatic language for getting work done.
In Go's case, I tried to give it the benefit of the doubt, and went through a couple of tutorials, but while there were some nice parts of it that just reinforced my initial impression.
I feel that braces on blocks are more important to readability/clarity—because blocks should be identifiable—compared to parentheses for if statements. I don't think the if gets lost in there, but if you do then that's fine.
> We also see that "make" is lowercase yet a method, but os.Create and ParallelWrite has caps for a method.
That's because "make" is a built-in function for building slices and maps.
Packages with exportable functions (i.e. os.Create, http.HandleFunc, etc, etc) use capitalisation to denote "public" functions[1]. Functions within the os or http packages (for example) that should not be used directly by someone using the library retain a lowerCase approach. This reduces the risk and confusion surrounding which functions you should be working with when using a library.
> It's also difficult to tell in the for loop if v is being assigned as "range m", or if "k, v" are a tuple resulting from "range m"
Each key:value pair in m (a map, or "dictionary") is being assigned—hence the :=, which declares & assigns k & v in one line—for the entire range ('length', really).
Obviously you don't agree with some of the syntax in Go. That's fine. But some of your criticisms appear to stem from a misunderstanding or lack of knowledge about some language-agnostic concepts (channels, range, exportable functions) that I don't think Go obscures.
Was uninformed about caps. That was a minor point for me, however, and in hindsight I should have at least investigated that before saying something.
Ok I see the consistency in :=, but in that sense I'd personally like to see something closer to Scala where the tuple is explicit by doing something like:
for (k, v) := range m {
Which doesn't look all that much better, mostly because of the := (I've never liked in any lang) and the spacing between range, m, and {. for (k, v) := range(m) {
Could be yet another way to help make it more clear what is modifying what.When you're tired and have been starting at code all day long having more visual gestalt in the language helps... syntax highlighting serves much of this but it's better IMHO if the language highlights itself.
He pointed out that utilizing a language through a DSL or FFI that utilizes indentation instead of another method makes utilizing that language inside another language more difficult as it is easy to introduce bugs in the host language that are non-obvious to debug based on the indentation being incorrect but not obviously so.
I recommend watching all of his videos as they are very illuminating due to his primary focus being that of software engineering rather than theory.
Every other language except:
- Actionscript, TypeScript, Haxe
var x:int = 10;
- ML, OCaml, Haskell and derivatives val x : int = 10;
- Pascal and derivatives Var x : Integer;
- Ada and derivatives x : integer := 10;
- Old-school MASM Assembly syntax DSEG segment
x word
- SQL CREATE TABLE tbl { x INT }
- Basic Dim x as Integer
- XML DTDs even <!ELEMENT x (#PCDATA)>I meant the [], not just generally the type.
go: data []byte most (all?) other languages that use [] in arrays: data byte[]
Nevertheless, it's similar to Algol's bracket syntax, except in Algol the type comes before the variable:
[]INT numbers = (0, 1, 2);It does look weird at first—I thought the same thing. But after writing some code with it, the design has a nice simplicity. When decoding C types, you have to sort of go back and forth "int * x[]" (an array of pointers to int) but in go it's always one direction: "int * []x". The type is always grouped together and that ends up being much easier for humans to parse.
Ditto for putting the return type after the function args. Seems backward if you're used to C/Java/etc but it makes things nicely composable, plus now every function starts with "func", and not a random return type.
I'm fine with the losing the parens around the ifs. Other languages do that and less syntax can look less messy. I do, however, HATE the required curlies. And the fact that stupid go-fmt always wants to format them out differently than I do:
if short_check { short_code() } // My preferred formatting for short error tests
if short_check { // go-fmt always wants to do this.
short_code()
} // Blech.
For that reason alone I refuse to use go-fmt on my code :-). But I'm stubborn that way...Google code style guidelines are anti-one liner, so that's not surprising to me that Go's formatter tries to enforce that.
I also employ one-liners but judiciously. It can be easy to miss the condition or side effect, particularly with returns. I waffle on whether it should or shouldn't be allowed. But there's something to code compactness on large projects...
Nooooo! :-p
I used to prefer short one-liners like that (well, still do in ruby), but in Go I'm starting to kind of enjoy the blindingly obvious, verbose way of doing it. It makes me feel like Mr. Rogers[1][2]. Sure it's plodding, but it's exceedingly clear and easy to understand.
[1] http://www.youtube.com/watch?v=yXEuEUQIP3Q [2] http://www.youtube.com/watch?v=Upm9LnuCBUM
def parallelWrite(data: Array[Byte])
No pointers to worry about, generics, etc ...> It's also difficult to tell in the for loop if v is being assigned as "range m", or if "k, v" are a tuple resulting from "range m"
The `range` clause returns two values: index, and value at that index. It's really pretty easy to read and get used to once you actually read some documents.
clearly c is some kind of "chan"nel-based synchronisation object for which <- is both the read & write operator (presumably blocking); the "go func" declaration is building a closure that is immediately invoked which, given this appears to be a parallelism demo, probably happens in a separate thread (green or OS unstated). m appears to be a map of string to string, so the assignment to k,v is almost certainly a tuple returned from iterator "range m" because that's just how things go in documentation-level examples.
I know nobody likes a smart-ass but it's a good example and even if some of the above is wrong, I got a taste of Go from it that I rather like. So thanks.
How much do I need to know about pointers to use and learn Go? Is Go garbage collected in the C#/Ruby sense?
I recently switched from full ORM usage to hand tuned SQL queries and loved watching the speed of my application increase 10-fold. I'm having a bit of a speed high and Go seems like the perfect language for this.
What book should I buy to learn Go from the ground up?
Edit:This seems like the perfect place to start.
Do yourself a favor, and learn the basics of pointers (might as well just read up on C), then move on to Go.
Before you go down the route of buying a paper book, try the interactive tutorial on the golang web site. It's pretty good. There's also a lot of good, and free, reading material on that site to help you learn.
Also, regarding pointers: They're really not that bad, but I understand a lot of people can have trouble with them.
Just realize that in languages like Ruby, and Python, you're never directly working with the computer's memory (as in RAM) - that is abstracted from you.
However, in a language like C, you are. (As an aside, you still aren't directly dealing with it, the operating system abstracts it from your program via the virtual memory system, but you can ignore that for now, and look it up some time when you see fit.) So the first thing you need to make sure is that you understand the difference between stack storage, and heap storage.
Once you understand the heap, and that it is essentially a large block of memory with sequential addresses, you can begin to understand pointers. They are just variables that contain the address of some other variable stored in memory. Languages that support pointers usually give you some syntactic sugar to make working with the "pointed to" object through the pointer easy.
Of course it can all get more complicated, but in summary, give them a shot...you'll gain a much better understanding of many things once you learn them a bit.
Very little. Just what pass by value and pass by reference mean in the context of pointers.
The very basic you need to know is: if a function argument is defined as (*foo), you are changing the item you pass to the function (like in Javascript or Java), whereas if it's defined as (foo), you're changing a copy of it and the original item remains unaffected.
Go has pointers, but no pointer arithmetic (in the base language), and it also has GC, so most of the problems people have with pointers in C are not there.
A quick example: the standard library `flag` package lets you parse command line arguments, and returns either pointers or values. You need to know which is which. It's easy, for example, to do this:
var filename = flag.String("file", "default.txt", "file to open")
fmt.Println("Using file ", filename)
The above code looks ok at first glance, but prints the address of filename rather than its value. It can be fixed by using `flag.StringVal` instead of `flag.String`, or dereferencing `filename` using `* filename` in the Println.So I would say you need to know way less about pointers than C but you still need to know the difference.
=============================
So it's like PHP where I need to pass in `function modify(&$foo) {` to modify a variable passed by reference.
If you're thinking in terms of PHP's primitive types, then yes: that's probably the best equivalent. PHP has the whole objects always being "passed by reference" [0] thing going on too.
JavaScript, however, is call-by-value. Primitive types (string, number, boolean) are passed to functions by copying their value, and reference types (such as any object you create) are passed by copying the value of their reference.
The reference semantics can be observed in JavaScript in some cases, such as:
var i = 0;
for (i = 0; i < 10; i++) {
setTimeout(function() {
document.write("i is now " + i);
}, 10);
}
Here the inner function gets reference of the variable i instead of its value.However, if you pass an object or an array, the called function can change a field in the object or an element in the array (the difference between those two is an optimization), and the change will be visible to the caller.
Go, however, lets you pass in an explicit pointer to an int, through which the function can change the int to which the caller pointed. Of ourse, the caller can also change the passed-in pointer if it wants, but that has no effect on the caller's variable.
Then I went through those. https://news.ycombinator.com/item?id=5365401
Do you understand how they work in C? Maybe try reading a little about that. For Go, I'd recommend starting here: http://tour.golang.org/#1 (Don't miss the next arrow in the lower right-)
After running through that you should have an idea of what you don't know- which makes asking questions people can provide useful answers to much easier. :)
>>Is Go garbage collected in the C#/Ruby sense?
I'm not sure what your sense of C#/Ruby GC is, but I'd go with yes.
As for learning pointers -- I've never been able to get entirely comfortable with pointers in C -- the syntax just feels unnatural to me. I much prefer either assembler (intel syntax) -- or Pascal, eg:
http://www.tutorialspoint.com/pascal/pascal_pointers.htm
Go syntax is closer to C, though. So knowing C, Go might be easier (than not knowing C) -- but it isn't a prerequisite.
And congrats!
EDIT: Yes I know what the faq says [1]. I was wondering if someone working on that can shed light on how the development of a satisfactory proposal has been going. Also, what's exactly wrong with template instantion like in C++ from the perspective of Go devs?
The Go authors have repeatedly stated that they will not be implementing generics.
They don't seem to miss them, I don't miss them, and indeed most people who write much Go don't seem to miss them. The people who continually whine about generics seem to be the type who say, "Oh boy, I'd sure LOVE to write a bunch of kickass code in Go, but I just couldn't do ANYTHING without generics! Why don't you put them in, then I'll try the tutorial"
It's not something we feel the need to work around, we just sit down and write concise programs that do the job, in fewer lines than C++.
Edit: as others have mentioned, it seems the authors would be willing to put them in if they find a way to do it without crapping up the language. If they do, I'll try writing Go code with generics, but they have a bad taste for me after dealing with code containing GenericType.cpp, GenericType.hpp, AbstractType.cpp, AbstractType.hpp, AbstractGenericType.cpp, and AbstractGenericType.hpp all in one place.
No, they have repeatedly made ho-hum excuses about how they can't think of any proper way of implementing them, and that they will do them if they find a "clean way".
>They don't seem to miss them, I don't miss them, and indeed most people who write much Go don't seem to miss them. The people who continually whine about generics seem to be the type who say, "Oh boy, I'd sure LOVE to write a bunch of kickass code in Go, but I just couldn't do ANYTHING without generics!"
Well, isn't this dismissal of them a kind of "confirmation bias"?
Sure, they people who don't care about generics can churn out tons of code without them. Like people have been churning out tons of code in C or pre-generics Java anyway. And, sure, they might not even miss them.
Plus, some of the core Go members have been using languages without generic for decades and even created some. So, being used to working like that, it makes sense for them not to miss them.
That doesn't mean the people who DO want them are wrong in wanting them in -- or that because guys writing C for several decades doesn't find a need for generics in Go, means that there really isn't one.
That's not true. We just don't have a way of doing them that works well in the language. http://golang.org/doc/faq#generics
The JVM engineers have been free to do whatever they want in terms of optimizations at runtime, like code inlining or escape analysis. They may even add trace compilation or whatever they feel like it's necessary. The JVM's GC is precise and generational. The CMS garbage collection rarely blocks the whole process and you've got options for GCs that are totally non-blocking. In fact, the JVM's GC is so efficient that allocating and deallocating short-lived objects is almost as efficient as doing that on the stack.
Russ Cox speaks about the boxing that Java does, but Java makes boxing almost a non-issue. Personally I've learned to appreciate the JVM and what it can do in the context of servers receiving tens of thousands of requests per second.
And here in lies the problem - Go is too low level to achieve the same level of optimizations that Java is able of. But on the other hand it's totally dependent on a per-process GC and personally I don't think we'll ever see a precise, generational GC for it precisely because Go is too low level. The Rust engineers at the very least redefined the problem by making individual threads in a process have their own heap and their own garbage collector.
Go on the other hand feels like a hack on multiple accounts. And to me it's not a beautiful hack either, plus once a language achieves inertia, you cannot change its fundamentals without redefining the language to be something else entirely. If Go will indeed get popular, it will join a long line of languages that people hate, because they have to maintain code-bases written in it, with no easy way out.
Its authors say they don't want Go to be like C++. In many ways, it already is.
If it's a feature needed for the standard library, then it's safe to say the devs will need it to. The devs aren't (shouldn't) be consistently writing programs that are more trivial than the standard library.
I could easily write a custom Append func in my own application because I would know the Slice types I'm trying to operate on. Writing a language feature is different than writing an application, and it has nothing to do with how trivial something is.
Honestly, Append() as a concept is about as trivial as it gets..
Not so http://golang.org/doc/faq#generics; "This remains an open issue." In the discussions I have read, if an implementation of generics is proposed that doesn't sacrifice performance and it truly generic, they are open to it.
What I have seen said is that implementing generics was not on the table for 1.1 or maybe even 1.x
Sounds like weasel speak for "take a hike and leave us alone".
The Go team is open to generics as soon as there is a proposal they feel fits right without performance penalties. Read: http://golang.org/doc/faq#generics
>>Does the community care about that?
Yes, but most people in the Go community are OK waiting for the "right" solution.
>>How have people been working around that?
Generics are nice and convenient, but you can write anything/everything without generics. Just look at everything written in C. And C doesn't have interfaces like Go.
Because using interface{} for the same tasks fits so much better and has so much better performance right?
Tons of languages have implemented Generics -- it's not rocket science since at least 2 decades.
If the Go team is not interesting in working on the thing, then I doubt they would be really evaluating any "proposal".
>>tons of languages have implemented Generics -- it's not rocket science since at least 2 decades.
Sure, but that doesn't mean there are not concerns about the way it is often implemented: http://research.swtch.com/generic
C compilers are fast, but they aren't that fast. Go compiles so fast that it changes the way you write and organize code; you would never consider compilation overhead in any decision you made in a Go source tree, where you might do that in a C codebase. For instance, Go programmers routinely compile code, run it, and throw away the compiled binary! You wouldn't think it would be possible for compiler speed to be so much better than C that it would make a difference, but Go's compiler manages it.
I would think that, even before I had used Go. Ignoring the smaller scanning benefits of Go that come about from the more rigid syntax for braces and such, the C preprocessor system introduces a complete nightmare when it comes to requiring multiple passes over the same code, especially for code that is naive about include guards, pre-compiled headers and other "best practices".
C (and C++ is even worse) has a lot of very large low hanging fruit to cull when it comes to writing languages with faster compilers. Whatever speed C compilers have now is due to the geniuses who wrote the compilers and decades of shoulders to stand on, the language is actively working against them at nearly every turn when it comes to compilation speed.
That aside, I agree. Go compiles very, very fast. So fast that it never occurred to me that "go get" did a compilation until it was pointed out to me that it did.
Sure, there are compilers that do a poor job at optimizing it, and it's very easy to make it slow on memory starved systems, but on a system with enough RAM to keep your headers in memory, and a compiler that doesn't totally disregard compilation speed, the overhead of skipping over blocks of include files using include guards is low and for code that doesn't, a compiler that can process multiple source files at the time can trivially cache large chunks of parsed headers.
As I've pointed out elsewhere, Bellard demonstrated TCCBOOT that used TCC to boot-time compile the Linux kernel in 15 seconds on a P4 - it's sufficient to demonstrate that it's difficulty in pre-processing or parsing C quickly that is the block for fast C compilation, but that to the extent it is even a real problem it is architectural decisions in the major C compilers and/or optimisation.
It's quite possible Go can be compiled faster, but so far I've not seen any compelling evidence that it is even roundly beating readily available C compilers. Certainly the numbers bandied around in this thread are not impressive.
I look forward to seeing the speed boost that C and C++ get if/when modules are available: http://llvm.org/devmtg/2012-11/Gregor-Modules.pdf
Okay, Go is fast, but it's not that fast. My 1000 LoC program takes ~1 second to compile. While it's certainly fast enough for me, it's not imperceptible.
A nicer, more accessible (python/ruby/etc folks seem to like it a lot), faster compiling reasonable alternative to C is a worthy goal - I really don't get why some people get into flamewars over it.
C compilers that are written to be fast rather than flexible can be extremely fast. E.g. see Fabrice Bellards "TCCBOOT", that he demonstrated compiling the Linux kernel at boot-time in 15 seconds on a 2.4GHz Pentium 4: http://bellard.org/tcc/tccboot_readme.html
TCC can also be treated much like an interpreter like your go example.
It all boils down to having the parse each include file every time it appears, because the preprocessor might change the meaning of the file in each inclusion.
I assume you are aware, but tcc can be treated exactly like an interpreter:
#!/usr/bin/tcc -run -lgmp
#include<stdlib.h>
#include "gmp.h"
/* all this in eg. fac.c */
void factorial(mpz_t r, int n)
{
unsigned int i;
mpz_t tmp;
mpz_init(tmp);
mpz_set_ui(r,1);
for (i=1;i<=n;i++)
{
mpz_set_ui(tmp,i);
mpz_mul(r,r,tmp);
}
mpz_clear(tmp);
}
int main(int argc, char** argv)
{
mpz_t r;
mpz_init(r);
int n;
if (argc == 2)
{
n = atoi(argv[1]);
factorial(r, n);
gmp_printf("%d!:%Zd\n", n, r);
mpz_clear(r);
} else {
exit(1);
}
exit(0);
}
chmod a+x fac.c
time ./fac.c 1000
1000!:4023872(... snip for formating ...)000
real 0m0.007s
user 0m0.004s
sys 0m0.000s
edit: removed actual factorial, as hn formating choked on the long line.edit #2: indentation/block formatting of code. edit #3: missing "time" prefix...
I did some ocaml work a few years ago and had a similar revelation. Its compiler is just as fast—my short little programs were more or less instantaneously compiled. Fast compiling is really, really nice, even though it seems like a silly thing to tout.
% make clean
% time make make-listener make-sender make-diag make-ssl...
3.42s user
1.05s system
105% cpu
4.240 total
% find src/ -name '*.go' | xargs wc -l | tail -1
17870 total
And that's building everything sequentially. If I switch to using -j4 I get a 2s build from clean. % make clean
% time make -j4 make-listener make-sender make-diag make-ssl...
5.75s user
1.99s system
382% cpu
2.020 total
An incremental build (no op) of the entire tree is one second: % time make -j4 make-listener make-sender make-diag make-ssl...
1.56s user
0.73s system
209% cpu
1.090 total
Yes, we wrap the go build tools with make. Not because they are lacking anything for Go but because we do other stuff (like build documentation and release packages).(I should have not counted the tests in the above analysis. There are 7,290 lines of tests and 10,580 lines of code).
My home server is an AMD FX-4100 (quad core, 3GHz; this is one of the early Bulldozer CPU's and definitively not a speed daemon - I picked up the CPU and motherboard for <$150 a year or two ago).
I just tested a 6k C program that compiled in 1s flat with gcc 4.7.2, or .44 seconds with -j4, and a 13k lines one that completed in 2 seconds, or .88 with -j4.
Gcc isn't exactly renowned for being a fast c compiler.
A "no op" build of the 13k project takes .004 seconds, though, perhaps that's the reason - if your make setup is horrendously complicated perhaps it's slowing your numbers down a lot. And it's certainly possible to make C compilation incredibly slow if you do lots of nasty pre-processor hacks.
But then again whether 6k, 13k or 18k lines, both your project and mine are tiny.
i.e. instead of issuing "go build foo/mylib" and "go build bar/myotherlib" in parallel, just issuing "go build foo/mylib bar/myotherlib".
I say this because I remember there being logic inside the go command to parallelize builds already, see the "-p" flag in "go help build". In particular, the go command will be able to avoid statting all the files, comparing mod times twice, recomputing the DAG, etc. Although, considering how fast it runs anyway, this speedup might be negligible...
> Yes, we wrap the go build tools with make.
Do you wrap `go build` or do you wrap the 6g/6l tools directly? : time go build -a
real 0m3.980s
user 0m5.012s
sys 0m1.140s
But that is unrealistic, in dev we skip the -a flag: : time go build
real 0m1.854s
user 0m1.760s
sys 0m0.332sedit: s/tpl/tpu/
btw, the tp linker - http://turbopascal.org/linking-modules-and-creating-exe-file
http://prog21.dadgum.com/47.html
edit: in fact a number of the things that Rob Pike has brought up in talks reminded me of that article
(For those that don't know, this website was created for a talk about Go given by Andrew Gerrand. Code: https://github.com/nf/go11 , slides: http://talks.godoc.org/github.com/nf/go11/talk.slide#17)
http://www.youtube.com/watch?feature=player_detailpage&v...
I guess the question then is "do you trust those guys?" So far the answer seems to be yes.
I'm surprised by the speed of the dev team. It seems that just a few days ago that we saw the latest RC and just a few days before then was the previous RC. Fast development!
Using GDB seems akin to working with assembly
http://geekmonkey.org/articles/20-comparison-of-ides-for-goo...
I'm the author of one of them (Zeus) and while the results are not as slick as the Visual Studio debugger it's a better than straight out GDB.
I wanna give Go a start but can't see any community website that lists Go libraries like NPM.
EDIT: I'm not asking for "npm install person/project", I'm asking for a community website and a file like package.json that records information about a project.
As I observe, Go projects are really messy. I saw some code importing dependencies like "import github.com/foo/bar".
I think Go should focus on declarative programming and its aesthetics culture.
That's not messy; that's idiomatic Go. By convention, package imports can be URLs to version control repositories, which the `go` tool uses to determine dependencies and install them automatically.
Go has no equivalent `package.json` file. All package information is inferred from the source code.
The closest thing to a central repository is on the Go wiki. [1] Many people also use godoc.org [2], which is searchable.
[1] - https://code.google.com/p/go-wiki/wiki/Projects
[2] - http://godoc.org/-/index
The two aren’t mutually exclusive. If that URL goes down, is there a fallback mechanism?
For what it’s worth, I agree with oakaz’s sentiment that Go is “very imperative” and “not simple”. It is deliberately designed that way, with lots of syntax and types for representing (abstractly) the inherent complexities of its intended domain. Any ugliness, however, is purely subjective.
The OP (of this thread) said, 'I saw some code importing dependencies like "import github.com/foo/bar."' I did not understand this as a criticism of the design choice of using URLs as imports, but rather, a statement about some Go projects doing something horrendously wrong.
Yes, one can think URLs as imports is both messy and idiomatic, but I do not feel that was central point of the OP. I suspect we will never get a clarification, though.
> If that URL goes down, is there a fallback mechanism?
I don't know what you mean. If the package is no longer available at the URL then it cannot be downloaded from that URL.
> For what it’s worth, I agree with oakaz’s sentiment that Go is “very imperative” and “not simple”. It is deliberately designed that way, with lots of syntax and types for representing (abstractly) the inherent complexities of its intended domain.
Go was not deliberately designed to be "not simple." In fact, it was deliberately designed to be simple. Simplicity's name is invoked again and again as a justification for including or not including changes to the language.
Haha.
Everybody understands Go has a tool that deals with dependencies for you. And any other language can have it.
And this is why I avoid monopolistic platforms even though they are fast. If the owner of your platform has no taste of aesthetics, you'll write fast and ugly looking code. which is not fun for me.
As PG says in his book, a good solution should also look good and simple.
Go is very imperative, ugly looking, and not simple.
This link is actually a self-answer by you.
I disagree.
>Go is very imperative and ugly looking, and not simple.
Further, this is just stupid:
>And this is why I avoid monopolistic platforms even though they are fast.
If you don't want to use `go`, so be it. The manual compiler and linker tools are available that you can cobble together with make or ant or whatever masochistic tool you prefer.
>This link is actually a self-answer by you.
What are you whining about? What do you want? That's just a laundry list of known/seen Go packages. As everyone else has already told you, there's no need for a package.json and this literally isn't a problem for anyone actually writing Go code.
These are by no means all the 3rd party stuff out there, but it's a good starting point.
Incidentally, this website is intended to automatically generate and serve the documentation for all those projects in a centralized place. You don't even have to submit your projects. Just type the import path in the search box, and the site fetches the code by itself.
Edit: And here's anther community-built site to do continuous integration testing for your projects. It too, has an index of registered projects: http://goci.me/
I think Go needs to focus on improving its community and its aesthetic culture.
You seem more eager to make grand proclamations than to gain understanding.
I'm pretty sure that page is auto generated by GoDoc, an automatic documentation tool that generates documentation on the fly.
For auto generated documentation I'd say it looks pretty darn good!
You must read different mailing lists, G+ groups and IRC channels than I do...
>>and its aesthetic culture.
ROFL, what? How do you feel about the "aesthetic culture" of C programmers? Because you know- thats not a very popular language or anything...
$ go get github.com/person/project
It will even figure out dependencies by checking every import (and you can do 'import "github.com/person/project"' too), and builds the source by default.And yes, "go get" comes with the standard gotools.
Edit: WTF? why this comment is down-voted now?
Nothing that I'm aware yet. It's mostly community-based discovery and recommendations, but a centralized repository would sure be nice.
http://golang.org/cmd/go/#hdr-Download_and_install_packages_...
The Go developers are aware of this limitation, and their typical recommendation on the mailing list is that you should never need to use anything other than the latest version of any third-party library, e.g.: https://groups.google.com/d/topic/golang-nuts/3gEseiCwdf0/di...
> The Go developers are aware of this limitation, and their typical recommendation on the mailing list is that you should never need to use anything other than the latest version of any third-party library
It's either that, or you pin the version you want in your own fork of the package. Which is not an unreasonable solution to the bitrot problem.
Regardless, this limitation doesn't stop the `go` tool from being awesome. It's easily one of the reasons why I use Go in the first place.
Along those lines, did you know that Maven2 (and possibly in Maven 3) it's possible to have dependencies that are pulled into your bundle that are at a lower version that specified in a top level pom? Yup, versioning is really hard.
No. You can compile for ARM + a platform (i.e. Linux, BSD) if you want to run Go code on an ARM device. Think RaspberryPi or Beaglebone running an ARM port of Ubuntu/Arch.
Writing Go code targeting iOS (or Android) is a whole 'nother ballgame.
Minux did an iOS port, it's not part of the official tree because an iOS port required a rooted device. Perhaps this might have changed as with two word funcs, the Go runtime doesn't do runtime code generation.
https://plus.google.com/115863474911002159675/posts/DWmyygSr...
I remember reading that Go was ported to darwin/arm, but it can never be supported since there is no way to legally run their test suite for it.
Maybe one day it'll come. If on that day iOS has gained a public XPC API I'll be quite the happy camper.
It would be interesting to compare number of downloads for Python/Ruby.
How practical is it to use such a language for large code bases?
But this is 2013, there are somethings that expected to come from a language default. Exceptions are one of them, few such things I can think of are things like regular expressions, closures etc.
It's really a hard design problem. I agree that some form of error handling should be a language default, but I'm not sure if "traditional" exceptions should be it. As a C++ dev who has worked on projects with and without exceptions, I can say there is pros and cons to both.
But this is 2013, there are somethings that expected to
come from a language default.
Very true! Exceptions are one of them,
Very false! :) Exceptions have a lot of detractors.I'm finding the multiplayer aspects of my current game to be an excellent fit for Go, making good use of concurrency and networking.