Live data from Hacker News

Crow – C++ Microframework for Web, inspired by Python Flask

github.com

21–30 of 65 posts

Re: Crow – C++ Microframework for Web, inspired by Python Flask

#22
Today i learned constexpr, enum class, and operator "". Thank you.

The full trie implementation caught my eye, are there no suitable alternatives in std or boost?

Mixed tabs and spaces (?) cause strange display in github in json.h from 555 through 670 or so.

Also at the start of json.h it seems a shame to repeat __builtin_expect rules, how about #if defined() || ?

Re: Crow – C++ Microframework for Web, inspired by Python Flask

#23
post #16

Earlier quoted context omitted.

It 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 wit…

Header-only libraries have several advantages (see 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.

Yeah 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. 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.

Re: Crow – C++ Microframework for Web, inspired by Python Flask

#24
post #16

Earlier quoted context omitted.

Header-only libraries have several advantages (see 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.

Yeah 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:…

> 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?

Re: Crow – C++ Microframework for Web, inspired by Python Flask

#25
post #6

I'm writer of this project and it's not completed yet. I planned to publish this after finishing basic features and documentations.

This 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.

Re: Crow – C++ Microframework for Web, inspired by Python Flask

#26
post #24

Earlier quoted context omitted.

Yeah 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:…

> 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?

No, 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.

Re: Crow – C++ Microframework for Web, inspired by Python Flask

#27
post #24

Earlier quoted context omitted.

Yeah 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:…

> 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?

`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.

Re: Crow – C++ Microframework for Web, inspired by Python Flask

#28

This is going to sound overly critical and judgmental to many - but to me, I just don't understand how you can spend the time involved in developing an entire web framework, and don't have the time to write a couple paragraphs for a README on how to use it and what it's all about along with some examples. I'm not talking full documentation - I'm just talking a few sentences and an example or two. Why bother releasing…

you're right, you do sound overly critical and judgmental.

Re: Crow – C++ Microframework for Web, inspired by Python Flask

#29
post #25
post #6

I'm writer of this project and it's not completed yet. I planned to publish this after finishing basic features and documentations.

This 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.

I 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.

Re: Crow – C++ Microframework for Web, inspired by Python Flask

#30
post #29
post #25

Earlier quoted context omitted.

This 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.

I 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…

You 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/

Post reply on HN