البنية التحتية العامة للغات (Common Language Infrastructure - CLI)
📘 درس Visual Basic - البنية التحتية العامة للغات (Common Language Infrastructure - CLI)
🔹 ما هي CLI؟
البنية التحتية العامة للغات (Common Language Infrastructure - CLI) هي مواصفة وضعتها مايكروسوفت لتحديد كيفية تشغيل وإدارة الكود في بيئة مشتركة بين مختلف لغات البرمجة. CLI هي الأساس الذي بُني عليه .NET Framework وتحدد طريقة تنفيذ الكود، وكيفية التعامل مع الذاكرة والأمان وأنواع البيانات.
💡 لماذا نستخدم CLI؟
لأنها تضمن إمكانية تشغيل الكود المكتوب بلغات مختلفة مثل Visual Basic وC# معًا بسلاسة، وتوفر بيئة موحدة لإدارة دورة حياة التطبيق.
✅ المكونات الأساسية لـ CLI
- Common Type System (CTS): نظام موحد لتعريف أنواع البيانات.
- Common Language Specification (CLS): قواعد لضمان التوافق بين اللغات.
- Metadata: معلومات تصف الكائنات والكود.
- Virtual Execution System (VES): بيئة التشغيل التي تنفذ الكود.
💻 مثال مبسط يوضح المفهوم
عند ترجمة كود Visual Basic، يتم تحويله إلى لغة وسيطة (IL) يفهمها CLI، ثم يتم تنفيذها بواسطة CLR.
Public Class Example
Public Function Multiply(a As Integer, b As Integer) As Integer
Return a * b
End Function
End Class
🌍 English Explanation
The Common Language Infrastructure (CLI) is a specification created by Microsoft to define how code is executed and managed in a shared environment among different programming languages. CLI is the foundation of the .NET Framework and defines how code is run, memory is handled, security is enforced, and data types are managed.
💡 Why Use CLI?
Because it ensures that code written in different languages like Visual Basic and C# can work together seamlessly and provides a unified environment for managing the application lifecycle.
✅ Main Components of CLI
- Common Type System (CTS): A unified system for defining data types.
- Common Language Specification (CLS): Rules to ensure language compatibility.
- Metadata: Information that describes objects and code.
- Virtual Execution System (VES): The runtime environment that executes the code.
💻 Simple Example Illustrating the Concept
When you compile Visual Basic code, it is converted into Intermediate Language (IL) understood by the CLI and then executed by the CLR.
Public Class Example
Public Function Multiply(a As Integer, b As Integer) As Integer
Return a * b
End Function
End Class
تعليقات
إرسال تعليق