10 ms·
I'm writer of this project and it's not completed yet. I planned to publish this after finishing basic features and documentations.
by ipkn 12y ago
I'm writer of this project and it's not completed yet. I planned to publish this after finishing basic features and documentations.
- amatheus 12y agoLook really nice! To make the people who will complain about no example in the readme, I would suggest you just copy the example.cpp file into the readme, that'll do until you have more time.
- mempko 12y agoLove the black magic!
- ipkn 12y agothe power of `constexpr'!
- jvickers 12y agoIt looks very convenient for making some relatively simple web services (based on me not knowing much C++, others would get more mileage probably). It looks like the kind of C++ project of a moderately small size that's implementing something that I'm very familiar with already, so I think it will be useful to help me learn C++. I have a couple of questions, and that is what is the reason for only having .h files with no .cpp files in the main part of the microframework? Did something force you to do it that way or was it done like that because you like that code structure?
- Mr_P 12y agoHeader-only libraries have several advantages (see http://en.wikipedia.org/wiki/Header-only http://en.wikipedia.org/wiki/Header-only). Most-notably, they are dead-simple to include with a project, as opposed to having to separately build and link to a shared-library.
- frankzinger 12y agoYeah but usually "header-only" implies templates, of which there seems to be little in this case. Without templates there's little point in putting everything in headers because all the code becomes inline. Inlining everything is bad because: - it makes the binary much bigger. - the smallest code change forces library users (applications) to be recompiled. For libraries it's usually better to go to the other extreme: hide as much code and data as possible in the source files. See, for example, https://en.wikipedia.org/wiki/Opaque_pointer https://en.wikipedia.org/wiki/Opaque_pointer. It greatly reduces the need for applications to be recompiled when the library is updated. It's actually very unusual to put all function implementations inline (edit: as in, inside the class declaration) in C++. I wonder whether the author is a heavy Java user.
- geon 12y ago> because all the code becomes inline. The language says that's just a suggestion to the compiler, right? Does any compiler actually inline for non-trivial methods?
- frankzinger 12y agoNo, not everything will be inlined, but there will still be much more inlining than there should be. And whether or not the compiler inlines the code, applications will still have to be recompiled whenever there's a code change in the library.
- pbsd 12y ago`inline` has a different meaning in C++. The compiler is free to inline the call if it wishes to, but `inline` means that the same function can be defined in multiple translation units without breaking the one definition rule. Example: // header.hpp inline int f(int x) { return x + 1; } // a.cpp #include "header.hpp" // b.cpp #include "header.hpp" If f was not marked inline, linking a.cpp and b.cpp together would find a conflicting method f, and compilation would fail. `inline` lets the compiler ignore this, and it simply picks one of the multiple definitions as the 'real' one and moves on with the compilation.
- jevgeni 12y agoTook a look at the source code. Noticed crow::black_magic::is_equ_p(...) I haven't yet tried the framework, but I already like you.
- fritz_vd 12y agovery cool
- acron0 12y agoSo, you are alive ;)
- davvid 12y agoThis looks nice. I would suggest avoiding macros in the final release; it should be possible to implement CROW_ROUTE() using template meta-programming instead of #define's.
- ipkn 12y agoI also want to remove CROW_ROUTE, but with the current c++ standard, it cannot be avoided. To check whether handler is valid with given URL at compile time, `url' (string literal) argument requires in compile time and in run time. const char* value is invalid for template argument and argument of non-constexpr function cannot be constexpr value. Thus I used macro to provied `url' argument twice; in template argument through constexpr function and in argument.
- pmr_ 12y agoYou can still do metaprogramming on single character constants and with a bunch of really ugly hackery make it somewhat pretty. You might be interested in metaparse [1] which can greatly simplify compile time parsing of strings but has a very steep learning curve. [1]: http://abel.web.elte.hu/mpllibs/metaparse/ http://abel.web.elte.hu/mpllibs/metaparse/
- ipkn 12y agoI already considered using a template with single character constants, and I thought the technic didn't have much benefit over the macro version. Maybe compile-time routing function genetation could be possible with it (and would faster), but requres HUGE work I think. I will try and benchmark it later.
- mtdewcmu 12y agoI'd hope that in the end, the efficiency of the routing matters more than templates vs macros. You will never finish anything if you pay too much attention to all the purists. Useful strings at compile time is a desirable feature beyond c++, though. A perfect hash could be a nice solution, I thought, but I got around to trying out gperf, and it was much slower than I expected. Probably too slow to use in ordinary situations. I guess gperf is for when (runtime) performance is incredibly important. Another possible approach to strings at compile time is something like flex, or re2c. I haven't tested them in this type of scenario. But, apparently Zed Shaw used ragel to parse http in Mongrel to excellent effect. My problem with ragel is its complicated syntax.