An example; try to sort a slice of runes.
An example; try to sort a slice of runes.
The real cost of this is definitely the verbosity for something that could be much simpler.
For me, next to everything from Microsoft is an example for a horrible api, the one from Javas standard library is rather meh and Go is pretty much the greatest thing since bread came sliced.
instead of three separate functions for len, swap and less, you'd just have one function
collection.sort(a => a.foo)
the swap and len functions are part of the collection type. the less function would be part of an interface on whatever type foo is.
it's not so much about api verbosity as not having to write the same functions over and over.
it's possible from a pure performance perspective that setting up the closures is bad but it's something i'd be willing to take for that much less code to write.
Note that I have no idea what a Rune is. But, you should check out Clojure's api. Here's a cheatsheet: http://clojure.org/cheatsheet
See also: http://stackoverflow.com/questions/6016271/why-is-it-better-...
BTW, I'd bet it takes longer to write a sort function than it does to search through api documentation and find one.
Also couldn't load the page.