Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Everything doesn't have to be JSON ;)


Agreed. The best format might be one specially defined for the job.

I built a GUI-builder ages ago (in Python, compiling to Python which calls Tkinter to build the GUI). Here's a sample of what the UI-definition language looked like: https://github.com/cabalamat/parrot/blob/master/simple2.par


Looks fine and dandy but could also be represented in JSON with not much effort and then you'd be using an interchange format understood by many tools instead of a bespoke language.

I'm definitely biased being a web dev but JSON is just so widely used and supported... seems ideal for small bits of config like this.


IMO, using JSON to specify a GUI would be a terrible idea. Its purpose is to serialize data for transport between disparate systems. JSON is verbose and writing anything decently complicated with it sounds like torture.

What you want for something like a GUI specification is a DSL designed for the task (e.g. QML), or a suitable general purpose language like HCL or YAML.


> JSON is verbose and writing anything decently complicated with it sounds like torture.

Except in comparison with XML :-)


> Looks fine and dandy but could also be represented in JSON with not much effort

Yes it could. But writing the UI descriptions would be harder in JSON than in my bespoke language.

My goal in writing the tool was to maker UI descriptions as easy to write as possible. If I hadn't cared about that I wouldn't simply continued to hard-code them in Tkinter.

> I'm definitely biased being a web dev but JSON is just so widely used and supported

JSON didn't exist when I originally wrote this. If i was doing it today, it's entirely possible I would use JSON as a data interchange format.


> But writing the UI descriptions would be harder in JSON than in my bespoke language.

For example, this:

    menu "File" {
        menuItem @New "New"
        menuItem @Open "Open..."
        menuItem @Save "Save"
        menuItem @SaveAs "Save as..."
        menuItem @Exit "Exit"
    }
Might become something like this:

    {'widget': 'menu', 'text': 'File', 'contents': [
            {'widget': 'menuItem', 'id': 'New', 'text': 'New'},
            {'widget': 'menuItem', 'id': 'Open', 'text': 'Open...'},
            {'widget': 'menuItem', 'id': 'Save', 'text': 'Save'},
            {'widget': 'menuItem', 'id': 'SaveAs', 'text': 'Save as...'},
            {'widget': 'menuItem', 'id': 'Exit', 'text': 'Exit'}
        ]
    }
Which would turn writing a UI from something that's a pleasure to something that's a chore. People who would deliberately write software that's a chore for others to use ought not IMO be writing software that will be used by other people.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: