[{"data":1,"prerenderedAt":293},["ShallowReactive",2],{"course-en-selecting-library":3},{"lesson":4,"number":287,"prev":288,"next":292},{"slug":5,"title":6,"description":9,"goal":11,"blocks":13,"summary":257,"exercises":268},"selecting-library",{"ru":7,"en":8},"","How to choose an FP library",{"ru":7,"en":10},"How to choose a library for FP in JavaScript and TypeScript: Vanilla JS, Lodash, Ramda, Sanctuary, fp-ts or Effect, by budget, stage, team and quality.",{"ru":7,"en":12},"Learn to choose between Vanilla JS, Lodash, Ramda, Sanctuary, fp-ts and Effect by the criteria of the project and the team (budget, stage, team, quality, performance and paradigm) rather than by taste or fashion.",[14,17,27,29,31,45,48,62,64,77,79,93,95,108,110,112,126,128,142,144,146,148],{"type":15,"ru":7,"en":16},"text","When you face the choice of which of the libraries described in the course and below, or a vanilla solution, to pick, you should not rely on the following principles, which I have often encountered in my own commercial development practice. You should not stick to the following:",{"type":18,"ordered":19,"items":20},"list",true,[21,23,25],{"ru":7,"en":22},"I like this library (personal wishes).",{"ru":7,"en":24},"It's trendy right now (personal wishes).",{"ru":7,"en":26},"I'm in charge, I decide, and that's what I want (personal wishes).",{"type":15,"ru":7,"en":28},"Everything described above is not a professional approach.",{"type":15,"ru":7,"en":30},"What you should pay attention to. Which criteria matter when choosing:",{"type":18,"ordered":19,"items":32},[33,35,37,39,41,43],{"ru":7,"en":34},"Budget. It is very important to understand the financial capacity of the investor (client) and their plans for the future. This is a very important point and, you could say, one of the main ones.",{"ru":7,"en":36},"How far along the project is, percentage-wise, or whether it is just at the beginning. Likewise: if the project is already written and everything works correctly, there is no need to rewrite it.",{"ru":7,"en":38},"Who works with you on the team and how many of you there are. You need to understand the onboarding process for a new developer joining the team, whether they are familiar with this library and with your architectural decisions.",{"ru":7,"en":40},"Product quality. The higher the complexity, the more the quality tends to grow.",{"ru":7,"en":42},"Performance. This is not the most important factor, since often it is a flaw in the application's logic that causes a slowdown rather than any particular library.",{"ru":7,"en":44},"The functional programming paradigm.",{"type":46,"ru":7,"en":47},"heading","Vanilla JS",{"type":18,"ordered":19,"items":49},[50,52,54,56,58,60],{"ru":7,"en":51},"Budget. The budget is small or medium.",{"ru":7,"en":53},"How far along the project is, percentage-wise, or whether it is just at the beginning. When the project was already started earlier in JS and has passed the horizon and the home stretch.",{"ru":7,"en":55},"Who works with you on the team and how many of you there are. For small teams with deep knowledge of JS. At times such a team works more effectively than a large one where the language is known only superficially. Deep knowledge of JS matters in TypeScript projects too: types are checked at compile time and on their own do not protect against errors in data that arrives at runtime.",{"ru":7,"en":57},"Product quality. Depends on the team, deadlines, and budget; often not high.",{"ru":7,"en":59},"Performance. It will be the highest given equivalent code compared to the libraries.",{"ru":7,"en":61},"The functional programming paradigm. Complete freedom: procedural, OOP, FP, and so on. And everyone does as they please.",{"type":46,"ru":7,"en":63},"Lodash",{"type":18,"ordered":19,"items":65},[66,68,70,72,73,75],{"ru":7,"en":67},"Budget. Suitable for projects of any scale, but it is best used on medium-sized projects.",{"ru":7,"en":69},"How far along the project is, percentage-wise, or whether it is just at the beginning. Only if the project has not reached the horizon but is at an early stage.",{"ru":7,"en":71},"Who works with you on the team and how many of you there are. For teams of any size who are superficially familiar with functional programming and want to simplify their routine.",{"ru":7,"en":57},{"ru":7,"en":74},"Performance. It will be lower than vanilla given equivalent code. The library's bundle is optimized for size.",{"ru":7,"en":76},"The functional programming paradigm. Not entirely functional: there are problems with immutability and with passing arguments in function composition, where the functions take the data first and only then the function. The lodash\u002Ffp module removes these problems: its functions are curried, do not mutate the data, and take it as the last argument. For those who are only just touching functional programming.",{"type":46,"ru":7,"en":78},"Ramda",{"type":18,"ordered":19,"items":80},[81,83,85,87,89,91],{"ru":7,"en":82},"Budget. Suitable for projects of any scale.",{"ru":7,"en":84},"How far along the project is, percentage-wise, or whether it is just at the beginning. At any stage, except for situations when the project is already wrapping up or another data-handling library is already present.",{"ru":7,"en":86},"Who works with you on the team and how many of you there are. For teams of any size who use functional programming either superficially or professionally and who want to simplify their routine.",{"ru":7,"en":88},"Product quality. The product quality is, as a rule, high.",{"ru":7,"en":90},"Performance. It will be lower than vanilla given equivalent code. The library's bundle needs to be optimized if you plan to use only a small part, 5-10%, of its functions.",{"ru":7,"en":92},"The functional programming paradigm. Full-fledged functional programming is used. It covers up to 98% of cases when working with data and is suitable for all projects. It has its own philosophy within functional programming. It is easier for newcomers to functional programming and sets the right tone. It does not have Lodash's ailments.",{"type":46,"ru":7,"en":94},"Sanctuary",{"type":18,"ordered":19,"items":96},[97,99,101,103,104,106],{"ru":7,"en":98},"Budget. Suitable for large-scale projects with an above-average budget.",{"ru":7,"en":100},"How far along the project is, percentage-wise, or whether it is just at the beginning. It is preferable to use it at the early stage.",{"ru":7,"en":102},"Who works with you on the team and how many of you there are. For teams of any size who use functional programming professionally and understand what they are writing.",{"ru":7,"en":88},{"ru":7,"en":105},"Performance. It will be lower than vanilla given equivalent code.",{"ru":7,"en":107},"The functional programming paradigm. Full-fledged functional programming is used, with its own philosophy that adheres more strictly to FP principles. Full-fledged use of monads and other abstract types. A high barrier to entry. For those who are truly into functional programming. Its own architecture of thinking. Keep in mind that the latest Sanctuary release, 3.1.0, came out on August 9, 2020 (according to the npm registry as of October 2026).",{"type":15,"ru":7,"en":109},"The next two libraries are designed for TypeScript. They can be called from JavaScript as well, but most of their value comes with type checking: a missing value and possible errors show up in the types, and the compiler checks how the code deals with them.",{"type":46,"ru":7,"en":111},"fp-ts",{"type":18,"ordered":19,"items":113},[114,116,118,120,122,124],{"ru":7,"en":115},"Budget. Suitable for medium and large projects with at least an average budget: the team needs time to learn it.",{"ru":7,"en":117},"How far along the project is, percentage-wise, or whether it is just at the beginning. Above all for projects that already use fp-ts. For new users, the fp-ts README points to Effect as the successor to fp-ts v2.",{"ru":7,"en":119},"Who works with you on the team and how many of you there are. For teams of any size who write TypeScript and use functional programming professionally: you need to understand Option, Either, Task and type classes such as functor and monad.",{"ru":7,"en":121},"Product quality. The product quality is, as a rule, high: a missing value and errors show up in the Option and Either types, and the compiler reminds you to handle both cases.",{"ru":7,"en":123},"Performance. It will be lower than vanilla given equivalent code: values are wrapped in Option and Either, and the steps of pipe are extra function calls. Modules are imported one by one (fp-ts\u002FOption, fp-ts\u002FEither), so there is no need to pull in the whole library.",{"ru":7,"en":125},"The functional programming paradigm. Full-fledged and strict typed functional programming modelled on Haskell, PureScript and Scala: type classes and an emulation of higher-kinded types, which TypeScript does not support natively. A high barrier to entry. The fp-ts project has announced that it is merging with the Effect ecosystem, and its author, Giulio Canti, has joined the Effect organization. Keep in mind that the latest fp-ts release, 2.16.11, came out on August 18, 2025 (according to the npm registry as of October 2026).",{"type":46,"ru":7,"en":127},"Effect",{"type":18,"ordered":19,"items":129},[130,132,134,136,138,140],{"ru":7,"en":131},"Budget. Suitable for medium and large projects where the cost of an error is high and there is time to train the team.",{"ru":7,"en":133},"How far along the project is, percentage-wise, or whether it is just at the beginning. Best at the early stage. Effect can be brought into an existing project gradually: Effect.runPromise returns an ordinary Promise, so the new code gets along with the old.",{"ru":7,"en":135},"Who works with you on the team and how many of you there are. For teams of any size who write TypeScript and are ready to learn a new model: the Effect\u003CA, E, R> type, Effect.gen generators, services and layers (Layer). Category theory is not required: code inside Effect.gen reads sequentially, much like async\u002Fawait.",{"ru":7,"en":137},"Product quality. The product quality is, as a rule, high: possible errors and required dependencies show up in the Effect\u003CA, E, R> type, and retries, timeouts, cancellation and concurrency are built into the library.",{"ru":7,"en":139},"Performance. It will be lower than vanilla given equivalent code: programs are run by Effect's own fiber-based runtime. Unused modules are dropped at build time (tree shaking), and version 4 rewrote the runtime to use less memory and run faster.",{"ru":7,"en":141},"The functional programming paradigm. Full-fledged and strict typed functional programming aimed at production. Effects are values: an Effect only describes the work and does nothing until the runtime runs it, and possible errors and required dependencies are recorded in the Effect\u003CA, E, R> type. On top of that come fiber-based concurrency and Schema for validating data at runtime. A high barrier to entry, but of a different kind than with fp-ts: you learn the effect model and a large API rather than type classes. According to the fp-ts README, Effect can be regarded as the successor to fp-ts v2. The current major version is 4: Effect 4.0.0 came out on October 1, 2026, and the 3.x line still receives fixes (according to the npm registry as of October 2026).",{"type":15,"ru":7,"en":143},"One can picture the degree of commitment to functional programming.",{"type":15,"ru":7,"en":145},"Vanilla JS (present) -> Lodash (not full-fledged) -> Ramda (full-fledged) -> Sanctuary (full-fledged and strict)",{"type":15,"ru":7,"en":147},"In TypeScript they are joined by fp-ts (full-fledged and strict, built on type classes) and Effect (full-fledged and strict, with effects and errors in the types).",{"type":149,"caption":150,"columns":152,"rows":161},"table",{"ru":7,"en":151},"Comparison table",[153,155,156,157,158,159,160],{"ru":7,"en":154},"Criterion",{"ru":7,"en":47},{"ru":7,"en":63},{"ru":7,"en":78},{"ru":7,"en":94},{"ru":7,"en":111},{"ru":7,"en":127},[162,174,186,199,210,222,232,242],[163,165,167,169,170,172,173],{"ru":7,"en":164},"Budget",{"ru":7,"en":166},"Small \u002F Medium",{"ru":7,"en":168},"Any",{"ru":7,"en":168},{"ru":7,"en":171},"Medium \u002F High",{"ru":7,"en":171},{"ru":7,"en":171},[175,177,178,180,181,182,184],{"ru":7,"en":176},"Project stage",{"ru":7,"en":168},{"ru":7,"en":179},"Early",{"ru":7,"en":168},{"ru":7,"en":179},{"ru":7,"en":183},"If fp-ts is already in use",{"ru":7,"en":185},"Early, or any (gradually)",[187,189,191,192,193,195,197],{"ru":7,"en":188},"Team size",{"ru":7,"en":190},"Small",{"ru":7,"en":168},{"ru":7,"en":168},{"ru":7,"en":194},"Any (pros)",{"ru":7,"en":196},"Any (pros, TS)",{"ru":7,"en":198},"Any (TS)",[200,202,204,205,207,208,209],{"ru":7,"en":201},"Quality",{"ru":7,"en":203},"Medium",{"ru":7,"en":203},{"ru":7,"en":206},"High",{"ru":7,"en":206},{"ru":7,"en":206},{"ru":7,"en":206},[211,213,215,217,219,220,221],{"ru":7,"en":212},"Performance",{"ru":7,"en":214},"4 out of 5",{"ru":7,"en":216},"3 out of 5",{"ru":7,"en":218},"2 out of 5",{"ru":7,"en":218},{"ru":7,"en":218},{"ru":7,"en":218},[223,225,227,228,229,230,231],{"ru":7,"en":224},"FP strictness",{"ru":7,"en":226},"1 out of 5",{"ru":7,"en":218},{"ru":7,"en":216},{"ru":7,"en":214},{"ru":7,"en":214},{"ru":7,"en":214},[233,235,237,238,239,240,241],{"ru":7,"en":234},"Barrier to entry",{"ru":7,"en":236},"Low",{"ru":7,"en":236},{"ru":7,"en":203},{"ru":7,"en":206},{"ru":7,"en":206},{"ru":7,"en":206},[243,245,247,249,251,253,255],{"ru":7,"en":244},"Philosophy",{"ru":7,"en":246},"Freedom of choice",{"ru":7,"en":248},"Utility",{"ru":7,"en":250},"Practical FP",{"ru":7,"en":252},"Academic FP",{"ru":7,"en":254},"Haskell-style FP",{"ru":7,"en":256},"FP for production",[258,260,262,264,266],{"ru":7,"en":259},"Choosing a library because \"I like it\", \"it's trendy\" or \"I'm in charge and that's what I want\" is not a professional approach.",{"ru":7,"en":261},"The criteria are the budget, the project stage, the team and the onboarding of new developers, product quality, performance and the functional programming paradigm.",{"ru":7,"en":263},"Performance is not the most important factor: a slowdown more often comes from a flaw in the application's logic than from a library.",{"ru":7,"en":265},"Lodash is not entirely functional: there are problems with immutability, and its functions take the data first and only then the function, which gets in the way of composition. The lodash\u002Ffp module removes these problems: its functions are curried, do not mutate the data and take it as the last argument.",{"ru":7,"en":267},"By commitment to functional programming the options line up like this: Vanilla JS (present) -> Lodash (not full-fledged) -> Ramda (full-fledged) -> Sanctuary (full-fledged and strict). In TypeScript they are joined by fp-ts and Effect, and according to the fp-ts README, Effect can be regarded as the successor to fp-ts v2.",[269,278],{"task":270,"starter":272,"solution":274,"expected":276},{"ru":7,"en":271},"From the list of orders, get a string with the titles of the paid orders over 100, comma-separated and in alphabetical order. Solve it three times: in Vanilla JS with array methods, in Ramda (R.pipe, R.filter, R.map and others) and in Sanctuary (S.pipe with a list of functions, S.filter, S.map, S.prop, S.sort, S.joinWith). Compare how each version passes the data along and how it builds the composition.",{"ru":7,"en":273},"const orders = [\n  { title: 'keyboard', total: 120, paid: true },\n  { title: 'mouse', total: 40, paid: true },\n  { title: 'monitor', total: 300, paid: false },\n  { title: 'laptop', total: 900, paid: true },\n  { title: 'cable', total: 15, paid: false },\n]\n\n\u002F\u002F your code: withVanilla, withRamda and withSanctuary :: [Object] -> String\n\nconsole.log(`Vanilla JS: ${withVanilla(orders)}`)\nconsole.log(`Ramda: ${withRamda(orders)}`)\nconsole.log(`Sanctuary: ${withSanctuary(orders)}`)",{"ru":7,"en":275},"const orders = [\n  { title: 'keyboard', total: 120, paid: true },\n  { title: 'mouse', total: 40, paid: true },\n  { title: 'monitor', total: 300, paid: false },\n  { title: 'laptop', total: 900, paid: true },\n  { title: 'cable', total: 15, paid: false },\n]\n\n\u002F\u002F Vanilla JS: a chain of methods, the data is the array itself\n\u002F\u002F withVanilla :: [Object] -> String\nconst withVanilla = (list) =>\n  list\n    .filter((order) => order.paid && order.total > 100)\n    .map((order) => order.title)\n    .sort()\n    .join(', ')\n\n\u002F\u002F Ramda: functions are curried and take the data as the last argument\n\u002F\u002F withRamda :: [Object] -> String\nconst withRamda = R.pipe(\n  R.filter(R.prop('paid')),\n  R.filter(R.pipe(R.prop('total'), R.lt(100))), \u002F\u002F R.lt(100)(total) means 100 \u003C total\n  R.map(R.prop('title')),\n  R.sortBy(R.identity),\n  R.join(', '),\n)\n\n\u002F\u002F Sanctuary: S.pipe takes an array of functions, the data also comes last\n\u002F\u002F withSanctuary :: [Object] -> String\nconst withSanctuary = S.pipe([\n  S.filter(S.prop('paid')),\n  S.filter(S.pipe([S.prop('total'), S.gt(100)])), \u002F\u002F S.gt(100)(total) means total > 100\n  S.map(S.prop('title')),\n  S.sort,\n  S.joinWith(', '),\n])\n\nconsole.log(`Vanilla JS: ${withVanilla(orders)}`)\nconsole.log(`Ramda: ${withRamda(orders)}`)\nconsole.log(`Sanctuary: ${withSanctuary(orders)}`)",{"ru":7,"en":277},"Vanilla JS: keyboard, laptop\nRamda: keyboard, laptop\nSanctuary: keyboard, laptop",{"task":279,"starter":281,"solution":283,"expected":285},{"ru":7,"en":280},"Find the title of the first paid order over a given amount, and if there is none, return \"none\". Do it in Ramda with R.find and in Sanctuary with S.find, S.map and S.fromMaybe, and check it with the amounts 500 and 1000. Then print what R.find and S.find themselves return when there is no matching order. Why is the Sanctuary answer more reliable?",{"ru":7,"en":282},"const orders = [\n  { title: 'keyboard', total: 120, paid: true },\n  { title: 'mouse', total: 40, paid: true },\n  { title: 'monitor', total: 300, paid: false },\n  { title: 'laptop', total: 900, paid: true },\n  { title: 'cable', total: 15, paid: false },\n]\n\n\u002F\u002F isPaidOver :: Number -> Object -> Boolean\nconst isPaidOver = (limit) => (order) => order.paid && order.total > limit\n\n\u002F\u002F your code: titleWithRamda and titleWithSanctuary :: Number -> [Object] -> String\n\nconsole.log(`Ramda, 500: ${titleWithRamda(500)(orders)}`)\nconsole.log(`Ramda, 1000: ${titleWithRamda(1000)(orders)}`)\nconsole.log(`Sanctuary, 500: ${titleWithSanctuary(500)(orders)}`)\nconsole.log(`Sanctuary, 1000: ${titleWithSanctuary(1000)(orders)}`)",{"ru":7,"en":284},"const orders = [\n  { title: 'keyboard', total: 120, paid: true },\n  { title: 'mouse', total: 40, paid: true },\n  { title: 'monitor', total: 300, paid: false },\n  { title: 'laptop', total: 900, paid: true },\n  { title: 'cable', total: 15, paid: false },\n]\n\n\u002F\u002F isPaidOver :: Number -> Object -> Boolean\nconst isPaidOver = (limit) => (order) => order.paid && order.total > limit\n\n\u002F\u002F Ramda: R.find returns the order or undefined, we check for emptiness ourselves\n\u002F\u002F titleWithRamda :: Number -> [Object] -> String\nconst titleWithRamda = (limit) => R.pipe(\n  R.find(isPaidOver(limit)),\n  (order) => (order === undefined ? 'none' : order.title),\n)\n\n\u002F\u002F Sanctuary: S.find returns a Maybe, either Just (order) or Nothing,\n\u002F\u002F and S.map and S.fromMaybe handle both cases\n\u002F\u002F titleWithSanctuary :: Number -> [Object] -> String\nconst titleWithSanctuary = (limit) => S.pipe([\n  S.find(isPaidOver(limit)),\n  S.map(S.prop('title')),\n  S.fromMaybe('none'),\n])\n\nconsole.log(`Ramda, 500: ${titleWithRamda(500)(orders)}`)\nconsole.log(`Ramda, 1000: ${titleWithRamda(1000)(orders)}`)\nconsole.log(`Sanctuary, 500: ${titleWithSanctuary(500)(orders)}`)\nconsole.log(`Sanctuary, 1000: ${titleWithSanctuary(1000)(orders)}`)\n\n\u002F\u002F there is no order over 1000: Ramda returns undefined, Sanctuary returns Nothing\nconsole.log(R.find(isPaidOver(1000))(orders))\nconsole.log(S.find(isPaidOver(1000))(orders))\n\n\u002F\u002F undefined is easy to miss: a forgotten check will crash the code later,\n\u002F\u002F for example when reading order.title. A Maybe states outright that there\n\u002F\u002F may be no result, and S.map and S.fromMaybe handle both cases",{"ru":7,"en":286},"Ramda, 500: laptop\nRamda, 1000: none\nSanctuary, 500: laptop\nSanctuary, 1000: none\nundefined\nNothing",26,{"slug":289,"title":290},"fp-in-typescript-and-effect",{"ru":7,"en":291},"FP in TypeScript and Effect",null,1792684725093]