Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

when referring to 'Number Crunching', how intensive is 'intensive'?

I am currently reading / learning Erlang, and it is often noted that it is not (really) suitable for 'heavy number crunching'. Now I often come across this phrase or similar, but never really know what 'heavy' exactly means.

How does one decide if an operation is computationally intensive? Can it be quantified before testing?

Edit:

is there a difference between the quantity of calculations, the complexity of the algorithm or the size of the input values.

for example 1000 computaions of 28303 / 4 vs 100 computations of 239847982628763482 / 238742

like image 667
beoliver Avatar asked Feb 20 '23 17:02

beoliver


2 Answers

When you are talking about Erlang specifically, I doubt that you in general want to develop applications that require intensive number crunching with it. That is - you don't learn Erlang to code a physics engine in it. So don't worry about Erlang being too slow for you.

Moving from Erlang to the question in general, these things almost always come down to relativity. Let's ignore number crunching and ask a general question about programming: How fast is fast enough?

Well, fast enough depends on:

  • what you want to do with the application
  • how often you want to do it
  • how fast your users expect it to happen

If reading a file in some program takes 1ms or 1000ms - is 1000 ms to be considered "too slow"?

If ten files have to be read in quick succession - yes, probably way too slow. Imagine an XML parser that takes 1 second to simply read an XML file from disk - horrible!

If a file on the other hand only has to be read when a user manually clicks a button every 15 minutes or so then it's not a problem, e.g. in Microsoft Word.

The reason nobody says exactly what too slow is, is because it doesn't really matter. The same goes for your specific question. A language should rarely, if ever, be shunned for being "slow".

And last but not least, if you develop some monstrous project in Erlang and, down the road, realise that dagnabbit! you really need to crunch those numbers - then you do your research, find good libraries and implement algorithms in the language best suited for it, and then interop with that small library.

like image 121
Anders Arpi Avatar answered Mar 24 '23 03:03

Anders Arpi


With this sort of thing you'll know it when you see it! Usually this refers to situations when it matters if you pick an int, float, double etc. Things like physical simulations or monte carlo methods, where you want to do millions of calculations.

To be honest, in reality you just write those bits in C and use your favourite other language to run them.

like image 35
Rich Bradshaw Avatar answered Mar 24 '23 02:03

Rich Bradshaw