News for hackers. Stuff that matters.
Re:How we made Haskell search strings as fast as Rust by dmitriid on Wednesday March 13, 2019 @03:58PM (#19383055)
What actually amazes me is that... Python is good enough:

> A naive Python script that loops over all needles and calls str.find in a loop to find all matches.

> working through all 3.5 gigabytes of test data once

> Time is ~6.5s.

I love these kinds of benchmarks. They consistently show that for specialised cases you do need to drop down to C/Rust/hand-written Haskell implementations. In many-many more cases, well, even Python with a naive implementation is good enough.

Not to diss Haskell or Rust. Only saying: chose your tools as you see fit, and benchmark.

Also kudos to the authors to use mean instead of average in the graphs.

Re:How we made Haskell search strings as fast as Rust by staticassertion on Wednesday March 13, 2019 @05:35PM (#19384112)
> Firstly, the program spends most of its time in the heavily-optimized str.find function, which is implemented in C.

I'm not going to outright call this "cheating", but most of the time, virtually unconditionally, when Python is fast it's because it isn't Python, it's C.

It definitely feels worth noting that Python is radically slower than other languages, and the main "tool" it provides for improving performance is to rely on another language entirely.

Re:How we made Haskell search strings as fast as Rust by zie on Wednesday March 13, 2019 @07:05PM (#19384872)
Well Python is written IN C, at least the standard version is, so I really wouldn't call it anywhere near cheating... :).

But I don't disagree that the Python owe's it's performance to C.. it owes everything to C :)

Re:How we made Haskell search strings as fast as Rust by staticassertion on Wednesday March 13, 2019 @09:23PM (#19385715)
I think there's a very big difference between the runtime being implemented in C and the libraries being implemented in C.
Re:How we made Haskell search strings as fast as Rust by blattimwind on Thursday March 14, 2019 @08:16AM (#19388514)
Example Java: Runtime written in C++, practically all libraries written in Java, including the standard library, and Java libraries are greatly preferred.
Re:How we made Haskell search strings as fast as Rust by kachnuv_ocasek on Wednesday March 13, 2019 @04:00PM (#19383090)
> Also kudos to the authors to use mean instead of average in the graphs.

What do you mean? "Mean" with no qualification usually denotes arithmetic average (or mean).

Re:How we made Haskell search strings as fast as Rust by dmitriid on Wednesday March 13, 2019 @04:36PM (#19383469)
Argh! Confused it with median. No kudos then!
Re:How we made Haskell search strings as fast as Rust by balodja on Wednesday March 13, 2019 @05:52PM (#19384264)
> Also kudos to the authors to use mean instead of average in the graphs.

For benchmarks much better option would be geometric mean. Because the relation of the results values not the difference.

https://dl.acm.org/citation.cfm?id=5673

Re:How we made Haskell search strings as fast as Rust by jzoch on Wednesday March 13, 2019 @04:21PM (#19383343)
> even Python with a naive implementation is good enough. There is nothing naive about their implementation. 1) It uses C FFI (as many low level python functions do) 2) It uses a suboptimal but still not naive algo.

Just because it isnt identical in implementation to the other languages doesn't mean its much simpler. Its fast because enough people cared to make it that way - it wasn't by some accident

Re:How we made Haskell search strings as fast as Rust by bjoli on Thursday March 14, 2019 @03:40AM (#19387204)
That is a fragile benchmark. For simple scripts where you rely exclusively on python procedures that are written in C python is often very fast.

Once you start working on that data using procedures actually written I python performance is usually far from stellar.

I have had that happen to me many times. Back in the guile 2.0 days I tried porting some utils to python based on preliminary benchmarks that were often an order of magnitude faster than my guile ones, but when the logic was implemented the difference was gone. Then guile 2.2 (and now guile 3) happened and everything got magically faster, even though less and less of the runtime is written in C.