4 ms·
Would you recommend D for web APIs? How fast is D compiler on a 100k line project? Does it support incremental compilation? How's the package management stor
by hu3 6y ago
Would you recommend D for web APIs?
How fast is D compiler on a 100k line project?
Does it support incremental compilation?
How's the package management story and where is D heading in this camp?
Thanks!
- destructionator 6y ago> How fast is D compiler on a 100k line project? I have a 140k line multi-purpose library that compiles in 2 1/2 seconds on my i5 computer w/ ssd. But this varies very heavily depending on what language features you use (compile time execution of functions can make a 3 line program compile in many minutes, or simple C-style code can compile 100k lines in a fraction of a second). So don't generalize too fast! Re web APIs, I've been doing serving and consuming with D for a long time now, I like it a lot. Using some of the compile time reflection stuff is really cool. Like this little demo site: http://arsdnet.net/cgi-bin/survey/record-survey http://arsdnet.net/cgi-bin/survey/record-survey has this source code: ``` import arsd.cgi; import arsd.dom; import arsd.jsvar; struct Survey { string thisIsFakeDontSpendRealTimeOnIt; string whyD; int yearsUsingD; string[] thingsYouWantMost; } struct AboutYou { string yourName; } class Site : WebObject { @AutomaticForm auto recordSurvey(/* @Flatten */ @DisplayName("") Survey s, @DisplayName("") AboutYou y) { struct Result { string message; Survey surveyAnswers; AboutYou aboutYou; } return Result("Thank you!", s, y); } // you can also specify things on functions @(Cgi.RequestMethod.GET) @DefaultFormat("json") int giveMeJson(int a) { return a; } // or have plain boring ones string hello() { return "hello, world!"; } @UrlName("different-url") string[] anyName(string other) { return ["Hello", "Friends", other]; } } void handler(Cgi cgi) { cgi.dispatcher!( "/".serveApi!Site ); } mixin GenericMain!handler; ``` The form is generated from function params, the html from return values, etc. OR you can do json too of course http://arsdnet.net/cgi-bin/survey/different-url?format=json&other=hello http://arsdnet.net/cgi-bin/survey/different-url?format=json&... so it is nice. On the client side, I also generate some code so the usage looks like ``` var result = gitlab.rest.users[myuid].pull_requests.GET; ``` and similar so it generates all those things as it needs it (the url made from the dot members, the return value just a dynamic dype). Not like perfect but plenty convenient.
- mhh__ 6y agoHN code-ifies text if it's indented after a newline
- crazypython 6y agoD can compile your entire 140KSLOC project faster than Rust, TypeScript, or C++ can compile a single file. (The lexer has tricks like skipping multiple spaces at once in order to achieve this.) So, there isn't really a need for incremental compilation yet.
- p0nce 6y agoIt depends on the style of code. In both C++ and D world, code with many template instantiation builds slower.
- mhh__ 6y ago> Would you recommend D for web APIs? vibe.d is quite good > How fast is D compiler on a 100k line project? The D reference compiler takes a few seconds on my machine and is about 450k lines. > Does it support incremental compilation? Not very well if at all. > How's the package management story and where is D heading in this camp? Uninspiring but more than enough to be productive - i.e. infinitely better than C++
- p0nce 6y ago> How fast is D compiler on a 100k line project? On Apple M1, a full rebuild of one of my product (approx. 80kloc) is 6 seconds. 1 seconds incremental.