Rust

ผู้ใช้ Firefox อาจเคยเจอปัญหาแอพแครช และเจอหน้าจอส่งรายงานการแครช Firefox Crash Reporter กลับไปยัง Mozilla เพื่อใช้วิเคราะห์

Firefox Crash Reporter มีสถานะเป็นแอพแยกขาดจาก Firefox แต่บันเดิลมาในชุดติดตั้งเดียวกัน เหตุผลที่ต้องแยกขาดจากกันเป็นเพราะเมื่อ Firefox แครช ตัว Crash Reporter จะยังทำงานได้ต่อไป ไม่ใช่โดนลากให้แครชตามไปด้วยกัน

อย่างไรก็ตาม Crash Reporter ถูกเขียนขึ้นมานานมากแล้ว (เบื้องหลังเป็น C++ และบางส่วนเป็น Objective-C สำหรับเวอร์ชันแมค) หลายส่วนเริ่มล้าสมัย เช่น เวอร์ชันแมคจะสร้างไฟล์ไบนารีด้วยเครื่องมือตัวเก่าที่แอปเปิลเองยังเลิกใช้ไปแล้ว โค้ดตัวเดิมจึงกลายเป็นภาระในการดูแลมากขึ้นเรื่อยๆ

ล่าสุด Mozilla ประกาศว่าเพิ่งเขียน Firefox Crash Reporter ขึ้นมาใหม่ด้วยภาษา Rust ด้วยเหตุผลหลายอย่าง เช่น ความปลอดภัยของหน่วยความจำ (memory safety) ที่ระดับของภาษา, ระบบตัวแปร type system และไลบรารีมาตรฐานทำให้ดูแลโค้ดได้ง่าย

หน้าตา Firefox Crash Reporter ตัวใหม่ ที่หน้าตาเหมือนเดิม

การเขียน Crash Reporter ใหม่ดูเหมือนไม่มีอะไรยาก เพราะทั้งแอพมีหน้าจอเดียว แต่เงื่อนไขของ Mozilla ก็มีข้อจำกัดมากมาย เช่น ต้องเรียกใช้โค้ดหรือไลบรารีภายนอกให้น้อยที่สุด เพื่อให้แอพเล็ก ไม่ซับซ้อน ตรวจสอบย้อนกลับง่าย เงื่อนไขนี้ทำให้การเรียกใช้ไลบรารีสร้าง GUI แบบข้ามแพลตฟอร์มเป็นไปไม่ได้เลย ทางออกจึงต้องพึ่งพาตัวเอง

แนวทางของ Mozilla ยังไปสุดคือ จะพยายามมีโค้ดเฉพาะแพลตฟอร์มให้น้อยที่สุด ดังนั้นโค้ดสร้าง GUI จึงต้องสร้าง GUI abstraction ตรงกลางขึ้นมาก่อน ใช้โครงสร้างแบบ declarative แล้วค่อยแปลงมันไปเป็น GUI แบบเนทีฟบนแต่ละแพลตฟอร์ม ผ่านชุดสร้าง GUI ของแพลตฟอร์มอีกที

  • Linux ใช้ GTK+ 3 ซึ่งถือว่ามีปัญหาน้อยที่สุด เพราะ GTK ค่อนข้างสมัยใหม่ ใช้แนวทาง declarative เหมือนกัน
  • macOS ใช้ Cocoa (AppKit และ Foundation frameworks) เจอปัญหาว่า GUI ของแมคมีโค้ดส่วนที่ถูก generated ด้วย Xcode เยอะมาก การเขียน GUI ขึ้นมาเองโดยไม่มี Xcode ต้องเขียนบางอย่างเองทั้งหมด เช่น ช็อตคัตคีย์บอร์ด
  • Windows ใช้ Win32 API ซึ่งเป็นแพลตฟอร์มที่เขียนยากที่สุด เพราะ Win32 API เก่ามากๆ แล้ว ไม่รองรับการทำ abstraction มากนัก ต้องคัสตอมโค้ดเยอะมาก

ในบทความยังมีรายละเอียดส่วนอื่นๆ อีกมาก ใครที่สนใจสร้างแอพด้วย Rust ก็ตามไปอ่านกันได้

ที่มา - Mozilla

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

btoy Fri, 26/04/2024 - 09:33

Windows ใช้ Win32 API ซึ่งเป็นแพลตฟอร์มที่เขียนยากที่สุด เพราะ Win32 API เก่ามากๆ แล้ว ไม่รองรับการทำ abstraction มากนัก ต้องคัสตอมโค้ดเยอะมาก

Windows นี่ยังคลาสสิคไม่เปลี่ยนแปลง

classic สิครับ มันเป็นภาษา C + Macro + UTF16 codepage หนิ
แต่ก็ใช้ดีอยู่นะเร็วดี
custom ได้ตามใจไม่ต้องกลัว overhead
UI API อื่นของ MS ก็ wrap API นี้ทั้งนั้น