ข้อได้เปรียบในการใช้ Rust ทำ web backend
Vee Satayamas

Vee Satayamas @veer66

About: I'm a Thai-Lao-English-speaking software engineer who has worked on data pipelines, web/app back-end, and multilingual text processing.

Location:
SE Asia
Joined:
Oct 31, 2017

ข้อได้เปรียบในการใช้ Rust ทำ web backend

Publish Date: Oct 1 '23
0 0

มีผู้ถามเข้ามาในกลุ่มตามหัวข้อ ผมก็เลยเอาคำตอบมาเรียบเรียงไว้อีกที

นอกจากประสิทธิภาพแล้ว Rust ได้เปรียบเรื่อง compile time type checking; Lemmy เทียบกับ GotoSocial ที่ใช้ Go มี 2 จุดคือ

  1. GotoSocial ทำ cache เลี่ยงเรียก database บ่อย ซึ่ง cache แชร์กันระหว่าง goroutine ไม่ผ่าน channel ต้อง lock กันเอง; แต่ถ้าเป็น Rust มี compiler คอยช่วยตรวจว่า lock จุดที่ควร lock หรือไม่
  2. Bun ORM ใน GotoSocial เวลา query ก็ส่ง string เข้าไป ไว้ parse เอาตอนรัน ซึ่งทำให้ compiler ช่วยตรวจไม่ได้; Diesel ใน Lemmy ใช้ macro ทำให้ check type ได้

Comments 0 total

    Add comment