Learning programming languages *split*

x = x +1 - this is a mathematical nonesense but widely used when teaching programming (of course due to being a notation supported by mainstream - old and new - languages)

When one approaches functional programing, habits such as using mutation must be abandoned. Hence why it may be more dificult

I also agree that it is actually easier as the handling of state the FP way results in programs that are easier to maintain and debug.

But there are "degrees" with regrads to functional programming. It is one thing not to use side effects and pass functions as objects. it is another to design APIs as algrebras, master recusion schemes, and to see Adjoints and coproducts everywhere. The latter involves quite a bit of study, and I'd argue that is more involving thatn your avereage design pattern, being more abstract.
 
Sure but where those are used, you are often looking at a mathematician at work, not necessarily a programmer who thinks Domain Driven Design and code readability are priorities!
 
I'd argue that these vastly empower programmers regardless.

All these concept don't come from matematics as a whole, but from a portion of it, cathegory theory. Cathegory theory is mearly a language used to describe laws and structures, but with no meaning intrinsec (abstract nonsense).
Which is , oftentimes, exactly what programing is about - applying structures and flows to various domains (sales, games, computer aided design)
 
the differentiation being the capitals and so on.
then dont differentiate with capitals.
NameOfObjectAmount = amount
instead of
Amount = amount

for example

modern ide's come up with a list when you type the first few letters so you only have to actually
type NameOfObjectAmount once, so theres no reason not to use long descriptive variable names
 
But functional programming is actually easier ... the problem is the initial people using it have often been mathematicians.

I watched that series with the guy making a text adventure by the way, very entertaining. There is also a great article on a team at Microsoft writing a new service completely in F#. They had a very smooth experience, exceeded all their expectations and documented it very well. One of the more remarkable things I took from that is how much better it is as a scripting language than power shell. They rewrote a 1400 line power shell script into 350 lines of F# or something like that.

The book I was referring to by Scott W is so good because it is very easy to read and takes your typical line of business app (order lines etc) as an example.

https://pragprog.com/book/swdddf/domain-modeling-made-functional
got the book! It is in beta state, latest release being in September. The first 50 pages of Domain explanation save for the UML at the beginning sounds unfamiliar to me, but then the F# part looks fine even for a beginner. However, in that sense the Book of F# is what I am reading and I am going to keep it reading it til there is some advance on my part.

then dont differentiate with capitals.
NameOfObjectAmount = amount
instead of
Amount = amount

for example

modern ide's come up with a list when you type the first few letters so you only have to actually
type NameOfObjectAmount once, so theres no reason not to use long descriptive variable names
oh well, I meant when it comes to objects at declaration time Car car("whatever comes here") = new Car();

On a different note, kinda off-topic I got the Roland Sound Canvas VA (I remember the conversation about MIDI with you but I can't recall in which thread it was) and the sound is awesome, especially the native GS files...wow... I have the Roland SD-50 and it's good but it's mostly a GM2 synth, GS sounds quite basic in it.
 
Making a platformer in F# with monogame:

https://bruinbrown.wordpress.com/2013/10/06/making-a-platformer-in-f-with-monogame/

I am also following the development of another functional language, also open source, called F* (which stands for F Star). It seems a lot to learn, but the idea is that when you know how to program in OO mode, or functional programming, what changes for the most part is the syntax.

https://www.fstar-lang.org/

Some interesting tidbits:

Programs written in F* can be translated to OCaml, F#, or C for execution.
 
How fast is F#, I'm programming in C# and even using unsafe & after a couple of hours I just couldn't match C++ speed, C# being an order of magnitude slower after optimising... :(
I just can't use something that slow, it means its wasting valuable CPU cycles therefore energy uselessly...
 
How fast is F#, I'm programming in C# and even using unsafe & after a couple of hours I just couldn't match C++ speed, C# being an order of magnitude slower after optimising... :(
I just can't use something that slow, it means its wasting valuable CPU cycles therefore energy uselessly...
Sure C# is slower but surely not 10x slower, one thing I'ld like done with C# is ability to disable GC and ability to call it only when I want it called. Still C# is my fav language
 
How fast is F#, I'm programming in C# and even using unsafe & after a couple of hours I just couldn't match C++ speed, C# being an order of magnitude slower after optimising... :(
I just can't use something that slow, it means its wasting valuable CPU cycles therefore energy uselessly...
some stats on how slower it is would be good to know... C++ is faster overall, they say, that's whey they use for AAA games. But not orders of magnitude faster, and you can produce very fast code with C#, also in games --Ori and the Blind Forest and Cuphead come to mind, which are programmed using Unity and C# and don't require a very powerful machine.

When I started to become interested in functional programming and learnt about Haskell (that'd be a great language to learn, however if I had to learn it I'd do it for academic reasons, because what makes F# stands out compared to it, is that it has good tools and a good ecosystem around, which many of those languages lack, imho) :) and F#, I was also interested in knowing which one is faster. Most of the replies I remember to that stuff pointed out at F# being faster.

People mentioned the fact that F# is faster than C#, maybe because you can express most of the same functions in less code and maybe while the computer is doing basically the same, the programmer's mind is freed from some extra steps to take and can think better and clearer on what code to use. :)

However, as of now, C# compiler -given the fact that the language is more popular- has gone through more some extra refinement that F# is lacking. afaik, for instance, when it comes to UWP, C# has access to a mode where the code runs much faster and is better optimised when you program a Windows store app, wp app, or Xbox app -UWP-. This is quite recent and it's still not present in F# but they will add that support in the future.
 
Modern programming languages do have some extra costs that does not appear in C/C++. For example, many modern programming languages require boundary check on all array access, and while it could be optimized away sometimes, it still makes array indexing more expensive.
Indirect object referencing is also much more common in modern programming languages than in C/C++, although it's not as slow. Indirect function call (which is generally slower than direct function call) is also very common in modern programming languages but relatively rare in C/C++.

The good news is that many programs with tight loops can actually be moved to the GPU, which normally uses a C/C++ like programming language.
 
There are a lot of gotcha’s too, like strings being immutable in C# and mutable in C++, which is why I was asking Roderic what he was comparing. It is a really obvious one to most but using Stringbuilder, meant for string operations, is really orders of magnitude faster.

Where F# normally wins against C# is type checking: it can do much more of that at compile time which saves time on runtime. Also some things you have to do differently to be fast - a loop in F# is fastest in a tail end recursive function, at which point it is 25%-30% faster than in C# I believe.

And of course managed code, running against a VM and running against .NET framework all come at penalties, so you have to make sure you compare like for like.

No doing async and parallel work is never easy, but in F# it is certainly more elegant than in almost any other language I know of!
 
Garbage collected languages are crap for games because they are very inefficient when it comes to memory access patterns (which is what usually takes most times in games and HPC-type programs) and are very indeterministic (the GC might run in one frame but not the other). Rust and modern C++ are better for games.
 
Want to make special mention to the resources the guy from the F# Delight video recommends to learn the language (gotta get those books, plus they are from the 4 version of the language, which means pretty recent) by the very end of the video:

http://fsharpforfunandprofit.com/

The book Beginning F# 4.0 from Kit Eason. Probably better than the book of F# for beginners?

http://www.apress.com/us/book/9781484213759

9781484213759.jpg


When you learn the basics well, this is the expert book he recommends. The book was partially written by Don Syme.

http://www.apress.com/us/book/9781484207413

9781484207413.jpg


Kit Eason's courses on PluralSight:

https://www.pluralsight.com/courses/fsharp-jumpstart

You can try HackerRank challenges in F#:

https://www.hackerrank.com/
 
Back
Top