Thursday, December 29, 2016

F# Advent: F# 4.0 function first constructor

Hi there!
I know it’s been long promised before, that I will discuss constructor as function in F# 4.0 in my previous blog entry of What’s new in F# 4.0.
This blog is part of F# blog Advent in December that contains blogs of F# developer communities, thanks to Sergey Tihan to organize this advent series! Full list of blog series
Now we can simply treat any object constructor as a simple function call that always returns an object typed as the same as the name of the function, and this is the same as constructor in C#/VB.

Quick background of OOP support in F#

F# is functional programming language, and we all know that it is basically what F# really shines as programming language. But F# has very good support for OOP, including the nature of inheritance, encapsulation, polymorphism and mutability. Every class defined in F# also supports method calls that parts of the object’s behaviors, including object’s constructors.
Since F# first release, OOP support is improving, including nice supports for upcast and downcast of a type. But this type casting support is nicely documented in F# documentation at Microsoft’s new documentation repository: https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/casting-and-conversions

Function constructor in action

Now let’s visit F# tutorial sample on Visual Studio:
VS2015_FSharp_templates
And we now have a Tutorial.fsx file opened. Go to the Classes section in the comments, and we will see the sample code to create class with default constructor that has 2 parameters:
tutorial_oo_classes
We can see that the code instantiate Vector2D by calling the constructor directly instead of using new keyword!
In previous release of F#, we have to use new to call constructor. For example:
let vector3 = new Vector2D(1.5, 4.5)
Now we can simply call the constructor without new, as demonstrated in the tutorial sample:
let vector1 = Vector2D(3.0, 4.0)
Yes, it’s more succinct, cleaner, and one thing is also nice: it’s more functional in style. This new function constructor is typed to return the same object as the function name, therefore there’s no constructor that will return void or unit because this is not allowed.
WARNING: The name resolution is important, we should not have implemented another function with the same name as the name of the class. Otherwise compile error will occur.
Unfortunately, current documentation of F# object expression does not cover this function constructor yet: https://docs.microsoft.com/en-us/dotnet/articles/fsharp/language-reference/object-expressions
I invite all of you, my blog reader, to contribute to F# docs repo. Enjoy contributing and happy coding!

Thursday, March 31, 2016

Current state of Visual Studio releases [March 2016]

Hi there, my blog readers!

I’m back to regular updates of giving what happened in Visual Studio world from February 2016 to the end of March 2016. It’s a bit late (31st March) as there are exciting news!

There were interesting news, including the update of Visual Studio, .NET Core, ASP.NET Core, the shocking nice update: Microsoft acquired Xamarin!

These are the updates from February 2016 to the end of March 2016:

  1. Microsoft acquired Xamarin! – February 25, it was discussed by Scott Gu in his blog entry, also in Xamarin’s blog, as well as others from Wall Street Journal, TechCrunch, etc.
  2. Visual Studio TFS 2015 Update 2 goes RTM!– March 30, 2016, – complete TFS 2015 Update 2 description is available at the official VS TFS 2015 Update 2
  3. Visual Studio 2015 Update 2 goes RTM! – March 30, 2016, – complete Update 2 description is available at the official Visual Studio release note page
  4. Microsoft joins Eclipse Foundation, as described in Brian Harry’s blog and in Visual Studio’s blog.
  5. Visual Studio 2005’s end of support announcement – March 11, 2016 – The official end of date is April 12th, 2016 but it is announced on this Visual Studio blog

These updates are cool! Especially on Xamarin’s acquisition and VS 2015 and TFS 2015 Update 2 releases.

Microsoft acquired Xamarin

Yes, Microsoft acquired Xamarin! Now Miguel de Icaza joins Microsoft as part of Microsoft developers. All of the Xamarin employees are part of Microsoft as well.

For more details, please read Microsoft official announcement in Scott Gu’s blog entry.

We are going to have Microsoft Xamarin Studio? Or new name? This is interesting!

Visual Studio 2015 Update 2 RTM

Yes, we have Update 2 RTM! To me, the most noteworthy notes in this Update 2 release are:

  1. Git indicator of committed changes that not yet pushed and uncommitted local changes
  2. Git submodule update is now available when submodule has to be refreshed for update
  3. Add support for these Git commands: reset –-hard, cherry picking, and staging)
  4. Typescript is updated to TypeScript 1.8

And many more! Again, check the complete list of new features and bug fixes at: https://www.visualstudio.com/news/vs2015-update2-vs

For #1, we can have Git indicator on the status bar below:

VS2015_Update2_git_feature01

This is small new features but it’s very useful to see the number of changes and number of committed changes that is not yet pushed. It might be unnoticed, but this indicator can be clicked. Clicking the “pencil” icon will display the changes page if there’s committed changes. Clicking the “up arrow” will go to the Synchronization page.

These are the new supported Git commands in the Update 2:

VS2015_Update2_git_feature02

The nice thing is the Cherry-Pick support, and I’m going to use this Cherry-Pick often!

Visual Studio TFS 2015 Update 2 RTM

This update is also very good update for TFS 2015 (on premise version of Visual Studio Team Services).

The notable features are:

  1. Creating and deleting team project is now available from the web interface
  2. Work items now can be deleted!
  3. Team Foundation Server extensions!
  4. Create new branch from bugs in Kanban board (new linking capabilities)

For more complete list of new features, changes, and bug fixes, please visit: https://www.visualstudio.com/news/tfs2015-update2-vs

Next blog entry will discuss the implications of Xamarin after acquired by Microsoft!

Monday, January 25, 2016

Current state of Visual Studio releases [January 2016]

Hi my dear blog readers!

The “Current state of Visual Studio releases” series has been quite in active for about 4 months. I know this is supposed to be updated regularly, but unfortunately there are very rare notable news and updates of Visual Studio and Microsoft’s Developer Division.

Also the series got a bit delayed, because I was focusing on previous Lambda Jakarta coding dojo meetup.

From the beginning of December 2015 to 20th January 2016, these are the updates of Visual Studio:

  1. Support period ending for .NET 4, 4.5, and 4.5.1
  2. The release of Visual Studio 2015 Update 1 (on November 30, 2015)
  3. Node.js Tools for Visual Studio version 1.1 released (on November 17, 2015)
  4. First preview of Visual Studio Java Language Service for Android

Now, let’s discuss those three! Except for the last one (number #4), I haven’t got the chance to fully use it.

This is still in preview, for more information please see the blog: https://blogs.msdn.microsoft.com/vcblog/2015/11/06/java-debugging-and-language-support-in-visual-studio-for-android/

Now, let’s start!

Support ending for .NET 4, 4.5 and 4.5.1

The original announcement is here: http://blogs.msdn.com/b/dotnet/archive/2014/08/07/moving-to-the-net-framework-4-5-2.aspx

This simply translate as “Microsoft will not provide supports anymore for .NET 4.0, 4.5, and 4.5.1 and this include hotfixes for these releases”. The next message is simply please update to at least .NET 4.5.2 or even better, 4.6.

The follow up of the original announcement is here: https://blogs.msdn.microsoft.com/dotnet/2015/12/09/support-ending-for-the-net-framework-4-4-5-and-4-5-1/

The interesting fact is from the link above is:

Applications targeting a .NET Framework version that is no longer supported will not need to retarget or recompile to a newer version as they can be run on a later .NET Framework version. The .NET Framework 4.5.2 and higher versions have higher compatibility, provided by a newer feature called “quirking”. Quirking is a pattern in which a .NET Framework version maintains the semantics of earlier versions, while including updated implementations. The .NET runtime knows which of these semantics or quirks to execute depending on the .NET Framework version that the application targets. More information on migrating an application can be found on the Migration Guide to the .NET Framework MSDN article.

Put it simply, it matches with my translation above. I believe this will bring more burden on the enterprise IT operations especially those that focusing on premises (instead of cloud such as Azure), because .NET 4.5 is still quite new for them.

It’s quite new for them, because .NET 4.5 was released in 2012 (with the same release date of Visual Studio 2012, and also Windows 8/Windows Server 2012). Fast forward to now, end of year of 2015, only less than 3 years but they have to immediately upgrade. Less than three years of platform update is inevitable,

This end of support is not just for us, developers. For those develop .NET applications that runs on Azure, the upgrades on Azure are necessary. Fortunately Microsoft has provided updated images (mostly in form of Virtual Machines) that more focusing on .NET 4.5.2 and above (including .NET 4.6).

Visual Studio 2015 Update 1 RTM

This release although it might seems a service release, it really contains many new things.

These are new features brought by Update 1:

  • Visual C#
  • Debugging enhancements (Visual C++ and IDE aspect)
  • Tools for Apache Cordova (now Update 5)
  • Tools for Universal Windows Apps version 1.2

And many more! For complete list of release notes, visit: https://www.visualstudio.com/news/vs2015-update1-vs

Let’s visit some of the new features:

Visual C# new features

This Update 1 brings you C# Interactive Window and C# scripting API. This C# interactive window is very much like F# interactive window, except it has these two quite subtle differences: it has intellisense and type coloring!

csinteractive_vs_update1

If you are wondering what to do at the C# interactive window, just type “#help” like above.

And now we have C# scripting API. Unfortunately, the documentation of C# scripting API is still incomplete and I could not test it further.

One thing is still missing: VB.NET Interactive window! Unfortunately, we won’t see VB.NET interactive in Visual Studio 2015 at all, even after Update 1.

 

Debugging and diagnostic enhancements

In VIsual C++, now we have support for Edit and Continue for /BigObj. This looks like minor feature but this is very important, because it enables debugging with Edit and Continue support for WIndows Store applications that’s written in C++.

In Visual C# and Visual Basic, now we have “Go to implementations” feature when you activate context menu in the source code window. This item will display the implementation of the object you want to observe, not just having knowing “Go to definitions” that was available since VS 2002 (also called Visual Studio .NET 2002).

cs_gotoimplementation

Yup, it’s a minor addition but it’s useful!

There’s also enhancements on Code Analysis, but unfortunately it’s not for Visual Studio Express Edition.

Tools for Apache Cordova (a.k.a. TACO) Update 5

The notable feature is support for iOS 9 and experimental support for Android M, a.k.a. “Marshmallow”. Now TACO is maturing well. The overall experience of using this release is much better than previous releases, including better performance especially responsiveness of the emulators when running Cordova applications.

Beginning with this Update 5, the Node.js will only focus on Node.js version 5. So please update your Node.js installation as well to focus on Node.js 5 and above!

For more information on this TACO update 5, visit: http://taco.visualstudio.com/en-us/docs/release-update-5/

Node.js tools for Visual Studio version 1.1

This is a very useful tool, and sometimes I use this tool to debug certain Node.js package or applications. Having Node.js support in Visual Studio is a very nice feature although this tool is available as Visual Studio extension:

Nodejs_tool_vs

For more information, please visit the official repo of Node.js for Visual Studio: https://github.com/Microsoft/nodejstools

Yes, it’s OPEN SOURCE!

After you download from the Visual Studio Extension and Updates (or you can get from VS Gallery), simply install the MSI:

nodejs_tool_vs_installation

The installation for this release, 1.1.1 will take about 5-7 minutes on VS 2015 Update 1.

One thing you must remember: it needs Node.js at least version 0.91 but it’s recommended to install Node.js 5.

Now, Visual Studio 2015 will have these new project templates: (under TypeScript)

Nodejs_tool_vs_templates

Now, enjoy and I welcome discussions! Smile

Thursday, January 21, 2016

Presenting F# at Lambda Jakarta’s Coding Dojo January 2016

Hi guys!

It’s now community time! I have been active in mostly these two communities, MUGI and Lambda Jakarta.

This time, it’s for Lambda Jakarta. For quick overview of Lambda Jakarta, please read my previous blog: speaking on Lambda Jakarta and welcoming new members on May 2015.

The agenda is having a Coding Dojo in January 16, 2016 that showcases solutions to a specific problem. Thanks to KMKLabs that generously provides us the place to have this meetup! Smile

This is the agenda link on meetup.com:

http://www.meetup.com/Lambda-Jakarta/events/227571071/

These are the language list that joined the coding dojo:

  • F# (brought by me)
  • Scala (brought by Herdy Handoko)
  • Haskell (brought by Abdullah)
  • Scheme
  • Elixir
  • .. and more (including Clojure!)

We have relaxed the coding dojo a bit, as we focusing on functional programming languages but we are welcome participations from attendees Smile

This means, we got a lot of contributions with lots of different programming languages. Bring it on!

coding_dojo_201601

The problems we’re going to solve are FizzBuzz and Dice Roll. Because of our limited time, we only had the chance to present FizzBuzz solutions.

You may read the problem description of FizzBuzz and Dice Roll on the event website. The interesting problem is the FizzBuzz, as it’s often asked at interview of software developer (see this site and this Jeff Atwood’s blog for example).

FizzBuzz was a child’s math puzzle, it’s simply saying Fizz for any number that is divisible by 3, and Buzz for any number divisible by 5, then FizzBuzz for any number divisible by 3 and 5.

put it simply: 3 – Fizz, 5 –Buzz, 15 – FizzBuzz

But then there are various solutions to the problems, as we are trying to solve with the languages we have at each of us disposal.

We have intro from Tito, developer of KMK Labs (the place and the host):

codingdojo_tito_host

I have the chance to present F# as my language to solve. Here, using Visual Studio projected to a large LED display:

WP_20160116_15_28_45_Pro

Here’s the code in F#, you can write this using F# pattern matching:

CodingDojo_FizzBuzz

Here’s the result display on F# interactive:

CodingDojo_FSInteractive_FizzBuzz

We also have Herdy, Abdullah, and others to present as well:

WP_20160116_15_16_30_Pro 

The next meetup? Just stick around at Lambda Jakarta meetup website: http://www.meetup.com/Lambda-Jakarta/

See ya!