5 ms·
Is that really it? Why cannot you get a marketing budget, sponsored perhaps? BTW: I am not fond of stuff like: // Sort lines import std.stdio; import s
by johnisgood 1y ago
Is that really it? Why cannot you get a marketing budget, sponsored perhaps?
BTW:
I am not fond of stuff like:
// Sort lines
import std.stdio;
import std.array;
import std.algorithm;
void main()
{
stdin
.byLine(KeepTerminator.yes)
.uniq
.map!(a => a.idup)
.array
.sort
.copy(stdout.lockingTextWriter());
Are there any ways to do this that do not involve a bunch of "."s? I do not understand "map!" and "a.idup" either, FWIW.
I really want to like D, but it tries to do too many things all at once, in my opinion.
Perhaps I will give C3 a fair try.
- WalterBright 1y agoThat code is an example of f(a) being equivalent to a.f(). You can do it the f(a) way if you prefer. `map` is an operation on a data structure that replaces one element with another, in this case `a` gets replaces with `idup(a)`. The `idup` makes a copy of its argument in memory, and marks the data is immutable.
- johnisgood 1y ago> That code is an example of f(a) being equivalent to a.f(). You can do it the f(a) way if you prefer. How would it look like with this particular code? Just for comparison. > The `idup` makes a copy of its argument in memory, and marks the data is immutable. How is one supposed to know this? Reading the documentation? I really want to look at the code and be able to know straight away what it does, or have a rough idea.
- zdragnar 1y agoSee https://en.m.wikipedia.org/wiki/Uniform_function_call_syntax https://en.m.wikipedia.org/wiki/Uniform_function_call_syntax - the examples section has two side by side. The Nim language version is also pretty readable even if you're not familiar with it. As for idup... The first several search results for "dlang idup" are all useful. > I really want to look at the code and be able to know straight away what it does, or have a rough idea. I presume you really don't like perl, ML based (ocaml, f sharp, rust) Haskell or K.
- johnisgood 1y agoI love Perl[1] and OCaml. I dislike the rest. It depends on the task. [1] https://news.ycombinator.com/item?id=44359539 https://news.ycombinator.com/item?id=44359539 > As for idup... The first several search results for "dlang idup" are all useful. Yes, I am sure it was, I am sure an LLM would have helped too, but I think that is besides the point here.
- zdragnar 1y agoIs it beside the point? Looking at that perl example: $string =~ s/\d+/NUM/g; I don't have a clue what is going on. Sure, I see the regex, but what is =~ doing? There's only so far you can stretch most languages before you need to actually put in effort to learn them.
- johnisgood 1y ago"=~" is the operator testing a regular expression match. It should be obvious, because on the right side you see regex, and you ought to know what "=" or "==" does. FWIW, I knew this as a kid, too, despite knowing absolutely nothing about the language at the time. Anyways, you should read https://news.ycombinator.com/item?id=44463391 https://news.ycombinator.com/item?id=44463391 if you care about why I dislike the way D does it.
- quietbritishjim 1y ago> > That code is an example of f(a) being equivalent to a.f(). You can do it the f(a) way if you prefer. > How would it look like with this particular code? Just for comparison. I do not know how to write D, so the following might not compile, but it's not hard to give it a go: copy(sort(array(map!(uniq(byLine(stdin, KeepTerminator.yes)), a => idup(a)))), stdout.lockingTextWriter()) > > The `idup` makes a copy of its argument in memory, and marks the data is immutable. > How is one supposed to know this? Reading the documentation? I really want to look at the code and be able to know straight away what it does, or have a rough idea. Are you serious? You are offended by the idea of reading documentation?This is not helping the credibility of your argument. Again, I'm not a D user, but this is just silly.
- johnisgood 1y ago> Are you serious? You are offended by the idea of reading documentation?This is not helping the credibility of your argument. Again, I'm not a D user, but this is just silly. If you knew me, and you read my comment history, you would have NEVER said that. It is not even a matter of reading the documentation or not. "idup" seems arbitrary, sorry, I meant the whole line sounds arbitrary. Why "a"? Why "a.idup"? Why "map!"? I was asking genuine questions. You do not have to bash me and see ghosts. I was curious as to why it was implemented the way it was. I am an active speaker against people who hate reading the documentation. And FYI, I love Perl[1] and OCaml[2]. [1] https://news.ycombinator.com/item?id=44359539 https://news.ycombinator.com/item?id=44359539 [2] You would have to check the comment history.
- quietbritishjim 1y agoI think perhaps you are not realising the negative tone of your comments. There is no way to read "How is one supposed to know this? Reading the documentation?" except sarcasm. No amount of good faith in unrelated comment threads changes this. I believe that's why you're getting downvoted - not because people are easily offended about D, as you seem to believe.
- johnisgood 1y ago
- spacechild1 1y ago> Reading the documentation? Yes? > I really want to look at the code and be able to know straight away what it does, or have a rough idea. You said elsewhere that you love Perl. Would you say your sentence above applies to Perl?
- johnisgood 1y agoIt does not, but Perl is a much older language, and I have familiarized myself with it through actual discourses regarding its syntax, implementation details, and so forth. But in this thread? All I got was wrongful accusations and down-votes. I am done replying to this thread. Should have just let Walter reply, but that was not enough for you people, was it? Funny though, because most of the things these people accuse me of are dead wrong, and my comment history is proof of that. In fact, I have been down-voted to oblivion for telling people to read the documentation. I guess we may have come full circle. Glad we had this utterly pointless chat.
- spacechild1 1y agoI'm not a D user and I don't have a ball in this game. I just found your critique of D's syntax rather odd because it can be applied to basically any language one is not already familiar with. Maybe I'm wrong, but I don't think my response was particularly rude...
- johnisgood 1y agoI mean, to me it just looks ugly. Perhaps written in a different way, it would have been better. I have seen Haskell and Elixir code, but they were much less ugly. Then again, it is entirely subjective, and we should not argue about taste. To each their own.
- p0nce 1y agoI don't think you're wrong, I have used D for 19 years and don't really use the UFCS dot style, it requires too much context. Just loops are more readable. In D you don't have much decisions forced on you tbh.
- johnisgood 1y agoI appreciate it.
- gallier2 1y agoI just wrote a somewhat bigger program in D and I mostly used UFCS chains for the toString() overrides to have better debug outputs. There are also some idiomatic forms that are frequent like conversion bar = foo.to!int is much more readable than bar = to!int(foo)
- sureglymop 1y agoSo it's basically a pipe or like the pipe operator in some languages? Looks interesting.
- JdeBP 1y agoIt has a fairly direct analogy in some languages. A C♯ programmer reading the above will immediately recognize the analogy to .Select(), .ToArray(), and so forth from LiNQ. * https://learn.microsoft.com/en-gb/dotnet/api/system.linq.enumerable.select https://learn.microsoft.com/en-gb/dotnet/api/system.linq.enu... * https://learn.microsoft.com/en-gb/dotnet/api/system.linq.enumerable.toarray https://learn.microsoft.com/en-gb/dotnet/api/system.linq.enu...
- WalterBright 1y agoYup, it looks and behaves very much like Unix piping.
- deleted 1y ago[deleted]
- vips7L 1y agoYou don’t like instance functions?
- johnisgood 1y agoI do not like this in particular: stdin .byLine(KeepTerminator.yes) .uniq .map!(a => a.idup) .array .sort .copy(stdout.lockingTextWriter()); I would like to emphasize that this is a personal preference. No need to continue to bash me over it. I prefer Elixir's |> operator, if you want an example of something I prefer.
- amiga386 1y agoAnd yet... Perl is good with its chained operators acting on lists? print join '', sort { $a cmp $b } grep { !$seen{$_}++ } # = uniq <STDIN>;
- johnisgood 1y agoI do not write such Perl code, but I have in the past.
- johnisgood 1y agoOh and by the way, it does not look that different from that of Rust. :) I have came across a lot of Rust projects.
- vips7L 1y agoWhat’s the difference? stdin |> byLine(yes) |> uniq |> map(a => aidup) |> array |> sort |> copy(stdout) I’m sorry if you took it as bashing. It’s mere curiosity as I’ve never seen that preference before.
- johnisgood 1y agoIs it a fair comparison? Would it work in Elixir? I have not seen it in Elixir projects as such.
- johnisgood 1y agoLook, I will not comment on D any further because it seems like it gets down-voted for no reason. Take your positive comments if you so wish, no need to down-vote the ones that express different opinions. You won. I will not be commenting on it any further. I shall NEVER be expressing my opinions on this language, nor will I ever raise any questions regarding the motivation for its implementation details. People are too quick to use the "down-vote" button, and are too quick to judge. I love documentation, I write them. I am an active speaker against people who hate reading the documentation. This was not a case against reading documentation, yet people - wrongfully - believed so. People always glance past things like: "not fond of", and "in my opinion". It is tiresome. This thread could have been educational, but instead it was a thread meant to bash me. It is my fault.