Does this work on Windows? #18

Closed
clintharris opened this Issue Dec 13, 2011 · 7 comments

Comments

Projects
None yet
3 participants

(Apologies if this is a dumb question.) When I installed on OSX I noticed that it compiled some C++ stuff... Assuming this means buffertools won't work on Windows?

Owner

bnoordhuis commented Dec 13, 2011

That's correct. You can, with some perseverance, get it to work on Windows (I think people compile buffertools into the node.exe) but it won't work out of the box.

bnoordhuis closed this Dec 13, 2011

Perhaps this is a poor place to ask the question, but are you aware of anything like buffertools that is Windows-compatible? Unfortunately the organization I'm working for uses Windows in production. Any advice would be appreciated.

Owner

bnoordhuis commented Dec 14, 2011

I don't think so, buffertools seems to have the market for native buffer extensions pretty much cornered. Once there is a sane build system for Windows, I'll port it but that probably won't be before v0.8 or v1.0.

What bits of buffertools do you need? There's been some talk in the past of integrating parts of buffertools into node core.

What bits of buffertools do you need?

Just the concat parts. I'm just looking for a more efficient way to append strings to one another while keeping the code simple.

There's been some talk in the past of integrating parts of buffertools into node core.

To me, concatenating strings is such a common task that having a more efficient way to do it built in to node would be a huge benefit to the community. I think some people don't even consider the downside of building strings with several + operators because they've never seen it done any other way in JavaScript. Having a "standard" way of doing this efficiently in node would perhaps encourage it as a best practice. I think that's happened with Java and StringBuffer, for example.

Thanks for taking this into consideration--I'm sure you're a busy guy.

Owner

bnoordhuis commented Dec 15, 2011

Just the concat parts. I'm just looking for a more efficient way to append strings to one another while keeping the code simple.

If you mean JS strings (as opposed to buffers) I can probably allay your fears a little. V8 is exceedingly clever when it comes to optimizing string concatenations.

A snippet like a += b + c does zero allocations, zero memory copies. V8 stores pointers to the individual strings in a tree-like structure (okay, I lied - V8 does one heap allocation for the tree structure), then operates on that. Try it, it's both fast and memory efficient.

nalbion commented Mar 18, 2015

@bnoordhuis - I'm building a gulp plugin to process (edit) test scripts. It scans through a file line by line and builds up a modified file (line by line). For large files, would your still say that V8 would be just as efficient if were to append each line to an ever-growing string?

Owner

bnoordhuis commented Mar 18, 2015

@nalbion Yes. Alternatively, you can accumulate the strings in an array, then join them once you've read all lines. Performance will be roughly on the same order as buffertools.concat() although memory usage may be a little higher if the strings contain non-ASCII. There may also be some string encoding overhead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment