Wednesday, November 13, 2013

F#

I decided recently that I was going to become a better programmer.  Not that I am a bad programmer, but I know that I could be better.  A few things that I think will make me, as well as others, become a better programmer are as follows:

1.  Start this blog
2.  Read more blogs
3.  Watch more technical videos
4.  Attend more live technical events
5.  Write more clean code
6.  Learn more programming languages or programming related technologies.

If you have read any of my posts, you know that I have been doing most of these already.  One item that has been on my list for a while falls into #6 on the list and that is the attempt to learn F#.  This post is not going to teach you F#, but may influence you to at least execute some F# code.  What I wanted to do for this post was to share my first real step in learning F#.

After searching for for a quick tutorial on F#, I found one and decided to open Visual Studio and begin the journey into F# land.  Before I could create a blank solution to determine what project type to add to my blank solution, I noticed a type of project named F# Tutorial.  Not knowing what this really was, I decided to select this one and take a look.












After creating the project, I remembered doing this in the past with Visual Studio 2010, but right away I noticed that the samples provided were a little different.  What I mean by that is that within the first few lines, which are comments, there is mention of something called F# Interactive and how you can highlight a section of the code and execute the code within F# Interactive.  If you are using Visual Studio 2010, the F# Tutorial project does not mention F# Interactive even though it is available to use.  Someone was smart and added the comments below to the Visual Studio 2012 version of the Tutorial.






So, I gave it a try and it was that easy.  The samples were enough to get me started and had simple string examples, lists, classes, recursive functions, and also an example connecting to a database.  Below are the two steps that I took to execute my first F# code within F# Interactive:

1. Highlight the Strings example

















2. Either Press Alt-Enter or right-click and select Execute in Interactive  



















As you can see it is pretty easy to execute F# code in F# Interactive and be on your way to being a better programmer.  I'm not sure when or if I will ever use it, but at least I know a little more about F# than I did yesterday.

peace yo!

3 comments:

  1. .Net Rocks just had a pretty descent F# episode: http://www.dotnetrocks.com/default.aspx?showNum=925

    ReplyDelete
    Replies
    1. Nice! I'll have to check that out on the way to the office.

      Delete
    2. I listened to most of the podcast this morning. It is awesome to hear the excitement and passion from functional programmers. Not sure what it is, but it makes you want to go out and learn it!

      Delete