Archive for October, 2008|Monthly archive page
Learning F#
My being a long-time C# coder, I finally decided to take a break from imperative programming and try something new. To be honest, I’ve quite often reached the point with my projects where I wonder: Couldn’t this be written so much more concisely and elegantly in another way? This thought occurs especially frequently in the context of mathematical and scientific coding. In response to this question, there have been suggestions (on more than one occasion) by David to try F# (specifically this functional language as he knew he couldn’t get me totally away from .NET yet). In case you’re not aware of it, it’s Microsft’s attempt at bringing functional programming to .NET, and has proven very successful so far.
It turned out that F# was surprisingly straightforward to learn, even for a language still in the beta stage (albeit the end thereof). Three or four days of regular coding gave me a pretty good idea of how it can be used for all sorts of purposes. Most likely my familiarity with lambda functions and LINQ in .NET 3.5/C# 3.0 made the task a lot easier. Even so, Microsoft have put together a number of helpful resources/links for getting started. The online documentation is especially useful given the (current) lack of XML intellisense comments inside Visual Studio. The Microsoft Research F# page and the F# Developer Center should be your first stops when learning the language. In addition, there is a pretty active community at hubFS and a host of blogs dedicated to F# out there. It seems like only a matter of time before there’s a multitude of forums and an IRC channel. I get the feeling that due to the ability to use the .NET framework from a functional language (and the fact that Microsoft will soon be making it a first-class language alongside C# and VB.NET), F# could have unprecented popularity.
After reading a few of the guides and beginner tutorials, I came across Project Euler, a series of mathematical/programming challenges that are particularly suited to the functional programming style. This website was really all I needed to get a solid grasp of the language, and was pretty fun aside from that. After trying some of the problems I finally had to admit that functional languages have their place in the programming world alongside imperative ones such as C# and C++. If you’re interested in some of my solutions to the first 23 problems, you can download the zipped project here. (Most solutions are under 5 lines in length, not including helper functions or input data.) I’ve had fair success optimising most of the algorithms, though in one or two cases you’ll find clearly more efficient solutions elsewhere. However, they’re not all terribly well commented, so feel free to question me about any of the algorithms.
Unfortunately I have quickly been forced back into the realm of imperative languages due to my project commitments (posts to come soon). Do however expect some upcoming posts and projects to feature F#, or at the least functional techniques.
Windows SSH Server
This is a notice to anyone who might be interested in my open-source Windows SSH Server project. Windows SSH Server is a project I started earlier this year as an attempt to fully implement an SSH2 server using the .NET 3.5 framework (primarily C# with a bit of C++ for interfacing with Windows Console). The project is currently hosted on Launchpad. I have maintained a Bazaar repository of the entire source code.
It has grown to become just about usable now, providing a shell interface to any Windows Console application (e.g. cmd, PowerShell), though not yet programs such as edit. The protocol library SSH.NET has been written from scratch and is probably about 90% complete (minus extra features such as TCP port forwarding) and all the necessary cryptographic algorithms have been implemented/integrated in full. The main task in order to make it fully usable is finishing the Windows Console scanner (also very nearly usable) and then create a proper user-interface for authentication, which is currently hard-coded. Of course, there are other aspects to the project such as the Windows Service (which is already working) and the admin interface, though they are not so important for the first release. I am also considering splitting the development into two seperate projects, one of them being the SSH server and the other an xterm shell for Windows Console applications (which would be utilised by the server). The main purpose of this is so that the xterm shell can be completed (or at least made stable) much sooner than the SSH server and can serve as a useful program by itself.
Unfortunately, although the project has come along very well I likely won’t be able to find the time to work much on such a large project in the near future. (A one-man team was never going to finish the job!) I am nonetheless keen to maintain the project and see it become mature with the help of other experienced coders. If you’re interested in contributing to Windows SSH Server (or the Windows Console xterm shell) in any way, please contact me via Launchpad and I’ll be glad to answer any questions and possibly set you up as a developer.
Comments (2)
Leave a Comment