{"id":479904,"date":"2026-05-15T16:12:19","date_gmt":"2026-05-15T16:12:19","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=479904"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=479904","title":{"rendered":"\u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 JVM \u044f\u0437\u044b\u043a\u043e\u0432: \u041d\u0443\u0436\u0435\u043d \u043b\u0438 \u0435\u0449\u0435 ThreadPool \u043f\u043e\u0441\u043b\u0435 coroutines, ZIO \u0438 Virtual Threads?"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!<\/p>\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/1033894\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1034938\/\" rel=\"noopener noreferrer nofollow\">\u0432\u0442\u043e\u0440\u043e\u0439<\/a> \u0447\u0430\u0441\u0442\u044f\u0445 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 Java <code>Thread<\/code>, thread pools, virtual threads, Kotlin coroutines, ZIO runtime \u0438 Clojure primitives. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0435\u0437 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u201c\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u201d \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c  \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u201c\u0410 \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u0435\u0449\u0435 \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u0435 thread pools?\u201d<\/p>\n<figure class=\"\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/e2\/f7\/71\/e2f771260dfd580ce25c899a294d4ae3.jpg\" sizes=\"(max-width: 780px) 100vw, 50vw\" srcset=\"https:\/\/habrastorage.org\/r\/w780\/webt\/e2\/f7\/71\/e2f771260dfd580ce25c899a294d4ae3.jpg 780w,&#10;       https:\/\/habrastorage.org\/r\/w1560\/webt\/e2\/f7\/71\/e2f771260dfd580ce25c899a294d4ae3.jpg 781w\" loading=\"lazy\" decode=\"async\"\/><\/figure>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<ol>\n<li>\n<p>Kotlin coroutines \u043f\u0440\u043e\u0442\u0438\u0432 ZIO runtime.<\/p>\n<\/li>\n<li>\n<p>Clojure <code>core.async<\/code> \u0438 \u0432\u043e\u043f\u0440\u043e\u0441, \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043c \u0430\u043d\u0430\u043b\u043e\u0433 \u043a\u043e\u0440\u0443\u0442\u0438\u043d.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u0442\u044c \u043b\u0438 \u0432 Clojure \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 ZIO runtime.<\/p>\n<\/li>\n<li>\n<p>\u0410\u043d\u0430\u043b\u043e\u0433\u0438 ZIO \u0432 \u0447\u0438\u0441\u0442\u043e\u0439 Java \u0438 Kotlin.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e \u0441\u0442\u0430\u043b\u043e \u0441 thread pools \u043f\u043e\u0441\u043b\u0435 Loom, coroutines \u0438 fibers.<\/p>\n<\/li>\n<\/ol>\n<hr\/>\n<h3>8. \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435: Kotlin coroutines \u0438 ZIO runtime<\/h3>\n<p>\u0422\u0443\u0442 \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u0430 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f. Kotlin coroutines \u0438 ZIO fibers \u043b\u0451\u0433\u043a\u0438\u0435, \u043d\u0435 \u0440\u0430\u0432\u043d\u044b platform threads, \u0443\u043c\u0435\u044e\u0442 cancellation, \u0434\u0430\u044e\u0442 structured concurrency \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043d\u0430 \u0432\u0438\u0434 \u043a\u043e\u0434 \u043f\u043e\u0432\u0435\u0440\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.<\/p>\n<p>\u041d\u043e ZIO \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 Kotlin coroutines: \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u043e\u0448\u0438\u0431\u043e\u043a <code>E<\/code>, \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 <code>R<\/code>, \u0435\u0434\u0438\u043d\u044b\u0439 \u0442\u0438\u043f \u044d\u0444\u0444\u0435\u043a\u0442\u0430, resource safety, supervision \u0438 \u0431\u043e\u0433\u0430\u0442\u0443\u044e \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432. \u042d\u0442\u043e \u043d\u0435 \u201c\u0435\u0449\u0451 \u043e\u0434\u043d\u0430 async-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u201d, \u0430 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443.<\/p>\n<p>Kotlin \u043f\u0440\u0430\u0433\u043c\u0430\u0442\u0438\u0447\u043d\u0435\u0435. \u0415\u0441\u0442\u044c <code>suspend<\/code>, <code>CoroutineScope<\/code>, <code>Flow<\/code>, <code>Job<\/code>. \u041e\u0448\u0438\u0431\u043a\u0438 \u0447\u0430\u0449\u0435 \u0438\u0434\u0443\u0442 \u0447\u0435\u0440\u0435\u0437 exceptions, <code>Result<\/code>, <code>Either<\/code> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438\u043b\u0438 sealed-\u043a\u043b\u0430\u0441\u0441\u044b. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f DI-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c, \u0430 \u043d\u0435 \u0442\u0438\u043f\u043e\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0430.<\/p>\n<details class=\"spoiler\">\n<summary>Kotlin: suspend + Either \u043a\u0430\u043a \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0435 \u043a typed errors<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"kotlin\">suspend fun loadUser(userId: UserId): Either&lt;DomainError, User&gt; =    either {        val raw = userClient.load(userId).bind()        raw.toDomain().bind()    }<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<p>\u0412 ZIO \u044d\u0442\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0442\u0438\u043f. \u0412 Kotlin \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u0440\u0443\u0442\u0438\u043d, Arrow \u0438 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e:<\/p>\n<pre><code>Kotlin coroutines - runtime \u0434\u043b\u044f suspend-\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.ZIO runtime - runtime \u0434\u043b\u044f \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 effectful-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c.<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h3>9. Clojure: \u0435\u0441\u0442\u044c \u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433 \u043a\u043e\u0440\u0443\u0442\u0438\u043d<\/h3>\n<p>\u0421\u0430\u043c\u044b\u0439 \u0431\u043b\u0438\u0437\u043a\u0438\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 &#8212; <code>core.async<\/code>.<\/p>\n<p><code>core.async<\/code> \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 CSP-\u043c\u043e\u0434\u0435\u043b\u044c: channels, <code>go<\/code> blocks, <code>&lt;!<\/code>, <code>&gt;!<\/code>, <code>alts!<\/code>. \u042d\u0442\u043e \u043c\u0438\u0440 \u201c\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043e\u0431\u0449\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043d\u0430\u043b\u044b\u201d, \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 \u043f\u043e Go \u0438 CSP, \u0430 \u043d\u0435 \u043c\u0438\u0440 <code>async\/await<\/code> \u043a\u0430\u043a \u0432 Kotlin.<\/p>\n<details class=\"spoiler\">\n<summary>\u041a\u0440\u0430\u0442\u043a\u043e: \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 CSP<\/summary>\n<div class=\"spoiler__content\">\n<p>CSP &#8212; Communicating Sequential Processes. \u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0435 \u043b\u0435\u0437\u0443\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u043e\u0431\u0449\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043d\u0430\u043b\u044b. \u041e\u0434\u0438\u043d \u043a\u043b\u0430\u0434\u0451\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0434\u0440\u0443\u0433\u043e\u0439 \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442.<\/p>\n<p>\u0412\u043c\u0435\u0441\u0442\u043e \u201c\u0443 \u043d\u0430\u0441 \u043e\u0431\u0449\u0438\u0439 mutable object, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u0435\u0433\u043e \u0437\u0430\u043b\u043e\u0447\u0438\u043c\u201d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u201c\u0443 \u043d\u0430\u0441 \u043f\u043e\u0442\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c\u0438\u201d. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, worker\u2019\u043e\u0432 \u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u0433\u0434\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u043d\u0430\u0431\u043e\u0440 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>Clojure: core.async go block<\/summary>\n<div class=\"spoiler__content\">\n<pre><code>(require '[clojure.core.async :as async :refer [go &lt;! &gt;! chan]])(def requests (chan))(def responses (chan))(go  (let [request (&lt;! requests)        response (handle request)]    (&gt;! responses response)))<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<p><code>go<\/code> block \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443 \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435: \u043a\u043e\u0434 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 state machine \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0430\u0440\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0441 \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438, \u043d\u0435 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a.<\/p>\n<p>\u041d\u043e \u044d\u0442\u043e \u043d\u0435 Kotlin coroutines:<\/p>\n<ul>\n<li>\n<p><code>go<\/code> block \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u043e parking \u043d\u0430 <code>core.async<\/code> channels;<\/p>\n<\/li>\n<li>\n<p>\u0432\u043d\u0443\u0442\u0440\u044c <code>go<\/code> \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043a\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 blocking I\/O;<\/p>\n<\/li>\n<li>\n<p>\u0434\u043b\u044f blocking-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <code>async\/thread<\/code>, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 executor \u0438\u043b\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 Java\/Clojure concurrency primitives;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0435\u0442 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0433\u043e <code>suspend<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439;<\/p>\n<\/li>\n<li>\n<p>structured concurrency \u0432 \u0441\u0442\u0438\u043b\u0435 <code>coroutineScope<\/code> \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e <code>core.async<\/code>.<\/p>\n<\/li>\n<\/ul>\n<p><code>core.async<\/code> &#8212; \u044d\u0442\u043e lightweight concurrency \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0438 \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u043d\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 Kotlin coroutines \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e async-\u043a\u043e\u0434\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0433\u0440\u0443\u0431\u043e:<\/p>\n<pre><code>Kotlin coroutine - suspendable computation.Clojure core.async go block - lightweight process around channel operations.ZIO fiber - lightweight task executing a typed effect.Virtual thread - lightweight JVM Thread for blocking-style code.<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h3>10. Clojure: \u0435\u0441\u0442\u044c \u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433 ZIO runtime<\/h3>\n<p>\u041f\u0440\u044f\u043c\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 ZIO \u0432 Clojure core \u043d\u0435\u0442.<\/p>\n<p>\u0418 \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u201c\u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0442\u0430\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443\u201d. Clojure &#8212; \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 Lisp. \u0412 \u043d\u0451\u043c \u043d\u0435\u0442 Scala-\u0442\u0438\u043f\u043e\u0432 \u0432\u0438\u0434\u0430 <code>ZIO[R, E, A]<\/code>, \u0433\u0434\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043e\u0448\u0438\u0431\u043a\u0430 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u0448\u0438\u0442\u044b \u0432 \u0442\u0438\u043f. Clojure \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0432\u0441\u044e effectful-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0438\u043f.<\/p>\n<p>\u0412 Clojure \u0435\u0441\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0449\u0438, \u043d\u043e \u043e\u043d\u0438 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438:<\/p>\n<ul>\n<li>\n<p>immutable persistent data structures \u043a\u0430\u043a \u0434\u0435\u0444\u043e\u043b\u0442;<\/p>\n<\/li>\n<li>\n<p>STM \u0434\u043b\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0446\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 mutable references;<\/p>\n<\/li>\n<li>\n<p>atoms\/agents\/promises\/futures \u043a\u0430\u043a \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 building blocks;<\/p>\n<\/li>\n<li>\n<p>core.async \u0434\u043b\u044f CSP \u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432;<\/p>\n<\/li>\n<li>\n<p>Java interop, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0431\u0440\u0430\u0442\u044c virtual threads, executors, CompletableFuture, Reactor, Netty \u0438 \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 JVM-\u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u0415\u0441\u043b\u0438 \u0438\u0441\u043a\u0430\u0442\u044c ZIO-like \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e \u0434\u0443\u0445\u0443, \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 <code>missionary<\/code>, <code>manifold<\/code>, <code>promesa<\/code>, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 Reactor. \u041d\u043e \u043e\u043d\u0438 \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0434\u043b\u044f Clojure \u0442\u0435\u043c \u0436\u0435, \u0447\u0435\u043c ZIO \u0441\u0442\u0430\u043b \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u0438 Scala-\u043c\u0438\u0440\u0430.<\/p>\n<p><code>missionary<\/code> \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u043a \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0443 \u043f\u0440\u043e functional effects: \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u043e\u0442\u043e\u043a\u0438\/flows, cancellation \u0438 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f. <code>manifold<\/code> \u0434\u0430\u0451\u0442 deferred\/streams \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e JVM-Clojure. <code>promesa<\/code> \u0434\u0430\u0451\u0442 promise-like \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043d\u0430 ClojureScript\/interop-\u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445. \u041d\u043e \u0432\u0441\u0451 \u044d\u0442\u043e \u043d\u0435 \u201cClojure ZIO\u201d \u0432 \u0441\u0442\u0440\u043e\u0433\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435.<\/p>\n<p>\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 Clojure \u0435\u0441\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u0438 ZIO runtime? \u0414\u0430, \u043d\u043e \u043d\u0435 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438.<\/p>\n<p>STM \u0438 immutable-by-default \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u0442\u0430\u043c, \u0433\u0434\u0435 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; shared mutable state. \u041a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c async-\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. ZIO \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c effectful-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. Clojure \u0447\u0430\u0441\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0441\u0430\u043c\u0443 \u043f\u043b\u043e\u0449\u0430\u0434\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043c\u0435\u043d\u044c\u0448\u0435 \u0433\u043e\u043d\u043e\u043a \u0437\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e \u201cruntime, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u043c\u0438 lightweight tasks, typed errors, dependencies, scopes, resources \u0438 supervision\u201d, \u0442\u043e Clojure core \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435 \u0434\u0430\u0451\u0442. \u0422\u0430\u043c \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0438\u044f \u0434\u0440\u0443\u0433\u0430\u044f: \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u043e\u0440\u0442\u043e\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b \u043f\u043b\u044e\u0441 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043b\u044e\u0441 interop \u0441 JVM.<\/p>\n<hr\/>\n<h3>11. \u0410\u043d\u0430\u043b\u043e\u0433\u0438 ZIO runtime \u0432 \u0447\u0438\u0441\u0442\u043e\u0439 Java<\/h3>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0434 \u201c\u0447\u0438\u0441\u0442\u043e\u0439 Java\u201d \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e JDK, \u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 ZIO \u043d\u0435\u0442.<\/p>\n<p>\u0412 JDK \u0435\u0441\u0442\u044c \u043a\u0443\u0441\u043a\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0435: <code>CompletableFuture<\/code>, <code>ExecutorService<\/code>, virtual threads, structured concurrency, scoped values, <code>Flow<\/code> API. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 effect system.<\/p>\n<details class=\"spoiler\">\n<summary>Java: CompletableFuture \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f async-\u0437\u0430\u0434\u0430\u0447<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">CompletableFuture&lt;Response&gt; response =    loadUserAsync(userId)        .thenCombine(loadOrdersAsync(userId), this::render)        .exceptionally(this::fallback);<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<p><code>CompletableFuture<\/code> \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u0440\u0438\u0440\u043e\u0434\u0430: \u043e\u043d eager, \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0435 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, cancellation \u0438 structured lifecycle \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u044b \u0432 \u0442\u0438\u043f\u0435.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0431\u0440\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 Java, \u0442\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0435 \u0441\u043e\u0441\u0435\u0434\u0438:<\/p>\n<ul>\n<li>\n<p>Project Reactor: <code>Mono<\/code>, <code>Flux<\/code>, schedulers, backpressure, Spring WebFlux;<\/p>\n<\/li>\n<li>\n<p>RxJava: <code>Single<\/code>, <code>Observable<\/code>, <code>Flowable<\/code>;<\/p>\n<\/li>\n<li>\n<p>Mutiny: <code>Uni<\/code>, <code>Multi<\/code>, Quarkus\/Vert.x-\u043c\u0438\u0440;<\/p>\n<\/li>\n<li>\n<p>Vert.x: event loop runtime \u0438 async-\u043c\u043e\u0434\u0435\u043b\u044c;<\/p>\n<\/li>\n<li>\n<p>Vavr: \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b (<code>Either<\/code>, <code>Try<\/code>, <code>Future<\/code>), \u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 runtime \u0443\u0440\u043e\u0432\u043d\u044f ZIO.<\/p>\n<\/li>\n<\/ul>\n<p>Project Reactor \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0432 Java backend, \u043d\u043e \u044d\u0442\u043e reactive streams runtime, \u0430 \u043d\u0435 ZIO.<\/p>\n<details class=\"spoiler\">\n<summary>Java Reactor: Mono.zip<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"java\">Mono&lt;Response&gt; response =    Mono.zip(loadUser(userId), loadOrders(userId))        .map(tuple -&gt; render(tuple.getT1(), tuple.getT2()));<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<\/div>\n<\/details>\n<p>\u0412 Reactor \u0435\u0441\u0442\u044c \u043c\u043e\u0449\u043d\u0430\u044f async-\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f, backpressure \u0432 <code>Flux<\/code>, \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441\u043e Spring. \u041d\u043e typed environment <code>R<\/code> \u0438 typed error channel <code>E<\/code> \u0442\u0430\u043c \u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.<\/p>\n<p>\u0412 \u0447\u0438\u0441\u0442\u043e\u0439 Java \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0432\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0430\u0447\u0435:<\/p>\n<pre><code>virtual threads + structured concurrency + scoped values<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0435 \u201cZIO \u0434\u043b\u044f Java\u201d, \u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 imperative\/blocking \u0441\u0442\u0438\u043b\u044c \u0441\u043d\u043e\u0432\u0430 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c.<\/p>\n<hr\/>\n<h3>12. \u0410\u043d\u0430\u043b\u043e\u0433\u0438 ZIO \u0432 Kotlin: \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u043e\u043d\u0438 \u0432\u043e\u043e\u0431\u0449\u0435?<\/h3>\n<p>\u0412 Kotlin \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0430\u043c \u044f\u0437\u044b\u043a \u0443\u0436\u0435 \u0434\u0430\u043b \u0442\u043e, \u0440\u0430\u0434\u0438 \u0447\u0435\u0433\u043e \u0432 Java \u0447\u0430\u0441\u0442\u043e \u0442\u044f\u043d\u0443\u0442\u0441\u044f \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435:<\/p>\n<ul>\n<li>\n<p><code>suspend<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>structured concurrency;<\/p>\n<\/li>\n<li>\n<p><code>Flow<\/code>;<\/p>\n<\/li>\n<li>\n<p>\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 extension functions;<\/p>\n<\/li>\n<li>\n<p>sealed classes;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0434\u043e\u0431\u043d\u044b\u0435 DSL.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u201cZIO \u0434\u043b\u044f Kotlin\u201d \u043d\u0435 \u0441\u0442\u0430\u043b \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u0446\u0435\u043d\u0442\u0440\u043e\u043c \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b: \u0440\u043e\u043b\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e runtime \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u0443\u0436\u0435 \u0437\u0430\u043d\u044f\u043b <code>kotlinx.coroutines<\/code>.<\/p>\n<p>\u0412\u043e\u043a\u0440\u0443\u0433 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 Kotlin \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432:<\/p>\n<ul>\n<li>\n<p><code>kotlinx.coroutines<\/code>: \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 runtime \u0434\u043b\u044f suspend\/coroutine\/Flow;<\/p>\n<\/li>\n<li>\n<p>Arrow: \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, <code>Either<\/code>, <code>Raise<\/code>, typed errors, resource-style \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>Ktor + coroutines: \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 backend-\u0441\u0442\u0435\u043a \u043d\u0430 suspend;<\/p>\n<\/li>\n<li>\n<p>Reactor interop: \u0432 Spring\/Kotlin \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0436\u0438\u0442\u044c \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 <code>Mono<\/code>\/<code>Flux<\/code> \u0438 <code>suspend<\/code>;<\/p>\n<\/li>\n<li>\n<p>Result\/Either-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 typed errors \u0431\u0435\u0437 \u043f\u043e\u043b\u043d\u043e\u0433\u043e effect runtime.<\/p>\n<\/li>\n<\/ul>\n<p>\u041d\u0443\u0436\u0435\u043d \u043b\u0438 Kotlin \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 ZIO runtime? \u041e\u0431\u044b\u0447\u043d\u043e \u043d\u0435\u0442, \u0435\u0441\u043b\u0438 \u0440\u0435\u0447\u044c \u043f\u0440\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 backend. Coroutines \u0443\u0436\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0442 runtime-\u0447\u0430\u0441\u0442\u044c: \u043b\u0451\u0433\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, cancellation, structured concurrency, dispatchers.<\/p>\n<p>\u041d\u043e \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e ZIO-\u043f\u043e\u0434\u0445\u043e\u0434\u0430: \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, typed environment, typed error, \u0435\u0434\u0438\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u0442\u043e Kotlin \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0430\u0451\u0442. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Arrow \u0438 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u0443, \u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043d\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e ZIO \u0432 Scala.<\/p>\n<p>\u041a\u043e\u0440\u043e\u0447\u0435:<\/p>\n<pre><code>Kotlin coroutines - \u0443\u0436\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 runtime \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438.Arrow - \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u0438\u0440\u043f\u0438\u0447\u0438 \u043f\u043e\u0432\u0435\u0440\u0445 Kotlin.ZIO-like \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0446\u0435\u043d\u0442\u0440\u0430 \u0432 Kotlin-\u043c\u0438\u0440\u0435 \u043d\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044f\u0437\u044b\u043a \u043f\u043e\u0448\u0451\u043b \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0451\u043c.<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<hr\/>\n<h3>13. \u0427\u0442\u043e \u0441 thread pools \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e<\/h3>\n<p>\u042f \u0431\u044b \u043d\u0435 \u0445\u043e\u0440\u043e\u043d\u0438\u043b thread pools. \u042d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 pool \u0447\u0430\u0441\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u043b \u0437\u0430 \u0432\u0441\u0451 \u0441\u0440\u0430\u0437\u0443:<\/p>\n<ul>\n<li>\n<p>\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043b \u043f\u043e\u0442\u043e\u043a\u0438;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u043b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c;<\/p>\n<\/li>\n<li>\n<p>\u0431\u044b\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u044e;<\/p>\n<\/li>\n<li>\n<p>\u0437\u0430\u0449\u0438\u0449\u0430\u043b \u0440\u0435\u0441\u0443\u0440\u0441;<\/p>\n<\/li>\n<li>\n<p>\u043e\u0442\u0434\u0435\u043b\u044f\u043b CPU \u043e\u0442 blocking I\/O.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u043e\u0441\u043b\u0435 Loom \u0447\u0430\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0443\u0445\u043e\u0434\u0438\u0442. \u042d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0438 \u0434\u043b\u044f I\/O-bound \u0437\u0430\u0434\u0430\u0447 \u0443\u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c virtual thread \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u0436\u043d\u043e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0411\u0414 \u0434\u0435\u0440\u0436\u0438\u0442 50 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u0442\u043e 100 000 virtual threads \u043d\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442 \u0411\u0414 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041e\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0440\u0443\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u043d\u0443\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043a connection pool.<\/p>\n<p>\u0418 \u044d\u0442\u043e, \u043a\u0441\u0442\u0430\u0442\u0438, \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u0438. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043d\u0435 \u043e\u0442\u043c\u0435\u043d\u044f\u044e\u0442 \u0444\u0438\u0437\u0438\u043a\u0443.<\/p>\n<hr\/>\n<p>\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0431\u043b\u0438\u0437\u043a\u0438 \u0442\u0435\u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u0441\u0442\u0430\u0440\u0442\u0430\u043f\u043e\u0432, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0430\u0441 \u0432 \u043c\u043e\u0451\u043c <a href=\"https:\/\/t.me\/tech_lead_rst\" rel=\"noopener noreferrer nofollow\">Telegram-\u043a\u0430\u043d\u0430\u043b\u0435<\/a>.<\/p>\n<hr\/>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f JVM-\u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0441\u0432\u0435\u043b\u0430\u0441\u044c \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044e. Java \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 <code>Thread<\/code>. Kotlin \u0432\u044b\u0442\u0430\u0449\u0438\u043b \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0432 <code>suspend<\/code> \u0438 coroutine runtime. Scala\/ZIO \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u043e\u043a\u0440\u0443\u0433 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438 fibers. Clojure \u0437\u0430\u0448\u0451\u043b \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b: \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 coordination primitives \u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c\u0443 JVM-\u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u0443.<\/p>\n<p>\u0410 thread pools \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0438\u0441\u0447\u0435\u0437\u043b\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0438 \u0431\u044b\u0442\u044c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u0432\u044b\u0436\u0438\u0442\u044c \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1035740\/\">https:\/\/habr.com\/ru\/articles\/1035740\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440!\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438 \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u044f\u0445 \u043c\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438 Java Thread, thread pools, virtual threads, Kotlin coroutines, ZIO runtime \u0438 Clojure primitives. \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0435\u043b\u0438 \u0431\u0435\u0437 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0434\u043b\u044f \u201c\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e\u201d \u0438 \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c  \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441 \u201c\u0410 \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u0435\u0449\u0435 \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u0435 thread pools?\u201d\u0412 \u044d\u0442\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:Kotlin coroutines \u043f\u0440\u043e\u0442\u0438\u0432 ZIO runtime.Clojure core.async \u0438 \u0432\u043e\u043f\u0440\u043e\u0441, \u0435\u0441\u0442\u044c \u043b\u0438 \u0442\u0430\u043c \u0430\u043d\u0430\u043b\u043e\u0433 \u043a\u043e\u0440\u0443\u0442\u0438\u043d.\u0415\u0441\u0442\u044c \u043b\u0438 \u0432 Clojure \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0435 \u043d\u0430 ZIO runtime.\u0410\u043d\u0430\u043b\u043e\u0433\u0438 ZIO \u0432 \u0447\u0438\u0441\u0442\u043e\u0439 Java \u0438 Kotlin.\u0427\u0442\u043e \u0441\u0442\u0430\u043b\u043e \u0441 thread pools \u043f\u043e\u0441\u043b\u0435 Loom, coroutines \u0438 fibers.8. \u0421\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435: Kotlin coroutines \u0438 ZIO runtime\u0422\u0443\u0442 \u0441\u0445\u043e\u0434\u0441\u0442\u0432\u0430 \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043a\u0430\u0436\u0435\u0442\u0441\u044f. Kotlin coroutines \u0438 ZIO fibers \u043b\u0451\u0433\u043a\u0438\u0435, \u043d\u0435 \u0440\u0430\u0432\u043d\u044b platform threads, \u0443\u043c\u0435\u044e\u0442 cancellation, \u0434\u0430\u044e\u0442 structured concurrency \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0439 \u043d\u0430 \u0432\u0438\u0434 \u043a\u043e\u0434 \u043f\u043e\u0432\u0435\u0440\u0445 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0442\u043e\u043a\u043e\u0432.\u041d\u043e ZIO \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u043e\u0439, \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0435\u0442 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 Kotlin coroutines: \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u0430\u043d\u0430\u043b \u043e\u0448\u0438\u0431\u043e\u043a E, \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0435 R, \u0435\u0434\u0438\u043d\u044b\u0439 \u0442\u0438\u043f \u044d\u0444\u0444\u0435\u043a\u0442\u0430, resource safety, supervision \u0438 \u0431\u043e\u0433\u0430\u0442\u0443\u044e \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432. \u042d\u0442\u043e \u043d\u0435 \u201c\u0435\u0449\u0451 \u043e\u0434\u043d\u0430 async-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u201d, \u0430 \u0441\u043f\u043e\u0441\u043e\u0431 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443.Kotlin \u043f\u0440\u0430\u0433\u043c\u0430\u0442\u0438\u0447\u043d\u0435\u0435. \u0415\u0441\u0442\u044c suspend, CoroutineScope, Flow, Job. \u041e\u0448\u0438\u0431\u043a\u0438 \u0447\u0430\u0449\u0435 \u0438\u0434\u0443\u0442 \u0447\u0435\u0440\u0435\u0437 exceptions, Result, Either \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0438\u043b\u0438 sealed-\u043a\u043b\u0430\u0441\u0441\u044b. \u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0431\u044b\u0447\u043d\u043e \u0440\u0435\u0448\u0430\u044e\u0442\u0441\u044f DI-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c, \u0430 \u043d\u0435 \u0442\u0438\u043f\u043e\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0430.Kotlin: suspend + Either \u043a\u0430\u043a \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0435\u043d\u0438\u0435 \u043a typed errorssuspend fun loadUser(userId: UserId): Either&lt;DomainError, User&gt; =    either {        val raw = userClient.load(userId).bind()        raw.toDomain().bind()    }\u0412 ZIO \u044d\u0442\u043e \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043e \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u0442\u0438\u043f. \u0412 Kotlin \u044d\u0442\u043e \u043e\u0431\u044b\u0447\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u043a\u043e\u0440\u0443\u0442\u0438\u043d, Arrow \u0438 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u044b \u043a\u043e\u043c\u0430\u043d\u0434\u044b.\u0415\u0441\u043b\u0438 \u043a\u043e\u0440\u043e\u0442\u043a\u043e:Kotlin coroutines &#8212; runtime \u0434\u043b\u044f suspend-\u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439.ZIO runtime &#8212; runtime \u0434\u043b\u044f \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 effectful-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c.9. Clojure: \u0435\u0441\u0442\u044c \u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0421\u0430\u043c\u044b\u0439 \u0431\u043b\u0438\u0437\u043a\u0438\u0439 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043e\u0442\u0432\u0435\u0442 &#8212; core.async.core.async \u043f\u0440\u0438\u043d\u043e\u0441\u0438\u0442 CSP-\u043c\u043e\u0434\u0435\u043b\u044c: channels, go blocks, &lt;!, &gt;!, alts!. \u042d\u0442\u043e \u043c\u0438\u0440 \u201c\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043e\u0431\u0449\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043d\u0430\u043b\u044b\u201d, \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 \u043f\u043e Go \u0438 CSP, \u0430 \u043d\u0435 \u043c\u0438\u0440 async\/await \u043a\u0430\u043a \u0432 Kotlin.\u041a\u0440\u0430\u0442\u043a\u043e: \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 CSPCSP &#8212; Communicating Sequential Processes. \u0418\u0434\u0435\u044f \u043f\u0440\u043e\u0441\u0442\u0430\u044f: \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043d\u0435 \u043b\u0435\u0437\u0443\u0442 \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u0430 \u043e\u0431\u0449\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043d\u0430\u043b\u044b. \u041e\u0434\u0438\u043d \u043a\u043b\u0430\u0434\u0451\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0434\u0440\u0443\u0433\u043e\u0439 \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u0442.\u0412\u043c\u0435\u0441\u0442\u043e \u201c\u0443 \u043d\u0430\u0441 \u043e\u0431\u0449\u0438\u0439 mutable object, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u0435\u0433\u043e \u0437\u0430\u043b\u043e\u0447\u0438\u043c\u201d \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u201c\u0443 \u043d\u0430\u0441 \u043f\u043e\u0442\u043e\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u0443\u0447\u0430\u0441\u0442\u043d\u0438\u043a\u0430\u043c\u0438\u201d. \u042d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d\u043e\u0432, \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, worker\u2019\u043e\u0432 \u0438 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u0432, \u0433\u0434\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u043f\u0440\u043e\u0449\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a \u043d\u0430\u0431\u043e\u0440 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432.Clojure: core.async go block(require &#8216;[clojure.core.async :as async :refer [go &lt;! &gt;! chan]])(def requests (chan))(def responses (chan))(go  (let [request (&lt;! requests)        response (handle request)]    (&gt;! responses response)))go block \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443 \u0432 \u043e\u0434\u043d\u043e\u043c \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435: \u043a\u043e\u0434 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442\u0441\u044f \u0432 state machine \u0438 \u043c\u043e\u0436\u0435\u0442 \u043f\u0430\u0440\u043a\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u0445 \u0441 \u043a\u0430\u043d\u0430\u043b\u0430\u043c\u0438, \u043d\u0435 \u0443\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044f \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u043f\u043e\u0442\u043e\u043a.\u041d\u043e \u044d\u0442\u043e \u043d\u0435 Kotlin coroutines:go block \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043f\u0440\u043e parking \u043d\u0430 core.async channels;\u0432\u043d\u0443\u0442\u0440\u044c go \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u043f\u043e\u043a\u043e\u0439\u043d\u043e \u043a\u043b\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0439 blocking I\/O;\u0434\u043b\u044f blocking-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 async\/thread, \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 executor \u0438\u043b\u0438 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 Java\/Clojure concurrency primitives;\u043d\u0435\u0442 \u044f\u0437\u044b\u043a\u043e\u0432\u043e\u0433\u043e suspend, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0441\u0438\u0433\u043d\u0430\u0442\u0443\u0440\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439;structured concurrency \u0432 \u0441\u0442\u0438\u043b\u0435 coroutineScope \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e core.async.core.async &#8212; \u044d\u0442\u043e lightweight concurrency \u0432\u043e\u043a\u0440\u0443\u0433 \u043a\u0430\u043d\u0430\u043b\u043e\u0432 \u0438 \u043e\u0431\u043c\u0435\u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f\u043c\u0438, \u0430 \u043d\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u0430\u044f \u0437\u0430\u043c\u0435\u043d\u0430 Kotlin coroutines \u0434\u043b\u044f \u043b\u044e\u0431\u043e\u0433\u043e async-\u043a\u043e\u0434\u0430.\u0415\u0441\u043b\u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0433\u0440\u0443\u0431\u043e:Kotlin coroutine &#8212; suspendable computation.Clojure core.async go block &#8212; lightweight process around channel operations.ZIO fiber &#8212; lightweight task executing a typed effect.Virtual thread &#8212; lightweight JVM Thread for blocking-style code.10. Clojure: \u0435\u0441\u0442\u044c \u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433 ZIO runtime\u041f\u0440\u044f\u043c\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 ZIO \u0432 Clojure core \u043d\u0435\u0442.\u0418 \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u201c\u043d\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0442\u0430\u043a\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443\u201d. Clojure &#8212; \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 Lisp. \u0412 \u043d\u0451\u043c \u043d\u0435\u0442 Scala-\u0442\u0438\u043f\u043e\u0432 \u0432\u0438\u0434\u0430 ZIO[R, E, A], \u0433\u0434\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438, \u043e\u0448\u0438\u0431\u043a\u0430 \u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u0448\u0438\u0442\u044b \u0432 \u0442\u0438\u043f. Clojure \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0435 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u0432\u0441\u044e effectful-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u0447\u0435\u0440\u0435\u0437 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0442\u0438\u043f.\u0412 Clojure \u0435\u0441\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u044b\u0435 \u0432\u0435\u0449\u0438, \u043d\u043e \u043e\u043d\u0438 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438:immutable persistent data structures \u043a\u0430\u043a \u0434\u0435\u0444\u043e\u043b\u0442;STM \u0434\u043b\u044f \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0446\u0438\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 mutable references;atoms\/agents\/promises\/futures \u043a\u0430\u043a \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435, \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 building blocks;core.async \u0434\u043b\u044f CSP \u0438 \u043a\u0430\u043d\u0430\u043b\u043e\u0432;Java interop, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0431\u0440\u0430\u0442\u044c virtual threads, executors, CompletableFuture, Reactor, Netty \u0438 \u0432\u0441\u0451 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0435 JVM-\u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u043e.\u0415\u0441\u043b\u0438 \u0438\u0441\u043a\u0430\u0442\u044c ZIO-like \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043f\u043e \u0434\u0443\u0445\u0443, \u043c\u043e\u0436\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 missionary, manifold, promesa, \u0438\u043d\u043e\u0433\u0434\u0430 \u043d\u0430 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441 Reactor. \u041d\u043e \u043e\u043d\u0438 \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0434\u043b\u044f Clojure \u0442\u0435\u043c \u0436\u0435, \u0447\u0435\u043c ZIO \u0441\u0442\u0430\u043b \u0434\u043b\u044f \u0447\u0430\u0441\u0442\u0438 Scala-\u043c\u0438\u0440\u0430.missionary \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u043a \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0443 \u043f\u0440\u043e functional effects: \u0437\u0430\u0434\u0430\u0447\u0438, \u043f\u043e\u0442\u043e\u043a\u0438\/flows, cancellation \u0438 \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f. manifold \u0434\u0430\u0451\u0442 deferred\/streams \u0434\u043b\u044f \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e JVM-Clojure. promesa \u0434\u0430\u0451\u0442 promise-like \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044e, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u0443\u044e \u043d\u0430 ClojureScript\/interop-\u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445. \u041d\u043e \u0432\u0441\u0451 \u044d\u0442\u043e \u043d\u0435 \u201cClojure ZIO\u201d \u0432 \u0441\u0442\u0440\u043e\u0433\u043e\u043c \u0441\u043c\u044b\u0441\u043b\u0435.\u041c\u043e\u0436\u043d\u043e \u043b\u0438 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 Clojure \u0435\u0441\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u0438 ZIO runtime? \u0414\u0430, \u043d\u043e \u043d\u0435 \u0432 \u0442\u043e\u0439 \u0436\u0435 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438.STM \u0438 immutable-by-default \u043c\u043e\u0434\u0435\u043b\u044c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0438\u043b\u044c\u043d\u0435\u0435 \u043a\u043e\u0440\u0443\u0442\u0438\u043d \u0442\u0430\u043c, \u0433\u0434\u0435 \u0433\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 &#8212; shared mutable state. \u041a\u043e\u0440\u0443\u0442\u0438\u043d\u044b \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c async-\u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435. ZIO \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c effectful-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b. Clojure \u0447\u0430\u0441\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u0441\u0430\u043c\u0443 \u043f\u043b\u043e\u0449\u0430\u0434\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b: \u043c\u0435\u043d\u044c\u0448\u0435 \u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043c\u0435\u043d\u044c\u0448\u0435 \u0433\u043e\u043d\u043e\u043a \u0437\u0430 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.\u041d\u043e \u0435\u0441\u043b\u0438 \u0432\u043e\u043f\u0440\u043e\u0441 \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e \u201cruntime, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u0430\u043c\u0438 lightweight tasks, typed errors, dependencies, scopes, resources \u0438 supervision\u201d, \u0442\u043e Clojure core \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0435 \u0434\u0430\u0451\u0442. \u0422\u0430\u043c \u0444\u0438\u043b\u043e\u0441\u043e\u0444\u0438\u044f \u0434\u0440\u0443\u0433\u0430\u044f: \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u043e\u0440\u0442\u043e\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0438\u0442\u0438\u0432\u044b \u043f\u043b\u044e\u0441 \u0438\u043c\u043c\u0443\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043f\u043b\u044e\u0441 interop \u0441 JVM.11. \u0410\u043d\u0430\u043b\u043e\u0433\u0438 ZIO runtime \u0432 \u0447\u0438\u0441\u0442\u043e\u0439 Java\u0415\u0441\u043b\u0438 \u043f\u043e\u0434 \u201c\u0447\u0438\u0441\u0442\u043e\u0439 Java\u201d \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e JDK, \u0442\u043e \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433\u0430 ZIO \u043d\u0435\u0442.\u0412 JDK \u0435\u0441\u0442\u044c \u043a\u0443\u0441\u043a\u0438, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043c\u043d\u043e\u0433\u043e\u0435: CompletableFuture, ExecutorService, virtual threads, structured concurrency, scoped values, Flow API. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 effect system.Java: CompletableFuture \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f async-\u0437\u0430\u0434\u0430\u0447CompletableFuture&lt;Response&gt; response =    loadUserAsync(userId)        .thenCombine(loadOrdersAsync(userId), this::render)        .exceptionally(this::fallback);CompletableFuture \u043f\u043e\u043b\u0435\u0437\u0435\u043d, \u043d\u043e \u0443 \u043d\u0435\u0433\u043e \u0434\u0440\u0443\u0433\u0430\u044f \u043f\u0440\u0438\u0440\u043e\u0434\u0430: \u043e\u043d eager, \u043e\u0448\u0438\u0431\u043a\u0430 \u043d\u0435 \u0442\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u043a\u0430\u043a \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, cancellation \u0438 structured lifecycle \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e\u0441\u0442\u0438, \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u044b \u0432 \u0442\u0438\u043f\u0435.\u0415\u0441\u043b\u0438 \u0431\u0440\u0430\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0438 Java, \u0442\u043e \u0431\u043b\u0438\u0436\u0430\u0439\u0448\u0438\u0435 \u0441\u043e\u0441\u0435\u0434\u0438:Project Reactor: Mono, Flux, schedulers, backpressure, Spring WebFlux;RxJava: Single, Observable, Flowable;Mutiny: Uni, Multi, Quarkus\/Vert.x-\u043c\u0438\u0440;Vert.x: event loop runtime \u0438 async-\u043c\u043e\u0434\u0435\u043b\u044c;Vavr: \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b (Either, Try, Future), \u043d\u043e \u043d\u0435 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 runtime \u0443\u0440\u043e\u0432\u043d\u044f ZIO.Project Reactor \u0431\u043b\u0438\u0436\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0441\u0442\u0438 \u0432 Java backend, \u043d\u043e \u044d\u0442\u043e reactive streams runtime, \u0430 \u043d\u0435 ZIO.Java Reactor: Mono.zipMono&lt;Response&gt; response =    Mono.zip(loadUser(userId), loadOrders(userId))        .map(tuple -&gt; render(tuple.getT1(), tuple.getT2()));\u0412 Reactor \u0435\u0441\u0442\u044c \u043c\u043e\u0449\u043d\u0430\u044f async-\u043a\u043e\u043c\u043f\u043e\u0437\u0438\u0446\u0438\u044f, backpressure \u0432 Flux, \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u044f \u0441\u043e Spring. \u041d\u043e typed environment R \u0438 typed error channel E \u0442\u0430\u043c \u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u044c\u044e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b.\u0412 \u0447\u0438\u0441\u0442\u043e\u0439 Java \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0442\u0430\u0432\u043a\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u043d\u0430\u0447\u0435:virtual threads + structured concurrency + scoped values\u041d\u0435 \u201cZIO \u0434\u043b\u044f Java\u201d, \u0430 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 imperative\/blocking \u0441\u0442\u0438\u043b\u044c \u0441\u043d\u043e\u0432\u0430 \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c.12. \u0410\u043d\u0430\u043b\u043e\u0433\u0438 ZIO \u0432 Kotlin: \u043d\u0443\u0436\u043d\u044b \u043b\u0438 \u043e\u043d\u0438 \u0432\u043e\u043e\u0431\u0449\u0435?\u0412 Kotlin \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441\u0430\u043c \u044f\u0437\u044b\u043a \u0443\u0436\u0435 \u0434\u0430\u043b \u0442\u043e, \u0440\u0430\u0434\u0438 \u0447\u0435\u0433\u043e \u0432 Java \u0447\u0430\u0441\u0442\u043e \u0442\u044f\u043d\u0443\u0442\u0441\u044f \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435:suspend;\u043a\u043e\u0440\u0443\u0442\u0438\u043d\u044b;structured concurrency;Flow;\u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 extension functions;sealed classes;\u0443\u0434\u043e\u0431\u043d\u044b\u0435 DSL.\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u044b\u0439 \u201cZIO \u0434\u043b\u044f Kotlin\u201d \u043d\u0435 \u0441\u0442\u0430\u043b \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u0446\u0435\u043d\u0442\u0440\u043e\u043c \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b: \u0440\u043e\u043b\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e runtime \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438 \u0443\u0436\u0435 \u0437\u0430\u043d\u044f\u043b kotlinx.coroutines.\u0412\u043e\u043a\u0440\u0443\u0433 \u044d\u0442\u043e\u0439 \u043c\u043e\u0434\u0435\u043b\u0438 \u0432 Kotlin \u043e\u0431\u044b\u0447\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432:kotlinx.coroutines: \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 runtime \u0434\u043b\u044f suspend\/coroutine\/Flow;Arrow: \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u0442\u0438\u043f\u044b, Either, Raise, typed errors, resource-style \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b;Ktor + coroutines: \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 backend-\u0441\u0442\u0435\u043a \u043d\u0430 suspend;Reactor interop: \u0432 Spring\/Kotlin \u0447\u0430\u0441\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0436\u0438\u0442\u044c \u043d\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u0435 Mono\/Flux \u0438 suspend;Result\/Either-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 typed errors \u0431\u0435\u0437 \u043f\u043e\u043b\u043d\u043e\u0433\u043e effect runtime.\u041d\u0443\u0436\u0435\u043d \u043b\u0438 Kotlin \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0430\u043d\u0430\u043b\u043e\u0433 ZIO runtime? \u041e\u0431\u044b\u0447\u043d\u043e \u043d\u0435\u0442, \u0435\u0441\u043b\u0438 \u0440\u0435\u0447\u044c \u043f\u0440\u043e \u043e\u0431\u044b\u0447\u043d\u044b\u0439 backend. Coroutines \u0443\u0436\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u044e\u0442 runtime-\u0447\u0430\u0441\u0442\u044c: \u043b\u0451\u0433\u043a\u0438\u0435 \u0437\u0430\u0434\u0430\u0447\u0438, cancellation, structured concurrency, dispatchers.\u041d\u043e \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e ZIO-\u043f\u043e\u0434\u0445\u043e\u0434\u0430: \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 \u043a\u0430\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, typed environment, typed error, \u0435\u0434\u0438\u043d\u0430\u044f \u0430\u043b\u0433\u0435\u0431\u0440\u0430 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432, \u0442\u043e Kotlin \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0434\u0430\u0451\u0442. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u0431\u043b\u0438\u0437\u0438\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 Arrow \u0438 \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u0443, \u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043d\u0435 \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e ZIO \u0432 Scala.\u041a\u043e\u0440\u043e\u0447\u0435:Kotlin coroutines &#8212; \u0443\u0436\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 runtime \u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u0438.Arrow &#8212; \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u0438\u0440\u043f\u0438\u0447\u0438 \u043f\u043e\u0432\u0435\u0440\u0445 Kotlin.ZIO-like \u0435\u0434\u0438\u043d\u043e\u0433\u043e \u0446\u0435\u043d\u0442\u0440\u0430 \u0432 Kotlin-\u043c\u0438\u0440\u0435 \u043d\u0435\u0442, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u044f\u0437\u044b\u043a \u043f\u043e\u0448\u0451\u043b \u0434\u0440\u0443\u0433\u0438\u043c \u043f\u0443\u0442\u0451\u043c.13. \u0427\u0442\u043e \u0441 thread pools \u043f\u043e\u0441\u043b\u0435 \u0432\u0441\u0435\u0433\u043e \u044d\u0442\u043e\u0433\u043e\u042f \u0431\u044b \u043d\u0435 \u0445\u043e\u0440\u043e\u043d\u0438\u043b thread pools. \u042d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442.\u041f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u043d\u044c\u0448\u0435 pool \u0447\u0430\u0441\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u043b \u0437\u0430 \u0432\u0441\u0451 \u0441\u0440\u0430\u0437\u0443:\u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043b \u043f\u043e\u0442\u043e\u043a\u0438;\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u043b \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u0438\u0437\u043c;\u0431\u044b\u043b \u043e\u0447\u0435\u0440\u0435\u0434\u044c\u044e;\u0437\u0430\u0449\u0438\u0449\u0430\u043b \u0440\u0435\u0441\u0443\u0440\u0441;\u043e\u0442\u0434\u0435\u043b\u044f\u043b CPU \u043e\u0442 blocking I\/O.\u041f\u043e\u0441\u043b\u0435 Loom \u0447\u0430\u0441\u0442\u044c \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u0443\u0445\u043e\u0434\u0438\u0442. \u042d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043f\u043e\u0442\u043e\u043a\u0438 \u0434\u043b\u044f I\/O-bound \u0437\u0430\u0434\u0430\u0447 \u0443\u0436\u0435 \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u043e, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c virtual thread \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443. \u041d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u043d\u0443\u0436\u043d\u043e.\u0415\u0441\u043b\u0438 \u0411\u0414 \u0434\u0435\u0440\u0436\u0438\u0442 50 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0439, \u0442\u043e 100 000 virtual threads \u043d\u0435 \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442 \u0411\u0414 \u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u041e\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0440\u0443\u0436\u043d\u043e \u0432\u0441\u0442\u0430\u043d\u0443\u0442 \u0432 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u043a connection pool.\u0418 \u044d\u0442\u043e, \u043a\u0441\u0442\u0430\u0442\u0438, \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u0433\u0440\u0430\u043d\u0438\u0446\u0430 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u043e\u0441\u0442\u0438. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u044b\u0435 \u043f\u043e\u0442\u043e\u043a\u0438 \u043d\u0435 \u043e\u0442\u043c\u0435\u043d\u044f\u044e\u0442 \u0444\u0438\u0437\u0438\u043a\u0443.\u0415\u0441\u043b\u0438 \u0432\u0430\u043c \u0431\u043b\u0438\u0437\u043a\u0438 \u0442\u0435\u043c\u044b \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438, \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u0438 \u0441\u0442\u0430\u0440\u0442\u0430\u043f\u043e\u0432, \u0431\u0443\u0434\u0443 \u0440\u0430\u0434 \u0432\u0438\u0434\u0435\u0442\u044c \u0432\u0430\u0441 \u0432 \u043c\u043e\u0451\u043c Telegram-\u043a\u0430\u043d\u0430\u043b\u0435.\u0412\u044b\u0432\u043e\u0434\u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f JVM-\u043a\u043e\u043d\u043a\u0443\u0440\u0435\u043d\u0442\u043d\u043e\u0441\u0442\u044c \u043d\u0435 \u0441\u0432\u0435\u043b\u0430\u0441\u044c \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u043f\u043e\u0431\u0435\u0434\u0438\u0442\u0435\u043b\u044e. Java \u0441\u0434\u0435\u043b\u0430\u043b\u0430 \u0434\u0435\u0448\u0435\u0432\u043b\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u0439 Thread. Kotlin \u0432\u044b\u0442\u0430\u0449\u0438\u043b \u043f\u0440\u0438\u043e\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 \u0432 suspend \u0438 coroutine runtime. Scala\/ZIO \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0430 \u043c\u043e\u0434\u0435\u043b\u044c \u0432\u043e\u043a\u0440\u0443\u0433 \u044d\u0444\u0444\u0435\u043a\u0442\u0430 \u0438 fibers. Clojure \u0437\u0430\u0448\u0451\u043b \u0441 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b: \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 coordination primitives \u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u043a\u043e \u0432\u0441\u0435\u043c\u0443 JVM-\u0445\u043e\u0437\u044f\u0439\u0441\u0442\u0432\u0443.\u0410 thread pools \u043d\u0438\u043a\u0443\u0434\u0430 \u043d\u0435 \u0438\u0441\u0447\u0435\u0437\u043b\u0438, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u0438 \u0431\u044b\u0442\u044c \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-479904","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/479904","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=479904"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/479904\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=479904"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=479904"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=479904"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}