data structures - most suitable language for computationally and memory expensive algorithms -
let's have implement tool efficiently solve np-hard problem, unavoidable possible explosion of memory usage (the output size in cases exponential input size) , particularly concerned performances of tool @ running time. source code has readable , understandable once underlying theory known, , requirement important efficiency of tool itself.
i think 3 languages suitable these 3 requirements: c++, scala, java. provide right abstraction on data types makes possible compare different structures or apply same algorithms (which important) different data types.
c++ has advantage of being statically compiled , optimized, , function inlining (if data structures , algorithms designed carefully) , other optimisation techniques it's possible achieve performance close of pure c while maintaining readability. if put lot of care in data representation can optimise cache performance, can gain orders of magnitude in speed when cache miss rate low.
java instead jit compiled, allows apply optimisations during runtime, , in category of algorithms have different behaviours between different runs, may plus. fear instead such approach suffer garbage collector, in case of algorithm it's common continuously allocate memory , java heap performance notoriously better c/c++ , if implement own memory manager inside language achieve efficiency. approach instead not able inline method invocation (which induces huge performance penalty) , doesn't give control on cache performance. among pros there's better , cleaner syntax c++.
my concerns scala more or less same java, plus fact can't control how language optimised unless have deep knowledge on compiler , standard library. well: clean syntax :)
what's take on subject? have had deal already? implement algorithm such properties , requirements in of these languages or suggest else? how compare them?
usually i’d “c++” in heartbeat. secret being c++ produces less (memory) garbage needs managing.
on other hand, observation that
however in case of algorithm it's common continuously allocate memory
is hint java / scala may more suited. use small object heap in c++ well. boost has 1 uses standard allocator interface, if memory serves.
another advantage of c++ use of abstraction without penalty through templates – i.e. can create generic algorithmic components can interact without incurring runtime overhead due abstraction. in fact, noted that
it's possible achieve performance close of pure c while maintaining readability
– looking @ things wrong way: templates allow c++ achieve performance superior of c while still maintaining high abstraction.
Comments
Post a Comment