7 ms·
These articles seem like they're playing code golf more than proving anything as a viable alternative to C. The goal is to analyze your needs and pick the lang
by jimbob45 7y ago
These articles seem like they're playing code golf more than proving anything as a viable alternative to C.
The goal is to analyze your needs and pick the language best suited to your task. The goal is not to find one language that excels at everything.
- zopppo 7y agoI could be wrong, but it seems like it wouldn't be difficult to outperform these implementations with a similarly hacky C implementation. I expect that blog post in the coming days.
- phaemon 7y agoWhy wait?! Do your "Beating C with C" blog post and enjoy your HN fame!
- barbegal 7y agoIt's mentioned in the post https://github.com/expr-fi/fastlwc/ https://github.com/expr-fi/fastlwc/
- zopppo 7y agoAh, I didn't see that. Thanks!
- ajeetdsouza 7y agoHey, author here. You are absolutely right - Go would have a hard time outperforming finely tuned C. Rather, the article was more focused on exploring concurrency mechanisms in Go. The (admittedly clickbait) title was more of a reference to the articles before it than anything else. That said, I think you'll find this SIMD-enhanced wc interesting: https://github.com/expr-fi/fastlwc/ https://github.com/expr-fi/fastlwc/
- manningthegoose 7y agoI actually disagree. If you look at the code written in the article, it's hardly unreadable or very code golf-y as you suggest. I think the author is really just trying to say that programmers shouldn't dismiss Go as a possible systems language in favor of C just because C has a reputation of being faster in all cases.
- dijit 7y agoAre we really saying a garbage collected language should be considered for a systems language? I know the GC is fast but surely memory managed languages are going to have less issues with pausing during execution, no?
- zenhack 7y agoRe: pause times, Go's garbage collector is actually really good here; you're looking at 10s of microseconds. I'm convinced the term "systems language" doesn't have a coherent meaning at this point. See: https://zenhack.net/2018/07/14/three-funerals-in-the-name-of-clarity-3-systems.html https://zenhack.net/2018/07/14/three-funerals-in-the-name-of...
- pleasecalllater 7y agoI always thought the GC pause depends on the heap size... a little searching... http://big-elephants.com/2018-09/unexpected-gc-pauses/ http://big-elephants.com/2018-09/unexpected-gc-pauses/.
- naikrovek 7y agoIt depends on how many things need to be collected, which is often a function of heap size.
- __d 7y agoRight, so when I’m trying to process a network packet in about a microsecond (a reasonable target for financial trading software), Go’s GC rules it out. Many low-level, high-performance systems language tasks aren’t feasible in Go for similar reasons. That doesn’t make it a bad language, but it’s not universally applicable either.
- ajeetdsouza 7y agoAuthor here. Why do you feel it is code golf? My primary focus when writing it was readability - I'm sure I could do it in much less than 70 lines if I had to. If you have any suggestions for improving the readability of my implementation, do let me know!
- cjensen 7y agoThe version you are comparing against is ancient and assumes a low-memory footprint. It only uses something like 10KB of data. It also has a ton more features -- like command line parsing, the ability to read from a file on the command line or stdin, and locale-specific recognition of whitespace. It's really not solving the same problem.
- ajeetdsouza 7y agoArgument parsing is hardly the bottleneck when you're scanning 1 GB of data. The reason I didn't implement the rest of the features was to keep the implementation light and readable, and I don't think a fully compliant wc implemented in Go with these patterns would be significantly slower. As for having a low-memory footprint, 2 of the 4 implementations I mentioned (one single core, one multi-core) consume less memory than wc, and still run much faster.
- aikah 7y agoHow much memory does your program uses VS the C program? Did you profile that?
- Someone 7y agoFTA: ”Our parallelized implementation runs at more than 3.5x the speed of wc, while matching its memory consumption”
- strange_aeons 7y agoYes, it's the last column in all the result tables.