Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

function naming convention #81

Closed
andrewdeandrade opened this issue Jun 27, 2014 · 11 comments
Closed

function naming convention #81

andrewdeandrade opened this issue Jun 27, 2014 · 11 comments

Comments

@andrewdeandrade
Copy link

This is a total bikeshedding issue (see Wadler's Law), so feel free to close this, but I was curious why you didn't use standard JavaScript function/method naming conventions with the mori API. I searched the open and closed issues and found nothing.

For example, why mori.is_list instead of mori.isList? It follows neither a normal JavaScript naming convention (camelCase) nor the Clojure function naming convention (kebab-case) (because that syntax would not accessible via dot notation). Is this the result of a default in the clojurescript compiler?

I can't help but imagine the gut reaction my colleagues would have to seeing snake_case appearing over any shared codebase I contribute to. Obviously this isn't going to stop me from experimenting and using mori, because it looks like an excellent library, but it's really funky to have all your code and all your libraries use the same naming conventions as ECMA-262, except for one.

Given that mori.js is transpiled from clojurescript code to JavaScript, I reckon it should be possible to define which naming convention you want used in the generated code. Is this already possible with the clojurescript compiler? I looked at the sample options for lein-cljsbuild and didn't see anything there for defining the naming convention (https://github.com/emezeske/lein-cljsbuild/blob/1.0.3/sample.project.clj)

@aearly
Copy link
Contributor

aearly commented Jul 6, 2014

Haha, +1 for the bikeshedding issue. Initially, I too was a bit taken aback by the snake_case, but seeing as mori is quite different from other JS libs, the naming convention seems to suit it. Seeing update_in rather than updateIn does give me pause, but in that pause it makes me think harder about what is actually going on.

@nathansobo
Copy link

It's unfortunate, but aesthetics matter, and this convention just doesn't blend in with the typical JS naming conventions. Despite how awesome this library seems to be, I'm somewhat reluctant to incorporate it into Atom because I don't want to introduce naming inconsistency to the API.

@andrewdeandrade
Copy link
Author

@nathansobo FWIW, immutable.js was just released by someone at Facebook. It was inspired by mori, but with a more JS friendly API. https://github.com/facebook/immutable-js HN discussion: https://news.ycombinator.com/item?id=8107447

@tgriesser
Copy link
Contributor

Or you could always module.exports = require('camelize')(require('mori'))

@swannodette
Copy link
Owner

@tgriesser nice

@nathansobo
Copy link

After thinking on my previous comment, I hope I didn't come of as complaining. Just wanted to provide feedback on this point. I'm a big admirer of your work @swannodette.

@andrewdeandrade
Copy link
Author

@nathansobo plus, to be fair, this isn't even a decision @swannodette made. Basically decisions in lein-cljsbuild are the reason for the funky naming convention.

@swannodette
Copy link
Owner

@nathan7 no worries. It's an occasional complaint, but Mori is now an old mostly unidiomatic JavaScript library and I don't really see the value in changing things up at the moment. I think there's value in immutable code sticking out for now - I might change my mind in the future which is why I haven't closed this ticket.

@swannodette
Copy link
Owner

@malandrew that's not actually true. Early on (> 2 years) back when hardly anybody in the JavaScript community was interested in immutable data structures I decided to use underscores simply to make the API stick out.

@cemerick
Copy link

@malandrew Just to further clarify: lein-cljsbuild is really just a thin leiningen shell around the various options provided by the ClojureScript compiler. It doesn't affect or impact naming in any way.

@swannodette
Copy link
Owner

fixed in master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants