4 ms·
But what you lose seems to be readability if going by this code sample let menu = GMenu.menu () in let explain = GMenu.menu_item ~packing:menu#add ~label:"Expl
by supercoder 13y ago
But what you lose seems to be readability if going by this code sample
let menu = GMenu.menu () in
let explain = GMenu.menu_item ~packing:menu#add ~label:"Explain this decision" () in
explain#connect#activate ~callback:(fun () -> show_explanation impl) |> ignore;
menu#popup ~button:(B.button bev) ~time:(B.time bev);
- samdk 13y agoIf you combine many lines of code into one, you lose readability in any language ;). Probably you would actually format this as follows: let menu = GMenu.menu () in let explain = GMenu.menu_item ~packing:menu#add ~label:"Explain this decision" () in explain#connect#activate ~callback:(fun () -> show_explanation impl) |> ignore; menu#popup ~button:(B.button bev) ~time:(B.time bev); Which is rather nicer.
- fzltrp 13y agoI don't know how other similar languages deal with GUI. It's always sort of hairy, obscure code when you look at it closely. Mainstream languages (like Java) usually give you GUI building tools which generate all the boilerplate stuff, but if you look at that generated code, it doesn't look so appealing either imho. If you know the GUI libraries inside out, then the code becomes much easier to grasp though. The lablgtk library (which provides gtk support) is quite well written, providing both a modular interface and objects, but indeed there's a learning curve. Lastly, you might find it more palatable with a little bit of formatting: let menu = GMenu.menu () in let explain = GMenu.menu_item ~packing:menu#add ~label:"Explain this decision" () in let callback () = show_explanation impl in explain#connect#activate ~callback |> ignore; menu#popup ~button:(B.button bev) ~time:(B.time bev)
- Eiwatah4 13y ago> I don't know how other similar languages deal with GUI. It's always sort of hairy, obscure code when you look at it closely. The best languages for GUIs I've seen are specialized declarative DSLs. Things like QML, XAML, JavaFX FXML, XUL, and even HTML. Anything else very much sucks, in my experience.
- danieldk 13y agoAnd Qt pre-QML. The user interface is declaratively described in XML (which can be edited visually with Qt Designer). You then use a utility (uic) to generate e.g. C++ class which you can use through composition and inheritance. UI events are wired to code through Qt's signal/slot system.
- gambogi 13y agoNot knowing how to read a language you don't know isn't a great readability metric