DEV Community

Cover image for Which is better for teaching? C# or F#

Which is better for teaching? C# or F#

Jakob Christensen on September 10, 2017

This article originally appeared on my personal blog. Recently I have had the pleasure of training a couple of colleagues in the wonders of progra...
Collapse
 
danieljsummers profile image
Daniel J. Summers

I'm a big F# fan, so I'd be remiss if I didn't mention that your "boiled down" F# example missed the module and [<EntryPoint>] declarations (unless you're running in an fsx file). :)

I'd agree that F# will fit the mathematician's mind better than C# will. Of course, a lot of the .NET Framework examples assume C#, so being passingly familiar with C#'s syntax will be a benefit to your protegΓ©s. So, as BG Adrian said - don't lead with the .NET Framework, lead with "automated mathematics," and bring in the framework when they need to do something the language doesn't handle "natively".

Collapse
 
t4rzsan profile image
Jakob Christensen

Thank you for your suggestions. I will start with real world assignments and bring in whatever is needed from the framework or from Nuget as we go.

I admit that I did cheat a bit with the F# example to state my point. But one of my points is that F# can be easily used for scripting (.fsx) so it is still valid :-)

Collapse
 
saint4eva profile image
saint4eva

C# can easily be used for scripting also - (.csx)

You can use Xamarin Workbook or VS Code to start teaching your colleagues.

You can just use WriteLine("Hello World"); After you have declared the using statement, which you did not do in your F# example - whence biases.

Anyways, teaching one programming depends on many factors and there must be biases and preferences. People will always resist new ways of doing things until you break that barrier by motivating and influencing them.

Without mincing words, C# is a powerful and wonderful language with many great features - check out C# 6, 7, 7.1 and upcoming version 8. And F# also is a great language. All of them running on a great and powerful platform - .NET or .NET Core.

So if you feel F# will be better for what they will be doing for the company, teach them F#. But is C# will be useful and better for what they will be doing, teach them C#. After all, I do not think is hello world they will be developing for the company.

Consider the prospect of the language, industry support, platforms they run on; how many different types of application you can develop using them. etc.

Collapse
 
bgadrian profile image
Adrian B.G.

Mathematicians == functional programming, there is no question.

But if they are not into programming, and you want them to enter just as a hobby do not include work matters, do not call upon the HUGE languages like .net where you get lost on stack overflow. Make funny projects with them, games are always good for the morale

start slow - Khan academy - JS canvas library
CodeCombat.com or codingame.com or other competitive ones, where you can battle each other, a tournament is always good for spirit
Unity3D - has Mono, but you can achieve a lot of things w/o scripting. Do weekend game jams.

Collapse
 
t4rzsan profile image
Jakob Christensen

I never thought about using non-.NET languages. JavaScript may be a good place to start. I will think about it.

Anyways, most of them are not completely new to programming. They have done some SQL and VBA and the intention is to level up. But you are right - none of them are really into to programming so your suggestions may show them the joys of it.

Thanks for your advice.

Collapse
 
bgadrian profile image
Adrian B.G.

Np, as a professor is hard to find something they might like. For kids Scratch works great for example.

You can try other fields too like: make a pathfinding route for the Roman empire or learn how to query one of the biggest public DB hosted at GCloud, like GDELT, make scripts to fetch those data or you download them, and make cool contests to find the weirdest popular news like how many ppl were killed by a parrot :).
The point is that languages are just tools, you will learn a tool when you have a project for it and understand it's utility, and want too.

Collapse
 
matthras profile image
Matthew Mack

Definitely F#, but highly suggest you be prepared to adjust your teaching approach on the fly depending on your colleagues. There'll be, in my experience, two ways of approaching a new topic:

  1. Learn the theory, then apply it to building stuff.
  2. Build stuff/scripts first, and then teach the theory afterwards. As a mathematician this is my approach with coding, because what I find fun is figuring out the abstraction, and then confirming/normalising that with the theory.

Definitely think about the learning curve. With your C# example it was far too steep to begin with, partially because your example had a lot of additional details that for you, it's easy to not worry about. For beginners, they have no idea what to focus on, so their attention goes everywhere and as a mathematician myself I'm obsessed with the details, so my head would also be springing with questions like "What's namespace, static, void? etc.".

Start with scripting and doing things, and if there's such thing as a symbolic maths package/library for F# you can have a bit of fun with that. I know nothing about F#, so I don't have any other specific suggestions.

Collapse
 
t4rzsan profile image
Jakob Christensen

Thank you for your comment.

I think you are right that there are too many details in C#.

Starting with scripting is a good idea and F# is really good at that. All you really need is a text editor.

Collapse
 
saint4eva profile image
saint4eva

I bet to differ. There are also many details in F# hello example, it was the writer who decided to leave them out for brevity. C# also has a scripting capability both in Visual Studio, VS Code, and Xamarin WorkBook.

You can just do WriteLine("Hello World"); in C# example. I would suggest the teacher do some researchers to find out what is needful and meaningful for the team based on the tasks they will be rendering the company.

Anyways, F# is a great language, and C# is a great language - all taking advantage of a powerful platform - .NET.

Collapse
 
yawaramin profile image
Yawar Amin

I highly recommend this course: coursera.org/learn/programming-lan...

It's a free online MOOC with short lecture videos, about 10 mins each. The professor has a knack for explaining functional programming concepts simply and succinctly. He teaches statically typed functional programming, and I think covers the concepts that will really open your mind to the specific way of thinking with types and functions.

About a year ago, I actually started a lunchtime study group with some of my colleagues to tackle this course, with the expectation that it would take about four to six weeks to finish. The course itself is taught in Standard ML, but I prepared some supplementary notes to convert the syntax and some techniques to F# (the two languages are very similar). I can send you the notes privately if you want.

In our case unfortunately we didn't have the time or discipline to keep up the course, but if you have some support and engaged learners it should be possible.

Collapse
 
t4rzsan profile image
Jakob Christensen

Thank you for your comment.

I will definitely take a look at your link.

Collapse
 
yonifra profile image
Jonathan Fraimorice

I think that C# has maybe a bit bigger learning curve at first, but afterwards you gain important knowledge in one of the most popular languages in the worlds, and knowing C# will help later on in moving to other similar languages such as Java.
I've never seen a job post with F# requirements, but maybe it's just me.

Collapse
 
t4rzsan profile image
Jakob Christensen

It seems that FP is gaining in popularity (especially Elm) but you are right about the popularity of C# and the missing job postings for F#.

Thanks.

Collapse
 
voronoipotato profile image
Alan Ball

F# is easier to teach someone to get started imho.