Best of Functional ProgrammingOctober 2024

  1. 1
    Article
    Avatar of communityCommunity Picks·2y

    Unleash JavaScript's Potential with Functional Programming

    JavaScript supports both Object-Oriented Programming (OOP) and Functional Programming (FP), enabling developers to write more modular, deterministic, and testable code. Key concepts such as pure functions, immutability, closures, higher-order functions, and declarative programming are fundamental to FP. The post explains these concepts in detail and demonstrates practical applications using JavaScript's array methods like map, filter, and reduce. Additionally, it highlights important principles like function composition, currying, and data privacy, aiming to transform the way you write JavaScript code.

  2. 2
    Article
    Avatar of itnextITNEXT·2y

    A Few Unshakable Principles for Writing Better Code

    Explore essential principles for writing better, cleaner code. The author shares insights on effective code practices, emphasizing that functions should perform one task and maintain a consistent return type. Highlighting the value of code readability, abstraction, and functional programming concepts such as map-reduce, the guide provides practical examples to illustrate these points.

  3. 3
    Article
    Avatar of hnHacker News·2y

    Gleam: A Basic Introduction

    Gleam is a statically-typed functional programming language designed for building scalable and maintainable software. Inspired by Elm and Rust, it compiles to Erlang, making it suitable for concurrent and distributed systems. This tutorial covers setting up the development environment, writing a simple 'Hello, World!' program, and demonstrating basic features like variables, types, arithmetic operations, functions, and case expressions.

  4. 4
    Article
    Avatar of curiosumCuriosum·2y

    Understanding essential SOLID Principles in OOP: A Developer's Guide

    SOLID principles, traditionally used in object-oriented programming, can be adapted to functional programming languages like Elixir to create maintainable, scalable, and adaptable software systems. The SOLID acronym stands for five key guidelines: Single Responsibility Principle, Open/Closed Principle, Liskov Substitution Principle, Interface Segregation Principle, and Dependency Inversion Principle. The post details how each principle can be practically applied in Elixir to enhance code clarity, modularity, flexibility, and reliability while reducing complexity.

  5. 5
    Article
    Avatar of lobstersLobsters·2y

    6 years with Gleam

    The author has been contributing to Gleam since 2018, appreciating its type-safe and scalable approach. Initially involved with Elixir and the BEAM, they found Gleam increased productivity, especially in rapid-change environments like startups. After a venture using Gleam and Elixir, they developed a JavaScript target for Gleam to extend its benefits to frontend development. Relocating to Sweden for a job at Northvolt, they continued leveraging Gleam for personal projects and noted ongoing improvements in the language. Recently, they discussed Gleam's promising future at Code BEAM Stockholm and are open to new opportunities.

  6. 6
    Article
    Avatar of communityCommunity Picks·2y

    Lustre and Gleam Make my Heart Rate Go Down - a Case Study

    A client needed a financial assessment app rebuilt, originally in Javascript on WordPress. The author, typically a backend developer, chose Gleam and the Lustre frontend framework for their stability, type safety, and immutability features. Despite the boilerplate, the application was delivered on time and under budget, leaving the author highly satisfied with Gleam and Lustre's reliability, simplicity, and predictability. It resulted in a small JS bundle and a high level of confidence in the code's stability over time.

  7. 7
    Article
    Avatar of andrewlock.NET Escapades·2y

    Is the result pattern worth it?

    The post concludes a series discussing the use of the result pattern over exceptions for flow control in C#. It highlights how LINQ can simplify nested lambda methods, improving readability. The discussion contrasts heavy and lightweight versions of the result pattern with perspectives from industry experts. It addresses the argument for substituting exceptions with the result pattern and presents LINQ as a readable but complex alternative for error handling. The post suggests that while LINQ can simplify code, developers must evaluate whether its complexity is justified in their specific use cases.

  8. 8
    Article
    Avatar of foojayioFoojay.io·2y

    Null object pattern to avoid null pointer exception with JEP-455

    JDK 23 introduces critical enhancements with JEP-455, which extends pattern matching to include primitive types in switch and instanceof statements. This update aligns Java more closely with functional programming paradigms. The null object pattern is highlighted as a method to avoid null pointer exceptions, illustrated using a vehicle sensor cache scenario. These changes promote better code maintainability and improved program execution speed.

  9. 9
    Video
    Avatar of communityCommunity Picks·2y

    The purest coding style, where bugs are near impossible

  10. 10
    Article
    Avatar of awelixAwesome Elixir·2y

    WhyElixir

    Elixir is a dynamic, general-purpose language designed for building scalable, concurrent, fault-tolerant, and high-performance applications. It features a syntax inspired by Ruby and operates on the Erlang Virtual Machine, providing essential features for distributed and responsive applications. Elixir's operational simplicity, straightforward syntax, and active community make it an appealing choice. Notable frameworks like Phoenix for web development and Nerves for embedded systems highlight its versatility. Companies like Adobe, Discord, and Pinterest use Elixir to handle millions of users, attesting to its reliability and efficiency.

  11. 11
    Article
    Avatar of andrewlock.NET Escapades·2y

    Safety and simplicity with LINQ

    Explore how LINQ's query syntax can be utilized with Result<T> in C# to improve code readability and maintainability. Discover how methods like Select and SelectMany can be implemented for the Result<T> type, transforming cumbersome error-handling code into more intuitive and elegant constructs. The post also discusses the caveats of overusing the result pattern and emphasizes the importance of applying such patterns judiciously.

  12. 12
    Article
    Avatar of rpythonReal Python·2y

    Using Type Hints for Multiple Return Types in Python – Real Python

    Type hinting in Python makes code easier to read, reason about, and debug. This feature is particularly useful for specifying multiple return types for functions, allowing for greater flexibility and adaptability. The concept is demonstrated through examples, including how to type hint callback functions. The course offers 7 lessons, downloadable resources, and a Q&A with Python experts.

  13. 13
    Article
    Avatar of rpythonReal Python·2y

    Structural Pattern Matching in Python – Real Python

    Structural pattern matching, introduced in Python 3.10, is a powerful control flow construct that enhances code readability and conciseness. It integrates conditional statements with destructuring, providing a more declarative coding style. This tutorial covers the key components of pattern matching, including the match statement, case clauses, various pattern types, and common pitfalls. Additionally, it highlights the use of guards, unions, aliases, and binding names to extract values from complex data structures while demonstrating customization for user-defined classes.

  14. 14
    Video
    Avatar of communityCommunity Picks·2y

    Validating Records in C#: Everything You Ever Wanted To Know but Had No One To Ask

    In C#, records as values don't inherently know their validity. Validation should be managed by the object containing the record to account for varying contexts. While records themselves cannot validate, structuring them carefully can ensure valid instances. For example, NonEmptyString records ensure no empty or whitespace strings, effectively validating data at compile-time. It highlights design practices for record validation, emphasizing compile-time validation and explicit design over runtime checks.

  15. 15
    Video
    Avatar of nickchapsasNick Chapsas·2y

    "You're Doing Validation Wrong in .NET" | Code Cop #023

    The post discusses different approaches to validation in .NET, highlighting both bad and improved methods. It covers the issues with common validation techniques—such as returning a Boolean or an enumerable of strings—and proposes alternative solutions, including using functional programming principles and the 'either' monad for cleaner and more maintainable code. It also explains the pros and cons of the fail-fast and comprehensive validation approaches.