Live data from Hacker News

A fast EDN (Extensible Data Notation) reader written in C11 with SIMD boost

github.com

11–20 of 43 posts

Re: A fast EDN (Extensible Data Notation) reader written in C11 with SIMD boost

#13

Can the metadata feature be used to ergonomically emulate HTML attributes? It's not clear from the docs, and the spec doesn't seem to document the feature at all.

I think you can use metadata to model html attributes but in clojure people are using plain vector for that. https://github.com/weavejester/hiccup

tl;dr first element of the vector is a tag, second is a map of attributes test are children nodes:

[:h1 {:font-size "2em" :font-weight bold} "General Kenobi, you are a bold one"]

Re: A fast EDN (Extensible Data Notation) reader written in C11 with SIMD boost

#14
Interesting, I had to look up what EDN is. Important to note that EDN doesn't have a concept of a schema like JSON Schema.

This is a `map`, which bears semblence with a Json object. The following might look like an incorrect paylood, but will actually parse as valid EDN:

  {:a 1, "foo" :bar, [1 2 3] four}
  // Note that keys and values can be elements of any type. 
  // The use of commas above is optional, as they are parsed as whitespace.

If one wants to exchange complex data structures, Aterm is also an option: https://homepages.cwi.nl/~daybuild/daily-books/technology/at...

Some projects in Haskell use Aterms, as it is suitable for exchanging Sum and Product types.

Re: A fast EDN (Extensible Data Notation) reader written in C11 with SIMD boost

#15
post #3

This is superb. Thank you for making it and licensing it MIT. I think this is a contender to replace the lexer within jank. I'll do some benchmarking next year and we'll see!

Wow, that is a greate news!) Thanks for looking at it from this perspective! There are some benchmarks already available in the project - https://github.com/DotFox/edn.c/blob/main/bench/bench_integr...

you can run it locally with `make bench bench-clj bench-wasm`

Let me know if I can do anything to help you with support in jank.

Re: A fast EDN (Extensible Data Notation) reader written in C11 with SIMD boost

#16

Interesting, I had to look up what EDN is. Important to note that EDN doesn't have a concept of a schema like JSON Schema. This is a `map`, which bears semblence with a Json object. The following might look like an incorrect paylood, but will actually parse as valid EDN: {:a 1, "foo" :bar, [1 2 3] four} // Note that keys and values can be elements of any type. // The use of commas above is optional, as they are parse…

One of a key design principles in EDN is to be exclusively data exchange format. Which is true even for JSON where json-schema is something that sits on top of JSON itself. Same goes to EDN - in Clojure there is clojure.spec that adds schema like notation, validation rules and conformation. https://clojure.org/about/spec , something like this could be implemented in other languages as well.

Re: A fast EDN (Extensible Data Notation) reader written in C11 with SIMD boost

#17

I think it would be better to not use Unicode (so that you can use any character set), and to use "0o" instead of "0" prefix for octal numbers. Also, EDN seems to lack a proper format for binary data. I think ASN.1 (and ASN.1X which is I added a few additional types such as key/value list and TRON string) is better. (I also made up a text-based ASN.1 format called TER which is intended to be converted to the binary D…

> EDN seems to lack a proper format for binary data

The best part of EDN that it is extendable :)

#binary/base64 "SGVsbG8sIHp6bzM4Y29tcHV0ZXIhIEhvdyBhcmUgeW91IGRvaW5nPw=="

This is a tagged literal that can be read by provided (if provided) custom reader during reading of the document. The result could be any type you want.

Re: A fast EDN (Extensible Data Notation) reader written in C11 with SIMD boost

#19

[dead]

Thanks for the link!

Yes, EDN is a textual format intended to be human-readable. There is also a format called Transit used to serialise EDN elements. Unlike raw EDN, Transit is designed purely for program-to-program communication and drops human readability in favor of performance. It can encode data into either binary (MessagePack) or text (JSON), but in both cases, it preserves all EDN data types and originates from the Clojure language.

https://github.com/cognitect/transit-format

Re: A fast EDN (Extensible Data Notation) reader written in C11 with SIMD boost

#20
I don’t wish to pick on this post, it looks quite well done. However, in general, I have some doubts about data formats with typed primitives. JSON, TOML, ASN.1, what have you. There’s very little you can do with the data unless you apply a schema, so why decode before then? The schema tells you what type you need anyway, so why add syntax complexity if you have to double check the result of parsing?
Post reply on HN