11 ms·
Cross platform GUIs and Nim macros
- awinter-py 10y agotook me a second to realize how important this is; my brain dismissed the final solution as 'so what, that's just like HTML'. then I got it -- the ability to use code generation to be declarative is incredible. having the ability to mix declarative (HTML / data structures) and imperative (javascript) is what makes react so powerful. The ability to do that almost-natively inside the language is amazing.
- nikki93 10y agoYeah I think one of the main things that React offers is a DSL for trees (JSX) that can lexically close over and also splice in JavaScript. Languages that allow creating your own DSLs offer this for other realms such as shader coding, logic programming etc. within the metalanguage.
- draegtun 10y ago>Languages that allow creating your own DSLs offer this for other realms... Rebol & Red are examples of this, there's a GUI dialect called VID [1][2] and in companion with this is a Draw dialect [3][4]. 1. http://rebol.com/docs/easy-vid.html http://rebol.com/docs/easy-vid.html 2. https://doc.red-lang.org/en/vid.html https://doc.red-lang.org/en/vid.html 3. http://www.rebol.com/docs/draw.html http://www.rebol.com/docs/draw.html 4. https://doc.red-lang.org/en/draw.html https://doc.red-lang.org/en/draw.html
- paxcoder 10y agoWhere do you see behavior mixing with presentation in wxnim's GenUI? The only thing that the macro is used for, besides saying what to draw and how, is to define events that the elements emit.
- awinter-py 10y agoyou're asking from an MVC perspective? This approach lets you blur the lines between MVC responsibilities. If you wanted to create a widget that had some traditionally 'business-logic' role (like network sync or database interaction) you could do that. I'm not recommending that but there's value in flexibility.
- paxcoder 10y agoI wasn't talking generally but I'm interested to hear about any purported benefits of conflated responsibilities.
- awinter-py 10y agoExample: The FB/google share buttons on websites totally break MVC. It's just a button but it has cookie & network traffic. I hate those buttons, people often argue they 'break the web' because of weird privacy/performance side effects, but developers use them because it's convenient to 'drop in' the platform integrations. By comparison -- integrating an android app with GMS requires modifying a bunch of files (xml layouts, java source, multiple build dependency files). You can't just 'drop it in'.
- norswap 10y agoWhy does the fact that GTK "looks non-native on Windows" disqualify it? If it's pretty enough for Linux, isn't also good enough for Windows? (Also my personal opinion is that it doesn't look too bad.)
- to3m 10y agoWhy should anybody have to put up with non-standard UI and behaviour? (Case in point: the very website's scrolling. Works great on desktop Firefox, not obviously distinguishable from any other website. On iOS... a sad joke, made at the user's expense.)
- binarycrusader 10y agoExcept they already do, every day in multiple applications such as: Spotify Microsoft Office NetFlix Chrome FireFox ...the list goes on. There is no such thing as a standard UI or behaviour at this point. Any one that owns a mobile device already has to be used to a mixture of UIs every time they switch between devices or specific applications.
- thomastjeffery 10y agoBehavior I can understand, but there is nothing difficult to "put up with" about the look of gtk or qt in Windows.
- tedmiston 10y agoI couldn't actually read the entire article on iOS because of the weird scrolling on a large block of code that more than filled the entire screen.
- redtuesday 10y agoUsing the reader mode resolved the problem for me.
- tedmiston 10y ago
- dom0 10y agoIn 2012 I could pack a whole Python interpreter, Qt and various image-processing libraries into an InnoSetup installer that just-so scratched the 12 MB mark; I doubt this has changed significantly. Contrary to what the linked (more interesting) survey article suggests, Qt is usually the answer to most issues when it comes to cross-platform UI. Gtk is not bad, but Gtk is what it is: it was created because Qt couldn't be used for licensing concerns (at the time) by people unexperienced with the matter (compared to the Trolltech staff), and is maintained by people who, for the most part, care about Linux. Qt on the other hand is supported commercially, and puts far more effort into supporting more platforms better. [Also the tooling and docs are really nice].
- vog 10y agoSide note: Back when I did Win32 packaging of cross-platform applications, I never liked InnoSetup much, mostly because of the many levels of unpacking into temporary directories, but also because it was relatively slow and not as compact as it could be. Instead, I always preferred NSIS using the makensis command. Among others, NSIS can be compiled on *nix systems, but still produces a Windows executable file (like a cross compiler), so you can put it in your cross compiling toolchain. That way, you can create your full Windows port including installer without ever having to touch a Windows.
- tonyedgecombe 10y agoInteresting, I've always been a huge fan of InnoSetup, I've used it for many projects a couple of which had very complex installation requirements.
- dom0 10y agoInnoSetup was very easy to get started with and get the expected results, while NSIS looked more complex. I'm not particularly opinionated about installers as long as they install and uninstall things :)
- kevin_thibedeau 10y agoYou could trim that down more with tkinter + Tix for native widgets.
- Lammy 10y agoThe state of the Web in 2017: This page is nothing but text but just renders as a blank page until you allow JavaScript
- pwg 10y agoOr, until you turn off CSS (firefox: View->Page Style->No Style). Then all the text appears, even without any JS running.
- progman 10y agoNice! Is there also a way to print the text? I just get almost empty pages.
- pwg 10y agoThere is a way, but it involves a bit of work (again because the author used styles that hide everything unless the JS runs). Save the page to disk (Firefox: File->Save Page As). Then open the saved html file in a text editor and delete all of the <link> tags in the <head> section that reference style sheets and save the changes. Then open the edited html page from disk, and the result will be printable.
- analognoise 10y agoA better solution: FreePascal + Lazarus. Cross Platform. Native. Compiled. A RAD tool that is tough to match.
- jadbox 10y agoFirst time I've heard of using FreePascal + Lazarus. Any success stories?
- analognoise 10y agoI coded a viewer for a binary file format reader at work that launched Octave via a TProcess and communicated with it over pipes. Rather than rewrite the Matlab that did the file processing, I just called the same functions our analysis guys were using. To get the data into Pascal, I had Matlab write binary files to disk and then read them in - this is because the pipe implementation on Windows (it was faster than the pipe). Then I used the BGRABitmap's BGRACanvas as a component to draw the bitmap images (frames of data). To this I added some crosshairs. There is also a chart component that displays the data that makes up our range calculation. It came to ~5MB executable, one non portable function (I asked Windows the size of the file Octave is writing until it returns the correct value, and I block on it - not bright, but easy to do. I prime the message pump with Application.ProcessMessage in that loop so the user doesn't see the blocking action. I compressed the executable down to 1.5MB, just to see how far it would go. The project is portable to Linux except for the one function (which will go in an ifdef when I get around to it). All of this with visual feedback, no make files, and 100% free as in freedom, Borland/Embarcadero can't take it from me, can't "change directions to focus on Enterprise", whatever. The community is amazing, and answered all of my questions, and many of them really know their shit. I can't recommend it enough.
- edwinyzh 10y agoThanks for sharing your real life experience, as a Delphi developer I've been watching FPC/Lazarus becoming more and more mature over the years, what a exciting thing! If you need an ORM/Web framework, check mORMot out, with the supplied rich set of samples, it's easy to get started: https://github.com/synopse/mORMot/tree/master/SQLite3/Samples https://github.com/synopse/mORMot/tree/master/SQLite3/Sample...
- MaxLeiter 10y agoSpeaking of cross platform UIs, on iOS the page hijacks scrolling so you can't scroll past the wx widget code segment.
- cstrahan 10y agoI came here to comment on that as well. I tried flicking the page right above the code fragment, but it turns out the scroll hijacking disables iOS's native inertial scrolling, so there's no way for me to read the rest of the article until I get back to my desktop. I don't see the need for down-votes here: clearly many authors (in absolute terms, if not relative terms) tease their viewers with 30 minutes of reading, only to frustrate them by making the rest of the page inadvertently unreachable. I would think of these kinds of comments as a courtesy to the author.
- tedmiston 10y agoI also hit this very frustrating point in the article on iOS where it became impossible to scroll further.
- bilkow 10y agoYou can read the article normally by using reader view on both Safari and Firefox, which make almost any article better to read anyway, at the expense that code blocks won't be properly formatted (in this case, on some sites code blocks just disappear).
- thomastjeffery 10y agoIt seems like the only real complaint this article addresses is that gtk (or other non-native toolkits) add a ~20mb dependency, and Windows didn't have a good package manager (since static compilation is preferred). Frankly, this is a non issue. Windows users are used to this. It comes with the territory. Toolkits like GTK and Qt are full featured, densely documented, fast, look good, and work well in any OS.
- lappet 10y agoSo I have used wxWidgets in the past with the help of python bindings and enjoyed using it and my end product. I hear electron[1] is picking up these days for cross-platform dev - anyone got experience with it? [1] https://electron.atom.io/ https://electron.atom.io/
- MaxLeiter 10y agoAn electron app ships with chromium; major unnecessary bloat. Check out electron file sizes.
- laumars 10y agoOnly from an end user perspective and frankly I hate it. It has all the size and performance problems complained about in that article but without the benefit of native widgets. And frankly if I wanted to run a web app on my desktop then I'd rather run it in my preferred browser. I know I'm getting old (in IT terms) and grumpy but I'm unconvinced our current frontend web stack are the right tools for modern web development; albeit it's what we're stuck with. So I'm even less convinced that it's the right stack for "native" desktop applications.
- thomastjeffery 10y ago> It has all the size and performance problems complained about in that article Complaining about electron being bloated now is just like complaining about gtk being bloated back in the 90s.
- laumars 10y agoTo be honest I've never been a massive fan of GTK either. Then or now. Though at least I can sympathise a little more with why GTK existed and at least GTK is native so still had better comparable performance (ie performed better on average hardware of that era than electron performs on average hardware of this current era).
- ekvintroj 10y agoThis post is like a copy paste of this one: https://news.ycombinator.com/item?id=13952007 https://news.ycombinator.com/item?id=13952007
- Entangled 10y agoWhy not using YAML for the UI definition? Easier, simpler and universal.
- corysama 10y agoThere is a project to get IUP working on OSX. https://github.com/ewmailing/IupCocoa https://github.com/ewmailing/IupCocoa
- ewmailing 10y agoAnd also iOS, Android, and a native web browser backend via Emscripten :) This was a proposal/prototype/intro video for IUP for iOS & Android for the IUP community. https://www.youtube.com/watch?v=UvrEfOg3Nyk https://www.youtube.com/watch?v=UvrEfOg3Nyk Repos: https://github.com/ewmailing/IupCocoaTouch https://github.com/ewmailing/IupCocoaTouch https://github.com/ewmailing/IupAndroid https://github.com/ewmailing/IupAndroid https://github.com/ewmailing/IupEmscripten https://github.com/ewmailing/IupEmscripten
- AsyncAwait 10y agoI am looking for a cross-platform GUI library that feels native across Mac/Win/Linux and has well maintained bindings in a language that is not C++ - an impossible task it seems.
- deleted 10y ago[deleted]
- jackmott 10y agomaking bindings isnt too hard
- AsyncAwait 10y agoQuick and dirty bindings? No. Ones that actually take into account the idioms of the host language and build idiomatic abstractions around the raw bindings? Not necessarily hard, but requires a significant time investment.
- vsakos 10y agoGo + Qt and/or QML
- AsyncAwait 10y agoYeah, https://github.com/therecipe/qt https://github.com/therecipe/qt seems like the best option right now...
- progman 10y agoGtkAda is a binding for Ada. Ada is like Pascal but much more powerful. GTK is available for Linux, Windows and OSX. However, you could also use Qt and import from C++ to Ada. http://www.ada2012.org/ http://www.ada2012.org/ http://www.adacore.com/gtkada/ http://www.adacore.com/gtkada/ http://compgroups.net/comp.lang.ada/gtkada-for-macos-x/1408220 http://compgroups.net/comp.lang.ada/gtkada-for-macos-x/14082... https://www.gtk.org/download/windows.php https://www.gtk.org/download/windows.php
- devwastaken 10y agoI've been struggling with finding a good cross-platform C#/.NET framework that can tie into Visual Studio. So far, you're making your entire UI in code (Like WxWidgets), having to use an app like XamarinStudio to even get fully packaged OSX apps, along with requiring an external framework such as https://github.com/picoe/Eto https://github.com/picoe/Eto, (its official package is broken in Xamarin though) I understand that win forms may not be great when you start to build a bigger application with a lot more presentation and data, but it makes building simple apps easy and convenient. We need something like that cross-platform. If anyone knows more about re-creating windows form apps cross-platform in a nice manner, I'd appreciate the info.
- kodablah 10y agoI don't spend much time w/ that stack, but Avalonia [1] seems to be a big player. Even better, they recently merged .Net core support [2]. You of course lose some native look and feel. 1 - https://github.com/AvaloniaUI/Avalonia https://github.com/AvaloniaUI/Avalonia 2 - https://github.com/AvaloniaUI/Avalonia/issues/314#issuecomment-277459855 https://github.com/AvaloniaUI/Avalonia/issues/314#issuecomme...
- devwastaken 10y agoWhat is the benefit of .net Core and how would that be used in comparison to .net Framework 4.5?
- kodablah 10y agoThis may be too small of a place to explain it and I'm not completely familiar w/ the ecosystem, but .Net core is the .Net runtime built for cross-platform use. It doesn't have all of .Net framework, but they are adding a bit at a time. See https://www.microsoft.com/net/core/platform https://www.microsoft.com/net/core/platform
- tonyedgecombe 10y agoWinforms is rapid until you want to make your app support high dpi, then it all starts to get quite cumbersome.
- marvy 10y agoNo one mentions fltk? I never used it, but is there some reason it's unsuitable?
- beagle3 10y agoFLTK is extremely lightweight and easy to use, and quite fast to boot. It doesn't integrate very well with e.g. platform accessibility hooks and stuff like that (but then, not many toolkits do). Highly recommended if you're using C++. FLTK's major problem is that it is too much of a C++ system; while wrappers for some languages exist, a lot of the properties that make it desirable in C++ are lost through those wrappers.
- i336_ 10y agoThe language itself also has some serious race conditions that are impossible to debug unless you're on really slow/embedded hardware. For example, I used the Dillo web browser (which is FLTK-based) for a couple years when I was stuck on an 800MHz PC, and when the system was swapping heavily, doing things like opening the (FLTK-generated) file-save dialog or dragging a window scrollbar (IIRC) would lock the mouse - FLTK uses X11 cursor locks to constrain the cursor in some situations, and due to the system's heavy I/O load, FLTK wasn't releasing the locks, and I had to kill the entire browser.
- beagle3 10y agoInteresting. But why do you think this is a race condition?
- i336_ 10y agoHmm. Good point; AFAIK Dillo doesn't use threading. I'm honestly not sure what was causing it, but I know that it only happened when the system was swapping a lot. So something that expected something else to be done or take a short amount of time didn't. For all I know it could be the way FLTK is using Xlib (I don't think it uses XCB yet).
- legulere 10y agoEven with cross platform toolkits you will never have apps that feel right. The right(TM) way to do it is to write a GUI for each platform separately.
- gribbly 10y agoActually I would prefer a GUI emerging which is the same across all platforms (except the lowest parts of the plumbing I suppose). OpenGL would be a good candidate for rendering.
- kodablah 10y agoI wish someone would pick back up wxc, the C interface for wxWidgets. IIRC the latest updates are in the wxc folder of wxHaskell [1]. That any non-C++ language is able to somewhat "import C++" (i.e. Nim and D) is nice and all, but doesn't really help the larger community and can be brittle in some C++ situations. 1 - https://github.com/wxHaskell/wxHaskell https://github.com/wxHaskell/wxHaskell
- progman 10y agoBrilliant idea! The code sample is the most clean GUI code I have ever seen. However, I haven't coded GUI for a very long time, so it may be that there are also other good GUI APIs which I don't know about. Nevertheless, this DSL reveals how powerful Nim actually is. It seems many developers have not realized it yet. With Nim they get C performance, seamless C FFI, and a very expressive pythonic syntax. I am using Nim for years now, and it's amazing how productive coding can be.
- ndh2 10y ago> the most clean GUI code I have ever seen That's because it doesn't actually do anything...
- vfclists 10y agoDo most GUI toolkit whinges ever come to accept the fact that most of these issues would go way if Trolltech/Qt/Digia/Nokia would actually bite the bullet and create a simple C interface to the C++ that even other C++ compilers cannot link cleanly to? C++ and its co conspirator Javascript have done so much to hinder programming development over the past 20 years. Linux has been round for over and there isn't a decent opensource graphical debugger for Linux that Visual Studio will have to step in some time in the future. All this is soooo depressing.