www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - How my little brother try D

reply Daniel Kozak <kozzi11 gmail.com> writes:
Few days ago, my little brother (13 years old) ask me about 
writing some small utility. He needed find all files with 
selected extensions and move them to some another location. He 
asked me about using D or C# for it. My answer was: try both and 
you will see which one suited you better.

After few hours he came to me and said that C# is better. When I 
asked why he answered me that in D there is no std.file.move 
method (I know there is a rename method but it is not obvious) so 
he has to use std.file.copy and std.file.remove. And when he try 
it with just std.file.copy (so he does not use remove yet) he end 
up with remove all files anyway. When std.file.copy is used with 
same src and dst (this was caused by anoher mistake) it removes 
original file and does not make the new one.

Maybe it would be nice to have alias for rename method or have 
better doc for rename. And probably we should fixed copy method 
to not remove files with same src and dst path :)
Apr 02 2016
next sibling parent reply Lass Safin <lasssafin gmail.com> writes:
On Saturday, 2 April 2016 at 21:29:27 UTC, Daniel Kozak wrote:
 Few days ago, my little brother (13 years old) ask me about 
 writing some small utility. He needed find all files with 
 selected extensions and move them to some another location. He 
 asked me about using D or C# for it. My answer was: try both 
 and you will see which one suited you better.
 [...]
 Maybe it would be nice to have alias for rename method or have 
 better doc for rename. And probably we should fixed copy method 
 to not remove files with same src and dst path :)
You're right in how it isn't obvious for non-techy people. I do suppose it would be doable without breaking any old code (unless for some arcane reason the code depends on static assert(!__traits(allMember, std.file).canFind("move"))...), so why not create a PR with "alias move = rename" inside?
Apr 02 2016
parent reply jmh530 <john.michael.hall gmail.com> writes:
On Saturday, 2 April 2016 at 22:54:09 UTC, Lass Safin wrote:
 You're right in how it isn't obvious for non-techy people. I do 
 suppose it would be doable without breaking any old code 
 (unless for some arcane reason the code depends on static 
 assert(!__traits(allMember, std.file).canFind("move"))...), so 
 why not create a PR with "alias move = rename" inside?
If I were looking at the documentation with fresh eyes, I would be just as confused as the OP's brother. It's not about being non-techy. Someone had an issue with the documentation and commenting on their inexperience won't improve the documentation. The documentation has no examples. It doesn't mention file paths at all. I.e., easy to get confused. Moreover, posix systems have mv, which can move and rename. mv is a crappy name, but at least if the function would have the same semantics as mv, they could have named it move instead of rename. Seems like a silly breaking change at this point, so they should just improve the docs.
Apr 02 2016
parent reply cym13 <cpicard openmailbox.org> writes:
On Sunday, 3 April 2016 at 03:28:48 UTC, jmh530 wrote:
 On Saturday, 2 April 2016 at 22:54:09 UTC, Lass Safin wrote:
 You're right in how it isn't obvious for non-techy people. I 
 do suppose it would be doable without breaking any old code 
 (unless for some arcane reason the code depends on static 
 assert(!__traits(allMember, std.file).canFind("move"))...), so 
 why not create a PR with "alias move = rename" inside?
If I were looking at the documentation with fresh eyes, I would be just as confused as the OP's brother. It's not about being non-techy. Someone had an issue with the documentation and commenting on their inexperience won't improve the documentation. The documentation has no examples. It doesn't mention file paths at all. I.e., easy to get confused. Moreover, posix systems have mv, which can move and rename. mv is a crappy name, but at least if the function would have the same semantics as mv, they could have named it move instead of rename. Seems like a silly breaking change at this point, so they should just improve the docs.
To be fair I've always thought that mv is a bad name because moving really is just renaming, there are no two separate operations. That said I too would have searched for "move" first exactly because as misleading as the name can be it corresponds to what the user wants to do.
Apr 03 2016
parent reply Daniel Murphy <yebbliesnospam gmail.com> writes:
On 3/04/2016 9:35 PM, cym13 wrote:
 To be fair I've always thought that mv is a bad name because moving
 really is just renaming, there are no two separate operations. That said
 I too would have searched for "move" first exactly because as misleading
 as the name can be it corresponds to what the user wants to do.
Except that's not true! Renaming doesn't (typically) work across devices.
Apr 03 2016
parent cym13 <cpicard openmailbox.org> writes:
On Sunday, 3 April 2016 at 13:24:20 UTC, Daniel Murphy wrote:
 On 3/04/2016 9:35 PM, cym13 wrote:
 To be fair I've always thought that mv is a bad name because 
 moving
 really is just renaming, there are no two separate operations. 
 That said
 I too would have searched for "move" first exactly because as 
 misleading
 as the name can be it corresponds to what the user wants to do.
Except that's not true! Renaming doesn't (typically) work across devices.
Right, thanks for pointing that out.
Apr 03 2016
prev sibling next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 4/2/2016 2:29 PM, Daniel Kozak wrote:
 And probably we should fixed copy method to not remove files with same
 src and dst path :)
https://issues.dlang.org/show_bug.cgi?id=15865
Apr 02 2016
prev sibling parent reply Jesse Phillips <Jesse.K.Phillips+D gmail.com> writes:
On Saturday, 2 April 2016 at 21:29:27 UTC, Daniel Kozak wrote:
 After few hours he came to me and said that C# is better. When 
 I asked why he answered me that in D there is no std.file.move 
 method (I know there is a rename method but it is not obvious)
Wait until he needs to rename a file in C#, then D suddenly becomes easier. Seriously though I agree, rename doesn't work across drives and Linux uses move for renaming (Windows uses rename for moving).
Apr 04 2016
parent reply Jesse Phillips <Jesse.K.Phillips+D gmail.com> writes:
On Monday, 4 April 2016 at 20:53:43 UTC, Jesse Phillips wrote:
 On Saturday, 2 April 2016 at 21:29:27 UTC, Daniel Kozak wrote:
 After few hours he came to me and said that C# is better. When 
 I asked why he answered me that in D there is no std.file.move 
 method (I know there is a rename method but it is not obvious)
Wait until he needs to rename a file in C#, then D suddenly becomes easier. Seriously though I agree, rename doesn't work across drives and Linux uses move for renaming (Windows uses rename for moving).
Oh this was the other thing I was looking for: http://stackoverflow.com/a/23231073/34435 C#'s move doesn't work across network. http://stackoverflow.com/a/20930431/34435 It also throws an exception if the file already exists instead of overwriting. And if you're in Windows you still need to worry about file locking. But D does worse there, and still has annoyances I don't recall.
Apr 04 2016
parent =?UTF-8?Q?Tobias=20M=C3=BCller?= <troplin bluewin.ch> writes:
Jesse Phillips <Jesse.K.Phillips+D gmail.com> wrote:
 Oh this was the other thing I was looking for:
 
 http://stackoverflow.com/a/23231073/34435
 
 C#'s move doesn't work across network.
That's wrong AFAIK. Tobi
Apr 05 2016