Hacker News new | past | comments | ask | show | jobs | submit login

You changed the model when you adapted the xml to lisp. You decided that some tags are unnecessary, dropped some attributes and assumed others are merely different types of child nodes - and now your sample doesn't actually have the same semantic meaning as the XML example. You also removed some comments. Was all this done to emphasis how much cleaner a lisp alternative would be? If we're playing this game, you can actually simplify the XML configuration file as well. If you attempted to capture everything that the XML does, it would make your lisp sample much more ugly.

Anyway, to each his own, but I think XML holds up very well and I do find it more readable and easier to work with that your lisp example.

I also never said XML is the best configuration format. For simple configurations a simple property file is by far the best option. For anything complicated (as in your example) XML does a great job. To contrast, JSON would fall flat on its face with this. Not to mention the fact XML parsing is typically part of the standard library of most programming language and most people are familiar with it.




> You changed the model when you adapted the xml to lisp.

That was a conscious decision, because the verbosity of XML prevents clear understanding of a data model, while the cleanness of S-expressions enables a clarity of vision which enables prudent judgement when laying out a data structure.

> You also removed some comments.

Yes, because they were akin to:

    // Add 1 & 2, assign to X
    x = 1 + 2
If you really want an S-expression version of the XML in that example, here is SXML[0]:

    (*top*
     (fof
      (*comment* " Common settings ")
      (common
       (*comment* " Container configuration ")
       (container
        (option (@ (name "componentNamespace")) "MyCompany\\MyApplication"))
    
       (*comment* " Dispatcher configuration ")
       (dispatcher
        (option (@ (name "defaultView")) "items"))
    
       (*comment* " Transparent authentication configuration ")
       (authentication
        (option (@ (name "totpKey")) "ABCD123456")
        (option (@ (name "authenticationMethods"))
                "HTTPBasicAuth_TOTP,QueryString_TOTP"))
    
       (*comment* " Model configuration. One tag for each Model. ")
       (model (@ (name "orders"))
              (*comment* " Model configuration ")
              (config
               (option (@ (name "tbl")) "#__fakeapp_orders"))
    
              (*comment* " Field aliasing. One tag per aliased field ")
              (field (@ (name "enabled")) "published")
    
              (*comment* " Relation setup. One tag per relation ")
              (relation (@ (type "hasMany") (name "items")))
              (relation
               (@ (type "belongsToMany") (name "transactions")
                  (localKey "foobar_order_id") (foreignKey "foobar_transaction_id")
                  (pivotLocalKey "foobar_order_id")
                  (pivotForeignKey "foobar_transaction_id")
                  (pivotTable "#__foobar_orders_transactions")))
              (relation
               (@ (type "belongsTo") (name "client")
                  (foreignModelClass "Users@com_fakeapp")))
    
              (*comment*
               " Behaviour setup. Use merge=\"1\" to merge with already defined behaviours. ")
              (behaviors (@ (merge "1")) "foo,bar,baz"))
    
       (*comment* " Controller, View and Toolbar setup. One tag per view. ")
       (view (@ (name "item"))
             (*comment* " Controller task aliasing ")
             (taskmap
              (task (@ (name "list")) "browse"))
    
             (*comment* " Controller ACL mapping ")
             (acl
              (task (@ (name "dosomething")))
              (task (@ (name "somethingelse")) "core.manage"))
    
             (*comment* " Controller and View options ")
             (config
              (option (@ (name "autoRouting")) "3"))
    
             (*comment* " Toolbar configuration ")
             (toolbar (@ (title "COM_FOOBAR_TOOLBAR_ITEM") (task "edit"))
                      (button (@ (type "save")))
                      (button (@ (type "saveclose")))
                      (button (@ (type "savenew")))
                      (button (@ (type "cancel"))))))
    
      (*comment* " Component backend options ")
      (backend
       (*comment* " The same options as Common Settings apply here, too "))
    
      (*comment* " Component frontend options ")
      (frontend
       (*comment* " The same options as Common Settings apply here, too "))))
Which I think is still indubitably and inarguably clearer & cleaner than the XML version.

Technically, the XML spec requires whitespace preservation, so really it’s this:

    (*top*
     (fof "
        "
          (*comment* " Common settings ") "
        "
          (common "
            "
                  (*comment* " Container configuration ") "
            "
                  (container "
                "
                             (option (@ (name "componentNamespace")) "MyCompany\\MyApplication") "
            ")
                  "
    
            "
                  (*comment* " Dispatcher configuration ") "
            "
                  (dispatcher "
                "
                              (option (@ (name "defaultView")) "items") "
            ")
                  "
            
            "
                  (*comment* " Transparent authentication configuration ") "
            "
                  (authentication "
                "
                                  (option (@ (name "totpKey")) "ABCD123456") "
                "
                                  (option (@ (name "authenticationMethods"))
                                          "HTTPBasicAuth_TOTP,QueryString_TOTP")
                                  "
            ")
                  "
    
            "
                  (*comment* " Model configuration. One tag for each Model. ") "
            "
                  (model (@ (name "orders")) "
                "
                         (*comment* " Model configuration ") "
                "
                         (config "
                    "
                                 (option (@ (name "tbl")) "#__fakeapp_orders") "
                ")
                         "
            
                "
                         (*comment* " Field aliasing. One tag per aliased field ") "
                "
                         (field (@ (name "enabled")) "published") "
    
                "
                         (*comment* " Relation setup. One tag per relation ") "
                "
                         (relation (@ (type "hasMany") (name "items"))) "
                "
                         (relation
                          (@ (type "belongsToMany") (name "transactions")
                             (localKey "foobar_order_id") (foreignKey "foobar_transaction_id")
                             (pivotLocalKey "foobar_order_id")
                             (pivotForeignKey "foobar_transaction_id")
                             (pivotTable "#__foobar_orders_transactions")))
                         "
                "
                         (relation
                          (@ (type "belongsTo") (name "client")
                             (foreignModelClass "Users@com_fakeapp")))
                         "
    
                "
                         (*comment*
                          " Behaviour setup. Use merge=\"1\" to merge with already defined behaviours. ")
                         "
                "
                         (behaviors (@ (merge "1")) "foo,bar,baz") "
            ")
                  "
    
            "
                  (*comment* " Controller, View and Toolbar setup. One tag per view. ") "
            "
                  (view (@ (name "item")) "
                "
                        (*comment* " Controller task aliasing ") "
                "
                        (taskmap "
                    "
                                 (task (@ (name "list")) "browse") "
                ")
                        "
                
                "
                        (*comment* " Controller ACL mapping ") "
                "
                        (acl "
                    "
                             (task (@ (name "dosomething"))) "
                    "
                             (task (@ (name "somethingelse")) "core.manage") "
                ")
                        "
                
                "
                        (*comment* " Controller and View options ") "
                "
                        (config "
                    "
                                (option (@ (name "autoRouting")) "3") "
                ")
                        "
                
                "
                        (*comment* " Toolbar configuration ") "
                "
                        (toolbar (@ (title "COM_FOOBAR_TOOLBAR_ITEM") (task "edit")) "
                    "
                                 (button (@ (type "save"))) "
                    "
                                 (button (@ (type "saveclose"))) "
                    "
                                 (button (@ (type "savenew"))) "
                    "
                                 (button (@ (type "cancel"))) "
                ")
                        "
            ")
                  "
        ")
          "
        
        "
          (*comment* " Component backend options ") "
        "
          (backend "
            "
                   (*comment* " The same options as Common Settings apply here, too ") "
        ")
          "
        
        "
          (*comment* " Component frontend options ") "
        "
          (frontend "
            "
                    (*comment* " The same options as Common Settings apply here, too ") "
        ")
          "
    "))
But I think that rather proves my point: XML obscures that which should be obvious.

(and apologies for these terribly vertical posts — I think that they go a long way towards demonstrating the need for a compact information representation).

0: http://okmij.org/ftp/Scheme/xml.html#SXML-spec




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

Search: