{"id":52,"date":"2007-12-28T12:25:55","date_gmt":"2007-12-28T18:25:55","guid":{"rendered":"http:\/\/www.philhassey.com\/blog\/2007\/12\/28\/64k-tinypy-keeps-plugging-along\/"},"modified":"2008-02-19T01:14:05","modified_gmt":"2008-02-19T07:14:05","slug":"64k-tinypy-keeps-plugging-along","status":"publish","type":"post","link":"https:\/\/www.philhassey.com\/blog\/2007\/12\/28\/64k-tinypy-keeps-plugging-along\/","title":{"rendered":"64k &#8220;tinypy&#8221; keeps plugging along &#8230;"},"content":{"rendered":"<p>So .. I had a hard time resisting working on my 64k version of &#8220;python&#8221;.  I&#8217;ve been able to get quite a few features into it and I&#8217;ve gotten my julia demo up to near-C speed as well as tamed the crazy memory problems I was having.<br \/>\nI suppose the question I ponder is &#8220;why bother&#8221;?  Well:<\/p>\n<ul>\n<li>It&#8217;s fun \ud83d\ude42<\/li>\n<li>I&#8217;m learning the basics of parsing, code generation.<\/li>\n<li>It might even be somewhat useful!<\/li>\n<\/ul>\n<p>The first two don&#8217;t require much explanation, the third (usefulness?):<\/p>\n<ul>\n<li>By keeping the codebase &lt; 64k, it will be readable by mortals<\/li>\n<li>By generating C code, it can build self-contained binaries easily<\/li>\n<li>It has a really simple &#8220;FFI&#8221; which auto-generates many of the &#8220;FFI&#8221; wrappers for you<\/li>\n<li>It&#8217;s sort of fast now (no promises for anything real)<\/li>\n<\/ul>\n<p>It, of course, isn&#8217;t python, it just looks a bit like it.  Notable differences are:<\/p>\n<ul>\n<li>Access to members is like lua \/ javascript.  x[&#8220;y&#8221;] and x.y mean the same thing.<\/li>\n<li>Most infix operators only work with numbers.  &#8220;x&#8221;+&#8221;y&#8221; won&#8217;t work.  (Rational: makes numerical math fast)<\/li>\n<li>It&#8217;s missing (and will never have) a bunch of really nice features.  Syntax checking is notably weak.  Maybe I should scrap my parser, etc and just use python&#8217;s.<\/li>\n<li>No exception handling.  Incorrect use of anything will result in a seg fault.<\/li>\n<\/ul>\n<p>Notable similarities:<\/p>\n<ul>\n<li>Language contains separate list and dict types.  I thought about doing like lua \/ javascript \/ php and having a single type, but it just didn&#8217;t feel right.<\/li>\n<li>It&#8217;s indented (duh)<\/li>\n<li>Garbage collection via libgc<\/li>\n<\/ul>\n<p>Well .. that&#8217;s about it.  I expect before I&#8217;m done I&#8217;ll make a game with it, to see how it works in the real world.  I&#8217;ve got a few more things on my TODO list to get done first.  If you are brave, check out svn:\/\/www.imitationpickles.org\/tinypy\/trunk and run .\/run_julia (linux) to see the julia demo.<\/p>\n<p>Oh, and for all you &#8220;test first&#8221; folks, I&#8217;ve (more or less) been doing that.  It&#8217;s made development considerably easier.  See the bottom of &#8220;pylang.py&#8221; &#8220;dumbparse.py&#8221; and &#8220;dumpout.py&#8221; for all the testing fun.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So .. I had a hard time resisting working on my 64k version of &#8220;python&#8221;. I&#8217;ve been able to get quite a few features into it and I&#8217;ve gotten my julia demo up to near-C speed as well as tamed the crazy memory problems I was having. I suppose the question I ponder is &#8220;why [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,6,19,8,2,32],"tags":[],"class_list":["post-52","post","type-post","status-publish","format-standard","hentry","category-crazy","category-development","category-gamedev","category-languages","category-python","category-tinypy"],"_links":{"self":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/52","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/comments?post=52"}],"version-history":[{"count":0,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/posts\/52\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/media?parent=52"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/categories?post=52"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.philhassey.com\/blog\/wp-json\/wp\/v2\/tags?post=52"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}