Showing posts with label Information. Show all posts
Showing posts with label Information. Show all posts

Wednesday, June 11, 2014

[Visual C# - Apple Swift] Comparison between Visual C# and Apple Swift

As you might have seen Apple has recently released a beta version of a new programming language called Swift (see here for more information). This new language is going to replace Objective-C for developing OSX and iOS applications. It is very similar to C# and I would like to show you a high level comparison of its features when compared to our preferred C# language. I have used the official Apple Language Guide for Swift to do the comparisons, which you can find here.

Data Types & Declarations

One of the first things you have to learn when beginning a new language is what data types are provided and how to declare constants and  variables. Lets see how it is done for both languages by looking at some basic examples.

In the Swift language constants are declared by using the let keyword, whereas variables are declared by using the var keyword. Type inference is supported and you can declare a specific type by using type annotations.

image

image

In the C# language constants are declared by using the const keyword, whereas variables are declared by using the var keyword. Type inference is supported and you can declare a specific type by using it instead of the var keyword.

image

Both languages support the use of Unicode characters within variable and constant names and they both have the same syntax for code comments.

image

You see that they are quite similar in how to handle constant and  variable declarations, there are very little differences. Nonetheless there is a big syntax difference that you might have spotted already: the Swift language does not require a line termination with semi-colons. It supports it if you need to put multiple operations in a single line, but it does not require it when you work in a standard way.

There are other similarities such as how to define Integer boundaries or how to work with Strings. They both provide min and max properties for Integers for example.

Swift:

image

C#:

image

They both have a similar approach on how to compare Strings and even some of the provided String methods are very alike:

  • hasPrefix() –> StartsWith()
  • hasSuffix() –> EndWith()
  • uppercaseString() –> ToUpper()
  • lowercaseString() –> ToLower()

Swift:

image

C#:

image

When looking at Arrays and Array Literals as well as Dictionaries and Dictionary Literals, we can see that both languages have a very similar approach, even the syntax is nearly the same.

Swift:

imageimage

C#:

imageimage

Control Flow

Both languages provide mostly the same control flow constructs:

  • for and while loops to perform actions multiple times
  • conditional if and switch statements to execute different code branches
  • break and continue statements to transfer flow execution

Again the Swift syntax bears a strong resemblance to the C# syntax. Both languages implement the traditional for-condition-increment loop as well as the more modern foreach/for-in loops, which makes it easier to loop over collection types such as arrays/lists, dictionaries, ranges, strings and sequences.

Swift:

image

image

C#:

image

image

Both languages provide the classic while and do-while loops. There are no significant syntax changes or functional differences between Swift and C# to speak of (the only visible difference is that there are no parentheses in Swift around the conditions). The same applies to the if-then-else, switch, break and continue statements.

 Swift:

image

image

image

C#:

image

image

image

Conclusion

You have seen that Swift has implemented more or less the same syntax approach that C# provides for a long time now. I think that C# developers can quickly switch over to Swift if needed. But given the fact that Xamarin allows to develop efficient applications for the OSX and iOS world using C#, I doubt that this will be necessary.

Apple has modernized its main programming language, but there is still a long way to go to concurrence all the fairly advanced language features of C#. I think it is a good thing that those languages converge, we might as well motivate Swift developers to use C# in the future (to convert them), since it will be very easy for them to switch over.

Note that this is by no means a complete comparison, I just wanted to give you a quick overview. There is so much more to compare, so please try it out for yourself and share your feedback.


Share/Save/Bookmark

Friday, May 17, 2013

[WinRT - Prism] Prism for Windows Runtime goes live !

This Friday 17th of Mai “Prism for Windows Runtime” is going live. This project is also known under the code name “Kona” by the patterns & practices team. It provides guidance on how to develop Windows Store Business Applications (basically Windows 8 applications).

It contains information on how to build loosely coupled, maintainable and testable applications based on the MVVM pattern for Windows Runtime (WinRT) with a focus on Line of Business (LoB) and Business to Consumer (BtC) applications.

Prism for Windows Runtime contents

  • A sample application “AdventureWorks Shopper” representing a real Windows Store application that you might find in the Windows Store. It has gone through the same approval processes all Windows Store applications have to go through.
  • This sample application demonstrates all the aspects of what Prism for Windows Runtime contains and how to apply them to your applications.
  • The Microsoft.Practices.Prism.StoreApps library, which contains code for implementing the MVVM pattern on WinRT. This means base classes, pages, ViewModels, a ViewModelLocator, application state management, validation, search and settings charms, etc...
  • The Microsoft.Practices.Prism.PubSubEvents library, which is basically the Prism 4.0 CompositePresentationEvent pub/sub events code moved to a Portable Class Library (PCL).
  • Quickstart examples and a thorough documentation

I was working on it together with Microsoft and the other members of the Developer Guidance Council in the lasts months, so I am happy to announce that it is available for the public now.

The release announcement on the blog can be found here:
http://blogs.msdn.com/b/blaine/archive/2013/05/18/just-released-prism-for-windows-runtime.aspx

The final resources (code, documentation, examples, etc…) can be found here:
http://code.msdn.microsoft.com/windowsapps/Prism-for-the-Windows-86b8fb72
http://msdn.microsoft.com/en-us/library/windows/apps/xx130643.aspx
http://www.microsoft.com/en-us/download/details.aspx?id=39042

The official CodePlex site can be found here :
https://prismwindowsruntime.codeplex.com

You can also find a Channel 9 webcast on the subject :
http://channel9.msdn.com/Shows/Visual-Studio-Toolbox/Prism-for-Windows-Store-Apps

There is also a Pluralsight course "Building Windows Store Business Apps with Prism" by Brian Noyes available here :
http://pluralsight.com/training/Courses/TableOfContents/building-windows-store-business-applications-prism

I will show you some examples in the next weeks if I get the time to prepare them for you. But if you can’t wait, just download the guidance from CodePlex and play with it. It is really easy to use and should give you all information necessary to build effective and robust Windows Store applications.


Share/Save/Bookmark

Wednesday, November 14, 2012

[Information] New adventure begins ! Cellenza here I come !

Just a quick note to inform you that I am leaving Capgemini Sogeti to work for Cellenza as CTO. This is going to be quite an adventure and I thank Cellenza in trusting me with this high responsibility.

logo-cellenza

You will see much activity around Cellenza in the next weeks. I am glad to announce that there are some very bright and intelligent people that I am going to work with. Also we are hiring so please contact me if you are interested in joining us !


Share/Save/Bookmark

Wednesday, August 8, 2012

[VS 2012 - .NET 4.5] Visual Studio 2012 & .NET 4.5 RTM in August

The RTM-versions of Visual Studio 2012, .NET 4.5 and Windows 8 will be available in less than a week on 15 August 2012. This is a very important date for all you developers out there !

image

image

Developers subscribing to MSDN will be able to download the Windows 8 RTM version on August 15. Microsoft announced that Visual Studio 2012 and .NET Framework 4.5 will also be available via MSDN on the same date.

Note that the RTM-versions (release to manufacturing) contains already everything that the final version for the customers will contain ! So from this date on you may validate your applications in a real production environment.

In the meantime download the Release Candidate versions and Release Preview versions and familiarize yourself with all the new features of those products.


Share/Save/Bookmark

Monday, October 17, 2011

[.NET 4.5] In-Place Upgrade to .NET 4.0 SP1

After the BUILD conference we now have more information on how Microsoft plans to do the upgrade from .NET 4.0 SP1 to .NET 4.5 and what this upgrade will imply.

Contrary to all other upgrades in the last years this will not be a side-by side upgrade but instead an in-place update. The .NET 4.0 SP1 framework will be replaced on the system during the upgrade process. Furthermore it seems that you won’t be able to go back once you have done the upgrade.

To allow such an update Microsoft will have to assure that old code that ran under .NET 4.0 SP1 will still run correctly under .NET 4.5 which is not an easy task. But the Microsoft staff is currently working hard to assure everything will work seamlessly when the final version of .NET 4.5 is shipping.

I will post a migration tutorial when the final version will be published and try to help you in having a good migration strategy.


Share/Save/Bookmark

Sunday, May 8, 2011

[MS Days 2011] Speaker at Microsoft Days 2011 in Grenoble
Session on Windows Azure

I am going to be speaker and animate a session with Fathi Bellahcene on Windows Azure during the Microsoft Days 2011 in Grenoble the 7th June ! So if you have the time and if you are around don’t hesitate and come to see us in action !

image


Share/Save/Bookmark

Thursday, December 16, 2010

[Visual C# 5.0] How-To: Asynchronous Programming (2/2)

My last article introduced the new asynchronous features in C# 5.0. I took an easy development example that calculates factorials for showing you how you may implement it in a synchronous and asynchronous C# 4.0 environment - a time consuming and not so easy task for the common developer.

In this article I am going to explain how you could do it when using the latest C# 5.0 features that were released with the current CTP. You will see the code necessary to make your synchronous code asynchronous and how simple and comprehensible it is done when using the new async / await language features!

Factorials Asynchronous Code in C# 5.0

For being able to develop the C# 5.0 version of the code you need to have the CTP October Release installed and to reference the “AsyncCtpLibrary.dll”. Then you are ready to test the new features.

The main function gets a new section that calls the asynchronous C# 5.0 code. All three cases can now be executed from the main function for being able to compare the results.

AsyncCSharp5_1

Now we need to implement the calling function that will start the asynchronous processing and wait for the asynchronous result. There are already changes in the function prototype since you need to add the async keyword before the function return type to mark the function to be asynchronous.

Furthermore you can see that I use the new await keyword in front of the function call which is done inside the function body. This will assure that the code inside of this function below this line is only executed when the asynchronous processing is finished. A calling function must have at least one and can have multiple await keywords.

AsyncCSharp5_2

The main differences exist in the implementation of the function that will execute the factorials calculation code. You already see that the keyword async is used before the return type (similar to the function above).

But if you look carefully you can see that the Task<T> class which was introduced in C# 4.0 for Parallel Programming is used as return type. Knowing that all asynchronous functions have to either return Task or Task<T>, this indicates that the new asynchronous features work hand in hand with the TPL.

Within the function body we create an execute a new Task<T> and define the code that should run asynchronously, which is exactly the same that was used in all examples before.

Please also note the await keyword after the return statement that indicates that the return will only be done when all asynchronous operations within the function are completed.

AsyncCSharp5_3

When executing the application the part that handles the asynchronous call makes that the factorial calculation is done in the background and the result is displayed when it is finished (similar to the example I presented in my last blog post).

Each step is marked in the logical order they are executed :

  • Step1: Enter User Data
  • Step2: Result of the calculation
  • Step3: Exiting the function call
  • Step4: Do some other stuff

When starting the application and entering a valid value you see that there is no more delay getting the output for Step3 and Step4 (as you have already seen for the C# 4.0 example). The application is not blocked by the processing which is done in Step2. When the asynchronous processing in Step2 is finished the result is written to the Command Line. That is why the execution order is different from the logical order.

AsyncCSharp5_4

So the behavior is exactly the same but the code is much leaner, more elegant, easier to maintain and to understand. The async / await keywords greatly help to facilitate the migration of you synchronous code to its asynchronous version. No more hassle with synchronization contexts, delegates, events or wait handles. No more spaghetti code that has CallBacks allover the place where you may get very confused during design and even during runtime.

A developer may take this code and easily see what happens in which order. He may maintain or extends this kind of code very quickly. So in the end it leads to a higher productivity of developers who may concentrate once more on generating applications with high business value.

Conclusion

This article described the new features in C# 5.0 which will help to develop asynchronous code in a much quicker and cleaner way than it was possible before. Please take care that those functionalities are currently in CTP state so their final implementation may differ slightly from what I have shown you above. I will continue posting about those very interesting features and will give you updates if there are any changes in the final version of C# 5.0 which may still take some time to be released.

You can download the source code from the source code section of my Blog:


Share/Save/Bookmark

Wednesday, December 15, 2010

[Visual C# 5.0] How-To: Asynchronous Programming (1/2)

Most of todays applications are developed to work sequentially. Developers are quite used to the sequential approach since it is easy to be implemented and easy to understand. But it makes no sense to always respond to development problems by using this approach. Furthermore, the user has to wait until each of the sequential operations have finished until the next ones can be processed. Sometimes this means waiting for a result on the user side – and users don’t like to wait!

There are multiple reasons why developers may want to structure their code in an asynchronous way. Sometimes it is to allow a better user experience (not waiting anymore) or better perceived performances and sometimes it is due to technical restrictions (such as for Silverlight for example).

The current version of C# 4.0 integrates everything necessary to implement asynchronous code manually. But as you might already know asynchronous code quickly gets unreadable and hard to maintain. But this is going to change in the future version of C# which will include a new abstraction layer that will greatly ease asynchronous programming.

I will take the example of calculating factorials in a Command Line project during these blog posts. But you may take any other code that you want to render asynchronous.

In the first step I am going to write the synchronous C# 4.0 version of the code. I will then show you how you could modify your code in C# 4.0 and C# 5.0 to make the same code asynchronous.

Factorials Synchronous Code in C# 4.0

The main function in the example project contains the user input code as well as the synchronous function call. I did not add any error nor exception handling for simplicity purposes.

SyncCSharp4_1

The synchronous function contains the main application logic: factorials calculated via a for loop (no recursion for simplicity purposes). I also added a Thread delay to simulate calculation time.

SyncCSharp4_2

Each step is marked in the logical order they are executed:

  • Step1: Enter User Data
  • Step2: Result of the calculation
  • Step2: Exiting the function call

If we start this application and enter a valid value you can see that there will be a certain delay until you will get the output for Step2 and Step3. This is completely normal and due to the synchronous calling.

SyncCSharp4_3

So the processing is blocked until all operations in the synchronous order are completely finished. If you don’t like this behavior then look carefully at the next sections!

Factorials Asynchronous Code in C# 4.0

The next step consists of extending the existing project by adding some new functions and modifying the existing main function. In the main function a new asynchronous function call is added.

AsyncCSharp4_1

To render the code asynchronous we need to add a delegate which will be used to decouple the function call. In my example I also use a CallBack function and a AsyncOperation. You could do this differently but I choose this approach to show how complex it can get when migrating you code to be asynchronous in the current version of C#.

AsyncCSharp4_2

The function with the application logic is the same as in the synchronous version of the code. The only difference will be that it won’t be called directly but by using the delegate that was defined above.

AsyncCSharp4_3

The callback function contains the business logic that is applied when the asynchronous call is completed.

AsyncCSharp4_4

I added also some logic to be able to get informed via an event when the CallBack function has finished (not used anywhere in my code however). But you might need to be informed when the asynchronous operation has been terminated.

AsyncCSharp4_5

When executing the application the part that handles the asynchronous call achieves that the factorial calculation is done in the background and the result is displayed when it is finished.

Each step is marked in the logical order they are executed :

  • Step1: Enter User Data
  • Step2: Result of the calculation
  • Step3: Exiting the function call
  • Step4: Do some other stuff

When starting the application and entering a valid value you see that there is no more delay getting the output for Step3 and Step4. The application is not blocked anymore by the processing which is done in Step2. When the asynchronous processing in Step2 is finished the result is written to the Command Line. That is why the execution order is different from the logical order.

AsyncCSharp4_6


Share/Save/Bookmark

Friday, October 29, 2010

[Information] Free Ebook on Windows Phone 7 Programming

Get this free eBook on Windows Phone 7 programming written by Charles Petzold and published by Microsoft Press. It contains 24 chapters and around 1000 pages that will help you build Windows Phone 7 application fast. This is an exclusive possibility to learn how to program for the new version of Windows Phone.

ProgWinPhone7

Get the PDF here. And the code samples here.


Share/Save/Bookmark

Thursday, June 10, 2010

[VS 2010] Visualization & Modeling Feature Pack for VS 2010

Microsoft has released its first Visualization & Modeling Feature Pack for Visual Studio 2010 Ultimate. It adds new functionality to Visual Studio 2010 and is completely free for MSDN Subscribers. The new UML features really help and are indispensible in your daily work when modeling and working with code at the same time.

Feature Pack Content

Increased Visualization Support

  • Visualization of native C++ code
  • Visualization of WAP / Web Sites / ASP.NET MVC code

Increased UML support

  • Source Code Generation from UML Class diagrams
  • UML Class Diagram Generation from Source Code
  • Architecture Explorer can finally be used to populate the Modeling Store in Modeling Projects (we waited for that!)
  • XMI 2.1 Import of UML Class / Sequence / Use Case elements
  • Create and view links from Work Items to model elements

Increased support for Layer Diagram Extensibility

  • Creation and validation of Layer Diagrams for C and C++ native code
  • Possibility to write custom code to create, modify, and validate Layer Diagrams.

MSDN Download Link

You can download it from here (MSDN Subscribers only):
http://msdn.microsoft.com/en-gb/vstudio/ff655021.aspx


Share/Save/Bookmark

Wednesday, March 24, 2010

[Event] MCT & Educator Virtual Summit

A quite interesting event for all Microsoft Certified Trainers is coming this year in April (and it’s for free !!!).

This is the place to connect to other MCTs and get information on the latest technologies and training techniques. Don’t hesitate and inscribe yourself.

You can find the agenda here:
http://www.mctvirtualsummit.com/Uploads/MCTEducatorVirtualSummitDownloadAgenda.pdf

 

MCT Virtual Summit


Share/Save/Bookmark

Wednesday, November 18, 2009

[Silverlight] Silverlight 4 Beta is Now Available

Scott Guthrie announced today at PDC that Silverlight 4 Beta is now available for testing purposes. These are very interesting news for all RIA developers out there.

Here are some of the new functionalities in Silverlight 4:
  • Out-of-browser capability enhancements for a high quality experience
  • Access to SharePoint 2010, Office, and IIS
  • HD-quality video experiences on the Web with native multicast and offline DRM support
  • Printing capabilities (print directly from within Silverlight)
  • Usage of WebCams and Microphones will be possible
  • Assembly sharing between .Net and Silverlight assemblies
  • etc...
You can get more information using the following links:

Share/Save/Bookmark

[VS 2010 - UML] Sequence Diagram Code Generation is not possible

In Visual Studio 2010 it will not be possible to create a new UML Sequence Diagram from scratch and then generate code from it. Sequence Diagrams will only be used for representation and modeling purposes.

The Sequence Diagram generation is a one-way operation. Meaning that even if you generated a Sequence Diagram from existing code and changed it you will not have the possibility to generate the code that reflects your changes. You will have to do it manually at the moment.

Furthermore there is not possibility to activate debugging in Sequence Diagram mode, which would be a very handy feature for the future.
Share/Save/Bookmark

[VS 2010 - UML] UML Model and Architecture Diagrams Viewer

Creation and modification of UML models and Architecture Diagrams will only be possible from within Visual Studio 2010 Ultimate. But developers will be able to open them in Viewer mode from within all other versions of Visual Studio 2010.
Share/Save/Bookmark

[Event] Microsoft Model Driven Days

Just a little reminder that this years “Microsoft Model Driven Days” will be Thursday 26/11/2009. This is a very interesting event on UML, MDA, SOA and similar subjects. A must for architects and developers that are interested by modeling. I will be attending and will be looking forward to see new faces.

The event is free of charge! So if you have the time register yourself(!) and come to the event. 

You can get further information on http://www.mdday.fr/.
image
Share/Save/Bookmark

Tuesday, November 17, 2009

[UML] OMG-Certified UML Professional Fundamental Exam (OMG-OCUP-100) Preparation Slides

The following slides greatly help for the preparation of the OMG-OCUP-100: OMG-Certified UML Professional Fundamental Exam. They contain all necessary information for passing the certification and can be used in combination with the certification guide.






Share/Save/Bookmark

Thursday, November 12, 2009

[Event] TechED 2009 – Experience Summary

Last Sunday I arrived at the TechEd 2009 in Berlin and registered in the evening. There were many people from all over Europe and even Speakers from the US. About 736 Sessions for over 7000 people were announced. What an event, the week promised to be awesome!

I did 4-5 session per day and also tried to do as much Hands-On-Labs and Interactive Discussions as possible. When I got a possibility to talk to Microsoft collaborators on upcoming technologies I did it!

I attended at sessions on Architecture, WCF 4.0, WIF, Dublin, Parallel Programming, SQL Azure and Visual Studio 2010 and many others. An enormous amount of news was given to the audience and I was very excited of what was presented.

WCF 4.0 will not have major updates but will get default bindings, default behaviors and standard endpoints that will make configuration in most cases much easier. There will be new protocol mappings, a whole new routing mechanism (!!!) and new ad-hoc service discovery features that make it possible to detect services on the network automatically. It will be possible to configure the content-type of the service return format (xml, text, json, atom, etc...).

The Geneva project, that will rewrite history for security handling in application, was renamed to WIF (Windows Identity Foundation). This new claims based approach decouples security handling and management from application development. It works via Tickets that are delivered via an STS (Security Token Service). Cardspace 2.0 will be used to provide users with the possibility to select an identity.

WIF is the framework that is used inside applications for being able to use Tickets and recover claims that are important for them. Finally an abstraction layer for security, something that will make application development much easier and security handling much more flexible!

Dublin, which was renamed to "AppFabric", will provide a new hosting environment for WCF. Some extensions to IIS were shown, that add for example, a new management Dashboard that greatly aids in managing WF 4.0 Workflows and WCF services. WCF 4.0 in conjunction with Dublin will really provide a whole new experience and will be a good alternative for BizTalk in many use cases. Definitely worth looking into it when it will be shipped!

The new Parallel Programming features in .NET 4.0 will make it much easier to get the most out of multi-core machines. In most cases you just have to identify the parts of the application that may be parallelized and use Tasks, PLINQ and the TPL (Task Parallel Library) to optimize for parallel processing. Thread optimization and complicated algorithms will rarely be necessary. There are many new features in Visual Studio 2010 that further aid the developer to master parallel development (Thread/Tasks can be separately debugged and profiled, Performance analysis can be done, etc...).

SQL Azure will be a relational database in the Cloud that can be used together with Windows Azure or client applications on client servers. The experience is seamless and you really see no difference inside your applications. You even can use SQL Server Management Studio (in a new version that can be found here) to manage your online databases. Your databases can have a size be up to 10 GB and the same on-a-use based payment model is applied as with Windows Azure ($9.99 and $19.99 payment plans).

And I could go on and on. This was really an amazing event and I am very happy that Winwise sent me to it. I would love to get into more detail on all the new features, so just contact me if you want additional information.
Share/Save/Bookmark

Wednesday, November 11, 2009

[WIF] TechED 2009 – Windows Identity Foundation, Cardspace 2.0, ADFS 2.0

The new claims based security abstraction layer (before project “Geneva”) was presented. It will likely change how applications implement security handling in the future.

Until now when you developed your application, you had to decide during development time what security approach you wanted to support.  Then your application was more or less coupled to the security implementation.

Changing your application from a Windows to a Web application could mean re-developing the whole security handling (recovery of rights and verification, etc…) for example.

New WIF Security Abstraction Layer

This is about to change considerately with Windows Identity Foundation (WIF), Cardspace 2.0 and ADFS 2.0 or any other provider that can act as STS.

Applications will not mind anymore from where security is coming. In fact they won’t know anymore. They will just know what rights – or better what claims they need and who they trust. It will be the responsibility of the Security Token Service (STS) provider to recover claims and sending them to requesting applications.

P1000382 P1000383
Security will be decoupled completely form application development in this scenario. And it is very easy to do!
The WIF API will provide all functions and objects, that are necessary to do the implementations in your applications. You may change your security configuration by modifying the application configuration file (like for WCF) and changes will be immediate even in production environments.

Claim Recovery Example

Here is an example of how to recover a claim (ex: “age”) that the application needs for security verification (note the usage of LINQ in this context).

P1000384

Visual Studio 2010 Tooling Support

Visual Studio 2010 will provide the tools necessary to make this as easy as possible. There will wizards that greatly help configuring your applications. You may even have a local simulated STS implementation that can be used during development (not everyone has a fully configured STS at hand).

P1000385P1000370P1000372 P1000373

ASP.NET & WCF Integration

With WIF authorization and security handling will provide more flexibility and will allow more complex scenarios.

P1000394 P1000395

Summary

The new security concept that will be provided by WIF will really change how application security will be built. There are already Hands-On-Labs and documentations on WIF and I encourage you to further “dive” into the subject. I for my part will closely follow the next releases and can’t wait to see the final product.

P1000413P1000411
Share/Save/Bookmark