107 points · by dsr12 · 10y ago · 63 comments
https://github.com/LeZuse/minimal-win32-app/blob/master/main...
The C code does basically the same thing but ends up being smaller because the Go code doesn't have an equivalent of windows.h with function and data type definitions. The Go code might be a little nicer if it used a Win32 API wrapper, but there doesn't seem to be a well supported and documented one out there. This was all I could find https://github.com/AllenDang/w32.
I remember just how painful working with the Win32 API could be (a lifetime ago), but I felt like I really understood how it worked. These days, it's layer upon layer of abstractions. Or bindings from my language of choice to an abstraction layer/framework running on the native OS.
I couldn't begin to explain how many of the popular UI frameworks work, all the way down to the native OS layer.
There was something substantial, concrete in programming at this layer rather than some higher level, fragile abstraction.
Think the UI the way I code it (declarative)
Don't have to think about screen resolution, colour depth,...
Don't have to bother with non unicode stuff
Have access to well behaved widgets
Can have portability if I need that
Even if I can't control 100% of the rendering process, my productivity has increased...
In any case, OWL, VCL and later on MFC were my tools during those days, when given an option.
I don't think it would be that ugly if you compared it C code that didn't include windows.h
Whatever, native GUI bindings has been a key factor for the adoption (or lack thereof) of some languages where they would have otherwise been perfectly fine.
after a while things will settle down and this "hello world" program will boil down to something much simpler, like:
import "win"
func PopWin(text string) {
win.NewWindow(text, ...)
}
also keep in mind that this is the version that purposely avoids using C and, as a consequence, can be cross compiled for windows on every machine with Go installed. there are benefits to that.Why?
Less bugs, better examples, community support.
I'm not sure I agree with this, it may have been true before VB on windows. People like Dropbox would also disagree, they use(d) python for their UI code on the desktop, I believe.
and .NET isn't?
Based on that, and the point you made, I'd definitely go the .NET/C# route if I ever ended up in the unfortunate position of having to develop software for Windows. Barring of course some reason that it had to be written in Go or something else.
One reason would be if you're trying to build a node based app which you would like to use across other platforms.
Note: I'm a total newbie at Go and Windows API so every bit of abstraction was a bless to me.
[0] https://github.com/golang/go/issues/14959 [1] https://github.com/golang/sys/tree/master/windows
Is it just me ?
Ideally this sort of platform import should be automated so that Win32 specific apps could import the more advanced GUI stuff (comdlg et all).