A few notes on choosing between Go and D for a quick project
krzaq via Digitalmars-d
digitalmars-d at puremagic.com
Mon Mar 23 04:59:14 PDT 2015
On Monday, 23 March 2015 at 11:31:16 UTC, FG wrote:
>> And honestly, compared to
>>> File("/tmp/a").byChunk(4096).joiner.startsWith(s)
>> you can *easily* guess that you have a file - do some
>> nonobvious magic on it - and check if *it* starts with `s`
>> just by reading it as plain English.
>
> Now you've injured yourself with your own weapon. I can guess
> that File(path) opens the file for reading (probably because of
> other language libraries)
That's why I used the word "guess" ;)
> and that byChunk(size) reads it one chunk at a time (but
> frankly only because it looked similar to byLine which I've
> known before), but what the hell is joiner? Does it glue ranges
> together so that they appear as a single contiguous one? Oh,
> wait, I may have actually read about it somewhere already. But
> if I didn't, I wouldn't have a clue.
I'd argue that joiner is intuitive enough, but I agree on
byChunk. I am also baffled why this byLine/byChunk madness is
necessary at all, it should be something like
File("path").startsWith(s)
or
File("path").data.startswith(s)
The same goes for stdin, something as simple as cin >>
intvariable in C++ rises to an almost insurmountable task in D.
> What should start with s? The file, any chunk, the joiner -
> whatever it meant? It is much clearer than the loop, but I'm
> not sure I'd guess what it does, because of the two middle
> elements in the UFCS chain. This *nonobvious magic* may have
> transformed the contents of the file in a way that makes
> startsWith(s) do something different.
You're right, I didn't even think of that.
More information about the Digitalmars-d
mailing list