You are viewing a single comment's thread from:

RE: Question for Programmers

in #life6 years ago

I would start in imperative world as that sounds like the space you came from. Get comfortable and feel like you are getting up to speed again then as a side project explore functional.

Even if you do not ever use it in anger it will change your perspective on code and how you plug it together.

C# and even Java have started to pick up aspects of functional now.

Take the following array of people objects

var people = 
    new[]
    {
        new Person {Name = "Tom", Age = 15),
        new Person {Name = "Bill", Age = 25),
        new Person {Name = "Bob", Age = 30),
    };

I am sure you couple probably think how you might might get the names of all people over 25. Loop through, check the ages and put the names into an array.

The more functional way is called map, filter, reduce. Here is the C# LINQ syntax in action

var names = people
    .Where(x => x.Age >= 18)
    .Select(x => x.Name)
    .ToArray();

Where is filter, it filters out based on the filter function it is given, in this case where age 18 or above. Select is map. It reshapes data, in this case it has picked the names out of the people object.

This is called a fluent interface. The results of each step are pushed into the next step to save holding intermediate variables etc

It also has a longer form syntax

var names = 
    from person in people
    where person.Age >= 18
    select person.Name;

As you can see it almost looks like a database SQL style language. This was intentional when they designed the syntax to make it feel familiar.

There are some real fun changes in languages from when you last touched them so just enjoy the journey and create small test programs to test new things you are trying to learn.

Sort:  

Very helpful. Thanks for the insight. That's my plan start small, get my feet under me again and then figure out the direction I wanna go in. It seems like there's a lot of options nowadays.

Too much choice. Back when I started working in code for a living (Mid 80s) you could keep a wide knowledge up to date. Not now the field is so wide you ether ending up with no depth to your stills and focus wide or go deep.

I prefer the deep route, makes you a better coder in that focused area. I explore other stuff when I get the chance, hence stuff like the F# roguelike. Big enough to test stuff but small enough to be throwaway just to learn :)

Thanks I'll definitely go focused once I decide where my interests and skills lay.

Coin Marketplace

STEEM 0.28
TRX 0.12
JST 0.033
BTC 69692.63
ETH 3775.19
USDT 1.00
SBD 3.76