[{"data":1,"prerenderedAt":439},["ShallowReactive",2],{"project-8130413":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":15,"shown_in_year":16,"top":17,"tier":18,"category":19,"subcategory":20,"format":21,"keywords":22,"reception":26,"sentiment":27,"stance_mix":28,"scored_comments":33,"aspects":34,"strip":42,"post_text":43,"what":44,"said":71,"maker_in_thread":199,"shape":210,"grid":215,"attempts":404,"same_week":405,"maker_shows":259,"maker_hidden":431,"reader_version":432,"card":433},"8130413","carp","A small virtual machine written in C","title","Show HN: A small virtual machine written in C","https:\u002F\u002Fgithub.com\u002Ftekknolagi\u002Fcarp","github.com","tekknolagi",1407128655,2014,212,91,2272,5,"notable","dev_tools","virtual machine","cli",[20,23,24,25],"stack machine","c interpreter","bytecode","mixed",0.381,{"positive":29,"neutral":30,"mixed":31,"critical":32},12,8,1,4,25,{"design":35,"execution":37,"docs":39,"idea":40,"performance":41},{"positive":32,"critical":36},0,{"positive":32,"critical":38},3,{"positive":31,"critical":31},{"positive":31,"critical":36},{"positive":36,"critical":36},[17,36,38,36,36,36,17,38,17,36,36,17,36,17,17,36,36,38,38,36,38,31,36,31,31,31,36,36,38,36,36,17,17,36,17,38,38,17,17,17],null,{"problem":43,"audience":43,"pricing":43,"motivation":45,"time_to_build":53,"stack":60,"openness":68,"stage":69,"team_size":70},{"value":46,"source":47,"evidence":48},"Build a small, reliable VM from the ground up while learning C.","commenter",[49],{"id":50,"by":51,"text":52},"8131048","zencoder",">The goal is to try and build a small (and decently reliable) VM from the ground up, learning more and more C as I go. The author explicitly mentions, he is in the process of…",{"value":54,"source":55,"evidence":56},"About 6 months, on and off.","maker",[57],{"id":58,"by":11,"text":59},"8130432","I have been working on this project on and off for about 6 months. I would love feedback on the code, design - whatever!",[61],{"value":62,"source":55,"evidence":63},"C",[64,65],{"id":58,"by":11,"text":59},{"id":66,"by":11,"text":67},"8130556","Oh interesting. That sounds... complicated. Thanks! It's my first big C project that isn't hideous :D","open_source","prototype","solo",{"praise":72,"objections":98,"requests":130,"questions":155,"alternatives":168},[73,88],{"value":74,"source":47,"evidence":75},"Clean, concise implementation",[76,80,84],{"id":77,"by":78,"text":79},"8130480","papaf","The code looks really clean to me. If you feel the urge to convert the VM to a JIT, rather than calling function pointers for each instruction, you might find this blog post…",{"id":81,"by":82,"text":83},"8130470","dsturnbull2049","Very concise implementation. I keep thinking there's missing files or at least I'm missing something in my understanding. :) I wrote a 0-operand VM in C a few years ago that used…",{"id":85,"by":86,"text":87},"8130565","akkartik","Can you give some directions for how to run it? ``` $ git clone https:\u002F\u002Fgithub.com\u002Ftekknolagi\u002Fcarp $ make $ .\u002Fcarp $ .\u002Fcarp --help # after peeking in carp.c help msg ``` There's…",{"value":89,"source":47,"evidence":90},"Binop macro and X macro ideas",[91,95],{"id":92,"by":93,"text":94},"8130577","axman6","Seems like [1] could benefit from use of the X macro [2], should make adding new instructions much easier and you can avoid the hassle of having to keep two separate tables in…",{"id":96,"by":11,"text":97},"8130616","Ah, I feel you — no problem! I do really love the binop macro.",[99,109,119],{"value":100,"source":47,"evidence":101},"Build instructions and examples do not work out of the box",[102,103,106],{"id":85,"by":86,"text":87},{"id":104,"by":86,"text":105},"8130600","You're welcome. I pulled the new commits, but I'm still having trouble running the examples: ``` $ .\u002Fcarp -f examples\u002Fcarp\u002Fcall.carp Unknown label \u003Cadd> ``` (I am very interested…",{"id":107,"by":86,"text":108},"8130618","Nope, rebuilding didn't help.. never mind, I'll look into it later tonight. Edit: I just noticed you changed the target (why?) and are also immediately deleting carp.out. So I…",{"value":110,"source":47,"evidence":111},"No tests",[112,116],{"id":113,"by":114,"text":115},"8133877","ravyoli","Out of curiosity - How are you testing your VM? meaning, how do you know it actually works correctly? I didn't see any tests in the github repository",{"id":117,"by":11,"text":118},"8134192","I am not testing — and I know this is horrifying. I need to write some tests. D:",{"value":120,"source":47,"evidence":121},"Mixed register and stack instruction design is inconsistent",[122,126],{"id":123,"by":124,"text":125},"8130572","ghkbrew","Is there a reason for the combination of register-based (logical ops) and stack-based (arithmetic ops) operations? Otherwise fun project.",{"id":127,"by":128,"text":129},"8130593","panic","The implementation is really clean! The mixing of general-purpose registers, special-purpose registers and the stack makes the instruction set a bit weird, though. For example,…",[131,138,147],{"value":132,"source":55,"evidence":133},"Add tests",[134,135],{"id":117,"by":11,"text":118},{"id":136,"by":11,"text":137},"8171303","I am now starting to write some tests with libtap. If you are game, come help out! :D",{"value":139,"source":55,"evidence":140},"Add documentation and help message",[141,144],{"id":142,"by":11,"text":143},"8130570","Hi there! Sorry for this. I actually have a help message but for some reason I forgot to commit it. It's coming soon! You run the examples like so: carp -f…",{"id":145,"by":11,"text":146},"8130582","Alright, try now. Also — thanks for the pull request!",{"value":148,"source":47,"evidence":149},"Consider JIT compilation",[150,151],{"id":77,"by":78,"text":79},{"id":152,"by":153,"text":154},"8130602","TheHydroImpulse","You'd essentially be generating machine code on the fly and letting the cpu execute it, instead of interpreting anything yourself.",[156,161],{"value":157,"source":47,"evidence":158},"How to run the examples",[159,160],{"id":85,"by":86,"text":87},{"id":104,"by":86,"text":105},{"value":162,"source":47,"evidence":163},"Literature on VM design",[164],{"id":165,"by":166,"text":167},"8130789","manish_gill","Can anyone link me to some literature on VMs? Sure, I can analyse the code, but from a design perspective, I would love to learn more about how VMs work, where they can be used,…",[169,178,185,192],{"value":170,"source":55,"evidence":171},"MSP430 instruction set",[172,175],{"id":173,"by":11,"text":174},"8130809","So I started off following this (http:\u002F\u002Fen.wikibooks.org\u002Fwiki\u002FCreating_a_Virtual_Machine\u002FRegister_VM_in_C) which was interesting but clearly never super influential in my design…",{"id":176,"by":11,"text":177},"8132419","I started off following MSP430 but just kind of wanted to make my own thing.",{"value":179,"source":47,"evidence":180},"Lua VM",[181],{"id":182,"by":183,"text":184},"8130993","lindig","As inspiration, I would suggest to look at the virtual machine (byte code interpreter) of the Lua language. You can find several papers describing the design at…",{"value":186,"source":47,"evidence":187},"Synacor VM challenge",[188],{"id":189,"by":190,"text":191},"8133138","abhorrence","This is neat. For others interested in this sort of thing, https:\u002F\u002Fchallenge.synacor.com\u002F specifies a virtual machine, and comes with a binary that performs a self-test -- it is…",{"value":193,"source":47,"evidence":194},"LC3b VM course at Georgia Tech",[195],{"id":196,"by":197,"text":198},"8130725","cobookman","Very cool! Georgia Tech offers a class where you code a VM for the LC3b instruction set (http:\u002F\u002Fusers.ece.gatech.edu\u002F~moin\u002Fs13a\u002Fhw.html). It was a great learning experience, and…",{"comments":200,"answered":201,"key":202},38,16,[203,206,207],{"id":204,"text":205},"8130585","Definitely interesting — I shall take a look! Feel free to make a pull request if you're game.",{"id":96,"text":97},{"id":208,"text":209},"8130646","Quick question. Is that code you've given ok to use in the project? I just realized that I added and pushed without asking. GPL?",{"commenters":211,"max_depth":212,"maker_replies":200,"first_comment_mins":213,"lifespan_hours":214},30,10,7,214,[216,218,220,223,225,227,229,232,235,238,240,242,245,248,251,253,255,258,261,264,266,268,270,273,275,277,279,281,282,284,286,287,289,291,294,296,300,301,303,305,307,310,312,313,315,317,319,322,323,325,327,328,330,332,334,336,338,340,344,346,349,352,354,357,359,362,364,366,367,369,372,373,376,379,382,384,386,387,388,393,394,397,399,402],[92,36,17,217,93,36],"project\u002Fpositive\u002Fdesign",[204,36,36,219,11,31],"maker\u002Fpositive\u002Fnone",[221,36,36,222,93,36],"8130612","commenter\u002Fneutral\u002Fnone",[96,36,36,224,11,31],"maker\u002Fpositive\u002Fdesign",[208,36,36,226,11,31],"maker\u002Fneutral\u002Fnone",[228,36,38,226,93,36],"8130695",[230,36,36,231,11,31],"8130701","other\u002Fneutral\u002Fnone",[233,36,36,231,234,36],"8131617","zura",[236,36,36,231,237,36],"8132802","voidlogic",[239,36,36,231,11,31],"8133127",[241,36,36,231,234,36],"8133202",[243,36,36,231,244,36],"8133258","IgorPartola",[246,36,36,231,247,36],"8134132","Alupis",[249,36,17,217,250,36],"8130995","spatulon",[127,31,38,252,128,36],"project\u002Fmixed\u002Fdesign",[254,31,36,222,11,31],"8130598",[256,31,36,257,11,31],"8130636","project\u002Fneutral\u002Fdesign",[77,259,17,260,78,36],2,"project\u002Fpositive\u002Fexecution",[262,259,36,263,11,31],"8130488","project\u002Fneutral\u002Fperformance",[152,259,36,265,153,36],"commenter\u002Fneutral\u002Fperformance",[267,259,36,265,11,31],"8130611",[269,259,36,265,153,36],"8130628",[271,259,36,265,272,36],"8130632","chewxy",[274,259,36,226,11,31],"8130644",[276,259,17,260,78,36],"8130604",[278,259,36,222,11,31],"8130619",[58,38,36,280,11,31],"project\u002Fneutral\u002Fnone",[81,38,17,260,82,36],[283,38,36,226,11,31],"8130472",[285,38,17,217,272,36],"8130552",[66,38,36,219,11,31],[288,38,36,231,82,36],"8141437",[290,38,36,219,11,31],"8142998",[292,38,36,231,293,36],"8130564","Hytosys",[295,38,36,222,11,31],"8130586",[297,38,36,298,299,36],"8159327","other\u002Fcritical\u002Fperformance","listic",[123,38,38,257,124,36],[302,38,36,257,11,31],"8130613",[304,38,38,226,234,36],"8131639",[306,38,36,226,11,31],"8132395",[308,38,36,231,309,36],"8134023","wsc981",[311,38,36,231,234,36],"8139427",[182,32,38,257,183,36],[314,32,36,222,11,31],"8132390",[85,17,31,316,86,36],"project\u002Fcritical\u002Fdocs",[142,17,36,318,11,31],"maker\u002Fneutral\u002Fdocs",[320,17,36,321,11,31],"8130574","maker\u002Fneutral\u002Fexecution",[145,17,36,321,11,31],[104,17,31,324,86,36],"project\u002Fcritical\u002Fexecution",[326,17,36,321,11,31],"8130608",[107,17,31,324,86,36],[329,17,36,222,11,31],"8130620",[331,17,31,324,86,36],"8130808",[333,17,36,321,11,31],"8130837",[335,17,36,222,86,36],"8130854",[337,17,36,222,11,31],"8132680",[339,17,36,321,11,31],"8130638",[341,17,36,342,343,36],"8130748","other\u002Fpositive\u002Fnone","proxyswapi",[345,17,36,222,11,31],"8130757",[347,17,38,348,343,36],"8130905","project\u002Fneutral\u002Fidea",[350,17,36,351,11,31],"8132388","maker\u002Fneutral\u002Fidea",[50,353,36,222,51,36],6,[355,353,36,222,356,36],"8131691","TheSoftwareGuy",[358,353,36,226,11,31],"8132422",[360,353,36,222,361,36],"8136480","wtetzner",[189,213,17,363,190,36],"project\u002Fpositive\u002Fnone",[365,213,36,222,11,31],"8133248",[196,30,17,363,197,36],[368,30,36,222,11,31],"8130740",[165,370,36,371,166,36],9,"other\u002Fneutral\u002Fdocs",[173,370,36,318,11,31],[374,370,17,375,166,36],"8130827","maker\u002Fpositive\u002Fdocs",[377,370,38,348,378,36],"8131776","VLM",[380,370,38,263,381,36],"8132444","astrobe_",[383,370,36,371,381,36],"8132078",[113,212,38,385,114,36],"project\u002Fneutral\u002Fexecution",[117,212,36,385,11,31],[136,212,36,385,11,31],[389,390,17,391,392,36],"8131297",11,"project\u002Fpositive\u002Fidea","jheriko",[176,390,36,348,11,31],[395,29,17,217,396,36],"8130772","n1ghtmare_",[398,29,36,222,11,31],"8130779",[400,29,17,401,396,36],"8130865","maker\u002Fpositive\u002Fexecution",[403,29,36,226,11,31],"8132430",[],[406,410,415,419,423,427],{"id":407,"name":408,"points":409,"category":19},"8135967","Slate",192,{"id":411,"name":412,"points":413,"category":414},"8117100","The Deal Truck",132,"web_saas",{"id":416,"name":417,"points":413,"category":418},"8122911","Omive","consumer_social",{"id":420,"name":421,"points":422,"category":19},"8118233","Emacs Mini Manual",130,{"id":424,"name":425,"points":426,"category":418},"8129123","Workfrom",117,{"id":428,"name":429,"points":430,"category":19},"8116525","hn",98,false,"v2",{"id":434,"name":5,"line":6,"ai":431,"cat":19,"year":13,"points":14,"comments":15,"rec":26,"s":435,"top":17,"kw":436,"maker":11,"domain":10,"tier":18,"attempts":36,"strip":437,"url":9,"mix":438,"praise":74,"objection":100,"sub":20},8130413,0.38,[20,23,24,25],"5030005350050550033031011100300550533555",[29,30,31,32],1794036520880]