Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

2024-04_llm-first-py-cxx.md 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. Title: The first example of a portable code
  2. Date: 2024-04-11 00:00
  3. Category: News
  4. Slug: llm-first-py-cxx
  5. Lang: en
  6. # Supported platforms
  7. To verify code portability, I selected the following platforms and languages:
  8. * C++: Linux, macOS, OpenWrt, Windows
  9. * JavaScript: Chrome, Firefox, Safari
  10. * Kotlin: Android
  11. * Python: Linux, macOS, Windows
  12. * Swift: iOS, macOS
  13. I created a simple "Hello World" example for each language to understand the basic requirements of each platform.
  14. By the way, OpenWrt turned out the most complex platform to create "Hello World" for, because my TP-Link TL-MR3020 r1 router is considered obsolete since 2018. I had to use the old 17.01.7 firmware, which took about three weeks.
  15. # Anchor language and limited language model
  16. For the whole month I was asking myself the same question: "Which language should I choose as a starting point to convert to other languages from?" Initial considerations were pointing me to C++ due to strong types. However, as soon as I found out Python has Type hints, I chose Python.
  17. Python is good because:
  18. * one can specify a type with Type hints
  19. * Python has portability across Linux, macOS, Windows out of the box
  20. * pip simplifies distribution of the language conversion instrument
  21. * Python does not require a separate compilation step, which speeds up development
  22. However, not every Python code will suite the language conversion instrument under development. Only the code that satisfies the constraints of the `Limited language model`.
  23. Limited language model is a subset of Python with various restrictions in both syntax and a set of available functions. Here is a glimpse of those restrictions, the image below depicts Python to C++ conversion result:
  24. ![Python to C++ example][pycxx]
  25. # April plans
  26. I'm going to write game logic for "Memory" in Python and convert it to C++ by the instrument under development.
  27. [pycxx]: ../../images/2024_llm-first-py-cxx.jpg