Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

llm-first-py-cxx.html 4.4KB

vor 1 Monat
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <!DOCTYPE html>
  2. <html>
  3. <meta charset="utf-8">
  4. <head>
  5. <link rel="stylesheet" href="../../style.css">
  6. </head>
  7. <body>
  8. <script data-goatcounter="https://services.opengamestudio.org:443/count" async src="//services.opengamestudio.org:443/count.js"></script>
  9. <div id="header">
  10. <div class="header2">
  11. <div class="menu">
  12. <a href="../../en/news/index.html">News</a>
  13. <a href="../../en/game/index.html">Games</a>
  14. <a href="../../en/tool/index.html">Tools</a>
  15. <a href="../../en/page/about.html">About</a>
  16. </div>
  17. <div id="lang">
  18. <a href="../../en/news/llm-first-py-cxx.html">EN</a>
  19. <a href="../../ru/news/llm-first-py-cxx.html">RU</a>
  20. </div>
  21. <div class="clear"></div>
  22. </div>
  23. </div>
  24. <h3 class="left_item_title">In the news...</h3>
  25. <center>
  26. <div class="news_item">
  27. <h2 class="news_item_title">
  28. <a href="llm-first-py-cxx.html">The first example of a portable code</a>
  29. </h2>
  30. <p class="news_item_date">
  31. 2024-04-11 00:00
  32. </p>
  33. <div class="news_item_contents">
  34. <h1 id="supportedplatforms">Supported platforms</h1>
  35. <p>To verify code portability, I selected the following platforms and languages:</p>
  36. <ul>
  37. <li>C++: Linux, macOS, OpenWrt, Windows</li>
  38. <li>JavaScript: Chrome, Firefox, Safari</li>
  39. <li>Kotlin: Android</li>
  40. <li>Python: Linux, macOS, Windows</li>
  41. <li>Swift: iOS, macOS</li>
  42. </ul>
  43. <p>I created a simple "Hello World" example for each language to understand the basic requirements of each platform.</p>
  44. <p>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.</p>
  45. <h1 id="anchorlanguageandlimitedlanguagemodel">Anchor language and limited language model</h1>
  46. <p>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.</p>
  47. <p>Python is good because:</p>
  48. <ul>
  49. <li>one can specify a type with Type hints</li>
  50. <li>Python has portability across Linux, macOS, Windows out of the box</li>
  51. <li>pip simplifies distribution of the language conversion instrument</li>
  52. <li>Python does not require a separate compilation step, which speeds up development</li>
  53. </ul>
  54. <p>However, not every Python code will suite the language conversion instrument under development. Only the code that satisfies the constraints of the <code>Limited language model</code>.</p>
  55. <p>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:</p>
  56. <p><img src="../../images/2024_llm-first-py-cxx.jpg" alt="Python to C++ example" /></p>
  57. <h1 id="aprilplans">April plans</h1>
  58. <p>I'm going to write game logic for "Memory" in Python and convert it to C++ by the instrument under development.</p>
  59. </div>
  60. </div>
  61. <div id="disqus_thread"></div>
  62. <script>
  63. var disqus_config = function () {
  64. this.page.url = "https://opengamestudio.org/en/news/llm-first-py-cxx.html";
  65. this.page.identifier = "llm-first-py-cxx.html";
  66. };
  67. (function() { // DON'T EDIT BELOW THIS LINE
  68. var d = document, s = d.createElement('script');
  69. s.src = 'https://opengamestudio.disqus.com/embed.js';
  70. s.setAttribute('data-timestamp', +new Date());
  71. (d.head || d.body).appendChild(s);
  72. })();
  73. </script>
  74. <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
  75. <div id="footer">
  76. The site has been generated by <a href="http://opengamestudio.org/pskov">PSKOV</a>
  77. from <a href="http://github.com/ogstudio/site-opengamestudio">this source code</a>.
  78. </div>
  79. </center>
  80. </body>
  81. </html>