
Native GUI library for Go - scapbi
https://github.com/andlabs/ui
======
chris_wot
I'm interested in this because I'm cleaning up and restructuring LibreOffice's
VCL (Visual Component Library) code. In terms of OO, it's a mess of tangled
code. This might give me some ideas.

~~~
oblio
You brave soul. I hope you accomplish what you've started - LibreOffice GUI
improvements, especially regarding the foundations, are greatly appreciated.

Would it be possible, long term, to use Qt? I mean switch the current
components to be based on Qt and then, over time, actually start using Qt?

~~~
chris_wot
There's already an effort underway. LO has a fundamental classes when it comes
to implementing the VCL: OutputDevice, SalGraphics, SalFrame and SalInstance.
Mainly SalGraphics and OutputDevice though. The problem is it is so
intertwined, the biggest issue being that classes don't follow the Single
Responsibility Principle.

It's getting there, but I've only really done any real coding in anger in the
last 5 months and this is a 25 year code base...

~~~
fithisux
Please do it in D. C++ is horrible. But if you insist in C++, isn't nana an
option?

~~~
andlabs
Doing it in another language would probably require rewriting the entirety of
LibreOffice, which is a very massive project with code spanning at least a
decade, if not more. They recently switched away from a proprietary (in the
sense that only they used it) build system to one of the more conventional
ones (I forget from what to what), so anything IS possible, but the question
is whether it would be worth it. I know LibreOffice has some Java
interoperability, but I don't know how much, or whether that could be
leveraged.

~~~
chris_wot
Oh... we are trying to get away from a dependency on Java :(

Nana looks interesting - I'm always looking at C++ toolkits to better
understand how they work. I was looking at it's event system, seems pretty
nice. gtkmm also has a nice signals system also.

But yes, rewriting in D would be more than complex. LO has over 7 million
lines of code, the real issue is that there is still a lot of cruft (e.g. the
Resource class, tools, etc) and we are progressively working on removing this
and replacing with saner libraries, such as boost.

Interestingly, VCL actually works pretty much by itself. I recently
resurrected some VCL demos and got them to work as standalone executables. VCL
could actually be as clean to work with as nana, but the guts need a rewrite.
And it would do it in a cross-platform way, but with largely native widgets.

------
crawshaw
An easier way of looking at the API:

[http://godoc.org/github.com/andlabs/ui](http://godoc.org/github.com/andlabs/ui)

------
laumars
Anyone had chance to try this yet? Is it any good?

I notice the Linux APIs call GTK which, while I can understand the logic of, I
rather liked the Qt Go Bindings I played around with last year.

~~~
fit2rule
It is very rudimentary; all the basics are there, but there are some glaring
things I couldn't figure out yet - like how to move the Window to a new screen
position, things like that. Might be my ignorance though, I've only had 15
minutes of glance at it, and as I'm mostly interested in learning Go casually,
maybe there's some things I've missed ..

~~~
sparkie
It may have been done with Wayland in mind, where there is no client-side way
of setting the window position, or even querying it, since wayland does not
let the client know. The position of windows is managed entirely by the
wayland server.

~~~
andlabs
While I do have Wayland in mind, that's specifically for what I can do with
the GTK+ backend when running against GTK+'s limits. For this particular
feature, there's a different rationale, but I can't remember what it was right
now. That being said, I may add such a thing in the future (there's something
in futureplans.md about centering the window right now, so...).

And yes, this is still rather incomplete (I'm surprised it's getting so much
attention this early!); please feel free to make suggestions!

------
fit2rule
Looks like a decent effort at creating the basics - certainly usable for basic
things like buttons and forms and such .. well, I appreciate the simplicity of
this ui kit so far, as I'm currently learning Go. I'm enjoying learning what
area_darwin.go/.m are doing .. toll-free bridge, k?

(wakeup doesn't run with the current version though, missing window w in args,
but that's an easy fix..)

So from 10 minutes of looking at it and getting wakeup built, I've learned
some new Go stuff. Thanks for that! :)

------
sdegutis
Although I'm skeptical about this project (as I usually am with widget
platform-native toolkits like this), I'm very interested about how it turns
out. It looks like it's in early development, but the author seems to know his
stuff. It would have been really cool to see back when I was first trying Go
out, but I've since lost interest in Go since they're taking so long to
implement generics, and I'm not interested in copy/pasting so much code. When
I'm writing OS X apps (I don't use any other platform these days), writing in
Swift seems like a much more fun option (too bad it's not open source, yet).

~~~
grey-area
Objective-C doesn't have generics either and is/was the blessed API language
on your chosen OS. The horror!

~~~
anon1385
Obj-C is 31 years old. I don't think it's unreasonable to expect new
languages/frameworks to have progressed in that time.

~~~
Artemis2
Isn't it normal to expect old languages to evolve too, especially when they
are pushed forward by companies as huge as Apple? Look at C++ (the same age as
Objective-C): C++11 was approved in 2011.

~~~
comex
Swift, Apple's days-old intended replacement for Objective-C, does have
generics.

~~~
Artemis2
Isn't it about time? I mean, they don't really have to make a brand new
language to add generics.

~~~
comex
As mentioned elsewhere, Objective-C is mostly dynamically typed, and you can
just silently cast id to things, so it doesn't need generics as much as a
language like Go, although they certainly could be useful. On the other hand,
the dynamic typing makes it slow with generics or not, and if you want to put
numbers in collections, you have to go through a very cumbersome boxing
process - two of the many things only a new language could resolve.

------
laurent123456
Though it's great to a see a new GUI library for Go, I'm wondering if it's
following the best approach. Most frameworks seem to be moving towards more
declarative languages (HTML for many platforms, QML for Qt), often mixed with
JS, and it makes it much easier to create GUI. Not sure if we need another
clone of wxWidgets/QtWidgets. I wonder if something like a native QML
interpreter in Go would be possible.

~~~
grose
Check this out: [https://github.com/go-qml/qml](https://github.com/go-qml/qml)

It's written by the same guy who made the awesome MongoDB driver for Go, so I
have high hopes!

~~~
andlabs
go-qml has already stirred up enough interest for that same guy to run a
program-making contest at the recent GopherCon so I guess it's safe to say
your hopes are reasonable =P

~~~
andlabs
links to the contest, thanks Nate Finch: [http://blog.labix.org/2014/03/13/go-
qml-contest](http://blog.labix.org/2014/03/13/go-qml-contest)
[http://blog.labix.org/2014/04/25/qml-contest-
results](http://blog.labix.org/2014/04/25/qml-contest-results)

------
GenKali
Is the readme supposed to look like that? The first few paragraphs are all
'h2' level text. Very difficult to read through.

~~~
andlabs
I just replaced it with a detailed placeholder for now. (Replacing it was
something I had stuck in the back of my mind for a while.)

------
skriticos2
Why do people hate images and videos so much? It's a GUI library! I skimmed
the whole readme and have no idea what it looks like and found no link that
would make me any smarter. Am I weird in this regard?

~~~
quarterto
It's platform-native. It looks like your platform. What else do you need to
know?

~~~
FooBarWidget
wxWidgets and <del>Swing</del>SWT are also platform-native. Now find me a
single wxWidgets and SWT app that doesn't look slightly off on Linux and OS X.

Looking and feeling native involves so much more than just using native
controls.

~~~
gldsmth
Swing is NOT platform native, that's why SWT was developed in the first place.
Swing can use native look-a-like theming but it's not the same thing as SWT's
actual, truly native widgets (with native keyboard shortcuts, system
services..).

wxWidgets and SWT are about as native at it can be in a cross platform GUI
library. I don't see why you'd need a screenshot of the go library, it would
look the same as a typical wxWidgets or SWT app, which is to say, it uses
native controls, but might not be designed according to the "common" UI
conventions of the platform.

~~~
Alphasite_
Its native on OSX, is it not?

~~~
FooBarWidget
No, it only tries to look like OS X by drawing the controls like that. But
there are still so many things off that I don't even know where to begin.

------
Hansi
Readme, check. Docs, check. Screenshots, nope. Why would you not include that
for a gui library?

~~~
tptacek
Stupid programmers with their writing code instead of making pictures.

~~~
danudey
Is it unreasonable to expect some kind of demonstration of what the code will
accomplish before having to actually write a project which uses it?

If this code works and is tested on OS X, Windows, and Linux, then one would
assume the author has at least one test implementation, so it wouldn't be too
far of a stretch to screenshot it, especially given that cross-platform
toolkits have never, in my experience, actually looked or felt native on OS X.

~~~
tptacek
People on HN have a very bad habit of assuming that any time something appears
on HN, it's because the authors wanted to put on a show for HN. No.

~~~
shadowmint
Oh please, what kind of excuse is that?

This library is clearly not written for the authors own personal benefit. Just
look at the old readme; it's obviously written for other people to use and
play with.

Examples and screenshots are good; there's no reason for anyone to be
defensive about not having them; the author can just add them. It's no big
deal; it's _helpful_ feedback.

~~~
stcredzero
_> > People on HN have a very bad habit of assuming that any time something
appears on HN, it's because the authors wanted to put on a show for HN. No._

 _> Oh please, what kind of excuse is that?_

Just demonstrated tptacek's point. The author could be at a point where he
wants others to see, but isn't quite ready for places like HN yet. In that
case, it's not an _excuse_. Attitudes like this encourage pathological
perfectionism.

~~~
shadowmint
It is an excuse.

You don't need to polish something into a shiny gem of perfection before
showing it to people; and you certainly don't need to get defensive about
feedback (which in this case wasn't harsh at all); especially not for
something out in the public that various people are already using.

Iterative feedback and improvement can only happen if you get feedback.

It's tempting to say that something isn't quite ready for others to see yet,
it needs a bit more polish, and bit more internal beta testing, a bit more
perfecting before you show it people.

...but I'd say that most cases, it's not the right attitude to encourage
(although there are some very specific cases; like product launches where a
botched launch has long term negative ramifications).

Have a think about what you wrote there.

You're _endorsing_ self defensive attitude of perfectionism _that you 're
criticizing_.

~~~
stcredzero
_You 're endorsing self defensive attitude of perfectionism that you're
criticizing._

No. I'm endorsing thinking a few steps ahead when criticizing. I think that
should be the lower bar for _feedback_. Otherwise, it's too easy to engage in
"feedback" as a means of self aggrandizement while humiliating others, which
is as close as we can get to the Internet's official sport. (In particular,
knee-jerk statements can be used to win over an uninformed crowd. They are the
favorite ammunition of trolls.)

~~~
shadowmint

        Is it unreasonable to expect some kind of demonstration of what the code will 
        accomplish before having to actually write a project which uses it?
    

You think that perhaps danudey needed to stop for a moment and have a quiet
think about that before posting it?

Perhaps word it in a more friendly way somehow?

Perhaps that it was a bit too harsh, and humiliated the original author?

I totally get the basic point you're making, but it's just completely
ridiculous to be making it in this _specific_ case.

~~~
stcredzero
_You think that perhaps danudey needed to stop for a moment and have a quiet
think about that before posting it?_

Yes, and he should produce a tree of possibilities and if he doesn't have
evidence precluding them all, he should briefly hypothesize about the most
likely positive possibility while making his request for further information.

Another way to interpret this: He should think like a creator as opposed to a
consumer. I think it's fair to ask this of visitors to GitHub, as it's
fundamentally a site facilitating the process of creation.

We all need to do more reflection before writing, myself very much included.
Unfortunately, the reward structure of the Internet combined with human nature
seems to encourage the opposite.

------
incompatible
It's amazing how many wheels need to be reinvented every time somebody
introduces yet another language.

~~~
feadog
Some folks at Microsoft were trying to circumvent this with Singularity OS
being based on something like CLR. Then everything could dynamically
interoperate with everything on a programming language level.

[http://xkcd.com/927/](http://xkcd.com/927/)

~~~
andlabs
If I recall correctly, the point of Singularity wasn't to have a platform base
where all programming languages shared the same infrastructure, but rather to
have an operating system that ran (almost) entirely in "managed code" (the
.net framework's safe-execution system).

.net itself is what you're thinking of.

------
CmonDev
Could be a good Go-alternative of Xamarin in ~5 years or so.

