IS F# going to replace C#

One tool can not fit all needs.

  • Did Asp.Net MVC replace Asp.Net Forms ? No, both are used according to the project needs.
  • Did Vb.Net replace C# ? No, both provide almost same functionality and options but pull developers from both families. Vb and C.
  • Has WPF replaced, WinForms ? not yet, might in future.
  • Chris Smith’s on his Blog, says

    ” But just because you can write code in a new language doesn’t mean you should. So why use F#? Because being a functional language, F# makes writing some classes of programs much easier than its imperative cousins like C#. Parallel Programming and Language-Oriented Programming are two such domains that can be expressed easily in F#.

    If you’ve ever written a .NET application and found yourself fighting against the language to get your idea expressed, then perhaps F# is what you’ve been looking for.”

    F# is basically an functional language by its nature. The argument here could be more towards the style of programming rather than features a language may support.

    As per Eric Lipert answer to a similar topic ( my post was inpired to ) at stackoverflow, following things are to be considered before one thinks about using F# as the language of choice for a project.

  • F# cannot solve any problem C# could.
  • F# is a functional language, statically typed.
  • F# is a functional language that supports O-O-Programming
  • more information and references:

    Microsoft F# Developer Center
    F# at Microsoft Research

    And to:
    Learn F#
    download F#
    F# FEBRUARY 2010 RELEASE

    Advertisements

    Working with Folder properties in C#

    Here is a simple programs that evaluates different properties for a folder in Windows

    class Folder : IComparable
        {
            public string name;
            public string path;
            public int size;
            public Folder(string _name, string _path, int _size)
            {
                name = _name;
                path = _path;
                size = _size;
            }
    
            #region IComparable Members
    
            public int CompareTo(object obj)
            {
                Folder folder = (Folder)obj;
                return folder.size.CompareTo(this.size);
            }
    
            #endregion
        }
    
    class SizeClculator
        {
            public static ArrayList directories = new ArrayList();
    
            public static void GetFolders(string path)
            {
                DirectoryInfo di = new DirectoryInfo(path);
                if (di.GetDirectories().Length > 0)
                {
                    foreach (DirectoryInfo dir in di.GetDirectories())
                    {
                        GetFolders(dir.FullName);
                    }
                }
                else
                {
                    int size = 0;
    
                    if (di.GetFiles().Length > 1)
                    {
                        FileInfo[] fileInfo = di.GetFiles();
                        foreach (FileInfo fi in fileInfo)
                        {
                            size = size + (int)fi.Length;
                        }
                    }
                    directories.Add(new Folder(di.Name, di.FullName, size));
                }
            }
            public static ArrayList GetFoldersList()
            {
                return directories;
            }
        }
    
    class Program
        {
            static void Main(string[] args)
            {
                string filePath = @"D:\Common\Test";
                SizeClculator.GetFolders(filePath);
                ArrayList al = SizeClculator.GetFoldersList();
                al.Sort();
                foreach (Folder folder in al)
                {
                    Console.WriteLine("Name:" +
                        "  || " + folder.name +
                        "  || Path: " + folder.path +
                        "  || Size: " + folder.size);
                }
                Console.ReadKey();
            }
        }