Feeds:
Posts
Comments

Archive for April, 2012

imageAt GoingNative in February, I emphasized the need for more modern and portable C++ libraries, including for things like RESTful web/cloud services, HTTP, JSON, and more. The goal is to find or develop modern C++ libraries that leverage C++11 features, and then submit the best for standardization.

Microsoft wants to do its part, and here’s a step in that direction.

Today I’m pleased to see Soma’s post about “C++, Cloud Services, and You” announcing the DevLabs release of Casablanca, a set of C++ libraries for Visual C++ users that start to bring the same modern conveniences already enjoyed by .NET and Node.js and Erlang users also to C++ developers on our local and cloud platforms, including modern C++ libraries for REST, HTTP, and JSON. From Soma’s announcement, adding my own emphasis and minor code edits:

Historically, we’ve lacked such simple tools for developers using C++.  While there are multiple relevant native networking APIs (e.g. WinINet, WinHTTP, IXMLHttpRequest2, HTTP Server API), these are not optimized from a productivity perspective for consuming and implementing RESTful cloud services using modern C++.  They don’t compose particularly well with code based on the standard C++ libraries, and they don’t take advantage of modern C++ language features and practices in their programming models.

This is where “Casablanca” comes in.  “Casablanca” is a set of libraries for C++ developers, taking advantage of some recent standard language features already available through Visual Studio.

“Casablanca” aims to make it significantly easier for C++ coders to consume and implement RESTful services.  It builds on lessons from .NET, from Node.js, from Erlang, and from other influencers to create a modern model that is meant to be easy to program while still being scalable, composable, and flexible.

As an example, here’s a snippet that uses the client HTTP library to search Bing for my name and output the results to the console:

    http_client bing( L"http://www.bing.com/search" );

    bing.request( methods::GET, L"?q=S.Somasegar" )
        .then( []( http_response response ) {
            cout << "HTML SOURCE:" << endl << response.to_string() << endl; })
        .wait();

and here’s a simple web listener hosted in a console application:

    listener::create( argv[1], []( http_request req ) {
            req.reply( status_codes::OK, "Namaste!" ); })
        .listen( []{ fgetc( stdin ); } )
        .wait();

For those of you looking to build Azure services in C++, “Casablanca” comes with a Visual Studio wizard to set up everything up correctly.  You can target both Web and Worker roles, and you can access Azure storage using the built-in C++ library bindings. […] Taking C++ to the cloud with “Casablanca” is another exciting step in that journey.

Today’s Casablanca release is as a DevLabs project, to get usability feedback and to eventually support these features in the full Visual C++ product. If you’re interested in using C++ to consume and implement cloud services, and sharing what kind of support you want and whether you think Casablanca is on the right track, please let us know in the forums.

Looking beyond Visual C++, one piece of Casablanca is already being proposed for standardization, namely the “future.then” nonblocking continuations that are required to be able to write highly responsive composable libraries – you really want all async libraries to talk about their work using the same type, and std::future already gives half of what we need (blocking synchronization) and just needs the non-blocking part too. Also being proposed as an optional layer on top of “future.then” is an “await” style of language support to make the async operations as easy to express and use in C++ as in any of the best languages in the world.

Note that there are other C++ libraries too for several of these facilities. Repeating what I said at GoingNative, we (Microsoft) don’t care whose libraries get standardized – whether ones we contribute or someone else’s. We care most that there be standard C++ libraries for these modern uses, starting with the most basic “future.then” support, and to encourage all companies and groups who have libraries in these important spaces to contribute them and take the best and make them available to C++ developers on all platforms. This is a small step in that process.

Read Full Post »

I’m seeing many younger programmers picking up C++. The average age at C++ events over the past year has been declining rapidly as the audience sizes grow with more and younger people in addition to the C++ veterans.

But this one just beats all [Facebook link added]:

A six-year-old child from Bangladesh is hoping to be officially recognised as the world’s youngest computer programmer.

Wasik Farhan-Roopkotha showed an aptitude for computing at an early age and started typing in Microsoft Word at just three years old, BBC News reports.

The precocious youngster was programming game emulators from the age of four and his achievements have already received extensive media coverage in his home country.

He has also gained knowledge of C++, the programming language developed by Danish computer scientist Bjarne Stroustrup, without any formal training.

This kid seems pretty exceptional. Welcome, Wasik! I don’t expect the programs to be very complicated, and I’ll leave aside questions of balancing computer time with real-world time and exercise, but this is still quite an achievement.

How young were you when you wrote your first program? I discovered computers for the first time at age 11 when I switched to a new school that had a PET 2001, and wrote my first BASIC programs when was 11 or 12, first on paper and then a little on the PET when I could get access to it. I still fondly remember when I finally got my own Atari 800 when I was 13… thanks again for the loan for that, mum and dad! the first loan I ever took, and paid off in a year with paper-route money. Having that computer was definitely worth a year of predawn paper delivery in the rain, sleet, and snow.

Read Full Post »

I just posted the following panel announcement to the C++ and Beyond site. The three-day event (plus evening-before reception) with me, Scott Meyers, and Andrei Alexandrescu will be held on August 5-8, and early-bird registration is open until May 31.

 


image_thumb[1]C++11 is kind of like “C++ Dreamliner.” It’s built with world-class modern materials. It took a couple more years to finish than originally expected. But now it’s starting to roll out worldwide and flying more safely and efficiently than ever. (European readers may equally consider it “C++ 380.”)

As I write and teach about C++11, I emphasize that:

Modern C++ is clean, safe, and fast – modern C++ code is as readable and as type- and memory-safe as code written in any other modern language [*], and it has always been the king of ‘fast’ and is now faster than ever with new features like move semantics.

Bjarne Stroustrup made me add, at the end of the “clean and safe” part:

“[*] When used in a modern style.” – Bjarne Stroustrup

Bjarne and I claim this to be true. Others have disputed various parts of this statement – whether C++11 really has a usable safe subset, whether C++ is really necessarily faster than code in other languages, and other questions. What’s the truth?

These answers matter. Type safety and memory safety are important not only for writing reliable code that will fail or be abused less often, but also for improving developer productivity so that developers can spend less time on overhead “taxes” like checking for unsafe casts or buffer overruns. And the claim that C++ really is the king of “fast” has been consistently challenged for most of its history.

In this panel, Scott, Andrei, and I will weigh in with discussion – and data – on these important and current questions.

Read Full Post »

In answering a reader question about Flash today, I linked to Adobe’s November press release and I commented:

Granted, Adobe says it’s abandoning Flash ‘only for new mobile device browsers while still supporting it for PC browsers.’ This is still a painful statement because [in part] … the distinction between mobile devices and PCs is quickly disappearing as of this year as PCs are becoming fully mobilized.

But what’s a “mobile device” vs. a “PC” as of 2012? Here’s a current data point, at least for me.

For almost two weeks now, my current primary machine has been a Slate 7 running Windows 8 Consumer Preview, and I’m extremely pleased with it. It’s a full Windows notebook (sans keyboard), and a full modern tablet. How do I slot it between “mobile device” and “PC,” exactly? Oh, and the desktop browser still supports Flash, but the tablet style browser doesn’t…

Since I’ve been using it (and am using it to write this post), let me write a mini-review.

I loved my iPad, and still do, and so I was surprised how quickly I came to love this snappy device even more. Here are a few thoughts, in rough order from least to most important:

  • It has a few nice touches that I miss on iOS, like task switching by simple swipe-from-left (much easier than double-clicking the home button and swiping, and my iPhone home button is started to get unreliable with all the double-clicking [ETA: and I never got used to four-finger swiping probably in part because it isn’t useful on the iPhone]), having a second app open as a sidebar (which greatly relieves the aforementioned back-and-forth task-switching I find myself doing on iOS to refer to two apps), and some little things like including left- and right-cursor keys on the on-screen keyboard (compared to iOS’s touch-and-hold to position the cursor by finger using the magnification loupe). In general, the on-screen keyboard is not only unspeakably better than Win7’s attempt, but even slightly nicer than iPad’s as I find myself not having to switch keyboards as much to get at common punctuation symbols.
  • I was happily surprised to find that some of my key web-related apps like Live Writer came already installed.
  • The App Store, which isn’t even live yet, already had many of my major apps including Kindle, USA Today, and Cut the Rope. Most seem very reliable; a few marked “App Preview” are definitely beta quality at the moment though. The Kindle app is solid and has everything I expected, except for one complaint: It should really go to a two-column layout in landscape mode like it does on iPad, especially given the wider screen. Still, the non-“preview” apps do work, and the experience and content is surprisingly nice for a not-officially-open App Store.
  • Real pen+ink support. This is a Big Deal, as I said two years ago. Yes, I’ve tried several iPad pens and apps for sort-of-writing notes, and no, iOS has nothing comparable here; the best I can say for the very best of them is that they’re like using crayons. Be sure to try real “ink” before claiming otherwise – if you haven’t, you don’t know what you’re missing. iPad does have other good non-pen annotation apps, and I’ve enjoyed using iAnnotate PDF extensively to read and annotate almost half of Andrei’s D book. But for reading articles and papers I just really, really miss pen+ink.
  • All my software just works, from compilers and editors to desktop apps for full Office and other work.
  • Therefore, finally, I get my desktop environment and my modern tablet environment without carrying two devices. My entire environment, from apps to files, is always there without syncing between notebook and tablet devices, and I can finally eliminate a device. I expected I would do that this year, but I’m pleasantly surprised to be able to do it for real already this early in the year with a beta OS and beta app store.

I didn’t expect to switch over to it this quickly, but within a few days of getting it I just easily switched to reading my current book-in-progress on this device while traveling (thanks to the Kindle app), reading and pen-annotating a couple of research papers on lock-free coding techniques (it’s by far my favorite OneNote device ever thanks to having both great touch and great pen+ink and light weight so I can just write), and using it both as a notebook and as a tablet without having to switch devices (just docking when I’m at my desk and using the usual large monitors and my favorite keyboard+mouse, or holding it and using touch+pen only). It already feels like a dream and very familiar both ways. I’m pretty sure I’ll never go back to a traditional clamshell notebook, ever.

Interestingly, as a side benefit, even the desktop apps are often very, and more, usable when in pure tablet+touch mode than before despite the apparently-small targets. Those small targets do sometimes matter, and I occasionally reach for my pen when using those on my lap. But I’ve found in practice they often don’t matter at all when you swipe to scroll a large region – I was surprised to find myself happily using Outlook in touch-only mode. In particular, it’s my favorite OneNote device ever.

By the end of this week when I install a couple of more apps, including the rest of my test C++ compilers, it will have fully replaced my previous notebook and my previous tablet, with roughly equal price and power as the former alone (4GB RAM, 128GB SSD + Micro SD slot, Intel Core i5-2467M) and roughly equal weight and touch friendliness as the latter alone (1.98lb vs. 1.44lb). Dear Windows team, my back thanks you.

So, then, returning to the point – in our very near future, how much sense does it really make to distinguish between browsers for “mobile devices” and “PCs,” anyway? Convergence is already upon us and is only accelerating.

Read Full Post »

David Braun asked:

@Tom @Herb: What’s so wrong with flash that it should be boycotted? Have I been being abused by it in some way I’m not aware of? Also,does HTML5 have any bearing on the subject?

I’m not saying it should be boycotted, only that I avoid it. Here’s what I wrote two years ago: “Flash In the Pan”.  Besides security issues and crashing a lot, Flash is a headache for servicing and seems to be architecturally unsuited for lower-power environments.

Since then, two more major developments:

1. Even Adobe has given ground (if not given up).

Adobe subsequently abandoned Flash for mobile browsers and started shipping straight-to-HTML5 tools.

Granted, Adobe says it’s abandoning Flash ‘only for new mobile device browsers while still supporting it for PC browsers.’ This is still a painful statement because:

  • it’s obvious that ceding such high-profile and hard-fought ground sends a message about overall direction; and
  • the distinction between mobile devices and PCs is quickly disappearing as of this year as PCs are becoming fully mobilized (more on this in my next blog post).

2. We’re moving toward plugin-avoiding browsing.

Browsers are increasingly moving to reduce plugins, or eliminate them outright, for security/reliability/servicing reasons. Moving in that direction crease pressure or necessity to either:

I’m not saying Flash will die off immediately or necessarily even die off entirely at all; there’s a lot of inertia, it’s still useful in many kinds of devices, and it may well hang on for some time. But its architectural problems and current trajectory are fairly clear, and it’s been months since I’ve heard someone complain that certain people were just being unfair – Jobs’ technical points are on the right side of history.

Read Full Post »

Last month in Kansas City I gave a talk on “Welcome to the Jungle,” based on my recent essay of the same name (sequel to “The Free Lunch Is Over”) concerning the turn to mainstream heterogeneous distributed computing and the end of Moore’s Law.

Perceptive Software has now made the talk available online [EOA: the talk itself starts six minutes in]:

Welcome to the Jungle

In the twilight of Moore’s Law, the transitions to multicore processors, GPU computing, and HaaS cloud computing are not separate trends, but aspects of a single trend – mainstream computers from desktops to ‘smartphones’ are being permanently transformed into heterogeneous supercomputer clusters. Henceforth, a single compute-intensive application will need to harness different kinds of cores, in immense numbers, to get its job done. – The free lunch is over. Now welcome to the hardware jungle.

I hope you enjoy it.

Warning: It’s two hours (with Q&A) because of the broad and deep material. There’s a nice pause point between major sections at the one-hour mark that makes it convenient to split it into two one-hour lunchtime brownbag viewings.

Read Full Post »

While spelunking through the code of a new project you recently joined, you find the following factory function declaration:

widget* load_widget( widget::id desired );

 

JG Question

1. What’s wrong with this return type?

 

Guru Questions

2. What is the recommended return type? Explain your answer, including any tradeoffs.

3. You’d like to actually change the return type to match the recommendation in #2, but at first you worry about breaking source compatibility with existing calling code; recompiling existing callers is fine, but having to go change them all is not. Then you have an “aha!” moment, realizing that this is a fairly new project and all of your calling code is written using modern C++ idioms, and you go ahead and change the return type without fear, knowing it will require few or no code changes to callers. What makes you so confident?

Read Full Post »

Older Posts »

Follow

Get every new post delivered to your Inbox.

Join 2,212 other followers