Why learning effect

Welcome to Effect!

First of all, what is effect? Why should you care?

TypeScript is quickly becoming the de-facto standard for writing business applications, across both front-end and back-end:

The most recent State of JS survey paints a clear picture of what javascript is missing:

State of Javascript survey 2023 results for "What do you feel is currently missing from JavaScript?"
State of Javascript survey 2023 results for "What do you feel is currently missing from JavaScript?"

We may argue that typescript solves the issue of static typing.

What about the others?

  • Standard library
  • Better date management
  • Immutable data structures
  • Pipe operator
  • Pattern matching
  • Error handling

Plain typescript doesn't help much with these.

The state of the typescript ecosystem

Many different libraries address some of these pain points. Each provide its own solution, with its own API, data structures, and conventions.

The problem comes when you try to integrate all these dependencies together. You end up writing more code to build bridges between multiple APIs instead of focusing on your business logic.

This is reflected in the same survey to the question "What aspects of JavaScript do you struggle with the most?":

State of Javascript survey 2023 results for "What aspects of JavaScript do you struggle with the most?"
State of Javascript survey 2023 results for "What aspects of JavaScript do you struggle with the most?"

Things like code architecture, managing dependencies, performance, finding packages are all daily pains for every typescript developer.

In short, TS doesn't have a strong standard library that addresses the problems of production software.

We end up with thousands of small npm packages that fill the holes in a way that doesn't quite compose, making our code a nightmare to maintain.

This situation is reflected in the 2024 Stack Overflow Developer Survey at the question "How satisfied are you in your current professional developer role?":

Effect to the rescue

Effect is the missing standard library for typescript.

If typeScript was created to be javascript that scales, Effect was created to be typescript that scales.

Effect provides native supports for all the major pain points of typescript:

  • Standard library: ecosystem of packages that all share the same core API
  • Better date management: DateTime module to handle date and time with or without timezone
  • Immutable data structures: Array, HashMap, HashSet, Trie, RedBlackTree and more, all immutable, stack safe, and performant
  • Pipe operator: Compose programs using pipe (fully-typed)
  • Pattern matching: Match module for exhaustive pattern matching in typescript
  • Error handling: module like Option, Either, Cause and more to handle both expected and unexpected errors

Furthermore, effect is maintained by Effectful Technologies Inc., a company all focused on supporting and improving Effect.

Everything inside effect that is released under MIT license will remain MIT licensed and we don't require CLAs.

The Effect organization is fully managed by the Community.

What effect provides

Before effect I explored different packages for things like pattern matching, schema validation, branded types, error handling, date formatting, and more.

This is a list of the packages that I used in the past:

  • Schema validation: zod, yup, joi, io-ts
  • Pattern matching: ts-pattern, unionize
  • Branded types: newtype-ts
  • Error handling: ramda, purify-ts, fp-ts
  • Dates: moment, date-fns, date-fns-tz
  • Http requests: axios, ky
  • Cookies: js-cookie
  • Encoding: js-base64
  • Data structures: lodash, underscore, immutable

Needless to say, maintaining all these dependencies quickly became problematic. Each library brings its own types and utility functions, often sharing the same names with other libraries.

This caused issues in bundle size and conflicts between dependencies.

With effect all the libraries above can be replaced with just 3:

  • effect: Effect core (pattern matching, branded types, error handling, dates, encoding, data structures, schema validation)
  • @effect/platform: Http requests, cookies (and more)

Furthermore, since all these libraries are built on top of the same core set of types and function, everything is composable and without conflicts.

Community around effect

The community around effect is growing by the day.

More and more people are trying effect, sharing experiences and new resources. A lot of interest and new contributions are coming from everywhere in the typescript community:

What's the catch then?

The main issue with effect is learning how to use it.

In order to exploit the full power of the typescript type-system, effect uses patterns that look different from "standard" javascript code.

export const main = Effect.gen(function* () {
  const baseClient = yield* HttpClient.HttpClient;
  const pokeApiClient = baseClient.pipe(
    HttpClient.mapRequest(
      flow(
        HttpClientRequest.acceptJson,
        HttpClientRequest.prependUrl("https://pokeapi.co/api/v2")
      )
    )
  );

  return yield* pokeApiClient.get("/pokemon/squirtle");
}).pipe(
  Effect.flatMap(HttpClientResponse.schemaBodyJson(Pokemon)),
  Effect.scoped,
  Effect.provide(FetchHttpClient.layer)
);

This is often a significant obstacle for beginners and teams on adopting effect.

💯 This is what this course aims to solve! 💯

At the end of this course you will be able to read, understand, and write full applications with effect.

We are going to explore how effect works from the basics.

We will start from the "Hello World" of effect and we will end with a full type safe, testable, and maintainable effect application.

We will cover everything that you need to get proficient with effect:

  • How effect code differs from plain typescript
  • What are the benefits of using effect
  • Explore the most common effect APIs step by step
  • Learn how to organize a full type safe and scalable architecture with effect

The course is organized in lessons each teaching one new concept. This structure allows you to progress one step at the time as we learn new effect APIs.

Brace yourself and let's get started! 🚀