-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clean up design #35
Comments
I prefer to have a low-level API, ideally auto generated,with one to one wrappers and a higher level API that uses those. Random and LinAlg in base take this approach and it works rather well. Shortcomings in the abstraction layer do not become showstoppers then. |
Tk.jl should ideally be only TK wrappers and the abstraction is in GUI.jl, which can have different backends including an html backend. Pythoncard is a good example to look at. It is simple enough for non computer scientists and we use it in circuitscape. |
I don't think much of auto-generated bindings. You get a huge pile of code that just leaves you where you started; you might as well call the c library yourself. Would you rather write:
or
Personally I don't need both versions. |
I would implement the first using the second rather than sprinkling ccalls all over. I prefer to organize code that way and it makes it easier for newcomers to contribute too. |
I don't think there's a fundamental conflict between these two visions. There's value in centralizing On the bigger point, I heartily agree with Jeff that a GUI cleanup is needed. Jeff, to your list of targets for abstraction I would add widgets (at least the core items), events, and layout management. For me, the last causes the most concern. I attempted to start a toolkit-independent layout manager with my LP-based On a related point: I couldn't help noticing that many of the "abstractions" in |
I wrote a package for R (gWidgets) that is meant to be an abstract layer The goal of complete portability across platforms is not that simple Unless someone wants to spend a lot of time on this, I'd say a better However, writing wrappers for the current Gtk.jl package is really a pain On Sun, Jun 16, 2013 at 7:52 AM, Tim Holy notifications@github.com wrote:
John Verzani |
@jverzani You should probably register |
@jverzani, that's valuable perspective; I didn't fully appreciate the depth of your experience with supporting graphics toolkits in various languages. I agree that there is a lot of merit in picking one and just using that, rather than trying to support many toolkits. Gtk, while being a step above Tk, worries me with regards to mobile (I have little doubt that someone will port julia to Android within a couple of years), and the momentum behind Gtk does not seem to be what it once was. So if we're going to pick just one and hope it's a great long-term solution, to me it seems to be basically a no-brainer that the choice should be between Qt and HTML5/web. What's held me back is that I'm put off by the barrier of generating a Qt wrapper (I definitely don't have time to start one myself), and I'm worried about the performance/interactivity of web. That, and the small matter that I don't know either one of them (as a programmer) myself. Thanks for the link to your |
Qt is much preferable to Gtk, assuming someone pushes past that barrier of On Sun, Jun 16, 2013 at 11:40 AM, Tim Holy notifications@github.com wrote:
John Verzani |
Can you elaborate on these difficulties? |
This conversation sent niggles off in my head that a little googling helped resolve; it turns out you're not the first to urge us to pick one and then run with it. At the time I was a main proponent of an abstraction layer, so this was basically an argument against my point of view :-). |
Unless Viral figured it out, there is the issue of upside down plots or oddities when resizing plots. John Verzani On Jun 16, 2013, at 1:01 PM, Tim Holy notifications@github.com wrote:
|
Sorry, I meant the obstacles facing R for Qt support:
|
Tim, it's true that Graphics is tied to Cairo. I decided this was ok for a few reasons: Cairo's rendering model is basically the SVG model, and so is very generic already (moveto, lineto, etc.) Cairo also has good support for every backend out there, so it's pretty unlikely you'd need something else for vector graphics. If you did, most of its API could probably be implemented. I also selected a pretty small subset. Between Jameson and me we'll be able to wrangle the needed ccalls for Gtk. Winston I think should be pulled apart into pieces and slowly put back together, so that will not be a barrier. Thanks to that link to Peter Wang's post, I'm reminded to focus on use cases. For example, if somebody wants to do serious Android development in julia they will need to create Android.jl, and we probably can't worry about all such possibilities up front. I think my primary concern is exploratory (repl-style) use and one-off applications (small GUIs that help you solve a particular problem). On the implementation side my concern is simple generic APIs like
If Gtk solves our install and display problems I think that will become the preferred back end for this layer in the short term. If we really want Qt, I think it makes sense just to write the layer we need in C++. If somebody really wants full Qt bindings, I consider that a different problem. As for this issue I think we should get rid of |
If we're first aiming for "simple" GUIs, then certainly Tk or Gtk will suffice, as long as the cross-platform issues work out satisfactorily. (Heck, on Linux Tk+Cairo is already much better than Matlab, so I don't think our needs here are particularly demanding.) And I love the idea of having a "safe" drawing API. So no complaints there. If you want to merge anything from With regards to choosing an underlying toolkit, I do think it may be more than a bit shortsighted not to take "eventual support for mobile" into fairly serious consideration. Of course, since I'm reluctant to be the pioneer on an HTML5/Qt wrapper, this is largely academic. On the issue of |
I think the hard part is really the generic API design. For example on another thread Jameson and I are trying to hash out the meanings of draw, reveal, configure, and (possibly) redraw. Once we figure out the "right thing" and have detailed specs, I think it is relatively easy to port to different backends. Your original concept of a generic layout manager would be nice to have. We could use it for graphical elements in a pure vector-rendering context with no UI, and also for widgets by using a toolkit's absolute placement as a backend. This also reduces the requirements on new backends; you just need x, y, width, height. Winston has a small amount of this kind of functionality, and it would be nice to abstract it out. |
Agreed. There have now been two people experienced with multiple toolkits in high-level languages who have said this may be sufficiently hard that it may not be worth it, and that we should just adopt one toolkit. That said, there's still a big part of me that's sympathetic to the notion of a generic layer for simple things, and thinks (perhaps foolishly) that for simple things an abstraction layer is achievable and worthwhile.
You have it already :-). I got the Layout package to the point where it seemed to work at least for simple tasks, with Julia that was current at the time. The part that was missing was integrating it into Winston etc. See https://github.com/timholy/Layout.jl/blob/master/test/simple.jl for an API demo that should take you about 2 minutes to understand, if you reference the image example linked above (and also from that file). It depends on SymbolicLP, which has recently been deleted from METADATA in preference for MathProg. However, the repository still exists in my github account, and if you decide you like Layout but would rather base on MathProg that should (I imagine) be quite straightforward. |
@jverzani The upside down plot oddity is only a mac issue, I believe, because the co-ordinates have to be transformed, and not all code-paths end up transforming. At casual glance, I was not able to fix it. The code is a bit all over the place, and I am not familiar with Tk - so I need to find some time to go through it patiently. |
@rsrock just fixed some of the display issues, and the OS X inversion is described by @loladiro in JuliaGraphics/Winston.jl#55 - just need to figure out how to fix it. GTK may still be better in other aspects, but the current Tk visual artefacts definitely seem addressable. Also, the fact that Tk is small is nice to have it for minimal systems. |
@timholy On qt issues with windows: I was premature on this. R's package is not available as a binary, but there are instructions for installation that would look familiar to any command-line user (http://cran.r-project.org/web/packages/qtbase/INSTALL). As for subclassing, the qtbase program does it here https://github.com/ggobi/qtbase/blob/master/R/class.R . I can't really comment if that is a big problem or a little one except that it would be huge for me. |
We need to rethink our GUI API.
As a small example, the Tk package currently has types
TkWidget
,Tk_Widget
,TTk_Widget
,Canvas
,TkCanvas
, andTk_CairoCanvas
. I know there are reasons for these, but this is not going to work from a usability perspective.In the work I started in tkwidget.jl, I was not really trying to provide "Tk bindings". This goes against the usual way scripting languages wrap libraries, which is to provide the same API as the original library, just callable from the scripting language. The usual approach does have advantages: (1) all functionality is exposed, (2) you can refer to existing documentation for the library, (3) people who already know the library have a shallow learning curve. This is the direction that @jverzani took things, and I greatly appreciate that work since it brought us a lot of functionality, and we will probably keep most of it.
But I would also like something else, which is a set of simple julian abstractions that would be directly meaningful to our users. Examples might include
Window
,Canvas
,DrawingWindow
,PlotWindow
,Canvas3D
, etc. (not all of those exist yet). It is possible this should be a new package, e.g. "GUI.jl", which can be implemented on top of Tk.jl and/or Gtk.jl. Then all my non-idiomatic-tk stuff in tkwidget.jl can be removed and the design will be less split. Or we could change Tk.jl and Gtk.jl to provide the desired API directly.The first approach is probably more typical. But personally, I value simplicity more than features and low-level control, and the higher-level "toy" API is the only one I'd want to use. It might be nice to preserve the ability to write Tk- or Gtk- specific code, but that also risks fragmentation, e.g. people writing GUI widgets that only work with one library. So I want to start talking about how we should move forward. cc @timholy
The text was updated successfully, but these errors were encountered: