4 ms·
It's not quite that bad in Go, (-b + math.Sqrt(bb - 4ac)) / (2 a) though if you're using a ton of matrices it could be. I for one have found Go great for co
by howeman 13y ago
It's not quite that bad in Go,
(-b + math.Sqrt(bb - 4ac)) / (2 a)
though if you're using a ton of matrices it could be.
I for one have found Go great for computing. The really quick compile times with static checking plus the composability are great. It definitely depends though; while the native concurrency is great there aren't a lot of easy solutions for non-shared memory computations. (I saw an MPI package at one point, but I haven't tried to use it)
- howeman 13y agoSorry, new to posting on HN. How do I get asterisk literals?
- scott_s 13y agoMake sure there are spaces on both sides. Asterisk: * (plain asterisk surround by spaces). Italics: foo ('foo' surrounded by asterisks).
- prodigal_erik 13y agohttps://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc says two leading spaces formats code verbatim: (-b + math.Sqrt(b*b - 4*a*c)) / (2*a)
- sampo 13y agoLeave a whitespace after the asterisk: 1 * 2 * 3 = 6 https://news.ycombinator.com/formatdoc https://news.ycombinator.com/formatdoc
- rprospero 13y agoIt's more than just matrices, though. For instance, I have a little library that propagates uncertainty for me. Without operator overloading, I'm back to descending into the rpn hole from my example. Another poster pointed out unit analysis. I've done this before with custom types that keep track of the units on measurements. Since you mentioned parallelization, that's another fun toy I've played with. By overloading the operators for an object that defines a snippet of OpenCL code, it's possible to push these snippets through pre-existing functions and have it return a final OpenCL function. You then call that returned function on your arrays of data to run everything through your GPU with just three lines of code changes from the sequential. Operator overloading is more than just adding matrices. It's a powerful technique that comes in handy almost any time that you're working heavily with numerical data. Of course, it's also dangerous as hell in the wrong hands. The code for the OpenCL example was actually some pretty terrible code that did extremely non-intuitive things during value comparisons.
- howeman 13y agoOperator overloading can certainly do good things. Not going to argue with you there. Though, in the case of units, you can actually go a long way with that (http://play.golang.org/p/iCqB2euJj8 http://play.golang.org/p/iCqB2euJj8). It's not perfect, you have to do some function calls to multiply units of differing type correctly, but you do gain all the proper compile-time safety, and you don't need to do all sorts of method calls. What are you doing with uncertainty that you can do operator overloading with? You usually want to do Bayes rule with probabilities, but that gets intractable fast.