On Sat, 2010-04-03 at 20:29 +0100, Nick Minutello wrote:
CamelCase is easier on the eye & less chars.
I think that's a matter of what you're used to - for me, I find
underscores make it much easier to read. I find camelCase annoying.

- Seems like most of the REST APIs out there do use '_', for example:
twitter, digg, ...
- couchdb, which has the same "spirit" of API as elasticsearch, uses
'_'.
Wasn't aware of the above 2 points
- A big question is the "eval" of those json to objects. It mainly
applied to dynamic langs. Most of them use the '_' notation (perl,
ruby),
Not sure if the majority use underscores. Perl and Ruby OK. JS, no. php
anything goes, and Python looks like a mixture, depending on what the
'thing' is, eg
http://github.com/defnull/bottle/blob/master/startbottle.py
so it means simpler usage on their side (or maybe they automatically
convert CamelCase to '_' ?).
They definitely don't convert automatically, although a simple regex
would suffice, eg in Perl:
$var = 'foo_bar_baz';
$var =~ s/_(\w)/\u$1/g;
-> 'fooBarBaz'
$var=~s/([[0-9_[:lower:]])([[:upper:]])/$1_\l$2/g
-> 'foo_bar_baz'
If only dealing with ascii, then:
$var=~s/([0-9_a-z])([A-Z])/$1_\l$2/g
- As clinton mentioned, JSON is derived from javascript, and
CamelCase is the norm there. Event the JSON page on wikipedia uses
CamelCase.
yes - probably because of the java inspiration of JS.
Certainly, in my API, I'm using underscores in my methods, eg
clear_cache, delete_by_query, and something similar for the parameters
(although I'm trying to support both).
--
Web Announcements Limited is a company registered in England and Wales,
with company number 05608868, with registered address at 10 Arvon Road,
London, N5 1PR.