Functional Thread 6 part 2: Exceptions

If I may, which is more suited to general programming use, Functional Programming or OOP?

I tend to find Functional way more versatile and a lot faster, especially considering that I code in JS for the most part. I will only really use OOP when I need to generate a lot of "user" data and store profile information in a standard way that writes to a DB nicely.

Also I would love to have a more in depth looking into this challenge, but I will need to download VS Code.
 
If I may, which is more suited to general programming use, Functional Programming or OOP?

I tend to find Functional way more versatile and a lot faster, especially considering that I code in JS for the most part. I will only really use OOP when I need to generate a lot of "user" data and store profile information in a standard way that writes to a DB nicely.

Also I would love to have a more in depth looking into this challenge, but I will need to download VS Code.
Both; languages like C#, F#, Java, Javascript, Kotlin, PHP, Swift, Ruby, Python, VB.Net, etc... have a long history with OOP architected frameworks and APIs, so from that point of view OOP will generally be unavoidable; however it doesn't mean that a majority of your codebase couldn't be functional. All of these languages have anyway embraced functional constructs in their standard libraries, and also have extended their language syntax to better support a functional style.

Note:
  • A general rule of thumb is that 80%+ can be functional and the remainder would be some from of OOP and/or Imperative code.
  • Scala as example is a very flexible Functional Language that actively embraces a marriage of Functional and OOP in the same codebases.
  • The architect of the Scala language, for example deems OOP to be an orthogonal to paradigms like Imperative and Functional. Meaning it's exists independent to those paradigms; yet it certainly doesn't mean it's either non-redundant and/or non-overlapping because there are many situations that could be rewritten functionally or imperatively.

Functional is typically less suitable for side effects because of the necessity to mutate global state, for example:
  • UI updates
  • JSON URL requests
  • SQL transactions
  • etc...
...but as you hopefully could see in this thread; there are even benefits to rewriting many of the OOP bits in a functional style, for example: the API for SQL.

Short answer:
They're complementary; however I tend to push OOP to boundaries where side effects are required; for the remainder I prefer to stay functional, because it's example:
  • far more terse,
  • simple to reason about,
  • simple to test; innately avoids Heisenbugs, ...
  • easier to enable concurrency & parallelism
  • easily avoids tight coupling
  • etc...
Plus points it will make you a better programmer, because it requires you to question the way that applications are architected.

If you need help:
Just PM if you need any help getting started, and BTW the downloadable code is for C# which requires Visual Studio (not VS Code); if you're on Windows then you can download the Visual Studio Community Edition (Free), or if you're on a Mac then you'd download Visual Studio for macOS (Free).
 
Last edited:
I will have a look into this at home.

I mainly use Linux, so I will need to download quite a few things.
 
I will have a look into this at home.

I mainly use Linux, so I will need to download quite a few things.
For Linux, VSCode is certainly the right option; you just need to install the latest .Net Core, and update the nuget packages (install this separately)
  • SqlClient works just fine on Linux;
  • I've also seen there's a universal driver for SQLite Linux on Nuget;
  • Failing that you can always compile it yourself.
As for VSCode support for C#; you could try this extension (appears to have most of what's needed, including csproj project support):
 
Top
Sign up to the MyBroadband newsletter
X