graue
Joined 14 years ago
Joined 14 years ago
var fooString = "foo";
var secondFooString = fooString;
secondFooString; // => "foo"
fooString = "bar";
secondFooString; // => "foo"
We set the variable fooString to point to a different string, but the original, underlying string hasn't changed. In JavaScript, we can think of a string as a value.This is not the case with arrays in JavaScript:
var firstArray = [1, 2, 3];
var secondArray = firstArray;
firstArray[0] = 100;
firstArray; // => [100, 2, 3]
secondArray; // => also [100, 2, 3]
Because we can change the underlying contents of the array, an array in JavaScript isn't a value. It's a place: a reference to a location in memory. The underlying value could be changed at any time.But, using Mori, collections are values, just like strings:
var firstVec = m.vector(1, 2, 3);
var secondVec = firstVec;
firstVec = m.assoc(firstVec, 0, 100);
firstVec; // => [100, 2, 3]
secondVec; // => still [1, 2, 3]
Instead of modifying firstVec in place, mori.assoc creates a new vector that is identical to firstVec except for the change we want. We then assign the result to firstVec. secondVec is unchanged. We are unable to go in and change the underlying values because a vector is a value, not a place.The most obvious way to build this would be to deep-copy the entire collection when it's changed, but that would of course be way too slow and wasteful — imagine copying a one-million-long array just to change one element. Clojure, ClojureScript and Mori minimize unnecessary copying using a very thoughtfully designed data structure you can read about here: http://hypirion.com/musings/understanding-persistent-vector-... The short story is that, surprisingly, you get "effectively O(1)" copying when you use assoc.
While Clojure surely has a bigger learning curve than Go, it's much simpler and more approachable than Scala. I've learned it recently and am an absolute convert. It seems perfect for your use case and you could even skip writing the prototype in Rails because you'll be just as productive in Clojure.
Note that I'm not trying to convince you to change; you obviously found something that works for you. But I am curious if there were obstacles to using Clojure (missing libraries? poor tutorials?) and if so, how that could be fixed.
However, I'm surprised that you single out a 40-hour work week as though it's something exceptional. Isn't that the standard? I would never consider joining a company that expected me to work weekends. I hope that's not as common as you imply.
Only in a naive implementation. Clojure, for example, has a persistent vector that only requires O(log32 n) copying, which grows so slowly as to be effectively O(1).
See: http://hypirion.com/musings/understanding-persistent-vector-...
https://en.wikipedia.org/wiki/Singular_they
Some object to the usage because:
> Proponents of gender-neutral language argue that the use of gender-specific language often implies male superiority or reflects an unequal state of society. According to The Handbook of English Linguistics, generic masculine pronouns and gender-specific job titles are instances "where English linguistic convention has historically treated men as prototypical of the human species." Words that refer to women often devolve in meaning, frequently taking on sexual overtones.
> These differences in usage are criticized on two grounds: one, that they reflect a biased state of society, and two, that they help to uphold that state. Studies of children, for instance, indicate that the words children hear affect their perceptions of the gender-appropriateness of certain careers. Other research has demonstrated that men and women apply for jobs in more equal proportions when gender-neutral language is used in the advertisement, as opposed to the generic he or man.
https://en.wikipedia.org/wiki/Gender-neutral_language_in_Eng...
Many years ago, I would have agreed with you that using "he" as neuter was correct and therefore preferable to singular "they". I no longer feel that way. I'd attribute that change in opinion to two causes:
One, I'm less concerned with by-the-book "correctness" and pedantry, and more concerned with the real-world effect my words have on people.
Two, I now realize that English is a living, evolving language, and there is no one authority on what is or is not correct usage. What is widely held to be proper English at a given time is a product of who happened to have influence in society at that time, no more, no less.
Also, although this is not what changed my opinion, I find it interesting to note that many of the same people who call the matter trivial will also expend considerable time and effort defending generic "he". If you find it so trivial, why not humor the people who think gender-neutral language is important?
https://scott.mn
email: scott@<the above domain>
https://twitter.com/graue
https://github.com/graue