Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Ruby

เลือกภาษาโปรแกรมมิ่งสำหรับ Mobile App Development ให้ถูกต้อง

ถ้าอยากพัฒนา mobile app คุณต้องรู้ภาษาโปรแกรมมิ่งสำหรับ mobile development แตยากเลือก best language (หรือหลายภาษา) สำหรับโปรเจกต์ มี options เยอะ ในโพสต์นี้ช่วย narrow down ให้เลือก best ได้

ภาษาที่เลือก depend on สิ่งที่สร้าง สำหรับบาง apps mobile developers อาจไม่ต้องการ features ทั้งหมดของภาษา ในสถานการณ์อื่น single app อาจต้องการมากกว่าหนึ่งภาษา ใน tutorial นี้จะผ่าน mobile development languages ต่างๆ และ highlight details ช่วย決策ถูกต้อง

Native Android Languages

Java

ตาม TIOBE Index Java เป็นภาษาที่ 3 popular จน January 2022 อยากพัฒนา Android apps likely จะอยู่กับ Java มี developer community ใหญ่และมั่นคง ได้ technical support และช่วยเหลือง่าย

พัฒนา mobile ด้วย Java คุณเสรีสร้าง app ใดๆ ที่คิดได้ ขีดจำกัดคือ imagination และ Java knowledge ของคุณ

Kotlin

Kotlin พัฒนาโดย JetBrains บริษัท Czech ที่รู้จัก IDE ยอดนิยม IntelliJ IDEA Google Android team ประกาศ 2017 officially support Kotlin

Kotlin พัฒนาแก้ issues ใน Java ตามแฟนภาษา Kotlin syntax simpler, cleaner, นำไปสู่ less code bloat ช่วยโฟกัสแก้ปัญหาจริง แทน struggle verbose syntax และ用 Kotlin และ Java พร้อมกันในโปรเจกต์เดียวได้ powerful มาก

Native iOS Languages

Swift

อยากพัฒนา iOS devices Swift อาจเป็นภาษาสำหรับคุณ Introduced 2014 open source 2015 Swift กลายเป็น dominant language สำห iOS developers

ตาม TIOBE January 2022 Swift เป็นภาษา popular ที่ 10

Apple เพิ่ม features ใหม่ใน Swift 5.5 รวม async/await, structured concurrency, actors และมากกว่า Apple efforts โปรโมท Swift ชัดว่าอยากให้ภาษานี้กลาย mainstream สำหรับ app ecosystem

Objective-C

Objective-C เป็น original development language สำห iOS Swift state-of-the-art แตโปรเจกต์เยอะยังพึ่ง Objective-C transition ช้า และอาจต้องทั้งคู่บางโปรเจกต์

Cross-Platform Languages

JavaScript With React Native

JavaScript มีประวัติยาวย้อน early World Wide Web front-end และ server-side language popular ให้ web developers ทำจาก enhance UX websites ถึงสร้าง complete web apps

วันนี้มี JavaScript frameworks เยอะ target mobile platforms หนึ่งคือ React Native

React Native framework ให้ traditional web developers combine JavaScript และ React syntax สร้าง apps สำห iOS, Android, และ web จาก single codebase หมายถึง developer เขียน app version เดียว run บน iOS และ Android

React Native 感覺像 React DOM สำห web แตแทน HTML และ DOM 用 native components ที่เจอบน iOS และ Android

Philosophy คือ "learn once, write anywhere" เรียน React ครั้งเดียว เขียน applications สำห web, Android, iOS

JavaScript With Ionic (For Hybrid Apps)

Framework อีกตัว cross-platform คือ Ionic Ionic ให้ mobile developers สร้าง hybrid mobile app ด้วย web technologies ที่มี: HTML, CSS, JavaScript

Idea คือเขียนโค้ดครั้งเดียว run across platforms seamlessly Hybrid app คือ web app ที่ embedded บน native device ผ่าน WebView Hybrid app ไม่ communicate ตรงกับ native device features มาก ใช้ bridge คือ Apache Cordova wrap native code ใน JavaScript API ให้ web app เข้าถึงได้

Ionic framework beneficial สร้าง elegant apps ด้วย pre-designed UI components, themes, typographies, และ elements อื่นๆ

Dart With Flutter

Flutter UI framework พัฒนา apps บน iOS, Android, web, และ desktop 2015 Google release initial Flutter 2018 launch first stable version

Flutter popularity เพิ่มจาก features 多 在 core framework รวม high-performance graphics engine กับ Dart programming language ใน development Dart ให้ full type safety และ hot reload สร้าง reliable apps เร็ว

Production Dart compile ไป native machine code graphics render สวยบนทุก platform

Flutter ไม่ต้อง bridges เพิ่มทำงานบน devices ต่างๆ และไม่เหมือน WebView frameworks อย่าง Ionic Flutter มี technology ของตัวเอง compile source code ตรงไป machine code setup นี้ improve speed และ performance มาก

Other Languages

C

C ภาษาเก่าที่สุดในลิสต์ แต perennially popular บน TIOBE index เหมือน Java community เต็ม seasoned developers ให้คำแนะนำ valuable เขียน bug-free code Dennis Ritchie สร้างขณะทำงาน Bell Labs C powerful ให้ manipulate low-level operations ของ computer ตรงๆ อยาก用 Android NDK (Native Development Kit) ต้อง familiar กับ C

C++

คุ้นเคย C จะ enjoy อ่านเขียน C++ code C++ extend C ด้วย high-level features และ support OOP C++ เป็น favorite ของ Android NDK developers ใช้ C++ พัฒนา Windows Mobile apps ได้ C++ head-to-head กับ Java ใน software development worth mastering

How to Classify the Languages

Mobile apps จัดกลุ่ม 3 categories: native, hybrid, native cross-platform Native apps 用 OS facilities และ features ทั้งหมด fastest performance แตต้อง maintain codebases แตกต่างต่อ platform เพราะแต่ละ platform 用ภาษาต่างกัน

เช่น Android 用 Java/Kotlin + C/C++ iOS 用 Objective-C/Swift ทั้งหมด compiled ไม่ใช่ interpreted

Hybrid mobile apps คือ websites designed ทำงานกับ mobile devices user เข้าถึง via mobile browser เหมือน visit website บน desktop HTML5, CSS, JavaScript obvious choice สำห web apps Ionic ตัวอย่าง WebView-based platforms

近來 batch ใหม่ mobile cross-platform frameworks emerged รวม best features ของ native และ hybrid fast, light, เข้าถึง full power ของ native device เยอะ coded ด้วย JavaScript และ web languages code reuse ระหว่าง platforms มาก React Native leading example ของ class นี้

Comparison of Features

ก่อนลึกลง language features ต้องเลือก platform อ้างอิง article Mobile Development Platforms ได้ idea platforms ต่างๆ และเลือก suit คุณ สมมติเลือก platform แล้ว 看 languages เปรียบเทียบ features

Native Android

อยาก native Android Java และ Kotlin obvious choices มาดู

Null Safety

Kotlin control Null references ดีกว่า NullPointerException bugs (common ใน Java) eliminate ง่าย ลด dev time เพิ่ม productivity

Concurrency

Java support concurrent operations แต code อาจ suffer readability และ maintainability Kotlin แก้ด้วย coroutines code อ่านง่าย เข้าใจง่าย

Type System

Java type system ไม่ consistent นำไปสู่ confusion primitive types (integer, boolean, etc.) ต้อง handle special cases Kotlin มี type system 简单และ versatile น้อย programmer errors

Supported Programming Styles

Java theoretically support various styles แตบาง developers คิดว่า promote OOP มากเกิน Kotlin ไม่ enforce particular style developers มีความเสรีเลือก approach ที่ fit แต Kotlin developers ต้องมี software architecture และ development principles knowledge ลึก

Which One to Choose?

กึ่งกลาง Kotlin ดีกว่า Java แตอาจใช้เวลา complete transformation หนึ่ง challenge programmers ใช้ thinking patterns ของ Java อีกคือ Kotlin relatively new features บางอย่างยัง experimental

Google ชัดเจน support Kotlin 完整 Android Studio official IDE มี full Kotlin support Features ใหม่เพิ่มตลอด ในอีก幾年 จะเจอ transition period Java ไป Kotlin ใน native Android development

Native iOS

Objective-C และ Swift สอง options iOS development มาดู features

Code Syntax

Swift syntax simpler clearer ช่วย programmers achieve goals ด้วย minimum lines of code ลด programmer errors easing bug fixing

Memory Management

Swift ชนะชัด Objective-C memory management Swift enforce robust reliable control mechanisms avoid memory leaks ไม่พึงประสงค์

Performance

Swift execution เร็วกว่า Objective-C มาก นำไปสู่ faster app performance และ better UX

Supported Programming Styles

ไม่เหมือน Objective-C Swift มี built-in support functional programming developers ไม่จำกัด predefined styles ช่วยเข้าใจปัญหาชัดเจน หา solution ดีกว่า

Which One to Choose?

เหมือน Kotlin replace Java ใน Android Swift sure thrive ใน iOS forcing Objective-C retire Apple extensive support Swift และจะดีขึ้น อีก幾年 iOS developers ก็ transition period เหมือน Android

มี code migration tools หลายตัว แตอาจไม่ fully convert Objective-C projects ไป Swift โดยไม่มี issues บางครั้ง workarounds เฉพาะเจาะจง ต้อง Objective-C knowledge ดี strategy 好: priority ให้ Swift เรียน Objective-C นิดหน่อยตอน absolutely necessary ต้อง follow latest Swift developments และ trends

Cross-Platform Apps

JavaScript (coupled with HTML5 technologies) most used cross-platform mobile development language มีภาษาอื่นอย่าง Dart แต JavaScript มี broadest support และ adoption

อยากลอง cutting-edge mobile development ด้วย Flutter เรียน Dart ไป แต่ไม่ guarantee Flutter platform จะอยู่ในอีก幾年 อยาก tried-and-true stick with JavaScript หรือ type-augmented sibling TypeScript

Conclusion

เลือก mobile development language tricky ถ้าไม่เข้าใจ features แต่ละตัว พร้อม industry trends ด้วยความรู้นี้ 容易เห็นว่าเลือกภาษา heavily depends on mobile development platform ด้วย

มั่นใจตอนนี้คุณมี clearer picture ของ mobile app development languages และ match relevance ของ features กับ latest trends เริ่มเขียนโค้ด app ถัดไปด้วยความมั่นใจ!

อยากช่วยเริ่มภาษาใหม่ check tutorials และ video courses linked ทั่วโพสต์ หรือ posts อื่นๆ เกี่ยว mobile development!

โพสต์นี้ updated with contributions from Kingsley Ubah Kingsley passionate สร้าง content educate และ inspire readers Hobbies: reading, football, cycling.