• Michal@programming.dev
    link
    fedilink
    arrow-up
    32
    ·
    17 hours ago

    I like this. I also like yaml, I’ve had very few issues with it and it’s nicer to work with than json.

    Json’s lack of support for trailing commas and comments makes it very annoying for everyday use.

  • Solemarc@lemmy.world
    link
    fedilink
    arrow-up
    22
    ·
    16 hours ago

    If this is where the toml train ends I will be happy with it. If they do a yaml, I will be very upset.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      7
      ·
      13 hours ago

      I don’t feel like it will stray very far from what’s dubbed “TOML 0.1” in the meme. Yes, it has inline tables and as of TOML 1.1, they’re allowed to span multiple lines, so it’s technically not anymore illegal to do what’s in the meme. But all things considered, this is still a miniscule change compared to TOML 1.0.

    • LiveLM@lemmy.zip
      link
      fedilink
      English
      arrow-up
      27
      ·
      16 hours ago

      The json spec is not versioned. There were two changes to it in 2005 (the removal of comments

      See, this is why we can’t have nice things.

      • Ephera@lemmy.ml
        link
        fedilink
        English
        arrow-up
        12
        ·
        12 hours ago

        I can kind of understand it after having to work with an XML file where users encoded data into comments for no good reason. But yeah, it does make JSON awkward for lots of potential use-cases.

          • Ephera@lemmy.ml
            link
            fedilink
            English
            arrow-up
            1
            ·
            37 minutes ago

            They’re not supposed to contain data, but some parsers will allow you to access what’s written into comments. And so, of course, someone made use of that and I had to extract what was encoded basically like that:

            <!--
                Host: toaster,
                Location: moon,
            -->
            <data>Actual XML follows...</data>
            

            My best guess is that they added this data into comments rather than child nodes or attributes, because they were worried some of the programs using this XML would not be able to handle an extension of the format.

            • flying_sheep@lemmy.ml
              link
              fedilink
              arrow-up
              2
              ·
              55 minutes ago

              That’s why they make sense in code and config files. JSON is neither, despite the insistence of far too many people to write configuration in it.

              • tetris11@feddit.uk
                link
                fedilink
                English
                arrow-up
                2
                ·
                edit-2
                47 minutes ago

                In an ideal world, yes. In a locked down world where you have access only to 1/4 the codebase or your job is more ontology-focused, all you have access to might be the JSON. Leaving a comment or two about why a particular value or hierarchy is as it is is sometimes more clear than writing up a seperate README that no one will read

        • FooBarrington@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          7 hours ago

          This would undoubtedly, unquestionably happen, and it would break JSON. The only reason it works so well is because comments aren’t allowed.

    • onlyhalfminotaur@lemmy.world
      link
      fedilink
      arrow-up
      8
      ·
      16 hours ago

      Almost all of those issues are solved by explicitly quoting your strings, the author even acknowledges that. Yeah it’s annoying that yaml lets you do otherwise, but the title is a bit dramatic.

      • luciferofastora@feddit.org
        link
        fedilink
        arrow-up
        8
        ·
        10 hours ago

        They were chucked out because, according to the guy who defined it, people started using them for parsing directives, which hurt interoperability because now you needed to be sure that the parser would both read the comments and interpret them correctly. Suddenly, those comments might make otherwise identical files parse differently. If the whole point is that it’s reliable and machine-readable, keeping it to the minimal set of features and not extending it any way whatsoever is a good way to ensure compatibility.

        What you can do is define some property for comments. It’s not standardised, but you could do stuff like

        {
          "//": "This is a common marker for comments",
          "#": "I've never seen that as a property name, so it might be safe?",
          "_comment": "Property names with underscore for technical fields seem common enough as well, and it's semantically explicit about its purpose"
        }
        
        • The_Decryptor@aussie.zone
          link
          fedilink
          English
          arrow-up
          1
          ·
          1 hour ago

          And also, JSON was intended as a data serialisation format, and it’s not like computers actually get value from the comments, they’re just wasted space.

          People went on to use JSON for human readable configuration files, and instantly wanted to add comments, rather than reconsider their choice because the truth is that JSON isn’t a good configuration format.

    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      32
      ·
      20 hours ago

      Well…

      It’s name-value pairs, with groups denoted by balanced brackets. It’s close to as good as you can get for one kind of data serialization.

      What is impressive is how many problems people manage to fit in something so small.

    • dohpaz42@lemmy.world
      link
      fedilink
      English
      arrow-up
      12
      ·
      22 hours ago

      That’s not JSON. Note the use of equal signs for the property names. That’s something else.

      • unmagical@lemmy.ml
        link
        fedilink
        arrow-up
        35
        ·
        21 hours ago

        Carcinisation is the phenomenon of non crabs to evolve crab like characteristics. It is not the process of non crabs becoming true crabs.

        In this case the language is trending toward JSON syntax, but it doesn’t have to actually be JSON for carcinisation to be an applicable analogy.

      • ulterno@programming.dev
        link
        fedilink
        English
        arrow-up
        18
        ·
        edit-2
        21 hours ago

        Equals schmequals.
        It could be a and it would be the same as JSON because it is still a single symbol used as a separator.

        a distinction without a difference

        Now, if it took multiple separators, each giving some specific different meaning, then it would be a something else.

        • dohpaz42@lemmy.world
          link
          fedilink
          English
          arrow-up
          2
          ·
          16 hours ago

          None of what you said makes any sense.

          This is the equivalent of an anti-vaxxer denouncing vaccines because they feel that their herbs are close enough to real medicine. 🤦‍♂️

          Don’t do that. Syntax absolutely matters.

          • ulterno@programming.dev
            link
            fedilink
            English
            arrow-up
            2
            ·
            edit-2
            11 hours ago
            #define EQUAL_TO =
            

            Look! I made a new programming language!


            1. Vaccines are not medicine. They are a more refined form of older (much dirtier and dangerous) practices of sharing sick people’s blood to create group immunity. I’m pretty thankful of not having to do the latter.
            2. No, herbs are far from factory produced, chemically engineered medicine.
            • Most usages of herbs are defined in a way that it acts much closer to cooking. Also most of the herbs used in everyday cooking have medicinal and detoxifying properties, which is 1 of the ways food recipes have developed the way they do.
            • Herbal medicine is much milder than the extremely refined medicine produced using modern methods
              • Hence, they are much slower to act and you need to be using them much earlier than what you can manage with modern ones
              • Hence, there is much less overdose related problems
            • Most herbal medicine tend to have multiple effects. This is in contrast with modern medicine, where extra effects tend to be mostly undesirable and detrimental
              • Hence, herbal medicine is a better choice for regular, low intensity problems, like the flu and what-not, rather than popping Paracetamol every time your temp goes 1℉ over the baseline.
            • Herbal medicine works along with nutrition. This means, it is much harder to develop a tolerance to it in a way that would make it harder for it to work in the future.
            • lad@programming.dev
              link
              fedilink
              English
              arrow-up
              1
              ·
              7 hours ago

              You seem to have had something like mint and thyme in mind as an example of herbal medicine, but try to substitute something like marijuana and nightshade to see that your description doesn’t fit all of the herbs. The only thing I agree is that effects often come coupled and you have to do something to isolate necessary ones.

              • ulterno@programming.dev
                link
                fedilink
                English
                arrow-up
                0
                ·
                4 hours ago

                While marijuana and nightshade (and coffee) would be herbal “medicine” substitute for MDMA, DMT, nicotine, cocaine etc,
                the others you mentioned would be a substitute for Chlorpheniramine Maleate, phenylpropanolamine and the likes.

                So if a herbal medicine doctor is prescribing you marijuana for cough and cold, you can perhaps consider it being a quack. Same for someone prescribing SSRIs to a functioning adult that works 40 hours a week, on their first visit.

                • lad@programming.dev
                  link
                  fedilink
                  English
                  arrow-up
                  1
                  ·
                  3 hours ago

                  My point was more along the lines that herbal doesn’t mean safe, mild, slow, etc

        • jcorvera@quokk.au
          link
          fedilink
          English
          arrow-up
          3
          ·
          19 hours ago

          It could be a ⇨ and it would be the same as JSON because it is still a single symbol used as a separator.

          Nah, that’s a Ruby Hash…

  • panda_abyss@lemmy.ca
    link
    fedilink
    arrow-up
    87
    ·
    22 hours ago

    If yaml didn’t have anchors and 8 different white space formats, it’d be a great replacement for this kind of thing.

    But yaml is a mess, and you’d think you could parse it easily, but you can’t.

  • AnyOldName3@lemmy.world
    link
    fedilink
    arrow-up
    42
    ·
    21 hours ago

    TOML’s design is based on the idea that INI was a good format. This was always going to cause problems, as INI was never good, and never a format. In reality, it was hundreds of different formats people decided to use the same file extension for, all with their own incompatible quirks and rarely any ability to identify which variant you were using and therefore which quirks would need to be worked around.

    The changes in the third panel were inevitable, as people have data with nested structure that they’re going to want to represent, and without significant whitespace, TOML was always going to need some kind of character to delimit nesting.

    • Ephera@lemmy.ml
      link
      fedilink
      English
      arrow-up
      23
      ·
      20 hours ago

      Well, Wikipedia does say:

      The [TOML] project standardizes the implementation of the ubiquitous INI file format (which it has largely supplanted[citation needed]), removing ambiguity from its interpretation.

      https://en.wikipedia.org/wiki/TOML

  • arcine@jlai.lu
    link
    fedilink
    arrow-up
    34
    ·
    21 hours ago

    Nix is the next step in that evolution. It’s basically just JSON that can generate itself !

    • KindaABigDyl@programming.dev
      link
      fedilink
      arrow-up
      19
      ·
      edit-2
      19 hours ago

      It’s basically just JSON that can generate itself !

      You have inspired me.

      I will make JSON with meta-programming

      I will call it DyJSON, i.e. “Dynamic JSON” but pronounced “Die, Jason!”

      It is JSON with meta-programming and the ability to call C functions from libraries

      Example:

      # This is a line comment
      
      # Put your function definitions up here
      (concat str_a str_b: "concat" "my-lib.so") # Import a function through a C ABI
      (make-person first_name last_name email -> { # Define our own generative func
          "name": (concat (concat $first_name " ") $last_name),
          "email": $email
      })
      
      # And then the JSON part which uses them
      [
          (make-person "Jenny" "Craig" "jenn.craig.420@hotmail.com"),
          (make-person "Parson" "Brown" null)
      ]
      

      As you can see, it is also a LISP to some degree

      Is there a need for this? A purpose? No. But some things simply should exist

      Thank you for helping bring this language into existence

      • KindaABigDyl@programming.dev
        link
        fedilink
        arrow-up
        6
        ·
        edit-2
        18 hours ago

        Here is the grammar:

        <json> ::=              <value> | <fn-def> <json>
        <value> ::=             <object> | <array> | <string> | <number> | <bool>
                                | <fn-def> | <fn-app>
                                | "null"
        <object> ::=            "{" [ <member> { "," <member> } ] "}"
        <member> ::=            <string> ":" <value>
        <string> ::=            "\"" { <char> } "\""
        <char> ::=              (ASCII other than "\"", "\\", 0-31, 127-159)
                                | (Unicode other than ASCII)
                                | ( "\\" (
                                    "\"" | "\\" | "/" | "b" | "f" | "n" | "r" | "t"
                                    | "u" <hex> <hex> <hex> <hex>
                                )
        <hex> ::=               /A-Fa-f0-9/
        <array> ::=             "[" [ <value> { "," <value> } ] "]"
        <number> ::=            <integer> [ <fraction> ] [ <exponent> ]
        <integer> ::=           "0" | /[1-9]+/ | "-" <integer>
        <fractional> ::=        "." /[0-9]+/
        <exponent> ::=          ("E" | "e") [ "-" | "+" ] /[0-9]+/
        <bool> ::=              "true" | "false"
        <fn-def> ::=            "(" <ident> { <ident> }
                                    ("->" <value> | ":" <string> <string>) ")"
        <ident> ::=             <startc> { <identc> }
        <startc> ::=            /A-Za-z_/ or non-ASCII Unicode
        <identc> ::=            <startc> | /[0-9-]/
        <fn-app> ::=            "(" <ident> { <value> } ")"
        <var> ::=               "$" <ident>
        
  • Is there any real reason why most progranming languages look more like the 3rd panel and not like the 1st panel? There’s gotta be a reason for all the nesting and indents that has nothing to do with readability since that shit makes it harder to read.

    • Brokkr@lemmy.world
      link
      fedilink
      arrow-up
      22
      ·
      21 hours ago

      Because the 3rd panel looks better when you have dozens of physical properties to track. It also makes retrieval easier because you can get all the physical properties at once, instead of having to read every line.

      For an example that small it doesn’t matter, but for something larger it could become a performance benefit.

    • Hudell@lemmy.dbzer0.com
      link
      fedilink
      English
      arrow-up
      12
      ·
      20 hours ago

      since that shit makes it harder to read

      It makes it harder to read the individual lines, but makes it easier to read them as a group, so you won’t have to read as many lines on your day to day.

    • ProfessorScience@lemmy.world
      link
      fedilink
      English
      arrow-up
      16
      ·
      22 hours ago

      I would guess that it has to do with making it easier to parse. The indents won’t matter very much, but the parser sees "physical = " and knows that a property named physical is being defined. What is the value of that property? Well, there’s a “{”, so the value is an object. And the value of that object is everything up until the matching “}”. If you have a structure more like panel 1, then it’s harder for the parser to know when the value of orange.physical is complete. There might be a [orange.physical.texture] section somewhere, for example.

    • 404@lemmy.zip
      link
      fedilink
      English
      arrow-up
      8
      ·
      edit-2
      21 hours ago

      For programming languages that make use of {}, the reason is (almost always) scope.

      Take for instance this:

      for i in 0..10
      do_thing();
      do_other_thing();
      

      compared to this:

      for i in 0..10 {
          do_thing();
      }
      do_other_thing();
      

      The intent of the first one is unclear. In the second one it’s clear you should loop do_thing() and then run do_other_thing() afterwards. The indentation is only for readability in the above though. Logically there would be no difference in writing

      for i in 0..10 { do_thing(); } do_other_thing();
      

      Languages that use indentation and line breaks for scope look more similar to this:

      for i in 0..10:
          do_thing()
      do_other_thing()
      
    • ulterno@programming.dev
      link
      fedilink
      English
      arrow-up
      6
      ·
      edit-2
      21 hours ago

      A good way to feel that for yourself is by programming a little program in Assembly and C.

      Make sure the program needs to loop a bit and perhaps also require some if/ else logic.
      A simple one would be to read a 1000 integers and return the sum.

      In C, you would do something like:

      int MAX = 1000;
      int accumulator = 0;
      int counter = 0;
      while (counter < MAX)
      {
          accumulator = accumulator + value_at_next_memory_location_by_counter;
          counter = counter + 1;
      }
      

      In assembly, you would go (writing pseudo, because I have forgotten most assembly stuff):

      set reg1 = 1000 // For max value
      set accumulator = 0 // just choose a register and consider it an accumulator. older CPUs have a fixed accumulator and you can only operate on that. I am not considering that here
      set reg2 = 0 // For counter
      tag LOOP:
      set flag if true reg2 < reg1
      jump if false -> END
      move from memory location @counter(reg2) to reg3
      add accumulator reg3
      add reg2 1
      goto -> LOOP
      tag END:
      

      I also realised that you could just try using C with goto instead of any loops and would realise similar things, but I’m not in the mood to rewrite my comment.


      In conclusion, it is easier to understand something like BASIC, if you haven’t been introduced to other languages, but these {} structures end up making it easier to catch control flows at a glance.
      That’s also the argument I use when telling people to have opening and closing brackets of the same level at the same indent, while people prefer stuff like:

      if {
      ...
      } else {
      ...
      }
      
  • somegeek@programming.dev
    link
    fedilink
    arrow-up
    8
    ·
    22 hours ago

    I think edn is almost the only more advanced and ergonomic option to json. Edn is like the evolved json, but its interesting that its roots are way older than JSON.

    The fact that you can very efficiently define whole applications and software just with edn (and the lisp syntax in general) is what makes really amazing.

    I think this blog post sheds more light on how we only need lisp for defining data and applications.

    https://stopa.io/post/265