Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

As someone who is 38, and has programmed in everything from 6510/68k/MIPS/ARM assembler to C/C++ to ActionScript/haxe/JavaScript to D to Python, et al, I also think Go is pretty great.

In addition to the cool things in the language, I really love what they are doing with the build system. The Go programming I've been doing has been on Windows but targeting an ARM CPU (the PXA168 in the Chumby 8 device) and cross-compiling Go code requires simply setting a couple of environmental variables. Sooo much nicer than having to set up a full-on GNU-style cross-compiling setup and using different toolchains for all your different targets.

eg:

set GOOS=windows

set GOARCH=386

go build

Just built my project for Windows x86.

---

set GOOS=windows

set GOARCH=amd64

go build

Just built my project for Windows x64

---

set GOOS=linux

set GOARCH=ARM

set GOARM=5

go build

Just built my project for the Chumby device.

---

I highly recommend checking Go out and looking past any of the superficial allergies you have to it (I'm historically a braces-on-their-own-line guy, so getting used to the strict enforcement of the other style was a pain for me) and giving it at least a few weeks to sink in. If it still isn't your cup of tea after that, then that's fine, but it is well worth a look, IMO.



Windows port details? I start at golang.org, link to http://golang.org/doc/install.html. Says "A port to Microsoft Windows is in progress but incomplete." That in turn links to the world's least helpful wiki page: Page "WindowsPort" Not Found.

Where do I find out more about the Windows port?


Go 1 is about to be released. See the install docs for Go 1 at http://weekly.golang.org/doc/install - these include windows instructions.


Thanks. If I was somehow supposed to know about the weekly site, I failed.


Nope, there's no way you could have known.

We've been working on Go 1 for about six months now, but have resisted pushing people toward the weekly (unstable) snapshots until the most recent one, as the documentation story was incomplete and we didn't want to leave newbies out in the cold. We're nearly ready on all fronts now, and hope to pull the pin on Go 1 before the end of the month.


As a coder who use mainly weekly (and now use godoc locally each time I need the package documentation), I still find it strange not to have links between release, weekly and tip on top of the documentation pages. Coders have to keep in mind the three links. I see a lot of questions on sites like stackoverflow that would probably not have been asked if the different documentations (and their existence) had been more visible.

And I suppose this small problem won't stop with Go1 as I hope we'll see new progress in weekly as we're used to.


You won't see progress with weekly as you're use to that's the point of Go 1. We are hoping to spend some time actually using Go, rather than building it.


Nice. How is the arm compiler holding up? I wrote the original 5g and ken did a large bug fix and optimizer sweep at some point so I'm interested in hearing how it has been going?


I haven't been inspecting the code of the arm compiler itself, but it has yet to fail me on my project, so kudos for the original implementation.

Having previously worked for chumby industries (makers of those bean bag alarm clock internet device thigies) I've got a nice collection of ARMv5 class devices laying around waiting to become useful and it is nice to have a modern language that is relatively low level support development on them. Quite a few other projects out there with arm support only care about v7+.


I'm historically a braces-on-their-own-line guy, so getting used to the strict enforcement of the other style was a pain for me

Wait, what?


    void func()
    {
    }
vs.

    void func() {
    }
Does Go really enforce the latter? That would be incredibly silly.


It does, but for a good reason. Its so the parser can find the line endings without needing complicated rules and look-ahead.

Go style is enforced mechanically with gofmt (http://weekly.golang.org/cmd/gofmt/), anyway, so one typically drops the pretension of these kinds of style quibbles. It is more important to have one consistent style than to make everyone happy. The gofmt style forced me to change several of my own habits, but it was definitely worth it for my code to look like everyone else's. I've never encountered a Go programmer who hasn't become grateful for gofmt, in the end.


Thanks for answering! I have no idea why someone downvoted your reply. People: downvoting is for mean and/or stupid comments, not things you disagree with.

Anyway, in that case I imagine we'll see a Go preprocessor that takes all the line-initial braces and moves them up a break before sending code to the compiler. People get pretty worked up about this stuff.


I work in a place where people don't use spaces and don't use empty lines to separate logical groups of lines. It's a real pain for me who is a code format junkie as our code ends up being an ugly pack of unrelated crap that's really hard to read.

It's Python code and I find it uglier than some fairly large C++ project I used to work on.

Anyway, I wish there was a gofmt in Python because at least, I'd drop all hopes of forging my own rules (silly junkies) and some basic clarity would be forced into our codebase.

I know there are beautifiers but when such things are enforced and not negotiable, it's just so much simpler and people just stop caring as well.


It's Python code and I find it uglier than some fairly large C++ project I used to work on.

I've always argued that if your team can't bother to even indent code properly than you have much bigger problems than any language formatting rules can solve.


One time we worked on some code, and one of the developers had the same habit: "It works, so why do I need to format it?"

We decided to make our build system run PEP over the code, resulting in a failure if PEP didn't pass.

It annoyed the hell out of him, but we quickly got the formatting up to a better standard.



My apologies, yes. Don't know why I missed the 8 off there.


I completely support enforced style -- it's part of what I love about Python and F#'s light mode -- but it has to be the right style.

I strongly believe that code should look like a screenplay, not a novel. More white space, in other words, is rarely a bad thing. Inline braces decrease white space and make unfamiliar code harder to scan, so to me they're Not Good.

Also wow, I didn't know it was even possible to write Python without spaces. Are we talking no spaces in arguments, like

    def func(arg1,arg2):
        print "Indented"
        return
or full-on no spaces?

    def func(arg1,arg2):
    print "Not indented"
    return
I thought the latter was prohibited.


Sorry, we are talking about that:

    def func(arg1,arg2):
        i=other_stuff(1,2,3,4,56,43,234+4*3)
        return i


Don't want to make this a big meta discussion, but I noticed that often the best comments are downvoted first, and eventually end up on the the top of the page. Don't worry this type of thing corrects itself.


Nothing in go is silly. There are multiple reasons why it's required.

The answer usually given is faster compile times and the removal of semicolons from the language. I don't know the details, but someone new complains about it on the mailing list fairly frequently.

Also having a tool enforced brace style is just plain practical. Less silly arguments/bikeshedding.

I was also a brace on its own line kinda guy, but between javascript and go, I've gotten over it.


Perhaps this will be Go's version of Python's whitespace issue. People will balk at the seemingly arbitrary nature of the syntax and avoid trying the language. However, after time, the rest of the language's advantages will lead people to get over their syntax aversion and try the language. Then after 6 months they'll look back and wonder what the big fuss was before.

Not that I have any experience with that...


What about using two characters for assignment?

a := 1 vs a = 1


":=" is type-inferred variable declaration and assignment, while "=" is just assignment.


It is a bit annoying having to press 3 keys using two hands instead of just one.

With '=' I can "hyperthread" my typing. While I'm finishing the LHS and pressing space I can move my right hand to press '=', while keeping my left hand thumb in place to press the space bar for the right side.

With ':=' I have to stop everything to press shift with my left hand, then press ':', then release shift and press '='. It's very inefficient for something that happens often.


I've never really had a big issue with this. I have no issue keeping my thumb on the spacebar while holding left shift, and in addition I've grown to rather like the syntax.

In the long run I'd say multiple assignment probably saves you more time writing declarations than an extra key-stroke would cost you.


Just think about how much more you'd have to type if you were programming C, and you'll be ok :)

My main gripe with := vs = is that as I change my code, an existing := may suddenly become invalid, meaning I have to go back and change it when compilation fails, or vice versa.


Yes, but thankfully compilation fails rather than succeed and then fail in some mysterious way at runtime.

As someone who has been stuck writing JavaScript for Yahoo Widgets (Vizio Connected TV) over the past month, my appreciation for the compiler errors you get in static languages has grown tremendously. Previously I had taken them too much for granted.


You might appreciate jslint or closure-compiler - both have their quirks, but they can be tremendously helpful at finding certain errors.


"a := 1" means "var a int = 1" which is not the same as "a = 1"


Having both := and = goes back a long, long, long way. Go isn't even the 100th language to differentiate them.


:= and = don't do what you probably think they do, the meaning is not the same as in Pascal. If you need to compare two variables, you use ==

    if a == b {}
= is the usual assignment, := declares and initializes a variable inferring the type.

    var a int
    a = 42
vs.

    a := 42
That means you'll see explicit types in variable declarations rarely.



From that page: "At the moment, all implementations use 32-bit ints, an essentially arbitrary decision. However, we expect that int will be increased to 64 bits on 64-bit architectures in a future release of Go."

So, in other words, it's Amateur Hour. All righty, then.

/backs toward door, reaches for doorknob, still smiling and nodding


Fantastically dumb comment. FWIW int in C is also 32 bit on all mainstream 64 bit operating systems, and Go has int64.


Why on Earth would you want 64 bit ints by default, though? I'm not sure why they are thinking about changing it.


ints are used in the definition of some of the core interfaces. This has implications on how many entries a collection (that implements these interfaces) can contain.

For example, sort.Interface:

  package sort

  // A type, typically a collection, that satisfies sort.Interface can be
  // sorted by the routines in this package.  The methods require that the
  // elements of the collection be enumerated by an integer index.
  type Interface interface {
  	// Len is the number of elements in the collection.
  	Len() int
  	// Less returns whether the element with index i should sort
  	// before the element with index j.
  	Less(i, j int) bool
  	// Swap swaps the elements with indexes i and j.
  	Swap(i, j int)
  }

It would have implications on array indices as well, since they are also int.


Fantastically dumb comment. FWIW int in C is also 32 bit on all mainstream 64 bit operating systems, and Go has int64.

ROFL. I challenge you to find documentation for the C language or any other language commonly used in production where they speculate that they might wake up one day and change sizeof(int) on an existing platform.

"Fantastically dumb," indeed.


C is that language, among so many others, sizeof(int) is implementation specific, and indeed it does vary, though (S)?ILP64 is rare. On the other hand sizeof(long) varies all the time.

You seem very ignorant, please learn and stop the FUD.


You seem very ignorant

Yeah, that must be it.


C doesn't even define them, other setting a minimum. There have been C implementations where char was 64 bits.

As far as the documentation for the C langauge where they speculate that it's not defined, just given a minimum bound: here you go: Their implementation-defined values shall be equal or greater in magnitude (absolute value) to those shown, with the same sign (C99 spec, section 5.2.4.2.1)

It also allows sign-magnitude integers (complement 1) in addition to complement 2 (C99 spec, section 6.2.6.2)

It also doesn't define the number of bits in a byte (C99 spec, section 3.6 p2)


Holy @#$@, people. Did I wake up in a naïveté vortex?

No, C doesn't define sizeof(int). It is implementation defined. But you don't change it once you implement it in a given development environment... not if you want people to create and maintain production code with your tools. You don't speculate that one day you might want to change sizeof(int). It's just not something you do if you want to be taken seriously.

Is anyone in this thread over the age of 16?


GCC has options to change the size of int without even modifying the compiler. The size of integer types isn't even fixed within one implementation, in other words.

If you write production C code that depends on anything other than the minimum sizes defined in limits.h, your code is buggy.


    void func() {

    }
Is my natural choice anyway, so I guess, this will not stand in my way. Let's go!


I see the line of reasoning behind this as explained by various comments here. But why can't this just be an user/editor preference while the file saved may use whatever convention?


You don't read only your code, but also code from other people. Go make it really easy, in my opinion, to fast decipher foreign code, due to shortness, clarity, and conventions. Convention help you recognize in that case the structure of the function without having to make your mind around the habit of the other coder.


I do not care who wrote the code -- It should be shown to me using my formatting preferences, just as I can use my own visual theme in the editor. Those themes do not affect the code as it is saved into the file, and those formatting preferences should not either.


Formatting is semantic in Go, newlines are significant, so a brace across a newline is quite reasonably different from a brace on the same line.


You have to build the standard libraries and cross compilers first. I've seen this pair of zsh functions around. It will build the necessary bits and will also build for win/mac/linux/freebsd in simple projects and zip up the results for distribution (You can link to the raw zips then on github). For others looking to do this with go: https://github.com/colemickens/scripts/blob/master/dotfiles/... (Minor editting is needed due to some assumed values $ARCH, $OS, etc)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: