kormer 2022-8-14 17:09
[url]https://www.infoworld.com/article/3668660/deno-vs-nodejs-which-is-better.html[/url]
time to switch? :smile_41:
rtrtrt2006 2022-9-7 20:03
現時程式界最著名的三個 JavaScript Runtimes:
[olist]
[*][url=https://bun.sh/]Bun[/url](使用 [url=https://ziglang.org/]Zig[/url] 開發)
[*][url=https://nodejs.org/en/]Node[/url](使用 C++ 開發)
[*][url=https://deno.land/]Deno[/url](使用 [url=https://www.rust-lang.org/]Rust[/url] 開發)
[/olist]
如果你只是用 JavaScript 來製作網站,不需要用其來作為 Production Server 的 JS Runtime,我覺得 Node.js 已經足夠。否則,我認為高效快速的 Bun 會比較適合用在遊戲伺服器,而 Deno 比較適合用在需要更高安全性的網購平台或付款應用的後台伺服器。
除了某些開發人員喜愛使用 JS 來作為 Full Stack 網站建設之外,我認為後台使用 Golang 或 Java 可以獲取更高伺服器端的用戶要求吞吐量,因為 JavaScript 是即時編譯的 Scripting Language,效能不可能比 Golang 和 Java 更快速。
更年興起編寫的[url=https://zh.wikipedia.org/zh-hk/%E5%8D%95%E9%A1%B5%E5%BA%94%E7%94%A8]單頁式應用程式[/url],基本上可以接納使用任何一種程式語言作為其後台。
香港很多公司以前一直承傳下來所開發程式都是用 Java 編寫,若然是這種情況,我認為沒有必要改寫成 JavaScript 的後台。
[[i] 本帖最後由 rtrtrt2006 於 2022-9-17 13:43 編輯 [/i]]
kormer 2022-9-10 13:08
[quote]原帖由 [i]rtrtrt2006[/i] 於 2022-9-7 20:03 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=551876648&ptid=30718933][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
現時程式界最著名的三個 JavaScript Runtimes:
[olist]
[*]Bun(使用 Zig 開發)
[*]Node(使用 C++ 開發)
[*]Deno(使用 Rust 開發)
[/olist]
如果你只是用 JavaScript 來製作網站,不需要用其來作為 Production Server 的 JS Runtime,我覺得 Node.js 已經足夠。否則,我認為 ... [/quote]
有無benchmark測試睇睇點快?
rtrtrt2006 2022-9-10 15:41
[quote]原帖由 [i]kormer[/i] 於 10-9-2022 13:08 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551950679&ptid=30718933][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
有無benchmark測試睇睇點快? [/quote]
如圖所示
kormer 2022-9-10 16:44
[quote]原帖由 [i]rtrtrt2006[/i] 於 2022-9-10 15:41 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=551954672&ptid=30718933][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
如圖所示 [/quote]
咁js backend 同傳統 backend 的比較呢?即係php, java, c# 等呢?
rtrtrt2006 2022-9-10 19:00
[quote]原帖由 [i]kormer[/i] 於 10-9-2022 16:44 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551956181&ptid=30718933][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
咁js backend 同傳統 backend 的比較呢?即係php, java, c# 等呢? [/quote]
根據你所編製的網站類型而選定後台程式應該使用什麼語言去編寫,如果只是一個普通的網站,就用 PHP,如果是比較是結構分明的就使用 Java 或 C#,事實上用什麼編程語言是一種經驗,因為我們還要看看有那些 Libraries 可以使用。
[[i] 本帖最後由 rtrtrt2006 於 2022-9-10 20:38 編輯 [/i]]
kormer 2022-9-10 19:18
[quote]原帖由 [i]rtrtrt2006[/i] 於 2022-9-10 19:00 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=551959423&ptid=30718933][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
根據你所編製的網站類型而選定後台程式應該使用什麼語言去編寫,如果只是一個普通的網站,就用PHP,如果是比較是結構分明的就使用Java或C#,事實上用什麼編程語言是一種經驗,因為我們還要看看有那些 Libraries 可以使用。 [/quote]
我想知道它們benchmark的數據?就是誰較快較慢?
rtrtrt2006 2022-9-10 20:37
[quote]原帖由 [i]kormer[/i] 於 10-9-2022 19:18 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551959807&ptid=30718933][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
我想知道它們benchmark的數據?就是誰較快較慢? [/quote]
排名大約是這樣的:
Rust ~ C > C++ > Go > C# > Java > Node.js > PHP > Ruby > Python > Perl
頭三位都是系統編程語言,後面的多數用於網站後台程序、研究AI或機器學習、桌面程式...
[[i] 本帖最後由 rtrtrt2006 於 2022-9-10 20:38 編輯 [/i]]
kormer 2022-9-10 21:04
[quote]原帖由 [i]rtrtrt2006[/i] 於 2022-9-10 20:37 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=551961345&ptid=30718933][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
排名大約是這樣的:
Rust ~ C > C++ > Go > C# > Java > Node.js > PHP > Ruby > Python > Perl
頭三位都是系統編程語言,後面的多數用於網站後台程序、研究AI或機器學習、桌面程式... [/quote]
咁用C語言點樣寫Web好呢?
rtrtrt2006 2022-9-11 13:22
[quote]原帖由 [i]kormer[/i] 於 10-9-2022 21:04 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551962127&ptid=30718933][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
咁用C語言點樣寫Web好呢? [/quote]
雖然 C 的確是有 Web Frameworks,例如 [url=https://facil.io/]facil.io[/url]、[url=https://kore.io/]Kore[/url]、[url=https://onion.io/tag/c-programming/]Onion[/url]、[url=https://github.com/fredrikwidlund/libreactor]libreactor[/url] 和 [url=https://gaut-hil.com/zcvisitor/0cbbbd90-3192-11ed-ba6e-12495d94f10b/c48f16c0-a519-11ec-9226-0a76dcc61f13?campaignid=537afa00-24f1-11ed-921a-0a918cbcbb97]Duda[/url],但用 C 來寫網站不會有什麼好處,不但減慢你的工作進度,還會令程序隨時出現更多的 Bugs,我建議大家還是選擇更上層的編程語言。
[[i] 本帖最後由 rtrtrt2006 於 2022-9-11 13:24 編輯 [/i]]
kormer 2022-9-11 17:58
[quote]原帖由 [i]rtrtrt2006[/i] 於 2022-9-11 13:22 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=551977926&ptid=30718933][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
雖然 C 的確是有 Web Frameworks,例如 facil.io、Kore、Onion、libreactor 和 Duda,但用 C 來寫網站不會有什麼好處,不但減慢你的工作進度,還會令程序隨時出現更多的 Bugs,我建議大家還是選擇更上層的編程語言。 [/quote]
我諗都未必,秒秒鐘幾十萬上落的金融系統可能要用到㗎,即係algo trading那些,只不過普通人不需要呢個級數,包括我在內。見你由低寫到高level,即C寫到就perl,就順便問吓。:smile_35:
rtrtrt2006 2022-9-11 21:28
[quote]原帖由 [i]kormer[/i] 於 11-9-2022 17:58 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551985879&ptid=30718933][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
我諗都未必,秒秒鐘幾十萬上落的金融系統可能要用到㗎,即係algo trading那些,只不過普通人不需要呢個級數,包括我在內。見你由低寫到高level,即C寫到就perl,就順便問吓。:smile_35: [/quote]
這種 Trading Program 對速度和安全性的要求非常高,我建議使用 Golang,C、C++、Java 和 C# 應該都不會比 Golang 更可靠。
kormer 2022-9-11 21:35
誰人有用bun這些?好像很冷門
[[i] 本帖最後由 kormer 於 2022-9-11 21:36 編輯 [/i]]
kormer 2022-9-11 21:35
[quote]原帖由 [i]rtrtrt2006[/i] 於 2022-9-11 21:28 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=551991351&ptid=30718933][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
這種 Trading Program 對速度和安全性的要求非常高,我建議使用 Golang,C、C++、Java 和 C# 應該都不會比 Golang 更可靠。 [/quote]
我反而有興趣知道(Java, C#, php)和 Node.js等backend技術在處理web request上效能的分別是怎樣... 假設不是計算密集的endpoint :loveliness:
rtrtrt2006 2022-9-11 21:43
[quote]原帖由 [i]kormer[/i] 於 11-9-2022 21:35 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551991544&ptid=30718933][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
我反而有興趣知道(Java, C#, php)和 Node.js等backend技術在處理web request上效能的分別是怎樣... 假設不是計算密集的endpoint :loveliness: [/quote]
早已有人做過相關的研究工作,請參考:
[url=https://www.toptal.com/back-end/server-side-io-performance-node-php-java-go]Server-side I/O Performance: Node vs. PHP vs. Java vs. Go[/url]
[size=2](不好意思,裡面不包含 C#)[/size]
[img]https://uploads.toptal.io/blog/image/126909/toptal-blog-image-1534449533146-fbfd7f7f8fef1c1642379e78288ff833.png[/img]
時間是在所有並發請求中完成請求的平均毫秒數,越低越好。
[img]https://uploads.toptal.io/blog/image/126910/toptal-blog-image-1534449549951-9c5873ba6add8234d456199df802891e.png[/img]
時間是在所有並發請求中完成請求的平均毫秒數,越低越好。
[img]https://uploads.toptal.io/blog/image/126911/toptal-blog-image-1534449565382-9c3f283d73f19b6d1164372e9b2611ea.png[/img]
每秒的請求總數,越高越好。
[[i] 本帖最後由 rtrtrt2006 於 2022-9-11 21:45 編輯 [/i]]
kormer 2022-9-11 22:46
[quote]原帖由 [i]rtrtrt2006[/i] 於 2022-9-11 21:43 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=551991681&ptid=30718933][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
早已有人做過相關的研究工作,請參考:
Server-side I/O Performance: Node vs. PHP vs. Java vs. Go
(不好意思,裡面不包含 C#)
[img]https://uploads.toptal.io/blog/image/126909/toptal-blog-image-1534449533146-fbfd7f7f8fef1c1642379e78288ff833.png[/img] [/quote]
[url]https://varteq.com/java-vs-nodejs-on-aws-lambda-benchmark-survey/[/url]
[attach]13580492[/attach]
其中一結果,node.js與java兩者之間的benchmark好似差唔多... :loveliness:
remarks: Java沒用ORM...
元宇宙元 2022-9-11 23:43
[quote]原帖由 [i]rtrtrt2006[/i] 於 2022-9-11 21:43 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551991681&ptid=30718933][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
早已有人做過相關的研究工作,請參考:
Server-side I/O Performance: Node vs. PHP vs. Java vs. Go
(不好意思,裡面不包含 C#)
[img]https://uploads.toptal.io/blog/image/126909/toptal-blog-image-1534449533146-fbfd7f7f8fef1c1642379e78288ff833.png[/img] [/quote]
不是這樣的. :smile_24::smile_24::smile_34::smile_34:
rtrtrt2006 2022-9-12 17:59
[quote]原帖由 [i]kormer[/i] 於 11-9-2022 22:46 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=551993555&ptid=30718933][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
https://varteq.com/java-vs-nodejs-on-aws-lambda-benchmark-survey/
[img]https://img.discuss.com.hk/d/attachments/day_220911/20220911_766b37ec03d696831b17Mf2olAlHCu0W.gif[/img]
其中一結果,node.js與java兩者之 ... [/quote]
預編譯無論如何都比即時編譯更加安全、快速和可靠,不過對於[url=https://zh.m.wikipedia.org/zh-hant/%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%AB%AF%E6%B8%B2%E6%9F%93]服務器端渲染(Server-side Rendering[/url]),Node.js 應該比 Java 更有優勢,Java 可能需要額外的 Library 才可達成。
[b]相關文章[/b]
[list]
[*][url=https://www.freecodecamp.org/news/server-side-rendering-your-react-app-in-three-simple-steps-7a82b95db82e/]如何通過三個簡單的步驟在你的 React 應用中實現服務器端渲染 - freeCodeCamp(英語)[/url]
[*][url=https://codeburst.io/jsx-react-js-java-server-side-rendering-ssr-2018-cf3aaff7969d]JSX — React JS+ Java 服務器端渲染 (SSR) - codeburst.io(英語)[/url]
[/list]
[[i] 本帖最後由 rtrtrt2006 於 2022-9-12 18:03 編輯 [/i]]
lhcdims 2022-9-14 10:44
[quote]原帖由 [i]rtrtrt2006[/i] 於 2022-9-11 21:43 發表 [url=https://www.discuss.com.hk/redirect.php?goto=findpost&pid=551991681&ptid=30718933][img]https://www.discuss.com.hk/images/common/back.gif[/img][/url]
早已有人做過相關的研究工作,請參考:
Server-side I/O Performance: Node vs. PHP vs. Java vs. Go
(不好意思,裡面不包含 C#)
[img]https://uploads.toptal.io/blog/image/126909/toptal-blog-image-1534449533146-fbfd7f7f8fef1c1642379e78288ff833.png[/img] [/quote]
我用 node.js 的 worker-threads 開 child process,好似係快左好多。不過 no. of child process set 左 cpu thread - 1,太多唔知點解唔會再快!:smile_35:
rtrtrt2006 2022-9-17 13:37
[quote]原帖由 [i]lhcdims[/i] 於 14-9-2022 10:44 發表 [url=https://computer.discuss.com.hk/redirect.php?goto=findpost&pid=552056489&ptid=30718933][img]https://computer.discuss.com.hk/images/common/back.gif[/img][/url]
我用 node.js 的 worker-threads 開 child process,好似係快左好多。不過 no. of child process set 左 cpu thread - 1,太多唔知點解唔會再快!:smile_35: [/quote]
如果真係要做「CPU-intensive JavaScript operations」,我寧願用 Golang 寫後台程式,Goroutine 比 Java Threads 所佔用的 Memory 和 CPU 使用效率都更高。
[[i] 本帖最後由 rtrtrt2006 於 2022-9-17 13:39 編輯 [/i]]
頁:
[1]