5 ms·
Microsoft open sources C++ REST SDK "Casablanca"
- zerop 14y agoWhat are some good web frameworks in C/C++ to implement REST API?
- stephen_g 14y agoI currently use Fastcgi++ and manage the headers and JSON with some custom libraries. The resulting application just runs through any FastCGI compatible web server.
- charliesome 14y agoDisappointed to see the continued use of wide strings in new projects.
- twoodfin 14y agoHas Microsoft given any indication of planning to abandon two byte strings in their future Windows C/C++ frameworks? That design seems pretty baked into their platform at this point, and would be presumably hard to change.
- abcd_f 14y agoYou can't abandon them if you want to have fast code. It is possible to write code in a portable fashion, accepting utf-8 as a standard string encoding, but this will then require converting to/from utf-16 for virtually every Windows API call that takes in a string variable. Not hard to do (MultiByteToWideChar), but there's a non-negligible performance penalty.
- plorkyeran 14y agoAs long as the Win32 API continues to not support UTF-8, using wide strings will remain the least bad option on Windows.
- marshray 14y agoBut this isn't using the Win32 API. At least not directly, and certainly not on Linux. Unrelated: Where is this "unsignedchar" keyword coming from?
- plorkyeran 14y agoIt does use both the Win32 API and WinRT (which also wants wide strings) directly. It appears to use narrow strings on Linux. The "unsignedchar" appears to be a bug in the syntax highlighter. It was parsed as two tokens, so either it's insane enough to split tokens or it dropped the space.
- marshray 14y agoBy "this" I meant the example code. On the whole I hate to nitpick, it looks like a darn good piece of work.
- apaprocki 14y agoWindows chooses to use UTF-16 rather than UTF-8, but is it really that much of a concern?
- plorkyeran 14y agoIt makes writing portable code a pain; either you have to use different string types on different platforms or do a bunch of converting between utf-8 and utf-16. Many libraries support only narrow strings, so even in a Windows-only application you often end up having to convert between utf-8 and utf-16 quite a bit.
- asveikau 14y agoI don't know what you're talking about, Win32 supports UTF-8. I can pass CP_UTF8 into WideCharToMultiByte() just fine. :-) Kidding aside, I don't really see the issue. Do you get upset about in-memory representation of strings often? How about when using Java or Python? Is this not why there is an entire programming practice called "serialization"? Windows started supporting UCS-2 before UTF-8 existed, and so the internal representation on Windows remains 16 bits per char.
- reddit_clone 14y agoIs this Windows/VisualC++ only or is it portable?
- twoodfin 14y agoFTA: We currently support Windows 7, Windows 8 (Windows store and desktop applications), and Linux.
- ajasmin 14y agoFrom the FAQ: Can I use Casablanca on iOS, Linux, Android, or other platforms? The API surface of Casablanca is platform-agnostic, however in this release we are only supporting Windows and Linux. Our goal for future versions is to enable true cross-platform portability of Casablanca-based code.
- ajross 14y agoCompletely off topic, but was anyone as disoriented as I was to realize they were browsing an Apache-licensed git archive on a Microsoft site? It wasn't even awful (not github, or really even gitorious, but not bad).
- ajasmin 14y agoMicrosoft has been supporting git on Codeplex (their Open Source hosting site) for a while and they announced git integration in Visual Studio last month. I don't know what license they tend to use for Open Source stuff but Apache is a good choice (we don't need yet another license).
- ajross 14y agoSure, and I knew all that (or at least remembered hearing about it). But there's a big difference between the abstract knowledge that MS isn't completely hostile to open source and actually finding yourself browsing source code on their site. I'm a crufty old cynic, but I was still shocked.
- jlgreco 14y agoMicrosoft has already given the world the "Microsoft Public License" and "Microsoft Reciprocal License".
- CamperBob2 14y agofile_stream<unsignedchar>::open_istream(L"myfile.txt").then([](basic_istream<unsignedchar> fileStream) I don't think I've ever seen this C++ idiom before (either the ".then" method or the use of anonymous brackets like that.) Is this common everywhere or just in Windows circles?
- ksherlock 14y ago.then() is just a method. The "anonymous brackets" is a c++11 lambda function. I don't think chaining it like that is common anywhere, yet.
- apaprocki 14y agoThe .then() method appears to be something on concurrency::task, which is part of the Microsoft's Parallel Pattern Library. This article says: "we've started a new project called Casablanca to build a modern C++ library for cloud-based client-server communication, in which all concurrent operations are exposed as PPL tasks." http://www.drdobbs.com/parallel/improving-futures-and-callbacks-in-c-to/240004255?pgno=2 http://www.drdobbs.com/parallel/improving-futures-and-callba... Link to Microsoft's C++ committee proposal (N3327): http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3327.pdf http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n332...
- HNLogInShit 14y agoUgh. It's "client/server", not "client-server".
- twoodfin 14y agoThat looks like Microsoft's new "async everywhere" approach to API design. It's probably a pretty good idea in concept, but I hope they don't expect C++ developers to actually write those awful nested lambda .then() blocks for what are conceptually sequential actions.
- marshray 14y ago
- ajasmin 14y agoFrom what I understand this is a REST client library for making HTTP requests and dealing with JSON. Can anyone recommend a good C++ framework for writing REST services and simple HTTP servers.
- oakenshield 14y agoFor HTTP clients and servers, I've not had too much trouble with cpp-netlib. It's heavily boost-based, and it uses Boost::Asio for concurrency and SSL handling, but if you're familiar with Boost, you can be up and running in no time. IIRC, this library is considered for official inclusion to Boost as well. I use cpp-netlib + RapidJSON for my REST API handling needs. http://cpp-netlib.org/0.9.4/index.html http://cpp-netlib.org/0.9.4/index.html https://code.google.com/p/rapidjson/ https://code.google.com/p/rapidjson/ I have no recommendations for writing REST services, however.
- alpatters 14y agoLooking at the source, it looks like this lib uses boost:asio on non windows platforms.
- lmfao 14y agoI really like that they used the new C++11 features like lambdas etc. Will download and dig through the source code, seems to be one of the first OS projects by a major company which feature C++11.
- mskierkowski 14y agoBack in the day (~4 yrs ago) there was a project called "Casablanca" at Microsoft which was supposed to be the native (C/C++) version of the Windows Communication Foundation. Is this the same "Casablanca"?
- abcd_f 14y agoIt's good to see the code using K&R naming convention (sans the class names starting with _). On the other hand, it's written in a C++ dialect that's incompatible with the one we are using. It also has quite a few unnecessary tie-ins into the native API and MSVC compiler specifics (#pragma endregion), so as nice of a gesture this is, it's not fit well for inclusion into other projects.