

Microsoft open sources C++ REST SDK "Casablanca" - Rooki
http://blogs.msdn.com/b/vcblog/archive/2013/02/26/the-c-rest-sdk-quot-casablanca-quot.aspx

======
charliesome
Disappointed to see the continued use of wide strings in new projects.

~~~
plorkyeran
As long as the Win32 API continues to not support UTF-8, using wide strings
will remain the least bad option on Windows.

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

~~~
zurn
Python supports full Unicode on all platforms now (x). Who cares about in-
memory representation as long as the user doesn't have to suffer from
surrogates and all that horror.

(x) pre-PEP393 there was a build option to use the limited 16-bit Unicode, was
unfortunately popular on Windows

~~~
asveikau
Hm. I picked Python because I knew it was an outlier, but I don't know all the
details. Does Python still suffer from the horrors of comparison between
diacritics made up of combining characters and the same glyph as a pre-
composed character? Seems like even if you expose strings as UTF-32 you'd
still have that issue.

~~~
zurn
Afaik the combining character problem hasn't changed, you still have to use
unicodedata.normalize() for that. But at least you can pass through Unicode
strings cleanly.

Are there other languages that handle this better?

~~~
asveikau
It's not really clear to me what "handle better" would be, which is why I
asked if Python did anything, as your post suggested it hides some ugliness of
Unicode (a claim like this I am always skeptical of, although reading PEP393
it seems kind of clever in that "why don't more libraries do this" kind of
way).

I suppose one form of "handle better" would be to always normalize all the
time, but then, there are those times when you want payload to be bit-
identical after a round-trip. I suspect it's just rooted in Unicode sucking
(even if it sucks less than the encodings it replaced); it's funny how Unicode
is supposed to make things simpler, but carries its own baggage and complexity
and nonsense to worry about. Every time I read about these details in Unicode
it seems to suck more than I remembered the last time.

~~~
plorkyeran
Other than the great UCS-2 cockup most of the issues with Unicode are either
due to that human languages are a pain or are unpleasant backwards
compatiblity things. Only having the fully normalized forms would make things
designed around Unicode a lot simpler, but the denormalized forms let things
not designed for Unicode mostly work, which was key for getting people to
actually use Unicode.

~~~
asveikau
Oh, I totally understand the reasons. Doesn't mean it still doesn't suck. It's
one of those "sucks less" type of scenarios.

------
ajross
Completely 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
Microsoft 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).

~~~
jlgreco
Microsoft has already given the world the "Microsoft Public License" and
"Microsoft Reciprocal License".

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

------
ajasmin
From 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
For 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>

<https://code.google.com/p/rapidjson/>

I have no recommendations for writing REST services, however.

~~~
alpatters
Looking at the source, it looks like this lib uses boost:asio on non windows
platforms.

------
zerop
What are some good web frameworks in C/C++ to implement REST API?

~~~
stephen_g
I currently use Fastcgi++ and manage the headers and JSON with some custom
libraries. The resulting application just runs through any FastCGI compatible
web server.

------
abcd_f
It'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.

------
CamperBob2

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

~~~
twoodfin
That 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
I expect you can define named functions for your "conceptually sequential
actions" if you prefer.

~~~
twoodfin
Sure, but is that much better? It reminds me of having to create named struct
classes to simulate closures prior to C++11 lambdas. The language syntax just
doesn't support that style of programming.

~~~
marshray
So how many languages actually do support this style directly?

The C# async keyword looks pretty clean, just give C++ a decade or so to catch
up.

------
mskierkowski
Back 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"?

------
reddit_clone
Is this Windows/VisualC++ only or is it portable?

~~~
twoodfin
FTA: _We currently support Windows 7, Windows 8 (Windows store and desktop
applications), and Linux._

