Hacker News new | ask | show | jobs
by zach43 2614 days ago
I think the question of "Why does it takes fifty lines to create a dialogue with a button" is very programming-language dependent:

If you're working with a higher-level programming language, you can make cross-platform GUIs very easily (see tkinter + python as others have recommended) without having to write 50 LOC.

If you're working with C / C++ specifically, then your bottleneck really is figuring out how to build and link with your cross platform library across all platforms. In my experience that has been much more painful than the lines of code required to set up a GUI in C++.

Once you've got the build/deployment system working in C++, most GUI libraries don't need as much as 50 lines of code. For example, even with Qt this is the code to get a dialogue with a button:

    #include <QApplication>
    #include <QPushButton>

    int main(int argc, char **argv)
    {
     QApplication app (argc, argv);

     QPushButton button ("Hello world !");
     button.show();

     return app.exec();
    }
In newer low-level languages with sane standardized package managers, like Rust, things should be much better, but I'm finding any good examples right now
1 comments

Especially, it takes one line in almost all toolkits to create Standard dialogs such as

   window.alert("Hello world");
You can show such windows even from the terminal in Powershell, Linux, OS X. With one line of code.

It's not everything so broken...

A message box is not the same as a dialog with user controls.
All major toolkits have confirmation modal windows, input modal windows, etc as single line "calls". Of course it's not a "custom window" but it is one.