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

> 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: