蜜蜂飞进家里预示什么| 心肌梗塞吃什么药| 宫颈炎吃什么药好得快| tg是什么指标| 腻歪是什么意思| 长沙有什么区| 龟吃什么| 老师家访的目的是什么| 小葱拌豆腐的下一句是什么| 什么食物含叶酸| 元旦北京有什么好玩的| 软下疳是什么症状| 领袖是什么意思| 集分宝是什么意思| 情劫是什么| 发字五行属什么| 吃什么美容养颜抗衰老| 烧心吃什么| 杀鸡吓什么| 武警支队是什么级别| 丰盈是什么意思| 10086查话费发什么短信| 带状疱疹后遗神经痛挂什么科| 活血化瘀是什么意思| 或缺是什么意思| 房颤吃什么药| 晚上睡觉多梦是什么原因| 蟑螂是什么样子的| 芹菜炒什么配菜好吃| 6月24是什么日子| 兰桂齐芳是什么意思| 一个土一个斤念什么| 胃息肉是什么症状| 白菜是什么颜色| 人工受孕和试管婴儿有什么区别| lv中文名叫什么| 内敛什么意思| 嗓子不舒服吃什么药| 公安厅长是什么级别| 忌诸事不宜是什么意思| 脑堵塞有什么症状| 精索静脉曲张有什么症状| 桃李满天下是什么生肖| 结石排出来是什么感觉| 乳房疼吃什么药| 脖子后面疼是什么原因| 十年婚姻是什么婚| 领养孩子需要什么条件| 区委副书记是什么级别| 神采什么| 怨天尤人是什么意思| 癌症有什么症状| 什么叫义齿| 阴虚吃什么调理| 十一月六号是什么星座| 状元及第是什么意思| 中药龙骨是什么| 血去掉一撇念什么| 右下眼皮跳是什么原因| 血小板是什么| 伏藏是什么意思| 穷字代表什么生肖| 沙姜是什么姜| 强磁对人体有什么危害| 8月8号什么星座| 白带是什么颜色| 2007属什么| 女人是什么| 官官相护是什么意思| 优势卵泡是什么意思| spo2是什么意思| 中段尿是什么意思| 球蛋白的功效与作用是什么| 雾化治疗的作用是什么| 脉搏是什么意思| 草莓什么季节| 吃柿子有什么好处和坏处| 肩胛骨突出是什么原因| 化疗有什么副作用| 令人发指是什么意思| 颈椎病头晕吃什么药| 飞吻是什么意思| 桃子又什么又什么| 湿气重可以吃什么水果| hyq什么意思| 梅干菜是什么菜做成的| 圆脸适合什么短发发型| 炒锅买什么材质的好| 月柱代表什么| 紫玫瑰代表什么意思| 吃什么消炎药可以喝酒| asa是什么意思| 六味地黄丸什么功效| 视网膜脱落有什么症状| 海带和什么菜搭配好吃| 我国的国球是什么球| 对唔嗨住什么意思| 忌入宅是什么意思| 女人喝蛇汤有什么好处| rococo是什么牌子| 韭菜什么时候种最好| 蚊子不咬什么血型的人| 脑供血不足吃点什么药| 江团鱼又叫什么鱼| 蔓字五行属什么| blush是什么颜色| 魔芋爽是什么做的| 二聚体是什么| 肚子老是疼是什么原因| 寒碜是什么意思| 中图分类号是什么| 凤凰代表什么生肖| 四平八稳是什么生肖| 一个益一个蜀念什么| 什么什么于怀| 尿崩症是什么症状| 李世民属什么生肖| 坠积效应是什么意思| c反应蛋白偏高说明什么| 超市属于什么行业| 哔哩哔哩会员有什么用| 幽门螺旋杆菌挂什么科| c5是什么意思| 青蛙为什么叫| 一什么月光| 扁平疣是什么引起的| 西红柿含什么维生素| 低压高什么症状| 无所事事是什么意思| 健脾胃吃什么食物好| 刺梨根泡酒有什么功效| 胆是起什么作用的| 松绿色是什么颜色| 三千烦恼丝什么意思| 长痣是什么原因引起的| 质子泵抑制剂是什么药| 青春痘长什么样| 什么是脱肛| 不良资产是什么| 贺涵为什么会爱上罗子君| 什么时候是安全期| 春天是什么样子的| 什么是珠心算| 补血吃什么水果| 免疫力是什么意思| 草木皆兵什么意思| 手指头发麻是什么原因引起的| 69是什么| 鼻炎用什么药效果好| 来月经属于什么期| 纸片人是什么意思| 轻如鸿毛是什么意思| 什么男什么女| 什么东西在倒立之后会增加一半| 7.12是什么星座| 不想睡觉是什么原因| 牙疼买什么药| 什么叫钙化灶| 胃打嗝是什么原因| 王秋儿和王冬儿什么关系| 真菌感染用什么药膏| 彩超是什么| 前哨是什么意思| 什么是血友病| 女人小便出血是什么原因| 猪肉不能和什么一起吃| c12是什么| 糖尿病2型是什么意思| 空调为什么要加氟| 脑疝是什么原因引起的| 梅花手表属于什么档次| 吃什么才能瘦下来| 转移灶是什么意思| 无花果为什么叫无花果| 狗眼屎多是什么原因| 什么叫五福临门| 骨癌的前兆是什么症状| hgh是什么意思| 姨妈期间不能吃什么| 手上十个簸箕代表什么| 升结肠憩室是什么意思| 赛能是什么药| 长征是什么意思| 下水道井盖为什么是圆的| 屎是什么味道的| 梭是什么意思| 吃什么降糖最快| 脚上长痣代表什么| 夏天中午吃什么| 牙疼有什么好办法| 微量元素是什么| cl是什么元素| 什么样的风景| 正常人突然抽搐是什么原因| 今年农历是什么年| 出炉是什么意思| 阴道感染用什么药| 傍家儿是什么意思| 抗锯齿是什么意思| 湿疹抹什么药膏| 04年是什么生肖| 乙肝dna检测是查什么| 山丘是什么意思| w3是什么意思| 迪桑特属于什么档次| 为什么吃肉多反而瘦了| 什么又什么| 此物非彼物是什么意思| 卡马西平是什么药| 梨和什么一起榨汁好喝| 鸡腿炖什么好吃| 心悸吃什么药| 肌电图挂什么科| 孕吐是什么时候开始| 奶粉二段和三段有什么区别| 丝状疣用什么药膏| 难为情是什么意思| 口干舌燥吃点什么药| 真露酒属于什么酒| 月经为什么叫大姨妈| 海螺吃什么食物| 吸渣体质是什么意思| 心心念念是什么意思| 折射率是什么意思| 9月15号是什么星座| 恶搞是什么意思| 鱼油不适合什么人吃| 什么叫托特包| 开门见什么最吉利| 受益匪浅是什么意思| 依山傍水是什么意思| fredperry是什么牌子| 身上长红痘痘是什么原因| 月子中心是做什么的| 蝴蝶是什么意思| 射手座男生喜欢什么样的女生| au是什么意思| 脚后跟疼吃什么药| 化疗前要做什么检查| 盐为什么要加碘| 常喝普洱茶有什么好处| bj什么意思| 法国铁塔叫什么| 40gp是什么意思| 什么叫有机| 皮肤爱出油是什么原因| 征文是什么| 孙耀威为什么被封杀| 肾阳虚吃什么中成药| 大小脸去医院挂什么科| 西洋参长什么样子图片| 什么鱼吃泥鳅| 罗锅是什么意思| 男性左下腹痛是什么原因| 汀是什么意思| com什么意思| 人生苦短是什么意思| 香菜什么时候种最合适| 翻什么越什么| 中耳炎吃什么药最有效| 喜欢白色的女人是什么性格| 头发硬是什么原因| 喝茶叶茶有什么好处| 猫的眼睛为什么会发光| 百度
Peter Wayner
Contributing writer

零就业贫困户 至少一人就业

Java is not the language it used to be, and that is mostly a good thing. Here are eleven ways Java is evolving to meet the challenges of the future.

百度 (记者李丹青)

java -- beans, grounds, coffee -- binary background
Credit: Nathan Dumlao

Is Java ancient yet? The kind of programming language used by old timers who prattle on about front panels with blinking lights and the days of floppy disks? Or is it still hip, with all the latest language enhancements for intuitive coding and top-notch performance? Maybe Java is somewhere in between: a mature language, but young at heart.

Close to 30 years ago on May 23, 1995, Java officially entered the world. It began as an enabling technology called “Oak” for a set-top box that Sun Microsystems imagined would soon colonize the American living room. That plan didn’t work out, not at first, anyway. But the language grew into one of the core foundations for modern software, running on everything from tiny sensor chips to large server boxes.

Since then, the idea of Java has changed dramatically. Sun and Oracle have done a remarkable job of grafting on features that keep the language feeling fresh without disturbing much of the core functionality. Maybe Java is just one of those languages that keeps going.

One thing we know for sure is that many of the features living inside the big tent called “Java” are different from what was originally envisioned—often radically so. Programmers are creating code that people in 1995, 2005, or even 2015 wouldn’t recognize, but the old code still runs. That’s a high-quality curation. Oracle, the company that bought Sun in 2010, is now delivering new versions regularly and adding features that keep the Java language relevant.

Here are eleven ways that Java has changed, mostly for the better.

11 ways Java programming is better than it used to be (and one way it’s not)

  1. Virtual threads
  2. Structured concurrency
  3. Immutable data
  4. Garbage collection
  5. Pattern matching
  6. Streamlined syntax
  7. Sealed classes
  8. Foreign functions and memory
  9. The Vector API
  10. Improved null processing
  11. Free as in … paid license?

Virtual threads

The original version of Java gave developers the opportunity to create their own Thread objects and control how the code ran in multithreaded and multicore environments. While it was better than nothing, programmers quickly learned that Thread objects were rather large and took too much time to create and destroy. Creating a permanent thread pool at the start of a program became a common workaround for clunky threads.

All that changed in Java 19, with the arrival of virtual threads. Now, the JVM handles much of the work of doling out system resources in Java programs. Programmers specify when parallelism is available and the runtime JVM runs the code concurrently where it can. Virtual threads are a boon to modern architectures like microservices, which are easier to develop and support.

Structured concurrency

Lighter-weight threads are just the beginning. Java is adding an abstract model for parallelism that will make it easier for programmers and the JVM to process workloads concurrently. The new structured concurrency model offers the programmer the chance to break a Java workload into tasks, which are then grouped into scopes. Scopes are collected into fibers that work together in the same thread.

The goal is to offer Java developers a standard, boilerplate model for building parallel programs, so they don’t need to reason deeply about it each time. Structured concurrency also makes it easier for the virtual machine to detect opportunities for concurrent execution and map them to processor cores.

Immutable data

In the beginning, Strings were fixed in stone. Once a String was created, it  could never be changed. Calling a function like toLowerCase would create an entirely new String. This made it simpler for the JVM to manage security and synchronization across Threads.

Now, Java programmers can specify the same immutable rules for their own objects by calling them “Records.” This simplifies multi-threaded safety, caching, and synchronization. The code lists the names and types of the fields and the JVM handles the rest. Common methods like equals, hashCode, and toString are created automatically. The rest of the time, the JVM ensures that the Records are immutable, which simplifies many program details and speeds up the running code.

Garbage collection

Java has always handled many of the details of memory allocation and reclamation, a feature that many programmers are happy to delegate to the JVM. Sometimes, though, the original garbage collector would pause long enough that users would notice when performance lagged.

Today, programmers have a choice between four garbage collectors, which use a variety of different garbage collection algorithms and are specialized for different types of applications:

  • The Garbage First (G1) Garbage Collector is the default choice, delivering better throughput with shorter pauses. G1 employs techniques that have grown out of lessons learned from earlier iterations of Java garbage collection, like shuffling the biggest blocks and finely tuned recognition of frequently changed small objects.
  • The Z Garbage Collector is designed to be very low latency, a requirement for web servers, streaming services, and other real-time data work. It can also do well with a very large heap because it was designed to scale to 16 terabytes of RAM.
  • The Concurrent Garbage Collector will run in the background without stopping the application at all. It’s best for work like interactive applications that shouldn’t ever pause, although it may not be as efficient.
  • Finally, the Parallel Collector uses multiple threads to collect data faster, but the stops are more unpredictable.

Developers aren’t stuck with a single method for garbage collection, and don’t have to resort to other solutions like simulating their own memory management by reusing objects. There are now four major choices and each one provides options for even more tuning and experimentation.

Pattern matching with switch

The Java team has also enhanced the language at some of the lowest syntactic levels, giving developers more options for writing cleaner, more expressive logic. The switch keyword, used to create stacks of if-then-else conditionals, now offers pattern matching, which means that the logic for specifying the various cases isn’t limited to basic expressions like equals.

Java code written with these patterns is especially concise, and it’s able to make distinctions not just on the value in the data but the object type. All reference types and the null pointer can be used. Of course, the more traditional logic with fall-through semantics is still supported so old code continues to run smoothly.

Streamlined syntax

In the beginning, writing Java wasn’t much different from writing C or C++. Curly brackets and semi-colons did much the same thing in Java as in C. Loops were structured with the classic three-part form. Although its guts bore a deep connection to Lisp, Java’s basic syntax wasn’t much different from C’s.

More recent additions, though, have all borrowed from the simplicity of scripting languages like Ruby and Python. For loops don’t need to spell out every detail because the compiler can now intuit them when you’re looping through a list or an array. Anonymous functions and lambda expressions are also good choices for programmers who want to save keystrokes.

Some of the wordiness and excess punctuation of C are still there, but today’s Java programmers can spell out complex structures with fewer characters.

Sealed classes

From the beginning, the JVM was designed to prevent many common security holes that programmers might leave in their programs by mistake. The newest versions have added even more options. Sealed classes, for example, allow the class creator to specify exactly which classes can extend it. That prevents someone else using a library from extending a class and adding or overriding some of the original functionality.

Sealed classes also run a bit faster than traditional ones because they allow more aggressive optimization and inlining. They can also simplify method dispatch.

Foreign functions and memory

The Java virtual machine was designed to be a walled garden or a typesafe sandbox. The virtual machine guards the code and prevents many general attacks that are possible when code runs natively.

For programmers in the know, the original Java Native Interface (JNI) was a bit of a backdoor. The Java team knew that some developers needed to connect to libraries and stacks written in other languages, and that some system calls were essential. So they opened up this hole in the JVM’s armor, with a simple warning about the dangers of using it.

Now, we have the Foreign Function & Memory API, currently a JEP in third preview. This API would make it easier and safer to connect with the outside. Much more of the work can now be written in pure Java, opening up opportunities for regular Java programmers to start connecting to general system memory. The proposal also adds better guardrails like type checking to block some of the worst potential overflow attacks.

This API would make it easier for Java code to take on more low-level tasks and data processing in system coding. It’s a safer way for Java programmers to start breaking out of the sandbox.

The Vector API

The original Vector class, known to many veteran Java programmers, was more of a data structure and less of a mathematical tool. It was a flexible and synchronized solution for stashing objects that wasn’t much different from List.

The new Vector API is much more. It’s a tool for the kind of mathematical data processing that’s becoming more common as artificial intelligence algorithms use matrices and vectors in more or less the same way as physical scientists and mathematicians do. The individual elements can be primitive types and many of the basic mathematical operations like dot products are supported.

A good way to see the difference between the Vector class and API is to see what the add method does. In the original class, it just stuck an object at the end of the data structure like all of the other Collections classes did. In the API, it’s used to mathematically add the individual elements, more like an engineer would expect.

The Vector API also promises to open up the massive computational powers of some newer SIMD processors, enabling Java programmers to craft code that can churn through many long vectors.

Better null processing

Is that object a null pointer? Much Java code is devoted to checking, double-checking, and then triple-checking objects. To simplify the code and speed things up a bit, Java has slowly been adding features that handle null pointers in a more graceful way. The Stream API, for example, can process long streams of data and won’t get hung up if an occasional null value comes along. The Optional class wrapper may or may not hold an actual object, allowing the code to flow nicely. And if you still want to check for nullity, there’s the null-safe operator (?.) that tests for null in a very concise way.

Free as in … paid license?

Java has always been pretty much free, at least for programmers. From the beginning, Sun wanted to attract developers with free tools and hardware, and in 1997 the company took the bold step of open sourcing many parts of the language and its virtual machine. Until recently, developers could more or less write once and run anywhere without paying a dime.

Now, the picture is getting murkier. Many Java versions from Oracle are free but some require a license with strange terms. It would seem that Oracle wants programmers to enjoy the freedom to create without monetary constraints, but also wants to extract a tax or rent from the enterprises that generate significant, long-term revenues from Java. In practice, this means charging for what Oracle calls Java’s subscription features. So, Java is still free, unless you want to upgrade it for commercial use.

喉咙发痒吃什么药 10.17是什么星座 什么东西能去脸上的斑 design是什么品牌 kelly是什么意思
肺部小结节是什么意思 农历10月24日是什么星座 魇是什么意思 lge是什么意思 隔离霜和防晒霜有什么区别
阳历7月7日是什么日子 什么人容易得白塞氏病 tpo是什么意思 有时候会感到莫名的难过是什么歌 nos是什么单位
向内求什么意思 心脏病吃什么药 四方草地是什么生肖 什么是总胆固醇 大姨妈期间适合吃什么水果
发扬什么词语搭配hcv9jop8ns2r.cn 痛风有什么不能吃hcv8jop7ns1r.cn 什么是同房hcv8jop6ns5r.cn 什么鸟一生只有一个伴侣hcv9jop4ns6r.cn gi值是什么hcv8jop2ns1r.cn
甲功是什么意思hcv7jop7ns0r.cn 肝瘘是什么hanqikai.com 煲什么汤去湿气最好hcv7jop6ns5r.cn 肛周水泡是什么病weuuu.com 忧郁是什么意思hcv8jop1ns0r.cn
pap是什么意思hcv8jop8ns9r.cn 什么是机械键盘hcv8jop3ns9r.cn 嘎巴拉是什么shenchushe.com 指甲凹陷是什么原因hcv7jop4ns5r.cn 肝内小囊肿是什么意思hcv9jop6ns9r.cn
胃窦糜烂是什么意思hcv9jop4ns6r.cn 捡到狗狗代表什么预兆hcv8jop6ns6r.cn 郎才女貌是什么意思hcv8jop4ns5r.cn 什么蔬菜不能放冰箱hcv8jop3ns1r.cn 苗子是什么意思hcv8jop2ns2r.cn
百度