JDK 19 对反应式编程的批判
我们知道 JDK 19 引入了虚拟线程,实现了 JEP425 草案,https://openjdk.org/jeps/425 该案对反应式编程的批判可谓犀利:
Improving scalability with the asynchronous style
Some developers wishing to utilize hardware to its fullest have given up the thread-per-request style in favor of a thread-sharing style. Instead of handling a request on one thread from start to finish, request-handling code returns its thread to a pool when it waits for an I/O operation to complete so that the thread can service other requests. This fine-grained sharing of threads — in which code holds on to a thread only when it performs calculations, not when it waits for I/O — allows a high number of concurrent operations without consuming a high number of threads. While it removes the limitation on throughput imposed by the scarcity of OS threads, it comes at a high price: It requires what is known as an asynchronous programming style, employing a separate set of I/O methods that do not wait for I/O operations to complete but rather, later on, signal their completion to a callback. Without a dedicated thread, developers must break down their request-handling logic into small stages, typically written as lambda expressions, and then compose them into a sequential pipeline with an API (see CompletableFuture, for example, or so-called "reactive" frameworks). They thus forsake the language's basic sequential composition operators, such as loops and try/catch blocks.In the asynchronous style, each stage of a request might execute on a different thread, and every thread runs stages belonging to different requests in an interleaved fashion. This has deep implications for understanding program behavior: Stack traces provide no usable context, debuggers cannot step through request-handling logic, and profilers cannot associate an operation's cost with its caller. Composing lambda expressions is manageable when using Java's stream API to process data in a short pipeline, but problematic when all of the request-handling code in an application must be written in this way. This programming style is at odds with the Java Platform because the application's unit of concurrency — the asynchronous pipeline — is no longer the platform's unit of concurrency.
在 golang 大行其道时 java 也算与时俱进了,愿 VirtualThread 的性能能不负所望。
JDK 19 对反应式编程的批判的更多相关文章
- Project Reactor 响应式编程
目录 一. 什么是响应式编程? 二. Project Reactor介绍 三. Reactor核心概念 Flux 1. just() 2. fromArray(),fromIterable()和 fr ...
- 07-Spring5 WebFlux响应式编程
SpringWebFlux介绍 简介 SpringWebFlux是Spring5添加的新模块,用于Web开发,功能和SpringMvc类似的,WebFlux使用当前一种比较流行的响应式编程框架 使用传 ...
- Objective-C 链式编程思想
链式编程思想 链式编程是什么 链式编程就是将调用多个方法用点语法连接起来,让代码更加简洁和可读性更高刚开始接触链式编程是Masonry,用起来真的非常爽 1 make.left.right.top.e ...
- 使用ReactiveCocoa实现iOS平台响应式编程
使用ReactiveCocoa实现iOS平台响应式编程 ReactiveCocoa和响应式编程 在说ReactiveCocoa之前,先要介绍一下FRP(Functional Reactive Prog ...
- [转]使用ReactiveCocoa实现iOS平台响应式编程
原文:http://www.itiger.me/?p=38 使用ReactiveCocoa实现iOS平台响应式编程 ReactiveCocoa和响应式编程 在说ReactiveCocoa之前,先要介绍 ...
- springboot2 webflux 响应式编程学习路径
springboot2 已经发布,其中最亮眼的非webflux响应式编程莫属了!响应式的weblfux可以支持高吞吐量,意味着使用相同的资源可以处理更加多的请求,毫无疑问将会成为未来技术的趋势,是必学 ...
- [转]springboot2 webflux 响应式编程学习路径
原文链接 spring官方文档 springboot2 已经发布,其中最亮眼的非webflux响应式编程莫属了!响应式的weblfux可以支持高吞吐量,意味着使用相同的资源可以处理更加多的请求,毫无疑 ...
- 【SpringBoot】SpringBoot2.0响应式编程
========================15.高级篇幅之SpringBoot2.0响应式编程 ================================ 1.SprinBoot2.x响应 ...
- Angular4学习笔记(五)- 数据绑定、响应式编程和管道
概念 Angular中的数据绑定指的是同一组件中控制器文件(.ts)与视图文件(.html)之间的数据传递. 分类 流向 单向绑定 它的意思是要么是ts文件为html文件赋值,要么相反. ts-> ...
- WebFlux基础之响应式编程
上篇文章,我们简单的了解了WebFlux的一些基础与背景,并通过示例来写了一个demo.我们知道WebFlux是响应式的web框架,其特点之一就是可以通过函数式编程方式配置route.另外究竟什么是响 ...
随机推荐
- Windows11忘记开机密码重置
在锁屏页面按着shift键重启,找到命令行输入一下两行代码 copy c:\windows\system\system32\utilman.exe c:\windows\system32\utilma ...
- C++ 第四节课 C和C++指针的区别 C的宏函数和C++内联函数的优缺点
#include <iostream> // 定义一个宏函数 #define ADD(x,y) x+y; // 宏函数具有速度快等特点 但是写代码有些业务比较繁琐,所以C++中使用了内联函 ...
- 在 Vue 实例中编写生命周期hook 或者其它 option/propertie 时,为什么不适用箭头函数 ?
首先,箭头函数没有自己的 this 环境变量 会沿用作用域使用父级this : 由Vue 管理的函数 ,如果写成箭头函数 this 就不在是 Vue 实例 了 :
- 58. vue常用的api
1. nextTick 使用场景:通过异步渲染的页面解构不能直接dom操作,要使用 nextTick (延迟回调)等待一下 :nextTick 的作用:感知dom的更新完成,类似于 updated ...
- 云原生周刊:Kubernetes v1.29 正式发布 | 2023.12.18
开源项目推荐 Robusta KRR Robusta KRR(Kubernetes Resource Recommender)是一个用于优化 Kubernetes 集群中资源分配的 CLI 工具.它从 ...
- KubeSphere Cloud 月刊|灾备支持 K8s 1.22+,轻量集群支持安装灾备和巡检组件
功能升级 备份容灾服务支持 K8s v1.22+ 版本集群 随着 Kubernetes 近一年频繁的发版.升级,越来越多的用户开始部署并使用高版本的 Kubernetes 集群.备份容灾服务支持 Ku ...
- 链表反转(反转全部,前n个,中间)
链表反转 反转全部 // 迭代 struct ListNode *reverseList(struct ListNode *head) { struct ListNode *pre = NULL; s ...
- vue项目整合echarts
准备工作: 首先我们初始化一个vue项目,执行vue init webpack echart,接着我们进入初始化的项目下.安装echarts, npm install echarts -S //或 ...
- java基础语法(从0开始到java方法)
文章目录 1.第一个java程序 2.数据的表示详解 2.1 整数在计算机中的存储原理 2.2 字符在计算机中的存储原理 2.3 图片视频声音的存储原理 2.4 数据的其他表示形式 2.5 不同进制在 ...
- PostgresSQL创建一个只读用户
create user readonlyuser with password 'R3333333341'; grant select on all tables in schema public to ...