Sure, C# is borrowing features from functional languages like records, pattern matching, and switch expressions. But it doesn’t make it a functional language.
At its core, C# is an Object Oriented language — with mutable state baked in. But it doesn’t mean we can make it functional with a few tweaks.
That’s the main takeaway from the talk “Functional Programming on .NET” by Isaac Abraham at NDC Conference 2024.
Here are some other lessons I learned from that talk.
Here are two misconceptions about Functional Programming
1. “It’s difficult”
When we hear “Functional Programming” what comes to mind is obscure jargon like monad, monoids, and endofunctors. They sound like you have to grow a beard to understand them. That scares programmers away from Functional Programming.
2. “I’m already using lambda expressions”
Lambda expressions and other recent features are syntactic sugar to make C# less verbose. Lambda expressions simplify delegates. And we’ve had delegates since C# 1.0 when C# looked way less functional than today.
The truth is functional programming could be simpler and lambda expressions don’t make C# functional.
If lambda expressions and other features don’t make C# functional, what is it then?
Expressions and Immutability.
Expressions mean everything has a result. Think of old-style switch/case statements vs switch expressions. We can assign the result of a switch expression to a variable, but not an old-style switch/case. If it can be assigned to the left of =, it’s an expression.
// This is not an expressionswitch(cardBrand){case"Visa":cardType=CardType.Visa;break;case"Mastercard":cardType=CardType.MasterCard;break;default:cardType=CardType.Unknown;break;}// This is an expressionvarcardType=cardBrandswitch{"Visa"=>CardType.Visa,"MasterCard"=>CardType.MasterCard,_=>CardType.Unknown};
And immutability means that everything is set for life. Think of records, the init keyword, and private setters.
With these two concepts, to make C# functional, we should forget about classes and inheritance to go with static methods. We should forget constructor injection and go with regular method parameters. And we should separate data from behavior instead of keeping them side by side in a class that mutates state.
Following these two concepts, a dummy Calculator that looks like this
A few lines of code. In F#, functions don’t have to live in classes. The compiler infers parameters types. And we don’t need to use the return keyword.
The perfect example of expressions and immutability in practice is LINQ.
LINQ is functional.
Every LINQ method returns a new collection. We don’t have “void” LINQ methods. Expressions. And no LINQ methods change the input collection. Immutability.
That’s why LINQ is the best of all C# features—It’s functional.
Voilà! We don’t need fancy features like discriminated unions to adopt functional ideas in C#. Only those two fundamental concepts. Sure, new features help a lot!
We don’t get an instruction manual to survive the corporate world and navigate the “people and interactions” side of software engineering.
After over 10 years, 3 jobs, 2 “we have to let you go,” and lost of trial and error, these are 14 lessons I’ve learned while navigating a career as a software engineer:
1. You Can Lose Your Job At Any Time
You can’t control it. A pandemic, a recession, or anything else. But you can control: your online presence, emergency fund, and side income.
2. Detach Your Sense Of Meaning From Your Work
Work gives value and meaning.
But you’re not your work. You’re the books you’ve read, places you’ve visited, and people you’ve met. You’re your connections, experiences, and knowledge.
You’re more than a job.
3. Build Multiple Sources Of Income
A rental property, stock portfolio, or digital products. You name it.
Don’t rely only on your salary and don’t live paycheck to paycheck. There’s no safe job. See #1.
4. Always Be Ready To Leave Your Current Job
If you wait for a layoff to take action, it’s already too late.
Grow your network, have your CV updated, and keep your “tell me about yourself” muscles in shape. Yes, hiring is broken.
5. Change Jobs Often
Or at least, don’t stay too long at stagnant jobs.
Otherwise, your CV will become outdated, your interviewing skills will get rusty, and you will leave money on the table.
6. Climbing The Corporate Ladder Is A Myth
Anyone can add or remove steps in the ladder. Or remove the entire ladder. The best ladder to climb is the one you build for yourself.
A new title comes with more meetings, extra hours, and the same salary. Instead of optimizing for a title, optimize for a lifestyle.
7. Vacations Don’t Change An Unfulfilling Job
Neither do pay raises.
They only move a “death sentence” a couple of months ahead.
8. You Don’t Have To Feel Miserable
If you don’t feel like getting out of bed to work at that place, make a change. Find a way to motivate yourself and keep learning. Or look for “greener pastures.”
9. You Don’t Get Burned Out By Doing Too Much
But by doing too little of the things you care about. (Jim Kwik, brain coach)
And seek help when people around you start to be affected by your burnout.
10. Software Projects Don’t Fail Because Of Programming Languages And Tech Stacks
Nope! They fail because of poor communication and unclear expectations. The same as marriages. Even unclear expectations are a communication issue.
11. Don’t Be A Hero. Be A Team Player
If you are the only one who knows or does something in your team, you’re being a hero.
It feels great when you are the one who saves the day, but being a hero is a trap. A hero can’t get sick, go on vacation, or be promoted. Be a team player instead.
13. Don’t Ask Someone Who’s Leaving To Finish An Important Task At Work
As soon as he leaves, something will happen to the task he finished: an unexpected issue, a change in requirements, or a new scenario nobody saw coming. And he will be the only one who knows how to handle it. Too late. He’s already gone.
14. The More Senior You Get, The Less It’s About Coding
There’s more than coding:
Team dynamics
Project management
Inter-team communication
Scope and deadline negotiations
Managing stakeholders’ expectations
There’s more than only source code in a text editor.
Parting Thought
Hoping and praying without taking action is a bad career strategy. Instead, define what you want from your career. Money? Connections? Recognition? Create a career plan that reflects that, pick the right jobs, and always have an escape plan.
“Your career is your responsibility, not your employer’s” — Clean Coder by Uncle Bob.
Refactor your coding career with my free 7-day email course. In just 7 emails, you’ll get 10+ years of career lessons to avoid costly career mistakes.
Learning a second language has been my best career decision.
Literally, it changed my life and doubled my salary.
Initially, I learned English to make my CV look more attractive to recruiters. But learning English has been more than a better CV for me.
It took me a couple of years to learn English and an extra couple of years to take full advantage of it. I went to a traditional language school: lots of grammar exercises and “repeat after me” sessions.
With the right method and consistency, you could learn a language faster. One year is a good time frame to reach a conversational level. Of course, your mileage may vary.
If you’re learning a second language to boost your career, prepare for your next vacation abroad, or connect with your extended family, follow these 7 proven steps:
1. Fluency Isn’t Perfection
Before learning a single word or grammar rule, understand that nobody speaks any language perfectly.
I don’t speak perfect English. I don’t even speak perfectly in my native language. Nobody speaks perfectly in any language.
Speaking a language isn’t about making zero mistakes. It’s about communication and human connection.
Fluency isn’t perfection.
With that myth debunked, let’s move to the next step.
2. Identify Your Goals
Start your language journey by identifying your goal and your time frame.
A clear goal helps you determine what skills you need to focus on and what vocabulary to master. Studying to pass a language certification exam in a few months is different from learning useful phrases for your next vacation.
To keep that goal in mind, set a language checkpoint or milestone. For example, your first checkpoint could be a 15-minute conversation with a native speaker after your first month of practice.
3. Find a Learning Method
The key to learning a new language is to tie it to activities you enjoy doing.
I enjoy listening to podcasts and watching videos. When I started to learn French, I found a podcast for beginners and followed it during my lunch breaks. While everybody else at the office was taking a nap, I was with my headphones on, listening and taking notes.
From Scott Young’s Ultralearning book, the guy behind the “One Year Without English” challenge, I learned to spend about 10% of the learning time finding resources and study guides.
Spend the first days, looking up good resources to learn your target language.
4. Find a Teacher or a Language Partner
No matter how shy you think you are, sooner or later you will have to open your mouth and let words out.
My best strategy is to find a teacher or language partner for one-to-one sessions. Personally, I have used iTalki to find my teachers and language partners. Some teachers offer structured lesson plans or only conversation practice. But with language partners, expect only chit-chat about anything. Usually, you split the practice session in half: switching languages each time.
I have to confess I’ve been lucky with my language partners. After several practicing sessions with a language partner, we became friends and met in real life. It happened we were on vacation in the same city. And, thanks to those unexpected life turns, my language partner’s husband was a lawyer and ended up helping me review my contracts before joining my first job at an international software agency.
A teacher or language partner will help you practice in a stress-free environment.
If you’re learning a language for work, ask them to role-play being your interviewer or a participant at a meeting you have to conduct.
5. Practice a Little Bit Every Day
“Little by little, a little becomes a lot.” — Jim Kwik, the Brain Coach.
If you want to see fast results, study a bit every day. Learn 5 phrases or listen to a short audio a day. That’s better than a long study session once a week.
If you think you don’t have time, take advantage of every dead time slot in your schedule: while waiting in lines, on the bus, or walking home.
Back in the day when I had to commute, I reviewed my Anki flashcards and listened to podcasts on my way home.
If you’re not used to practicing a language daily, tie your study or practice sessions to an already-built habit. Do you have to do the dishes? The laundry? Listen to an audio lesson while doing it. You said you don’t have already built habits? What about listening to podcasts while in the shower? You shower regularly, right?
6. Learn Phrases Instead of Words
Don’t memorize words or grammar rules.
I know it’s frustrating when your teacher asks you to open a textbook to work on grammar rules in your first class. It kills all the fun of learning a language.
Instead of learning individual words, learn complete phrases and use them as LEGO bricks you assemble and interchange. You will learn words in context along with their gender. Yes, words have gender in other languages. And it’s funny when one word has a different gender in your target language.
Also, don’t overthink grammar rules or find logic in your target language.
When we were children, we didn’t receive a grammar book to learn our native languages. We absorbed grammar rules after being exposed to the language for hours and hours.
7. Immerse Yourself in the Language
This is the #1 tip to study from home – Create a language environment around you and your hobbies:
Change your phone and computer language
Read the news or watch TV
Follow social media
Listen to music
You name it!
You don’t have to travel abroad to learn a language, you can do it in the comfort of your bed.
Parting Thoughts
Thanks to learning a new language, I’ve made good friends, doubled my salary, and discovered a passion for learning and teaching.
We become a new person with every language we learn. I feel like I’m more extroverted when speaking English.
I have found that there’s no better way to build trust with coworkers or clients at work than to say hi, thanks, yes/no, and bye in their target language. It will bring smiles to their faces and show you’re interested in their culture.
So if you’re looking for a twist in your career, try a new language. Try Arabic to work in the oil industry, German for the automotive industry, or Spanish to join a rising startup in Latin America…who knows!
A second language could change your life too.
Refactor your coding career with my free 7-day email course. In just 7 emails, you’ll get 10+ years of career lessons to avoid costly career mistakes.
For months, I ran a series called: Monday Links. Every time I found interesting posts about programming and software engineering, I compiled them until I had five or six and then published them in a post.
It was a way to document what I read and react to the other people’s posts, when my reaction didn’t merit a separate post. Think of Twitter/X threads on my blog.
I’m moving my Monday Links to an email list.
The format is almost the same. Every Friday, I send five posts about software engineering and programming. But I sprinkle other interesting subjects in between. Also, I include one of my own posts published the same week and share updates about the projects I’m creating.
I hope I don’t have to write a CV anymore. I hope you don’t either.
A personal brand is the new CV and portfolio.
But since you’re reading this one, probably you still need to write a CV. I wish it won’t end up in the dumpsters behind a company careers page. I’ve tried that route with zero results.
More than once, some friend or ex-coworker has asked me to take a look at his CV. I’ve asked them too.
I realized I had already given (and received) the same tips about CVs. These are five tips I always give to write better CVs as software engineers.
1. Keep Your CV to Only One Page
These days of endless scrolling on TikTok, nobody has time and attention to read more than that.
Make it easy for people to review your CV. More than two pages are too long.
Imagine your CV is a business card in a A4 page. You only have one or two minutes to introduce yourself in a business card. Do the same in a CV.
Keep font size, spaces, and borders consistent.
2. Don’t Include a Photo, Marital Status, National ID, or Other Personal Information
Only add your professional email and LinkedIn profile, or any other social media profile to showcase your expertise. GitHub, Medium, dev.to handles work too.
I even skip phone numbers. You don’t want strangers calling or texting you in the middle of the night for a “life changing opportunity at a well-know company in the tech sector.”
You will be asked for personal information once you’re hired, not before.
And only include your city and country if you’re applying for a position that requires being in a particular location. Don’t put your home address either.
3. Don’t Add Every Single Experience Since You Started Working
Use your most recent experience. The last five years, for example.
And, include only the experience relevant to the job you’re applying for. Don’t add the unrelated part-time job you had in your first year at university.
4. Don’t Include a Cloud of Keywords, Languages, or Library Names
Stars or years working with a language don’t mean expertise.
Probably, you’re riding a bike since you’re 4 or 5, but it doesn’t give you a place in the Tour de France. It’s the same with years of experience with a language or tool. What does five years with XML mean?
Instead, describe what you did and what accomplishments you made in your previous jobs. Use numbers in your job descriptions.
For example, “I wrote an order processing component that scaled up to X orders per month by…“ instead of “C#/ASP.NET Core/SQL Server.” Somebody reading your CV would wonder what you did with those tools.
A bunch of names by themselves mean nothing.
5. Skip Fancy Lines Like “Honest, Hard-Working, Team Player”
Everybody uses the same buzzwords.
“Team player,” “detail-oriented,” and “enthusiast” only take extra space in your single-page CV. Do you still remember tip 1, right? And guess what? Everybody desperate for a job is a detail-oriented enthusiast team player who like to work under pressure in their CV.
Instead of fancy lines, describe in a paragraph what you do and how you can help your next employer.
Voilà! Five tips as promised. Remember recruiters, technical managers, and CTOs will read your CV looking for different information, not only a cloud of languages and libraries.
A CV is to start an interview process. Keep it short and to the point. Be clear. “If you confuse, you lose.”