Re: My Meeting C++ Keynote video is now available
On 1/15/2019 11:08 PM, Nicholas Wilson wrote: I'm pretty sure Jacob is talking about a completely different type of macro (i.e. not textual substitution), AST macros. I understand he means AST macros, but they aren't fundamentally different in the characteristic I'm talking about. I'd be interested to see how close we could get if we allowed mixin template to contain expression as well as declarations (obviously these could only be instantiated in function contexts). Anyway something to play around with at DConf. I won't discourage you to play around with it, but I don't think it's what D needs in the near future.
Re: My Meeting C++ Keynote video is now available
On 2019-01-16 08:08, Nicholas Wilson wrote: I'm pretty sure Jacob is talking about a completely different type of macro (i.e. not textual substitution), AST macros. Yeah, I should come up with a new name than "macro". A soon as Walter sees the word "macro", regardless of its meaning in the context, he will throw his hands in the air and run the other way. -- /Jacob Carlborg
Re: My Meeting C++ Keynote video is now available
On 1/15/2019 11:39 AM, 12345swordy wrote: If there were a dip that involves deprecating class, I wouldn't worry about that getting very far :-)
Re: My Meeting C++ Keynote video is now available
On 2019-01-16 06:32, Walter Bright wrote: You deliberately wrote that, and I'm confident you'd never try to pass that off as good work. Yes. I'm showing it's possible to write bad code in all programming languages with all (most) features. Macros are not required for that. With macros, however, programmers are convinced they are creating models of clarity. I've seen programmers truly believe: #define BEGIN { #define END } improves their C code. Fortunately, that was ridiculed out of existence in the 1980s, but the more subtle abuses persist with their ardent defenders. I used to use a lot of macros in my C code, and a few years back made an effort to remove them all from the dmd source code. The result was very satisfactory. I've seen entire code bases abandoned because of macros after the original developer left. D has done a great job of replacing the C preprocessor with alternative features. These include: "import", "debug" and "version". These features are great and don't need much improvement. They take care of the stuff that is really difficult to avoid the preprocessor in C for. Then we have the other stuff: macros. To insert code at the instantiation point. For this, D has string mixins and template mixins. This is where D is lacking some features. For example, it's not possible to insert a symbol with a string mixin that the surrounding scope at the instantiation point cannot access. For example, you want to insert two symbols, but the surrounding code should only have access to one of the symbols, the other one is a helper symbol to the first one. This is not possible today. Unfortunately that doesn't stop anyone from trying to come up with there own workarounds and solutions, like generating some obfuscated symbol name. It's not gonna make it less accessible, just less likely to collide with an existing symbol. It's also not possible to insert a symbol that refers to another symbol in another module without risking a symbol conflict in the local scope. There's a word for this, mixins are not hygienic. While D improves a lot on the C preprocessor it didn't reach all the way to cross the finish line. -- /Jacob Carlborg
Re: My Meeting C++ Keynote video is now available
On Monday, 14 January 2019 at 10:18:34 UTC, Martin Tschierschke wrote: This is exactly the argument to get a database driver (mysql,postgres...) and probably a webserver in std. Absolutely not! Please... IMHO, what needs to be in std are just APIs (modules, interfaces, declarations)... Leave the implementations elsewhere please. Standard library is already too large for my taste! What should be in std are just core stuff that is needed everywhere. However, the REFERENCE IMPLEMENTATIONS of these APIs could be, and in fact SHOULD be, in a set of higher-level implementation libraries that should be developed by the D Foundation, and available on the dlang.org for downloads. (part of some kind of Standard Library Suite)
Re: My Meeting C++ Keynote video is now available
On Wednesday, 16 January 2019 at 11:35:15 UTC, Dejan Lekic wrote: On Monday, 14 January 2019 at 10:18:34 UTC, Martin Tschierschke wrote: This is exactly the argument to get a database driver (mysql,postgres...) and probably a webserver in std. Absolutely not! Please... IMHO, what needs to be in std are just APIs (modules, interfaces, declarations)... Leave the implementations elsewhere please. Standard library is already too large for my taste! What should be in std are just core stuff that is needed everywhere. Depends on what you consider core stuff. I don't think webserver should be a part of the standard library, but I think stuff like sockets, XML and JSON should. Serialization? Debatable. Database driver? Maybe not specific backends, but there could be a generic driver interface.
Re: My Meeting C++ Keynote video is now available
On 1/15/19 4:37 AM, Martin Tschierschke wrote: On Monday, 14 January 2019 at 18:52:02 UTC, Jacob Carlborg wrote: On 2019-01-14 15:42, Steven Schveighoffer wrote: That's a bad example :) The clear answer is mysql-native, which is what vibe.d recommends. Exactly, and I don't need five minutes for that. Five seconds is enough :) Ok, bad example, but let's say you want ORM mapping, too and to have the ability to switch to Postgres later? So what would you recommend? I should have said that your point is mostly correct, just that this is a bad example :) I've looked for ORM on code.dlang.org, and never found one yet that I liked. So the answer would take infinite seconds to complete. But let's say we put ORM into Phobos. Certainly, it would get heavy use, but I would be likely to believe that it would not cover the problem space completely, and leave quite a bit to be desired. I think that there are some things that can go into the standard library and live there happily. There are other things that should be left to the community, even though they are essential, simply because locking into one implementation/API/idea is too restrictive. -Steve
Re: hunt library 1.0.0 released!
On Wednesday, 16 January 2019 at 06:57:13 UTC, Brian wrote: we found that the performance of vibed was not as good as that of other programming languages. Chances are you've used it wrong then. To me at least it performs better than any alternatives.
Re: My Meeting C++ Keynote video is now available
On Wednesday, 16 January 2019 at 14:59:20 UTC, Steven Schveighoffer wrote: On 1/15/19 4:37 AM, Martin Tschierschke wrote: [...] I should have said that your point is mostly correct, just that this is a bad example :) I've looked for ORM on code.dlang.org, and never found one yet that I liked. So the answer would take infinite seconds to complete. But let's say we put ORM into Phobos. Certainly, it would get heavy use, but I would be likely to believe that it would not cover the problem space completely, and leave quite a bit to be desired. I think that there are some things that can go into the standard library and live there happily. There are other things that should be left to the community, even though they are essential, simply because locking into one implementation/API/idea is too restrictive. -Steve +1 I'm waiting, for example, for a revamp of IO, just to start... --- Paolo
Re: My Meeting C++ Keynote video is now available
On 1/16/19 10:06 AM, Paolo Invernizzi wrote: I'm waiting, for example, for a revamp of IO, just to start... We're working on it... https://github.com/schveiguy/iopipe https://github.com/MartinNowak/io -Steve
Re: My Meeting C++ Keynote video is now available
On Wednesday, 16 January 2019 at 16:30:17 UTC, Steven Schveighoffer wrote: On 1/16/19 10:06 AM, Paolo Invernizzi wrote: I'm waiting, for example, for a revamp of IO, just to start... We're working on it... https://github.com/schveiguy/iopipe https://github.com/MartinNowak/io -Steve I was exactly referring to that two... they are great, and I've used both! Despite that, they seem stalled: any plan to go ahead in the medium term? Thanks for your work (and to Martin too) --- Paolo
Re: My Meeting C++ Keynote video is now available
On 1/16/19 11:43 AM, Paolo Invernizzi wrote: On Wednesday, 16 January 2019 at 16:30:17 UTC, Steven Schveighoffer wrote: On 1/16/19 10:06 AM, Paolo Invernizzi wrote: I'm waiting, for example, for a revamp of IO, just to start... We're working on it... https://github.com/schveiguy/iopipe https://github.com/MartinNowak/io I was exactly referring to that two... they are great, and I've used both! Despite that, they seem stalled: any plan to go ahead in the medium term? Slowly... Sorry, it's not my day job to improve these :) But I am working currently on an http client using iopipe (https://github.com/schveiguy/httpiopipe) and improving/releasing the json parser that I wrote for my talk 2 years ago (https://github.com/schveiguy/jsoniopipe). Hint: I hope to have a working REST client soon. I also have a library that's stalled, but I have to pick it up again in order to deal with parsing using ranges (not yet published). I think in order to make this more palatable, though, we really do need to focus on the io base with some sort of async fiber-based driver. Thanks for your work (and to Martin too) You're welcome! Thanks for the kind words. It's actually one of the more fun projects I have worked on. -Steve
B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)
On Saturday, 12 January 2019 at 15:51:03 UTC, Andrei Alexandrescu wrote: https://youtube.com/watch?v=tcyb1lpEHm0 Now as to the talk, as you could imagine, it touches on another Somebody on the C++ side has written a reply https://brevzin.github.io/c++/2019/01/15/if-constexpr-isnt-broken/ Although looking at the implementation of std::conditional in the type_traits header makes me sad... I would love to see the whole checkedint thing in C++ side by side with the d code (and generated -Os object code). Conversely I'd love to see a Rust implementation too :-) Given that I have probably written a lot more C++ code in my life than d... ...I do find it remarkable that I can read the d code quite easily without reaching for the reference manual, but to make sense of his C++, it sends me trawling around cppreference.com I find Andrei's claim that checkint with a void hook reverts to int is amazing, and would love to verify that at the assembly level for both the C++ and d implementations.
Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)
On Wed, Jan 16, 2019 at 11:43:19PM +, John Carter via Digitalmars-d-announce wrote: [...] > Given that I have probably written a lot more C++ code in my life than > d... > > ...I do find it remarkable that I can read the d code quite easily > without reaching for the reference manual, but to make sense of his > C++, it sends me trawling around cppreference.com Yes, that's one of the outstanding qualities of D, and one that I was immensely impressed with when I perused the Phobos source code for the first time. After having (tried to) read glibc's source code (if you never have, I advise you not to unless you're a jaded, hardened, hardcore C professional -- it's *not* for the faint of heart), it was like a breath of fresh air. D does have its warts and dark corners, but I think on the readability front it has scored a home run compared to the equivalent C/C++ code. > I find Andrei's claim that checkint with a void hook reverts to int is > amazing, and would love to verify that at the assembly level for both > the C++ and d implementations. This is actually quite trivial in D. I'm too lazy to actually check the checkedint source code, but I'd surmise it's something as simple as: template CheckedInt(alias hook) { static if (is(typeof(hook) == void)) alias CheckedInt = int; else { struct CheckedInt { ... // actual CheckedInt implementation here } } } or something along these lines. Standard D practice. (I daren't even try to imagine what I'd have to do to make this work in C++. After having worked with C++ for about 2 decades or so, I don't have many good things to say about it, nor do I expect very much from it anymore.) T -- Windows 95 was a joke, and Windows 98 was the punchline.
Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)
On 1/16/2019 3:43 PM, John Carter wrote: Somebody on the C++ side has written a reply https://brevzin.github.io/c++/2019/01/15/if-constexpr-isnt-broken/ From the article: D (with corrections): static if (maxLength < 0xFFFE) { alias CellIdx = uint16_t; } else { alias CellIdx = uint32_t; } C++: static constexpr auto get_type() { if constexpr (maxLength < 0xFFFE) { return type; } else { return type; } } using CellIdx = decltype(get_type())::type; 1. you've got to write a function separately for every declaration you want to declare in a conditional. Imagine doing 4 or 5 of these. 2. imagine this: static if (condition) int x; ... static if (condition) ++x; The C++ idiom would require (along with creating another function) creating a dummy x declaration for the (omitted) else branch of the static if. Doable, but ugly. It kinda reminds me of the C diehards who showed you can write virtual function dispatch in C. It's remarkable that these things can be done in C++, but the amount of "noise" and "boilerplate" in the solutions make them pretty hard to read.
Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)
On 1/16/2019 4:19 PM, H. S. Teoh wrote: On Wed, Jan 16, 2019 at 11:43:19PM +, John Carter via Digitalmars-d-announce wrote: ...I do find it remarkable that I can read the d code quite easily without reaching for the reference manual, but to make sense of his C++, it sends me trawling around cppreference.com Yes, that's one of the outstanding qualities of D, and one that I was immensely impressed with when I perused the Phobos source code for the first time. Bartosz Milewski is a C++ programmer and a Haskell fan. He once gave a presentation at NWCPP where he wrote a few lines of Haskell code. Then, he showed the same code written using C++ template metaprogramming. The Haskell bits in the C++ code were highlighted in red. It was like a sea of grass with a shrubbery here and there. Interestingly, by comparing the red dots in the C++ code with the Haskell code, you could understand what the C++ was doing. Without the red highlighting, it was a hopeless wall of < > :-) Since I mention Bartosz, I should link to his blog: https://bartoszmilewski.com/
Re: B Revzin - if const expr isn't broken (was Re: My Meeting C++ Keynote video is now available)
On Thursday, 17 January 2019 at 01:59:29 UTC, Walter Bright wrote: Bartosz Milewski is a C++ programmer and a Haskell fan. He once gave a presentation at NWCPP where he wrote a few lines of Haskell code. Then, he showed the same code written using C++ template metaprogramming. The Haskell bits in the C++ code were highlighted in red. It was like a sea of grass with a shrubbery here and there. Interestingly, by comparing the red dots in the C++ code with the Haskell code, you could understand what the C++ was doing. Without the red highlighting, it was a hopeless wall of < > :-) Since I mention Bartosz, I should link to his blog: https://bartoszmilewski.com/ It was an article on Bartosz's blog where I first found out about D. I think this was the first one: "The more things change, the more we need “immutable”" https://bartoszmilewski.com/2009/01/
Re: hunt library 1.0.0 released!
On Wednesday, 16 January 2019 at 15:04:55 UTC, bauss wrote: On Wednesday, 16 January 2019 at 06:57:13 UTC, Brian wrote: we found that the performance of vibed was not as good as that of other programming languages. Chances are you've used it wrong then. To me at least it performs better than any alternatives. We will not compare with vibed, because vibed cannot meet our use needs.
hunt-grpc 0.1.1 released! (Google gRPC for D)
Google gRPC is A high performance, open-source universal RPC framework. You can find it here: https://grpc.io/ hunt-grpc is a GRPC framework developed in D language. The new version mainly supports two-way communication and fixes some known errors. Example for server: ```D import helloworld.helloworld; import helloworld.helloworldrpc; import grpc; class GreeterImpl : GreeterBase { override Status SayHello(HelloRequest request , ref HelloReply reply) { reply.message = "hello " ~ request.name; return Status.OK; } } string host = "0.0.0.0"; ushort port = 50051; Server server = new Server(); server.listen(host , port); server.register( new GreeterImpl()); server.start(); ``` Example for client: ```D import helloworld.helloworld; import helloworld.helloworldrpc; import grpc; import std.stdio; auto channel = new Channel("127.0.0.1" , 50051); GreeterClient client = new GreeterClient(channel); HelloRequest request = new HelloRequest(); HelloReply reply = new HelloReply(); request.name = "test"; auto status = client.SayHello(request , reply); if(status.ok()) { writeln(reply.message); } ``` Example for streaming: We implemented the offical example RouteGuide offical link:https://github.com/grpc/grpc/blob/master/examples/cpp/cpptutorial.md More support in hunt-grpc github repo: https://github.com/huntlabs/hunt-grpc