Charles already pointed out well why it is beneficial to stick with the functional approach. It takes some time to comprehend the functional coding paradigm, but it really helps to write better code in general, even in imperative languages! Well, at least it helped me.
However, as mentionned above, I will have most probably to include JAVA librairies into my modules (maths), and might loose overall Immutability through these as well.
If you write your own Java Module, and if the result of a function is always the same for a given input, you can annotate this function as "deterministic" [1] (which should be the case for most mathematical operations, except creating random numbers). This way, it will be rewritten and optimized similar to native XQuery code.
Christian
[1] http://docs.basex.org/wiki/Java_Bindings#Context-Awareness ___________________________________
2013/11/12 Charles Duffy charles@dyfis.net
On Tue, Nov 12, 2013 at 3:05 PM, jean-marc Mercier jeanmarc.mercier@gmail.com wrote:
Thus I could use maps to simulate HashSet, it not a very big overload. However, is there any incentive to trade off 20% performance ?
Immutability is its own reward, or, rather, comes with its own set of them. :)
Working with immutable data makes lock-free thread-safety comparatively trivial, and enables a wide array of aggressive optimizations (including providing the compiler the option to make operations concurrent at-will; safe caching/memoization; etc).
Moreover, introducing things that *aren't* known to be immutible, thread-safe, deterministic operations into an environment where those guarantees otherwise exist means that a lot of optimizations are suddenly off-the-table / unsafe.
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk