Erlang OTP: Distributed & Fault-Tolerant Systems Programming · درس

فلسفة «دعها تتعطل»

افهم نهج Erlang القائم على «دعها تتعطل»، وكيف يؤدي عزل الأخطاء وإعادة التشغيل النظيف وتجنب البرمجة الدفاعية إلى إنتاج أنظمة أكثر موثوقية.

الدرس 4 من 413 خطوة

فلسفة «دعها تتعطل» درس مجاني في Erlang OTP: Distributed & Fault-Tolerant Systems Programming على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Erlang OTP: Distributed & Fault-Tolerant Systems Programming، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Erlang OTP: Distributed & Fault-Tolerant Systems Programming 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

A Different Mindset

Most languages encourage catching every possible error. Erlang takes the opposite view: let it crash. A process that hits an unexpected state should die and be restarted into a known-good state.

Why Crashing Is Good

A crash is a clean, well-defined failure. Trying to limp along in a corrupted state often causes worse, harder-to-debug problems later.

Process Isolation

Erlang processes share nothing. One crashing process cannot corrupt another's memory, so a failure stays contained.

Happy-Path Code

Because supervisors handle failures, you write only the success case. No tangle of defensive checks.

handle(Request) ->
    {ok, Data} = fetch(Request),  % crashes if not ok
    process(Data).

Assertive Matching

The match {ok, Data} = fetch(...) doubles as an assertion: if fetch returns anything else, the process crashes immediately rather than continuing with bad data.

Supervisors Do the Recovery

A supervisor (covered earlier) watches workers and restarts them per its strategy. Let-it-crash works because supervision provides recovery.

Separating Logic from Errors

Keep risky operations in worker processes that may crash, while a stable supervisor process holds the recovery policy. This separation keeps both simple.

When NOT to Crash

Expected, recoverable conditions (a user typing a bad value) are not exceptional. Handle those normally; crash only on truly unexpected states.

case validate(Input) of
  ok -> save(Input);
  {error, Reason} -> {error, Reason}
end.

Errors vs Exits

A runtime error (like a failed match) crashes the process with reason {badmatch, ...}. You can also crash deliberately with exit/1 to signal an unrecoverable problem.

exit(disk_full).

Crash Reports & Logging

When a process dies, OTP logs a crash report with the reason and stack. SASL and logger capture these so failures are observable even though you did not catch them.

The Payoff

Let-it-crash plus supervision yields systems that self-heal from transient faults and stay running for years. Code is smaller, clearer, and focused on the real work.

Quick Check

Test your understanding of the philosophy.

Recap

You learned the let-it-crash philosophy.

  • Crash on unexpected state instead of coding defensively
  • Process isolation contains failures
  • Supervisors provide recovery
  • Still handle expected, recoverable cases normally
البدء مجانًا

تعلم Erlang مع معلم ذكاء اصطناعي — مجانًا

اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.

الدورات
12
الدروس
48

الأسئلة الشائعة

هل درس «فلسفة «دعها تتعطل»» مجاني؟

نعم — نص درس «فلسفة «دعها تتعطل»» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Erlang OTP: Distributed & Fault-Tolerant Systems Programming، انتقل إلى CoddyKit PRO. تتضمن دورة Erlang OTP: Distributed & Fault-Tolerant Systems Programming 4 دروس في المجموع.

ماذا ستتعلم في «فلسفة «دعها تتعطل»»؟

افهم نهج Erlang القائم على «دعها تتعطل»، وكيف يؤدي عزل الأخطاء وإعادة التشغيل النظيف وتجنب البرمجة الدفاعية إلى إنتاج أنظمة أكثر موثوقية. تتمرن على Erlang OTP: Distributed & Fault-Tolerant Systems Programming مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Erlang OTP: Distributed & Fault-Tolerant Systems Programming؟

لا تُشترط خبرة سابقة. Erlang OTP: Distributed & Fault-Tolerant Systems Programming على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «فلسفة «دعها تتعطل»»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Erlang OTP: Distributed & Fault-Tolerant Systems Programming هذا؟

نعم. كل درس في Erlang OTP: Distributed & Fault-Tolerant Systems Programming يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. شرح الروابط والمراقبين
  2. معالجة الأخطاء المتينة
  3. التصميم وفق مبدأ الانهيار أولًا
  4. فلسفة «دعها تتعطل»
← العودة إلى Erlang OTP: Distributed & Fault-Tolerant Systems Programming