T
Timeless
timelessrepo.com · Group blog · on HN since 2011
Timeless is a Ruby-focused developer blog covering JSON, REST and HATEOAS, Ruby language features, and gem packaging.
What HN saysHN commenters cite it as a reference for why JSON is not strictly a JavaScript subset and as worthwhile reading on HATEOAS.
33HN people shared it
25linked it in comments
10stories submitted
261story points
8 years agolast shared
2011people per year2026
Most-shared posts
- 1JSON: The JavaScript subset that isn't19 people · 163 points · first shared 2011 · 35 comments on HN
- 2Haters Gonna HATEOAS7 people · 66 points · first shared 2011 · 44 comments on HN
- 3Refinements in ruby3 people · first shared 2012
- 4Abstraction Creep2 people · 30 points · first shared 2012 · 6 comments on HN
- 5Haiku2 people · first shared 2012
- 6Tail call optimization in Ruby1 people · 1 points · first shared 2012 · discussion on HN
- 7Making Ruby Gems1 people · 1 points · first shared 2013 · discussion on HN
- 8Tribute1 people · first shared 2013
- 9Mockup driven development1 people · first shared 2011
- 10On camping vs sinatra1 people · first shared 2013
What HN people wrote when they linked it
smoyer · 2014-02-08
It's really worth reading the thesis that started it all (http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm) and I also find this HATEOAS article (http://timelessrepo.com/haters-gonna-hateoas) worthwhile reading, but to answer your question succinctly, here's my short definition:
"REST is inter-computer communication structured such that the server doesn't maintain any client state so that neither the duration between requests nor the number of clients impacts the resource usage of the server."
It's not quite true, but the architecture has benefits:
1) No need to replicate client sessions in a clustered environment.
2) There's no impact if a client wait hours between requests.
3) Every resource a client uses has a unique location on the network.
Rauchg · 2012-12-27
Magnus Holm did a great job describing this after he fixed the problem in Rack::JSONP. Good reference as well for those interested in the topic:
http://timelessrepo.com/json-isnt-a-javascript-subset
acjohnson55 · 2018-06-25
JSON is not actually strictly a subset of JavaScript, surprisingly. Although, in practice, it doesn't really matter, because you wouldn't want to blindly eval JSON data, anyway.
I mention this not to be pedantic, but in case it helps another coder from wasting a couple days chasing a bug like I once had to, when I thought I could template raw JSON into a script file to make some server-side data available as a global var on in the browser.
http://timelessrepo.com/json-isnt-a-javascript-subset
josephg · 2018-06-04
I really wish we had a JSON 2 format which could fix JSON's obvious shortcomings. I would like to see:
- Support for Maps and Sets (unlike objects, maps allow arbitrary types to be used as keys)
- A standard Date format
- Embedded binary blobs. No idea how to do this and keep it human readable, but when you need this its super useful. Maybe something similar to WS's binary message encoding.
- Arbitrary precision integer support. This is particularly useful for cryptocurrencies and for interoperability with 64 bit integers in other languages. And bigints are coming to javascript - https://github.com/tc39/proposal-bigint
- Maybe even fix JSON's weird unicode encoding: http://timelessrepo.com/json-isnt-a-javascript-subset
Unfortunately it seems like nobody 'owns' JSON enough to give JSON 2.0 the political weight it would need for cross-language support.
guscost · 2017-07-14
> Insisting that a URL change with state is taking it too far. It's not how I understood what Tim Berners-Lee and others were saying at the beginning. I would be interested, however, in articles that espouse this.
I'm referring to HATEOAS, the final and most demanding "stage" of RESTful API design: http://timelessrepo.com/haters-gonna-hateoas
> A better rule is one URL per "document" or "record." So in your Photoshop example, there would be a different URL per file that you edit (www.photoshop.com/image001.psd) but not per edit. Well, if the app saved versions, then you could append ?v=203. But in general I think it's enough to align URLs to "documents" (like a news story) or "records" (like a particular profile in a contact database).
This sounds like a good idea.
deathanatos · 2017-05-07
While the person you're responding to might genuinely be confused about JSON usually being valid JavaScript, arbitrary JSON isn't guaranteed to be: http://timelessrepo.com/json-isnt-a-javascript-subset
alayne · 2017-04-25
That's not technically true (JSON is a subset of JavaScript) due to some extra characters allowed in JSON http://timelessrepo.com/json-isnt-a-javascript-subset.
Franciscouzo · 2016-08-20
To be pedant, JSON is NOT a subset of Javascript [1], using U+2028 or U+2029 inside a JSON string is perfectly valid, but is not in Javascript.
[1] http://timelessrepo.com/json-isnt-a-javascript-subset
luikore · 2014-10-26
Not all JSON are valid javascript: http://timelessrepo.com/json-isnt-a-javascript-subset
gnaritas · 2014-10-11
Try learning something jackass: http://timelessrepo.com/json-isnt-a-javascript-subset
draegtun · 2014-10-09
And to back up gnaritas comment... JSON: The JavaScript subset that isn't - http://timelessrepo.com/json-isnt-a-javascript-subset
msgilligan · 2014-04-28
The horribly-named HATEOAS is one possible solution: http://timelessrepo.com/haters-gonna-hateoas
robmil · 2013-10-07
Ruby is gradually adding the ability to monkey patch without polluting the global scope via Refinements:
http://timelessrepo.com/refinements-in-ruby
shadeless · 2013-09-12
Reminded of haikus written in Ruby: http://timelessrepo.com/haiku
daxelrod · 2013-09-10
I was skeptical, but I did some searching, and you appear to be right! The difference seems to come down to string handling:
http://timelessrepo.com/json-isnt-a-javascript-subset
nonchalance · 2013-08-02
Technically not true: http://timelessrepo.com/json-isnt-a-javascript-subset
{"JSON":"ro
cks!"}
(there's a unicode line separator -- 2028)
ryanpetrich · 2013-08-02
JSON is not actually a strict subset. Certain characters when left unescaped in a JSON string make for invalid JavaScript: http://timelessrepo.com/json-isnt-a-javascript-subset
thousande · 2013-07-08
there are also some unicode character differences, see: http://timelessrepo.com/json-isnt-a-javascript-subset
buro9 · 2013-03-22
http://timelessrepo.com/haters-gonna-hateoas#hateoas
It shows in the example:
<entry>
<id>1337</id>
<author>Steve Klabnik</author>
<link rel = "/linkrels/entry/newcomment"
uri = "/entries/1337/comments" />
<link rel = "self"
uri = "/entries/1337" />
</entry>
But I would go further and suggest that whether to show those shouldn't just be based on what the API can do, but what the client (and perhaps user controlling the client) can do.
As in... if they can read but not create, then show the "self" link but not the "newcomment" link.
Thus we're not just saying "our API has these endpoints", we're saying "you can do this".
minikomi · 2013-01-08
Nice! Reminds me of judofyr's "On Camping vs Sinatra"
http://timelessrepo.com/on-camping-vs-sinatra
judofyr · 2013-01-08
I was about to say that it reminds me of the Haiku's I've been collecting:
http://timelessrepo.com/haiku
Or Tribute (that I wrote):
http://timelessrepo.com/tribute
michaelmcmillan · 2012-12-28
Judofyr has covered this in depth on his blog: http://timelessrepo.com/json-isnt-a-javascript-subset
MostAwesomeDude · 2011-11-19
http://timelessrepo.com/json-isnt-a-javascript-subset
Also see my other reply.
VMG · 2011-05-26
Minor correction: JSON is not a subset of js http://timelessrepo.com/json-isnt-a-javascript-subset.
nnq · 2013-07-07
Ah, destructuring is so sweet!
You're right, it's no real need for it and it's unfeasible because you need to either (a) fully static type analyze everything or (b) what anonymous just explained... and they're both out of the question.
The refinements thing was a joke, in the spirit of what else can one add: it's a controlled form of monkeypatching / classboxing about which a lot of fuss was made in the Ruby community after Matz decided to add it to the language (http://timelessrepo.com/refinements-in-ruby), mainly because it's very hard to implement without creating more problems, even if you have your own interpreter to hack on (short answer: don't bother looking about it and even if you're smart enough to figure out a way to add it to a compile-to-JS language, don't waste your effort on it - they're not an anti-feature and they could make sense in languages that allow monkeypatching, like JS and Ruby, but they're too much work for too little benefit and too much possibility for bad use and unneeded complexity).