Rust

ชุมชนโปรแกรมเมอร์ภาษา Rust เผยผลสำรวจความคิดเห็นผู้ใช้ภาษา Rust ประจำปี 2022 (เพิ่งมาเผยแพร่ตอนนี้) จำนวน 9,433 คนจากทั่วโลก พบว่าราว 30% มีการใช้งาน Rust ในที่ทำงาน (ไม่ใช่แค่เขียนเองใช้ส่วนตัว) เพิ่มขึ้น 52% จากผลสำรวจรอบก่อนหน้า

เหตุผลหลักที่เลือกใช้ Rust เป็นเรื่องประสิทธิภาพ, การเขียนซอฟต์แวร์แบบไม่มีบั๊ก, ความสนุกในการเขียน, ความปลอดภัยจากตัวภาษา

ส่วนเหตุผลของคนที่ตอบว่าไม่ใช้ Rust มีทั้งจากปัจจัยภายนอกอื่นๆ และปัญหาว่าหัดเขียนยากเกินไป ซึ่งค่อนข้างตรงกันระหว่างกลุ่มที่เคยใช้แล้วเลิกใช้ กับกลุ่มที่ยังไม่ใช้งานมาตั้งแต่แรก

สิ่งที่ผู้ตอบแบบสอบถามเป็นห่วง ได้แก่ ห่วงว่าในอุตสาหกรรมมีคนใช้งานไม่เยอะพอ และภาษา Rust มีความซับซ้อนสูงเกินไป

ที่มา - Rust Blog

Hiring! บริษัทที่น่าสนใจ

Carmen Software company cover
Carmen Software
Hotel Financial Solutions
Next Innovation (Thailand) Co., Ltd. company cover
Next Innovation (Thailand) Co., Ltd.
We are web design with consulting & engineering services driven the future stronger and flexibility.
KKP Dime company cover
KKP Dime
KKP Dime บริษัทในเครือเกียรตินาคินภัทร
Kiatnakin Phatra Financial Group company cover
Kiatnakin Phatra Financial Group
Financial Service
Fastwork Technologies company cover
Fastwork Technologies
Fastwork.co เว็บไซต์ที่รวบรวม ฟรีแลนซ์ มืออาชีพจากหลากหลายสายงานไว้ในที่เดียวกัน
Thoughtworks Thailand company cover
Thoughtworks Thailand
Thoughtworks เป็นบริษัทที่ปรึกษาด้านเทคโนโยลีระดับโลกที่คว้า Great Place to Work 3 ปีซ้อน
Iron Software company cover
Iron Software
Iron Software is an American company providing a suite of .NET libraries by engineer for engineers.
CLEVERSE company cover
CLEVERSE
Cleverse is a Venture Builder. Our team builds several tech companies.
Nipa Cloud company cover
Nipa Cloud
#1 OpenStack cloud provider in Thailand with our own data center and software platform.
Bangmod Enterprise company cover
Bangmod Enterprise
The leader in Cloud Server and Hosting in Thailand.
CIMB THAI Bank company cover
CIMB THAI Bank
MOVING FORWARD WITH YOU - CIMB is the leading ASEAN Bank
Bangkok Bank company cover
Bangkok Bank
Bangkok Bank is one of Southeast Asia's largest regional banks, a market leader in business banking
MuvMi (Urban Mobility Tech Co.,Ltd.) company cover
MuvMi (Urban Mobility Tech Co.,Ltd.)
Shape the future of urban mobility towards affordable, clean, and safe solutions
T.N. Digital Solution Co., Ltd. company cover
T.N. Digital Solution Co., Ltd.
TNDS has been involving in every first move of banking’s major digital transformation.
KBTG - KASIKORN Business-Technology Group company cover
KBTG - KASIKORN Business-Technology Group
KBTG - "The Technology Company for Digital Business Innovation"
Siam Commercial Bank Public Company Limited company cover
Siam Commercial Bank Public Company Limited
"Let's start a brighter career future together"
Icon Framework co.,Ltd. company cover
Icon Framework co.,Ltd.
Global Standard Platform for Real Estate แพลตฟอร์มสำหรับธุรกิจอสังหาริมทรัพย์ครบวงจร มาตรฐานระดับโลก
REFINITIV company cover
REFINITIV
The Financial and Risk business of Thomson Reuters is now Refinitiv
H LAB company cover
H LAB
Re-engineering healthcare systems through intelligent platforms and system design.
The Gang Technology Co., Ltd. company cover
The Gang Technology Co., Ltd.
We're a Digital Agency that helps our customers transform their business into digital with ease.
LTMH company cover
LTMH
LTMH มุ่งเน้นการพัฒนาผลิตภัณฑ์ที่สามารถช่วยพันธมิตรของเราให้บรรลุเป้าหมาย
Seven Peaks company cover
Seven Peaks
We Drive Digital Transformation
Wisesight (Thailand) Co., Ltd. company cover
Wisesight (Thailand) Co., Ltd.
The Best Choice For Handling Social Media · High Expertise in Social Data · Most Advanced and Secure
MOLOG Tech company cover
MOLOG Tech
We are Modern Logistic Platform, Specialize in WMS, OMS and TMS.
Data Wow Co.,Ltd company cover
Data Wow Co.,Ltd
We enable our clients to realize increased productivity by solving their most complex issues by Data
LINE Company Thailand company cover
LINE Company Thailand
LINE, the world's hottest mobile messaging platform, offers free text and voice messaging + Call
LINE MAN Wongnai company cover
LINE MAN Wongnai
Join our journey to becoming No.1 food platform in Thailand

ไม่เกี่ยวกับ pointer น่ะครับ

ที่ผมว่า C++ มันยากน่ะเพราะมันต้องรู้เงื่อนไข complier ที่จะ generate code (constructor, ...)ให้ บางทีก็ต้องสั่งลบที่มัน generate ให้อีก
กับพวก type security (const, volatile)
แล้วยังพวก standard ที่ออกมานาน 2ปีแล้ว แต่ complier, toolchain ไม่ support อีก (ผมก็งงอยู่นั้นล่ะว่าเขียนผิดตรงไหน)
ยังมี intellisense มึนกับ standard ใหม่อีก
ไม่งั้นก็ compile ไม่ผ่านสักที

ในฐานะที่ต้องเขียนทั้ง C++ และ Rust ในงานจริง ผมมองว่ามันยากคนละแบบอ่ะครับ

C++ นี่เอาเข้าจริงมัน "หยวน" กับ Code กว่าครับ ใช้ type ผิดกันไปบ้าง lifecycle ไม่ใจร้ายเท่าไหร่ (แล้วไปตายตอน runtime เอา)

แต่ Rust ก็อย่างคอมเมนต์อื่นบอกล่ะครับ ละเอียดแล้ว strict มากจนบางทีผมรำคาญก็มีนะ โดยเฉพาะพวก Result type เนี่ย E ไม่ตรงนี่ยังแทบไม่ให้ผมผ่านอ่ะ เสียเวลาจัดการเยอะ แต่นานๆ ทีจะเจอ panic เขียนจบแล้วก็คือจบไมท่ค่อยมีให้น่ากังวล อ้อ! package manager ของ Rust นี่ก็ตามภาษาสมัยใหม่แล้ว ถือว่าดีเลย

C++ เริ่มจับง่าย เข้าถึงง่าย ยืดหยุ่นสูง แต่ยากที่จะ Master โดยเฉพาะเรื่อง Memory Allocation Model ที่ผูกกับคอมพิวเตอร์ยุคใหม่สุด "บัดซบ" C++ หลายโปรเจกต์ที่ทำ Multi-platform จะมีกฎของการเขียน Memory Allocation Model ตามกำหนดตั้งแต่ต้นเลย ถ้าใช้โมเดลอื่นนอกเหนือจากกำหนดจะไม่ให้โค้ดผ่านเข้า Repo หลักทันที เลยมี Learning Curve เล็กน้อยตอนที่โยกโปรเจกต์ไปมาเพราะมันไม่ได้ใช้อย่างเดียวกันตลอด

Rust มัน Type-safe ตั้งแต่ต้น อะไรเสี่ยง ๆ คอมไพเลอร์มันด่าเราแบบยับ ๆ แต่ส่งผลดีในระยะยาว เพราะสร้างนิสัยการเขียนโค้ด Low/Mid Level ที่ดีให้กับนักพัฒนาตั้งแต่แรก และอาจส่งผลดีต่อการเขียนโค้ดในภาษา Unsafe อื่น ๆ ในอนาคตอีกด้วย แต่เพราะอย่างนี้เลยทำให้มันเริ่มจับยากมากจากความเคยชินจากภาษา Low/Mid Level แบบเดิม ๆ

บริษัทผมรับ Consult การพอร์ต C/C++ มา Rust นะครับ ให้บริการโดย Engineer ที่มีประสบการณ์กับ C/C++ มาตลอดเกือบ 20 ปี ตัวอย่างโปรเจคครับ https://github.com/ultimicro/zfi บริษัทไหนสนใจสามารถติดต่อได้ทางอีเมลในหน้า GitHub ครับ การพอร์ตในที่นี้ไม่ใช่การ Rewrite ทั้งหมดในคราวเดียวนะครับ แต่เป็นการเพิ่ม Rust เข้าไปใช้งานคู่กับ C/C++ แล้วค่อย ๆ เปลี่ยนผ่านจนกลายเป็น Rust โดยสมบูรณ์

ข้อดีของ Rust เมื่อเทียบกับ C/C++ คือให้ Productivity สูงกว่ามากเมื่อใช้ได้คล่องครับ เหมือนเราได้ภาษา High-level อย่าง Python แต่ Performance ระดับ C/C++ บวกกับความ Safety ของตัวภาษาที่ช่วยป้องกันไม่ให้ Junior ยิงเท้าตัวเองด้วย Segmentation fault ครับ ซึ่งจะช่วยลดงานของ Senior เวลา Review code ได้ครับ

ตัว Package Manager ของ Rust นี่คือดีงามจริงๆ ส่วน C++ จะอารมณ์แบบว่าจอมยุทธ์น้อยพกกระบี่ออกไปท่องยุธภพ แล้วเจอว่าโลกนี้มันช่างกว้างใหญ่ แต่ละสำนักก็ล้วนแต่มีวิธีของตัวเอง

หลังๆนี่เริ่มเข้าใจอะไรอย่างนึง ศึกษา C++ เท่าที่ใช้พอ ไม่ต้องพยายามไปเรียนรู้ทั้งหมด เลือกที่คิดว่าโอเคและเหมาะกับงานเรา

ico Wed, 30/08/2023 - 05:28

learning curve ช่วงแรกๆมันสูงกว่าภาษาอื่นมาก แต่ทดแทนมาด้วย doc, compiler ที่ดีสุดๆ
compiler is your best friend สำหรับคนเริ่มเขียน :)