Comments on: On JSON and REBOL
REBOL Technologies

Comments on: On JSON and REBOL

Carl Sassenrath, CTO
REBOL Technologies
13-Dec-2012 6:39 GMT

Article #0522
Main page || Index || Prior Article [0521] || Next Article [0523] || 13 Comments || Send feedback

Flipping through some Github blog pages, I came across the Github API in JSON. For example: https://status.github.com/api

It's ironic. Every time I run across JSON examples, I see REBOL without the elegance. The two languages are related of course. REBOL strongly influenced the design of JSON.

Consider the above github API example...

In JSON:

[
 {
   "status": "good",
   "body": "Battlestation fully operational",
   "created_on": "2012-12-07T18:11:55Z"
 },
 {
   "status": "minor",
   "body": "Almost done reticulating splines",
   "created_on": "2012-12-05T12:08:33Z"
 }
]

In REBOL:

[
 [
   status: good
   body: "Battlestation fully operational"
   created_on: 2012-12-07/18:11:55
 ]
 [
   status: minor
   body: "Almost done reticulating splines"
   created_on: 2012-12-05/12:08:33
 ]
]

It's clear, isn't it?

Expression of information is not just about structure. It's not just about name-value pairs. It's also about the datatypes as values and the ability to handle and manipulate those too.

Meaning isn't just in strings, it's in the full expression itself. A holistic representation. The REBOL form includes set-words, words, strings, dates, and blocks - lexically cleaner, less syntax, as well.

Unfortunately, many programmers don't think outside of the box. They're stuck in a narrow world of strings and unnecessary punctuation.

The mind is naturally capable and comfortable with so much more. Use it.

13 Comments

Comments:

Steven White
14-Dec-2012 6:47:32
I wonder if it's possible that you might be so far above others in your understanding of such issues that others are thinking something like, "What in the world is he talking about" while you are thinking "How in the world can you not get this?" I am more on the not-getting it side, although I do think I see the point regarding the created-on item. If the alleged date is represented as just a sting, a program has to examine it to figure out what it is. In REBOL, you just "know" what it is, it's right there, "obviously" a date.

I wonder if your mission in the new R3 open source world should move toward hammering on all of us with theory and examples to help us get out of our boxes. That could help the wider world of programming, not just REBOL. You could be like Edsger Dijkstra and his "go-to considered harmful" article that launched structured programming.

Fork
14-Dec-2012 12:09:08
I didn't write this. But it's profane and funny, and it features the word "FoRK" for some reason:

http://www.xent.com/pipermail/fork/Week-of-Mon-20091109/054578.html

While I'm on a rant, F*CK JSON. I mean, first f*ck XML thoroughly and nastily, but let's call it like it is -wrt- JSON. Anything that forces me to do this sh*t:

{ 'someSymbolicKeyAsString': 'someUriValueAsString' }

...is BROKEN BY DESIGN!

NO MORE TUNNELING CRAP IN STRINGS!!!

*REAL WORLD*, modern datatypes, built-in, literal, batteries-included PLEASE!!! If the following aren't first-class types with first-class literal constructors / representations supported *at the language level* then your new programming language ISN'T EVEN ON THE PLAYING FIELD

But let's be fair, here. Douglas came to you and he did try. He was really stoked about Rebol...still sings its praises to this day...but when we talked he said he just couldn't sell it as it was, and he wanted to participate with the world. You kind of tied his hands with the licensing model and he saw the writing on the wall. He hates the compromise as much as you, but he made it because he had no open source Rebol to bring to the table.

But that's all water under the bridge. Now we have it. Let's see where this goes...

Carl Read
14-Dec-2012 12:12:27
In REBOL, you just "know" what it is, it's right there, "obviously" a date.

It's not just about how your code reads though, but an integral part about how you think about coding. This from the REBOL console...

>> r-day: 12-12-12/10:33
== 12-Dec-2012/10:33

>> r-day + 1 == 13-Dec-2012/10:33

>> r-day + 1:15 == 12-Dec-2012/11:48

>> for date r-day r-day + 3 1 [print date] 12-Dec-2012/10:33 13-Dec-2012/10:33 14-Dec-2012/10:33 15-Dec-2012/10:33

>> for date r-day r-day + 3 12:15 [print date] 12-Dec-2012/10:33 12-Dec-2012/22:48 13-Dec-2012/11:03 13-Dec-2012/23:18 14-Dec-2012/11:33 14-Dec-2012/23:48

Now while there's no logical reason why an integer value should increase the date/time by a day (instead of a year or a minute etc. - deciding it'd be a day was just a practical choice), it is obvious that a time value should add hours and minutes to the date/time value.

Having dates and times and a large number of other useful datatypes available on tap in REBOL is one of the advantages of REBOL from the programmer's POV.

Scot
14-Dec-2012 22:14:34
Data-types are one of the main reasons I use REBOL. For instance, I have 1000 log files we captured from our network with a naming convention that includes the system date and time. REBOL parses this in a single line of code and makes sorting by date or time or anything trivial. Just wrote a similar function in Javascript that took 20-30 lines of code. Why write it in JavaScript when I can do it in REBOL. Well... uhhh... Runs on an iPod Touch.
Carl Sassenrath
14-Dec-2012 22:48:54
Steven, it's a good idea. In addition to above comments, I should write more about it and why it matters. Thanks for the suggestion.
MaxV
17-Dec-2012 4:07:19
I totally agree with Carl, and I marked it in my post on:

http://rebol2.blogspot.it/2012/12/json.html

Ade
17-Dec-2012 5:24:15
I agree and have done for years, used to work with visual basic and it would make assumptions for you. For example the contents of a textbox, a$ and b$ if you later coded a$ * b$ the sw assumed, oh, ok, well now they are numbers. Then they changed it all with Vers 5 I think, then you wern't allowed to do that sort of thing anymore. A high level language should take all of the drudgery out of programming, and make intelligent assumptions, If I ask my child to pass the salt, I dont expect him to tell me but dad, you havent specified what type of salt, are we talking salts of sodium, monohexaflouride, or salts of chromium, or vanadium, because if you are, we havent got any of those in.

If you want finickity syntax rules, thats a low level language which must be that way, but a high level language, working up here with us humans should be doing most of the drudgery for us. But of course, thats exactly how programmers and software companies keep mere humans from muscling in on this billion dollar industry. Heaven forbid that a mere shop owner should decide to cobble together a small database program to keep track of his stock for Free, then start passing copies of the code to other shop owners. Thanks for your amazing work to all at the Rebol Team.

Kaj
17-Dec-2012 8:44:39
Agreed, except that the industry myth you speak of extends to low-level languages. Even with a low-level language, you can get quite far in making it understand you. Red/System is achieving code that's amazingly close to REBOL and Red.
Austin
23-Apr-2013 10:11:03
I've always liked Rebol, especially the rich data types and rich constants and lack of unneeded punctuation.

I'm wondering if, now Rebol is open source, there could be a formal grammar published defining a minimal (and "safe") subset of Rebol for data definition just as JSON is a formally defined subset of JavaScript.

Brain Lesion - (how to c
6-May-2013 11:55:58
I'm watching a youtube video on json. They can talk for an eternity about the punctuation and all the arcane notation, without ever discussing wtf they can actually do with the data, except maybe move it from A to B.

At that point they begin talking about more notation and conversion to make it acceptable as a new notation...

It just hurts, listening to this stuff.

They just called it "technology" again.

Bad Format
6-May-2013 13:58:27
While we are on the subject of elegance...

I have these inane logs that parcel each value in matching double quotes, and then use a comma as a delimiter. Like this: "yada yada","bob is your uncle","yada2"

Unfortunately they also use a comma inside of values to separate subset elements in terms of date and time values.

What is the correct parse rule to turn every "," occurrences into a tab. That is double quote comma double quote, to a single Tab. I do not want to disturb single lone occurrences of commas. they have to be with quotes as in: "," to qualify.

Thanks.

Rebol's a breeze..
6-May-2013 18:56:31
Prints each value enclosed in quotes, on a newline... (They may not show as separate lines here)

Rebol[]

foreach elem (read/lines %log.csv) [foreach value parse elem "," [print value: mold to-string value]

Yeilds this output:

"06 May, Mon, 09:30:52" "82.95.235.xxx" "Cable/DSL" "XS4ALL Internet BV" "Europe" "Netherlands" "Noord-Holland" "Amsterdam" "52.35" "4.91669999999999" "MSIE 9" "Windows 7" "Other" "24 Bit (16.7M)" "JS Enabled" "" "" "" "http://www.linkedin.com/home?trk=hb_tab_home_top"

Pierre
13-May-2013 7:39:09
Bad Format: this definitely sounds like you are dealing to some sort of csv file?...

There are some Rebol scripts dealing with such files (not so insane, in my humble opinion; I use them very often for data transfer between databases (postgresql), spreadsheets, and they prove to be very reliable ;-)).

Just search in rebol.org, you'll find many scripts concerning .csv files.

This one, from Brian Hawley, seems quite recent: http://www.rebol.org/view-script.r?script=csv-tools.r

Post a Comment:

You can post a comment here. Keep it on-topic.

Name:

Blog id:

CS-0522


Comment:


 Note: HTML tags allowed for: b i u li ol ul font p br pre tt blockquote
 
 

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, spams, personal attacks, politics, religion, etc.

Updated 31-May-2023   -   Copyright Carl Sassenrath   -   WWW.REBOL.COM   -   Edit   -   Blogger Source Code