• 请不要在回答技术问题时复制粘贴 AI 生成的内容
wdwwtzy
V2EX  ›  程序员

这个各大语言性能测试结果挺有意思

  •  3
     
  •   wdwwtzy · Jun 27, 2022 · 24786 views
    This topic created in 1592 days ago, the information mentioned may be changed or developed.
    182 replies  •  2022-10-29 16:50:11 +08:00
    1  2  
    ❮ ❯
    INCerry
    INCerry
    Jun 27, 2022❤️19
    1
    C# yyds
    dcsuibian
    dcsuibian
    Jun 27, 2022❤️2
    2
    知道 Python 慢,不过没想到有这么慢
    liushuangbill
    liushuangbill
    Jun 27, 2022❤️7
    3
    Node.js 还挺快
    v23x
    v23x
    Jun 27, 2022
    4
    Rust the only true god
    kerrspace
    kerrspace
    Jun 27, 2022
    5
    有没有大佬来说一下 rust 替代 c++的前景
    qrobot
    qrobot
    Jun 27, 2022
    6
    Java 不是性能取决于 JVM 么?
    zmqiang
    zmqiang
    Jun 27, 2022
    7
    看了两遍才发现图的左边和右边顺序不一样
    min
    min
    Jun 27, 2022❤️1
    8
    C#可以啊
    icyalala
    icyalala
    Jun 27, 2022
    9
    这有另外一个更知名的: https://github.com/kostya/benchmarks
    ragnaroks
    ragnaroks
    Jun 27, 2022
    10
    我虽然经常黑 java ,但是 java 不应该这么慢,最多落后 dotnet 两个身位,如果这个图是 dotnet 6 、java 11 那当我没说
    Phishion
    Phishion
    Jun 27, 2022❤️1
    11
    python3 倒数第一几个意思?后面没有其他语言了?
    INCerry
    INCerry
    Jun 27, 2022❤️4
    12
    @ragnaroks 看了下原链接 https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/csharp.html
    C# .NET SDK 6.0.101
    Java openjdk 18 2022-03-22 OpenJDK 64-Bit Server VM
    Leviathann
    Leviathann
    Jun 27, 2022
    13
    swift 是不是最慢的 native 语言
    mosfet
    mosfet
    Jun 27, 2022
    14
    我记得 C# JAVA GO 都差不多的,半斤八俩
    ragnaroks
    ragnaroks
    Jun 27, 2022
    15
    @INCerry 我没有实际测试,就不发表评论了,不过根据我的个人经验,dotnet 6 和 java 17 差距很小
    ecnelises
    ecnelises
    Jun 27, 2022 via iPhone
    16
    OCaml 的速度有点令人惊喜啊(虽然 Haskell 更快)。

    Swift 直接毙了吧,背靠 LLVM 的静态语言搞成这样,不知道加入所有权后能提高多少。
    MakHoCheung
    MakHoCheung
    Jun 27, 2022
    17
    Swift 不是编译成二进制的吗,这么慢
    bk201
    bk201
    Jun 27, 2022
    18
    java 的性能有这么差吗?
    buxudashi
    buxudashi
    Jun 27, 2022
    19
    lua 不是说很好吗?怎么连 PHP 都不如?
    makelove
    makelove
    Jun 27, 2022
    20
    我大 javascript 神一样的存在
    nmap
    nmap
    Jun 27, 2022
    21
    go 比起 c/c++/rust 还是差不少啊😥
    liuxu
    liuxu
    Jun 27, 2022
    22
    @kerrspace C++不清楚,linux 内核下个版本 5.20 要合并 rust 的基础设施了,现在 5.19 ,https://www.phoronix.com/scan.php?page=news_item&px=Rust-For-Linux-5.20-Possible
    iyaozhen
    iyaozhen
    Jun 27, 2022❤️1
    23
    @Phishion Python 是真的拉胯 很容易遇到性能瓶颈
    ifdef
    ifdef
    Jun 27, 2022
    24
    我大 javascript 神一样的存在
    Phishion
    Phishion
    Jun 27, 2022
    25
    @iyaozhen 但是我觉得上面好些已经是事实上的 dead 语言了,或者根本没什么人用,可见以 Python3 的使用人群来说,性能也不是什么问题。
    ragnaroks
    ragnaroks
    Jun 27, 2022
    26
    @buxudashi lua 应该有两种用法,一个是基于 luajit 动态解析运行,一个是(开发游戏常用)直接编译成 lua.dll ,前者性能差到以为是网络卡了,后者应该在 c/c++ 的十倍以内
    Cyshall
    Cyshall
    Jun 27, 2022❤️1
    27
    c# 为什么这么屌?
    princelai
    princelai
    Jun 27, 2022
    28
    这个一年多前就讨论过了啊,我也画过图,https://www.v2ex.com/t/776893#reply51

    另外 python 慢是因为他是用纯内置语言来实现算法,但实际上 python 除了调用 C++和 fortrain 写的东西外,在 numpy 和 numba 等技术加持下,python 写数值计算和算法并不慢,甚至能超过 90%的语言,我是没遇到过什么瓶颈。
    luob
    luob
    Jun 27, 2022❤️1
    29
    基本符合日常经验,c/c++开了 o2 之后谁也打不过,go 和 java 一个水平,比 nodejs 快 30-40%,python 比主流语言慢两个数量级(
    tabris17
    tabris17
    Jun 27, 2022❤️1
    30
    壮哉!大 python
    iyaozhen
    iyaozhen
    Jun 27, 2022
    31
    @Phishion 不是说人多就没有性能问题。

    Python 主要是乘着 AI 的大船,不然使用量会少很多。这里说的是语音本身,但 Python 的特色是胶水语言和 C 紧密结合,这块大大提高了性能天花板
    Phishion
    Phishion
    Jun 27, 2022
    32
    @iyaozhen 实际体验我也没觉得 Python 比主流慢几十倍这个样子,我不知道你用 Python3 做什么开发,能很容易就遇到性能瓶颈?
    min
    min
    Jun 27, 2022
    33
    @mosfet go 内存占用小一些,速度和 java C#半斤八两
    Mark24
    Mark24
    Jun 27, 2022
    34
    ruby 可以开 JIT ,会再快一倍左右
    damngood
    damngood
    Jun 27, 2022
    35
    swift 和 go 的内存消耗指标很不错.
    iyaozhen
    iyaozhen
    Jun 27, 2022
    36
    @Phishion web 开发,或者一些压测工具。非 AI
    INCerry
    INCerry
    Jun 27, 2022❤️1
    37
    @min
    在他们测的这个场景下
    C# 内存占用排名 6 Go 排名 8 Java 排名 13
    Java 可真耗内存
    lolizeppelin
    lolizeppelin
    Jun 27, 2022
    38
    erlang 居然只比 python2 好一点点?
    snoopyhai
    snoopyhai
    Jun 27, 2022
    39
    印象中, deno 不是说因为 node 差, 才生出来的嘛. node 都在榜上, deno 上不了榜么?
    kerrspace
    kerrspace
    Jun 27, 2022
    40
    @liuxu 哎 日了 早晚要开始学 rust ,我乍一看感觉曲线挺陡的
    28Sv0ngQfIE7Yloe
    28Sv0ngQfIE7Yloe
    Jun 27, 2022❤️3
    41
    Go 其实没大家想的那么快,而且做 WEB 开发心智负担有点大,还是适合写一些基础设施、中间件
    nullref
    nullref
    Jun 27, 2022
    42
    说 js 差的,这个数据有点打脸了😂,现在不是 php 是最好的语言,现在是 python
    AV1
    AV1
    Jun 27, 2022
    43
    @buxudashi
    你说的那个是 LuaJIT ,类似于 PyPy 之于 Python ,性能跟 JS V8 相当。
    zhuangzhuang1988
    zhuangzhuang1988
    Jun 27, 2022❤️2
    44
    C# 牛逼
    icyalala
    icyalala
    Jun 27, 2022❤️1
    45
    @Leviathann @MakHoCheung
    Swift 的安全特性,很多都是默认开启放在运行时的。比如 a + b 实际运行时会添加额外指令来检测 overflow 。
    如果要考虑性能的话,至少要明白这点,比如 a + b 应该改为 a &+ b 来允许 overflow 。

    这个测试代码很多都没考虑这点:
    https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/swift.html
    ktqFDx9m2Bvfq3y4
    ktqFDx9m2Bvfq3y4
    Jun 27, 2022 via iPhone❤️3
    46
    什么时候 C#打包的应用能和 Go 一样小就更 NB 了。

    利益相关:C#程序员
    cnoder
    cnoder
    Jun 27, 2022
    47
    lua 应该没算 luajit 吧
    svt
    svt
    Jun 27, 2022
    48
    开打开打
    lujiaosama
    lujiaosama
    Jun 27, 2022
    49
    nodejs 还挺快, 问题是 nodejs 也算语言??
    wanacry
    wanacry
    Jun 27, 2022
    50
    没 js 吗
    INCerry
    INCerry
    Jun 27, 2022❤️5
    51
    @Chad0000 目前是可以做到, 有一个 reflection-free 选项,开启以后打包出来的只有几 MB
    但是需要放弃很多特性(比如反射会弱的一批,动态加载没了,EMIT 代码生成没办法了-基本上很多 AOP ORM 框架都用不了了),写起来就跟直接用 Go 差不多了,很不爽。
    https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/reflection-free-mode.md
    ysc3839
    ysc3839
    Jun 27, 2022 via Android
    52
    @MakHoCheung 编译成机器代码不代表中间运行时没有开销。比如 Objective-C 也是编译成机器代码的,但是对象间进行消息传递(类似别的语言的函数调用)要走 objc runtime 绕一圈,开销较大。
    @snoopyhai 是觉得 Node.js 设计得不好吧,而不是底层引擎性能差。
    @lujiaosama 准确说应该是 V8 引擎,除非这个测试涉及了网络部分。
    Building
    Building
    Jun 27, 2022
    53
    Swift 已经沉浸在各类语法糖中无法自拔,在稳定性上用点心好吗?
    maclon
    maclon
    Jun 27, 2022
    54
    rust 超屌
    cnnbboy
    cnnbboy
    Jun 27, 2022
    55
    Swift 这么拉跨。。
    roundgis
    roundgis
    Jun 27, 2022 via Android❤️2
    56
    @Phishion python 慢的基本上不是用 c 就是 cython 重寫了 所以實際上差距並不明顯

    如果涉及到和數據庫交互 差異就更小了
    gimp
    gimp
    Jun 27, 2022
    57
    悲哉!我大 Python
    Features
    Features
    Jun 27, 2022
    58
    实际上 99.99%的人都不会遇到语言上的瓶颈
    都是其他方面的
    后端基本是 I/O 的,前端是 webview ,浏览器环境调优
    客户端就海了去了,基本没有一个是语言本身带来的瓶颈
    qrobot
    qrobot
    Jun 27, 2022❤️1
    59
    @Features 如果语言本身没有瓶颈 , 那么能解释一下 Discord 为什么要从 go 切换到 rust ?
    qrobot
    qrobot
    Jun 27, 2022
    60
    @Features 能解释一下这篇文章里面说的信息吗?

    https://discord.com/blog/why-discord-is-switching-from-go-to-rust
    abersheeran
    abersheeran
    Jun 27, 2022❤️2
    61
    @qrobot 显然 discord 的这个业务是那 1%,你可以尝试去调查一下,有多少人开发的业务需要精细化到扣 GC 时间。绝大部分的业务甚至连 Python 的瓶颈都摸不到。更别提 Golang 了。

    类似于 V2EX 甚至 Instagram 的 CRUD ,Python 就够用了。
    greygoo
    greygoo
    Jun 27, 2022
    62
    看看好玩就行了,没有什么参考性,性能都是要代价的
    oops0119
    oops0119
    Jun 27, 2022
    63
    jsnb
    qrobot
    qrobot
    Jun 27, 2022
    64
    @abersheeran

    交换机, 路由器, 还有 arduino 设备。 也是其中的 1%吗? 还有 linux 内核 等等, 你这个 1% 确实有点多啊。。。。。
    qrobot
    qrobot
    Jun 27, 2022
    65
    @abersheeran 在补充一下 chromium 如果也是 1% 那么你说的百分之一占据的全世界的开发还是挺多的
    abersheeran
    abersheeran
    Jun 27, 2022❤️1
    66
    @qrobot 💦给你说个反直觉的东西,Web 服务,php 的占有率高达 78.9%。这世界上的程序远比你想象的多。
    abersheeran
    abersheeran
    Jun 27, 2022❤️1
    67
    @qrobot chromium 既然你提到这个,那你思考一下,是在 chromium 上面跑页面的业务多,还是开发 chromium 的多。
    NeezerGu
    NeezerGu
    Jun 27, 2022
    68
    如果这是跑分图,我大 python 秒天秒地 doge
    qrobot
    qrobot
    Jun 27, 2022
    69
    @abersheeran 实际上开发 chromium ,或者基于 chromium 开发出来的程序,比你想想中的多的多
    NeezerGu
    NeezerGu
    Jun 27, 2022
    70
    @ecnelises 我怎么记得 OCaml 速度应该比 haskell 快很多?不是常常用来写量化交易还是什么的吗?
    Protocol
    Protocol
    Jun 27, 2022
    71
    明明 C++是第一,而且 C#比 C++性能表现已经低了一倍,为什么那么多喊 C#牛逼的却没有喊 C++牛逼的?
    abersheeran
    abersheeran
    Jun 27, 2022
    72
    @qrobot 嗯,我最近的活刚好就是有一部分涉及到 chromium 。你说是网站多,还是开发 chromium 的多?
    qrobot
    qrobot
    Jun 27, 2022
    73
    @abersheeran PHP 的占有率是百分之 78.9%, 这是原文,如果是这个去调查肯定不太准啊

    这个调查结果是来着这里的对吧 https://w3techs.com/technologies

    Methodology
    When interpreting our surveys, you should know the following:

    We investigate technologies of websites, not of individual web pages. If we find a technology on any of the pages, it is considered to be used by the website.
    We include only the top 10 million websites (top 1 million before June 2013) in the statistics in order to limit the impact of domain spammers. We include all sites that are either in the Alexa top 10 million or in the Tranco top 1 million list. Website popularity rankings are sometimes considered inaccurate for measuring website traffic, but we find that they serve our purpose of providing a representative sample of established sites very well. The Alexa service retired on May 2022, but the ranking API will be operational until December 2022. We keep using Alexa for the time being, and we are working on alternatives.
    We exclude sites that have no useful content, e.g. sites that only show the default web server page. We also exclude sites that are essentially duplicates of other sites.
    We do not include redirected domains. For example, Sun.com redirects to Oracle.com, and is therefore not counted.
    We do not consider subdomains to be separate websites. For instance, sub1.example.com and sub2.example.com are considered to belong to the same site as example.com. That means for example, that all the subdomains of blogger.com, wordpress.com and similar sites are counted only as one website.
    We use the official part of the Public Suffix List to determine what exactly is a website. Because this differs a bit from Alexa's and Tranco's definition, the "top 10 million" websites are actually not exactly 10 million. However, this has no statistical significance.
    Our reports are updated daily.
    Please be aware of the limitations indicated in our disclaimer.
    min
    min
    Jun 27, 2022
    74
    @Protocol 玩不转 C++,不会用,性能再高也白搭
    qrobot
    qrobot
    Jun 27, 2022
    75
    @abersheeran 开发 chromium 绝对不可能是只有 1%, 甚至开始说的 0.01% 是绝对不可能的
    ktqFDx9m2Bvfq3y4
    ktqFDx9m2Bvfq3y4
    Jun 27, 2022
    76
    @INCerry
    哇,发现了新天地。不过这部分确实用不着。用 C#就是图语法好性能也高工作也好找(国外)。
    ktqFDx9m2Bvfq3y4
    ktqFDx9m2Bvfq3y4
    Jun 27, 2022
    77
    @Protocol
    我觉得可能是因为不少国人对 C#还停留在.net framework 时代。
    qrobot
    qrobot
    Jun 27, 2022
    78
    @Chad0000 C# 确实很不错, 但是害怕 microsoft 这家公司, 你不知道什么时候会和 IE 一样。
    di1012
    di1012
    Jun 27, 2022
    79
    作为一个.netor 很欣慰
    Mithril
    Mithril
    Jun 27, 2022
    80
    @Protocol 因为 C++牛逼这事不用喊,大家都知道。。。
    ltmst
    ltmst
    Jun 27, 2022
    81
    同样解释性语言,nodejs 和 python 为啥差这么多
    nullref
    nullref
    Jun 27, 2022
    82
    @Protocol 因为 v 站用的人太少了吧
    novolunt
    novolunt
    Jun 27, 2022
    83
    @Phishion hhaahhaha
    INCerry
    INCerry
    Jun 27, 2022
    84
    @Protocol 因为 C/C++一直都是天花板 但是 C# 开发效率高 另外是带 JIT GC Runtime 里面跑的最快的
    Mark24
    Mark24
    Jun 27, 2022
    85
    @gbw1992 谷歌爸爸在 JavaScript V8 引擎里给 带了 JIT ,默认开启。
    ltmst
    ltmst
    Jun 27, 2022
    87
    @Protocol
    C++牛逼按说不需要喊吧,因为是爸爸
    就类似~大家都喊 c++牛逼为啥没人喊 c 牛逼~
    Mark24
    Mark24
    Jun 27, 2022
    88
    86 楼的图,换了个图床

    hronro
    hronro
    Jun 27, 2022
    89
    @buxudashi #19

    我记得他这个测试里用的是原版 Lua 而不是 LuaJIT
    cclin
    cclin
    Jun 27, 2022 via Android
    90
    haskell 这么快我是没想到的
    andrew2558
    andrew2558
    Jun 27, 2022
    91
    go 和 dart 这么差吗
    andrew2558
    andrew2558
    Jun 27, 2022
    92
    dart 比 node.js 差是有点不理解
    tramm
    tramm
    Jun 27, 2022
    93
    我记得 Java 性能能达到 C 的 70%左右的啊
    bbqqddwhy
    bbqqddwhy
    Jun 27, 2022
    94
    引战贴,坏人啊
    aviator
    aviator
    Jun 27, 2022
    95
    不知道 java 有没有用到后端编译的 JIT
    AV1
    AV1
    Jun 27, 2022
    96
    @gbw1992 脚本语言开启 JIT 后,也会有编译过程,已经不完全算“解释执行”了。
    karatsuba
    karatsuba
    Jun 27, 2022
    97
    C++ + Python 哈哈哈
    fgwmlhdkkkw
    fgwmlhdkkkw
    Jun 27, 2022
    98
    @zhangchongjie #42 这是 v8 强,js 就是垃圾啊
    fgwmlhdkkkw
    fgwmlhdkkkw
    Jun 27, 2022
    99
    @gbw1992 #81 v8 有 jit ,python 没有。
    GrayXu
    GrayXu
    Jun 27, 2022
    100
    话说 benchmark 具体的测试项目应该也影响不小吧。。这图里 Go 居然和 Java 差不多速度。。
    1  2  
    ❮ ❯
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1525 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 194ms · UTC 23:03 · PVG 07:03 · LAX 15:03 · JFK 18:03
    ♥ Do have faith in what you're doing.