18

Ocaml, the strictest language when it comes to types i have ever seen, parses a string to a general json object in around 5 loc.

Take notes java.

Comments
  • 5
    JsonElement json = new JsonParser().parse("your string");

    1 line now what?
  • 0
    @EaZyCode thats a hashmap (if i remember correctly) with string keys
  • 3
    @EaZyCode also that aint one line, thats a full fucking gson library
  • 1
    @ganjaman ocaml doesn't need a library? Well ok you win
  • 0
    I considered learning Ocaml a few times... Is it really worth it? I heard that it is used in aviation in some places as a functional language.
  • 1
    @ganjaman pretty sure ocaml's json conversion code is a few thousand lines long too or does it use magic?
  • 0
    @wholl0p quickly becoming my favourite, worth picking up if you wanna substitute js with something sane
  • 0
    @sSam to be fair i didnt count typedef lines, but you have to write those anyway
  • 0
    @ganjaman I don't do JS, to be more precise: I hate JS.. But I love Python, may be a good addition or alternative. I'll have a look
  • 0
    @ganjaman I'm referring to your statement that in Java it's not one line because you have to include a library. Same is with Ocaml.
  • 0
    @sSam i dont really have to include yojson (thats the name btw, like 2k lines) to serialize a json string. I have to do it for other stuff, yeah but mapping a json to a hashtable in java would take a lot more, and making a general object would be really fucking long. Used java the past 4-5 years, i know what im talking about
  • 0
    @ganjaman you still have to use code, which is probably in standard library. It doesn't make much difference if it's in standard library or external one as it takes literally 1 minute to include a library in Java project.
    Also you can parse json to object with a few lines?
Add Comment