Tag Archives: c++

Visual C++ will implement all of C++ 11 and C++ 14, some of C99 says Microsoft

Microsoft’s Herb Sutter spoke at Microsoft Build in San Francisco on the future of C++.

image

Microsoft has been criticised for being slow to implement all the features of ISO C++ 11. Sutter says most features are now included in the public preview of Visual Studio 2013 – which has a “Go Live” license so you can use it in production – including the oft-requested variadic templates. The full list:

  • Explicit conversion operators
  • Raw string literals
  • Function template default arguments
  • Delegating constructors
  • Uniform int and initializer_lists
  • Variadic templates

More features are coming in the RTM (final release) of Visual Studio 2013 later this year:

  • Non-static member initializers
  • =default
  • =delete
  • ‘using’ aliases

A technical preview will then follow and Sutter listed possible features of which there will be a subset. Full conformance will follow at an unspecified time.

Microsoft is also promising a full implementation of C++ 14, the next update to the standard, even though the exact specification is not yet fully agreed. Some C++ 14 features will be implemented ahead of C++ 11 features, if they are considered to add high value.

Two other points of interest.

Async/await (familiar to C# developers) will be implemented in the post-RTM CTP because it is such a useful feature for Windows Runtime app developers, even though it is not part of the ISO standard.

Finally, Microsoft will also several C99 features in the RTM of Visual Studio 2013:

  • Variable decls
  • C99_Bool
  • compound literals
  • designated initializers

The reason for implementing these is that they are needed to compile popular open source libraries like FFmpeg.

I asked Sutter why Microsoft is not planning full conformance to C99. He said it was a matter of priorities and that work on C++ 11 and C++ 14 was more important. If there are particular additional features of C99 developers would like to see implemented, contacting Sutter with requests and rationale might eventually yield results.

image

Miguel de Icaza: don’t blame Google for Microsoft’s contempt for developers

Xamarin’s Miguel de Icaza (founder of the Mono project) has complained on Twitter about Microsoft’s Windows Division’s “contempt for developers” when it created the Windows Runtime and a “4th incompatible Xaml stack”, in a conversation prompted by the company’s spat with Google over the YouTube app for Windows Phone. Google wants this removed because it does not show YouTube ads, to which Microsoft counters that the API for showing these ads is not available.

image 

I am more interested in his general reflections on the wisdom (or lack of it) shown by Microsoft in creating a new platform for touch-friendly apps in Windows 8, that lacks compatibility with previous Windows frameworks. “No developer wants to build apps twice for Windows: one for desktop, one for winstore” he also remarked.

The four XAML stacks are Windows Presentation Foundation, Silverlight (for which de Icaza created a version for Linux called Moonlight), Windows Phone (which runs a slightly different version of Silverlight), and now the Windows Runtime.

Could Microsoft have done this differently, without compromising the goal of creating a new tablet personality for Windows rather than continue with doomed attempts to make the desktop touch-friendly?

The obvious answer is that it could have used more of Silverlight, which had already been adapted to a touch environment for Windows Phone. On the other hand, the Windows division was keen to support native code and HTML/JavaScript as equally capable options for Windows Runtime development. In practice, I have heard developers remark that HTML/JavaScript is better than C#/XAML for the new platform.

It is worth noting that the Windows Runtime stack is by no means entirely incompatible with what has gone before. It still uses the Windows API, although parts are not available for security reasons, and for non-visual code much of the .NET Framework works as before.

Xamarin acquires LessPainful, announces Test Cloud for mobile apps

Xamarin, a company which provides tools for cross-platform development in C#, has announced its acquisition of LessPainful and the creation of cloud-based testing for mobile apps based on LessPainful’s technology and the Calabash scripting language it created.

The Test Cloud will perform automated user-interface tests on real devices, hosted by Xamarin, will provide detailed reports in the event of test failures, and will support Continuous Integration so that bugs are caught as early as possible.

image

“After you’ve conquered the cross-platform mobile development problem, testing is the next large pain point” says Xamarin CEO Nat Friedman. “You can’t just get by with manual testing. There’s a need for the same level of tools and processes in mobile testing that you have in desktop and web testing.”

“Quality is actually more important on mobile than in other places. Mobile sessions are very short. People are really intolerant of low quality on mobile. The release cycles are shorter too. People are revving more frequently, and testing is a bigger challenge.”

Another issue with mobile testing is the number of devices out there, especially if you throw cross-platform into the mix. “You have on Android all these manufacturers who customise the OS in different ways, you have multiple different versions that are in use, and you have multiple different form factors and device capabilities. The testing permutation matrix is huge.”

“Automated UI testing is the only kind of testing that can ensure that the app does what it is supposed to do.”

Friedman says that the Xamarin UI tests are more robust than competing UI test frameworks because they do not depend on UI image recognition. “The right answer is object-based, you identify user interface elements on the screen by object IDs”.”

How does testing on real devices work? If you have 50 developers testing on 27 devices in Xamarin’s cloud, will there be racks and racks of devices to support them?  “That’s what it looks like at our end, racks and racks of devices,” confirmed Friedman. “The service is going to be built based on device/hour usage. We’ll be able to scale up to match what people need.

“We talk to developers who spend $8,000 a month just to get new devices. That’s not counting the labour and everything else they need to do, to set up their own testing infrastructure. It’s a giant pain point.”

Xamarin’s Test Cloud will offer plug-ins for Jenkins, TeamCity, and Microsoft’s Team Foundation Server, to support Continuous Integration.

The scripting language for the Test Cloud is either Calabash , or C# scripting which is under development by Xamarin.

The Test Cloud is not just for applications developed using Xamarin’s C# framework, but also supports other frameworks including those written in native iOS Objective C. However, only iOS and Android are supported.

Availability is set for the third quarter of 2013.

Xamarin’s Evolve conference is currently under way in Austin, Texas, with around 600 developers in attendance. Friedman says the company is growing fast. 1000 developers a day download the tools, there are over 15,000 paid developers, and the company now has 65 employees.

More information on the Xamarin Test Cloud is here.

Xamarin 2.0 and Xamarin Studio announced, build for OSX, iOS and Android with C#

Xamarin has announced significant updates to its developer platform. Xamarin is the company formed around 18 months ago, when Novell discontinued its investment in Mono, a cross-platform implementation of C# and the .NET Framework. Its focus is on mobile platforms, in particular iOS and Android, though there is also support for the Mac. On Windows and Windows Phone, the presumption is that developers will continue to use Microsoft’s .NET Framework.

“If you look at what you can develop with C#, there’s about 1.2 billion Windows machines out there, but there’s now about a billion Android and iOS devices. Together we can make C# a universal language for application development and reach 2.2 billion devices,” Xamarin co-founder and CEO Nat Friedman told me.

“There’s a wonderful built-in audience of C# developers, millions of them, who need a bridge to mobile. We can help them take their existing skills and tools, and even code they’ve already written, and bring them to mainstream mobile platforms like iOS and Android.”

The key announcements:

  • Xamarin Studio is  an updated version of MonoDevelop, the Mono IDE. It runs on Mac and Windows.#
  • You can now develop iOS apps in Visual Studio for the first time
  • MonoTouch, the framework for iOS, has been renamed Xamarin.iOS
  • Mono for Android is now called Xamarin.Android
  • A new component store has pre-built components for download, some free, some commercial.
  • Xamarin now offers a free Starter edition, and pricing plans for independent developers, smaller businesses, and enterprises. Indie is $299 per platform per year, Business is $999 per platform/year, and Enterprise $1800 platform/year.

The Starter edition is not much use. It has a limited app size, and even the sample project I downloaded, an Employee Directory, exceeded that size and I had to register for a trial.

Xamarin’s philosophy is to share non-visual code, but to create a user interface that is native for each platform. This is a compromise in terms of the effort involved in supporting multiple platforms, but ensures a native experience on each device. “That’s fundamental to our platform,” says Friedman. “We tell our developers to separate the UI layer from the rest of the app. That allows them to share all the non-UI code across platforms, but to deliver a fully native UI, even though the whole app is written in C#. That’s what users demand now, people want native experiences.”

“We’ve been building tools that essentially project the underlying iOS APIs or Java [Android] APIs into C#”, explains co-founder Miguel de Icaza. “What it means is that people need to build a new UI for each platform.” He adds that Microsoft platform developers should be used to this, as Microsoft itself has several similar but incompatible .NET platforms. “There’s the one on Silverlight, the one on WPF, the one on Windows RT, and the one on the phone, it’s four,” he says. “Developers have had to resort to putting their logic into shared libraries, and build a per-platform UI. We’re reusing that knowledge.”

The ability to develop for iOS in Visual Studio is new. “It’s our most-requested feature of all time.” said Friedman.

I downloaded Xamarin Studio, which in my case was around 1.3GB including an updated Android SDK.

image

The IDE itself is clean and fast, and very much code-centric. It lacks the bloat of Visual Studio, though you will miss many of the features of Microsoft’s IDE.

image

I build the sample Employee Directory app and deployed it to an Android emulator which I use for Nexus 7 development. Deploying the runtime components took a long time, but after waiting patiently the app launched successfully.

image

If you want to do iOS development you will need a Mac of course. Although you can code on Windows, if you then the code is pushed over the the Mac side for compilation and debugging. In order to use Visual Studio, one option is to run Windows in a virtual machine on a Mac, as I have done with reasonable success using Embarcadero’s cross-platform tools.

Xamarin says it is growing fast. There have been 230,000 downloads of its tools, increasing by around 700 per day, and over 12,000 paying customers.

Despite Xamarin’s roots in the open source world (and Mono is still open source), a quick look at the pricing table shows that this is a fully commercial offering and priced accordingly. Presuming customers keep on subscribing, that is a good thing, ensuring the future of the platform; but it is not so good for the smallest developers who might otherwise give it a try.

Xamarin brings C# to development of apps for the Mac App Store

Xamarin has released Xamarin Mac which adds Mac support to the existing iOS and Android compilers from the company:

  • MonoTouch: apps for iPhone and iPad using the MonoDevelop IDE on the Mac
  • Mono for Android: apps for Android using either Visual Studio or MonoDevelop
  • Xamarin.Mac: apps for Mac OS X using MonoDevelop on the Mac

The major platforms missing from the above are Windows and Linux (unless you count Android), even though Mono began as a Linux implementation of Microsoft’s .NET platform.

Xamarin says that a Windows version is not necessary since you can use Microsoft’s tools to code in C# for Windows desktop and Windows phone.

You can also get Mono for Windows, Mac and Linux from the old Mono project site.

Why would you bother with paid-for Xamarin.Mac when you can get Mono for Mac as a free download? There is even a Mac packager which lets you create a standalone package for your Mono app. A good question, but I guess the answer is the benefit of Xamarin-specific libraries and support from the company. Xamarin has also done the work to ensure that you can distribute your app via the Mac App Store.

Xamarin.Mac costs $399 for personal use, or $999 for an enterprise license which allows internal as well as app store distribution. A one year, one seat license with priority support costs $2,499.

Xamarin knows how to charge then, and in the end that may be a key reason why the project is working, whereas Mono struggled as an open source project that never had the resources it deserved.

The Mono Project site now says that it is “sponsored by Xamarin” so open source developers are getting some benefit from the commercial offshoot.

Xamarin is important for the C# language, since it represents a viable implementation which is independent of Microsoft.

Embarcadero launches C++ Builder XE3: first built on Clang

Embarcadero has released C++ Builder XE3, the first version built on the open source clang front end for the LLVM compiler. This has enabled the product to support many new features, including extensive C++ 11 support and a 64-bit compiler.

image

While it is a shame that the old Borland C/C++ Compiler is no more, it makes sense for Embarcadero to bring its VCL (Visual Component Library) and FireMonkey framework to Clang rather than continuing to work on its own compiler.

The other big change is cross-platform support. Through FireMonkey, C++ Builder XE3 supports Windows (including Windows 8) and Mac OS X, with iOS and Android promised for 2013.

Although Windows 8 is supported on the desktop, there is no official support for the Windows Runtime (Windows Store apps). Instead, Embarcadero has a curious application framework called Metropolis which fakes the Windows 8 style but with desktop applications, as if the Windows 8 world were not already sufficiently confusing.

The big question is how compatible VCL applications created for earlier versions of C++ Builder are with the XE3 release. With a new compiler and major changes to the VCL in order to support the new compiler, you might expect some issues.

“That’s what we’ve been spending all of our time on,” Embarcadero VP Michael Swindell told me. “This is fully compatible with all our previous C++ dialects. We’ve completely re-engineered the C++ front end but it’s engineered to be compatible with C++ Builder applications and Borland C++ applications.”

I would rather hear that from developers though, rather than from Embarcadero.

Although C++ Builder is a cross-platform compiler, it only runs on Windows. A common scenario is to run in Windows emulation on a Mac, using VMware Fusion or Parallels.

Similar changes are on the way for Delphi, which uses the same VCL and FireMonkey frameworks but with the Delphi language based on Object Pascal.

Note that the new Clang-based compiler is 64-bit only. You are meant to continue using the old Borland compiler for 32-bit, making it hard to maintain a single code base for both.

Hands on Windows 8 development: Twitter and hyperlink hassles

I have been messing around with a Windows 8 app to present content from ITWriting.com in an app, mainly as a learning exercise. I came up with the idea of showing recent tweets on the main page of the app. Like this:

image

I thought this would be easy, but encountered several problems. I am developing in XAML and C#; this aspect would probably be easier in HTML.

The first problem: retrieving the tweets. The Twitter REST API version 1.1 has GET statuses/user_timeline which does what I want, except that it requires “user context”, in other words a Twitter log-in. That is an unacceptable requirement for a user simply viewing my tweets, rather than their own timeline.

The deprecated  Twitter RSS API on the other hand is perfect. Unfortunately:

Please note that there is no support for the RSS response format in API v1.1. Properly versioned API v1 URLs will cease functioning in March 2013

Never mind, it will do for the moment. I created a Twitter data source which retrieves the tweets as RSS. In my XAML I have a ListView which is bound to this data source. This ListView has an ItemTemplate which defines what appears in the list. I added a TweetItemTemplate in the Resources section of the XAML which displays each tweet in a TextBlock. So far so good.

image

No hyperlinks though – they are dead. What is the use of a tweet without hyperlinks? Not much. I thought of a hack which would let you click or tap an entire tweet, look to see if a hyperlink is there, and then launch it. Ugly, and would only work for one hyperlink per tweet.

TextBlock does not support hyperlinks. However there is a way to do this using RichTextBlock. This supports a collection of inline elements. You can have a Run element containing text, then an InlineUIContainer containing a HyperLinkButton, then another Run element and so on. The Hyperlink will be out of alignment, as shown here, but you can fix that by tweaking margins and padding.

Of course, this approach does mean parsing the tweet to extract the URLs and then building the RichTextBlock content. So in place of my simple TextBlock binding I now have this:

  <ContentControl Content="{Binding Path=Title,Converter={StaticResource tweetToBlocks}}"></ContentControl>

I have also written a converter class which takes the bound value, builds the RichTextBlock in C#, and returns it. This gets you the result in the first image in this post. Not too bad, and the links work.

What is annoying though is that the mouse pointer does not change to a hand icon when you hover over the link. I thought I could fix this by subclassing HyperLinkButton and adding code to change the cursor on the PointerEntered event:

Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Hand, 1);

This does not work. At least, you can see a flash as the cursor tries to change, but it is overridden by the RichTextBlock which changes it back to a text select cursor. I have not found a way round this yet.

I then tried another approach. You can use a RichEditBox which does support links. The approach is different; you set the text of the Document property and then use the Link method to assign a link to a TextRange within it. It works; but I was frustrated to find that the mouse pointer still does not change to a hand when over the link. The RichTextBlock actually works just as well and is more integrated with XAML.

image

I am sure you could fix this by using a WebView – embedded IE – for each tweet, but that seems to me an unduly heavyweight approach. Better perhaps would be a single web view showing all the tweets, which I might try when I have a moment.

Even so, I was surprised how tricky it is to show tweets with hyperlinks in a ListView.

Microsoft Project Austin: superb C++ code sample for Windows 8

No time to blog in detail about this; but developers with any interest in Windows 8 should check out Project Austin, a sample project for Windows 8 whose quality exceeds most of what is currently available in the Windows Store.

This is a simple note-taking app but beautifully rendered and with support for adding photos, sharing via Charms, and more:

It’s amazing how useful just a pen and a paper are by themselves. But when you take that concept to the computer realm and expand it to do things like add photos and annotate them right on the spot, and digitally share what you create, then the possibilities are endless.

say the project’s creators. More to the point:

Austin aims to demonstrate with real code the kind of device-optimized, fluid and responsive user experience that can be built with our newest native tools on the Windows8 platform.

Most of the code has been put on CodePlex under the Apache 2.0 license. It demonstrates C++ AMP, the new parallel library for GPU computing, as well as C++ coding for the Windows Runtime.

I downloaded and built the project with few issues, following the helpful guidance here. I did have to add the boost libraries manually to the include path.

image

It is not completely stable but is already very pretty.

image

Immersive UI of course. The tools disappear while you are working. I am still not sure how well I like this, but it is good to see examples of how Microsoft thinks this should work.

Embarcadero adopts open source Clang for future C++ versions

A couple of months ago Embarcadero’s John Ray Thomas published a roadmap for the company’s C++ tools. Coming soon: not only a long-awaited 64-bit compiler for Windows, but also native iOS and Android support. On top of that, there are plans for “the very best in C++11 and C99 language and library compliance in the industry.”

Sounds good; but this forthcoming upgrade is not quite what it seems. I spoke to technical evangelist David Intersimone about the changes. The company is adopting Clang, an open source project which creates a C/C++/Objective C front-end for the LLVM compiler. “We’re integrating all that into our IDE,” said Intersimone. “We’re also going to be using that same toolchain world with our Delphi compiler as well.”

“We have analysed what to do about C++. Our compilers both for Delphi and C++ have been around for a lot of years, and over time it just got harder and harder to add new capabilities to make programming simpler and also to add power and richness to the languages. In C++ in particular the language continues to be updated, with now C++ 11. So we made the decision to use Clang and LLVM on the C++ side, for the 64-bit compiler. We’re going to keep our existing compiler for 32-bit Windows for now, and then eventually replace that.

“For Delphi we’re still using our existing compiler to do some of the work, but we’ve been working on a next-generation compiler for Delphi and that is still in the works. For a while we’ll have two compilers, the existing architecture compilers, and then new compilers.”

Embarcadero has its own C++ extensions to support component development, and is working on adding them to Clang. “We’re leveraging and extending the Clang compiler with the property-method-event extensions that we added to our own C++ compiler.”

It is a sad moment in some ways, bearing in mind the long history of what was once the Borland C++ compiler. Equally, it is a sensible move. Intersimone said that the work of keeping up with the evolving C++ specification was disproportionate to the benefits. “It’s a monster language, with a lot of power and a lot of complexity. It made perfect sense to fit our extensions [to Clang] versus building a compiler from scratch and having to continue to track the language into the future.”

Embarcadero can focus instead on its IDE and tools, and on the frameworks for Windows and for cross-platform.

Look out for a more detailed interview with David Intersimone in a future article for Hardcopy.

What is the best programming language for a child progressing from Scratch?

Someone asked me what is the best programming language for a child to learn after starting (and having success) with Scratch.

Scratch is a visual programming language which actually runs on Smalltalk, though its users do not need to know this. Scratch 2.0 seems to be written in Adobe Flash so you can create and program projects in a web browser. As far as I can tell though, there is no obvious and natural progression from Scratch to a code-centric programming language.

I guess the first answer is not to move away from Scratch until you need to. You can do a lot with Scratch, as the many shared projects demonstrate.

Still, I agree that it makes sense to learn text-based programming before too long. What is the best one for a child to learn, not necessarily with computer science or a professional career in mind, but just to take the next step and create some cool games and applications?

I find myself leaning towards Microsoft’s C#. The reason is that there is a capable free version and  you can add XNA Game Studio for game development. C# is an excellent language and has some family resemblance to other languages including C, C++, Java and JavaScript, and Visual Studio is a strong IDE that is perhaps more approachable than say Eclipse or Netbeans.

Snags with C# are that Visual Studio only runs on Windows, the language is proprietary to Microsoft (though Mono is free and open source) and it is not ideal if you want to run on the Mac, or Google Android or Apple iPad.

That said, I could also make a case for Java, or JavaScript, or Python.

I would value suggestions though: what would you recommend to a teenager?