[{"data":1,"prerenderedAt":246},["ShallowReactive",2],{"project-23017085":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":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":5,"format":21,"keywords":22,"reception":26,"sentiment":27,"stance_mix":28,"scored_comments":32,"aspects":33,"strip":39,"post_text":40,"what":41,"said":63,"maker_in_thread":156,"shape":162,"grid":166,"attempts":208,"same_week":209,"maker_shows":237,"maker_hidden":238,"reader_version":239,"card":240},"23017085","compiler","A compiler for a small language into x86-64 assembly","title","Show HN: A compiler for a small language into x86-64 assembly","https:\u002F\u002Fgithub.com\u002FMauriceGit\u002Fcompiler","github.com","EllipticCurve",1588151698,2020,74,22,842,3028,28,"notable","languages","cli",[5,23,24,25],"x86-64 assembly","small language","code generation","loved",0.417,{"positive":29,"neutral":30,"mixed":31,"critical":31},5,1,0,6,{"performance":34,"docs":35,"design":36,"idea":38},{"positive":30,"critical":31},{"positive":31,"critical":31},{"positive":37,"critical":31},3,{"positive":30,"critical":31},[31,29,31,37,31,29,31,29,31,29,31,29,31,31,31,31,31,31,31,31,31,31],null,{"problem":42,"audience":40,"pricing":40,"motivation":52,"time_to_build":40,"stack":59,"openness":60,"stage":61,"team_size":62},{"value":43,"source":44,"evidence":45},"Learning and implementing compiler stages from source to x86-64 assembly","maker",[46,49],{"id":47,"by":11,"text":48},"23017100","This is my first compiler, so I expect there to be several things I can improve :) I tried to follow the Assembly calling conventions the best I could. I am looking forward to…",{"id":50,"by":11,"text":51},"23036122","Those are some of my currently open tabs :) Lots of Google use on top of that. The parser is actually quite straight forward. The much harder part (for me) was the code…",{"value":53,"source":44,"evidence":54},"Wanted to build a first compiler and understand each step manually",[55,56],{"id":47,"by":11,"text":48},{"id":57,"by":11,"text":58},"23036021","Yes, I did (at least a bit). That and I read, that Go has a build-in yacc as well. But decided, that for the first compiler, I want to actually do all steps manually myself for…",[],"unknown","prototype","solo",{"praise":64,"objections":84,"requests":97,"questions":116,"alternatives":125},[65,77],{"value":66,"source":67,"evidence":68},"Simple, clean syntax and language flow","commenter",[69,73],{"id":70,"by":71,"text":72},"23035990","lioeters","Very cool! Reading the \"Why\" section resonated with me, as I think creating one's own language is something every programmer should do for the experience. The syntax flows well,…",{"id":74,"by":75,"text":76},"23040408","kreco","Sorry I won't be able to give you a lot of feedback. As a matter or preference I really like colons and semi-colons. That said your work is amazing. This is a true example of…",{"value":78,"source":67,"evidence":79},"Motivating for learning compilers",[80],{"id":81,"by":82,"text":83},"23036481","saintfiends","Thank you for this. I like that it's small enough to be motivational instead of being complex and intimidating. World needs more of these for other complex topics.",[85,91],{"value":86,"source":44,"evidence":87},"Performance is only about 90% of C at -O0 with no optimization yet",[88],{"id":89,"by":11,"text":90},"23036105","Thanks :) That's where I was trying to get to. I did some smaller performance comparisons against C (with -O0), where I was at about 90% speed. But there is a lot of performance…",{"value":92,"source":44,"evidence":93},"Missing strings, files and input",[94],{"id":95,"by":11,"text":96},"23036345",":) I (now) agree. In fact, each part isn't even really that hard. It's mostly just a lot to work. And then code generation. I had some headaches with multiple return values and…",[98,105],{"value":99,"source":67,"evidence":100},"Intermediate representation or optimization suggestions",[101],{"id":102,"by":103,"text":104},"23033520","kragen","Congratulations! It looks like a useful and practical design. How is the performance of the generated code? What are you thinking about doing for memory management? Have you…",{"value":106,"source":67,"evidence":107},"Advice on learning compiler construction",[108,112],{"id":109,"by":110,"text":111},"23034401","tmountain","Very cool. What resources did you use to learn how to write the compiler? The \"turn code into ASM\" step has always mystified me, and I'd like to learn more about how that part of…",{"id":113,"by":114,"text":115},"23039296","Veera_Sivarajan","What would be your advice to someone who's about to write a compiler? I'm planning to start by reading the Dragon book.",[117,121],{"value":118,"source":67,"evidence":119},"How is generated code performance and memory management handled",[120],{"id":102,"by":103,"text":104},{"value":122,"source":67,"evidence":123},"Use cases and whether it can run on Raspberry Pi",[124],{"id":70,"by":71,"text":72},[126,137,144],{"value":127,"source":67,"evidence":128},"FASM, YASM, NASM assemblers",[129,133],{"id":130,"by":131,"text":132},"23033536","smlckz","You can try FASM (http:\u002F\u002Fflatassembler.net) besides YASM and ld.",{"id":134,"by":135,"text":136},"23035182","fao_","Well this is funny. Originally (a number of years ago) I looked at using MASM, then I was informed to switch to MASM. Then (last year or something) I find out YASM is actually…",{"value":138,"source":67,"evidence":139},"ANTLR parser generator",[140],{"id":141,"by":142,"text":143},"23035831","itsmemattchung","Curios if you looked into ANTLR? That's what was used most recently as part of my compiler's course at Georgia Tech.",{"value":145,"source":67,"evidence":146},"Dragon book and other compiler textbooks",[147,148,152],{"id":113,"by":114,"text":115},{"id":149,"by":150,"text":151},"23039692","abnercoimbre","You both should try \"Compiler Construction: Principles and Practice\" [0]. Theory is interleaved with substantial examples and exercises. You create an entire compiler for a tiny…",{"id":153,"by":154,"text":155},"23040044","nils-m-holm","http:\u002F\u002Ft3x.org\u002Ft3x\u002Findex.html#t3x9 If you plan to buy the book, you will have to go to Lulu.com and search for it, as order links seem to be down after a site redesign.",{"comments":157,"answered":32,"key":158},9,[159,160,161],{"id":47,"text":48},{"id":89,"text":90},{"id":50,"text":51},{"commenters":163,"max_depth":37,"maker_replies":157,"first_comment_mins":164,"lifespan_hours":165},14,2,52,[167,169,171,173,175,176,178,180,182,185,188,190,191,193,195,197,198,199,200,203,204,205],[47,31,31,168,11,30],"project\u002Fneutral\u002Fnone",[102,31,29,170,103,31],"maker\u002Fpositive\u002Fperformance",[89,31,31,172,11,30],"project\u002Fneutral\u002Fperformance",[109,31,37,174,110,31],"maker\u002Fneutral\u002Fdocs",[50,31,31,174,11,30],[70,31,29,177,71,31],"project\u002Fpositive\u002Fdesign",[95,31,31,179,11,30],"project\u002Fneutral\u002Fdesign",[81,31,29,181,82,31],"project\u002Fpositive\u002Fidea",[183,31,31,184,11,30],"23036811","maker\u002Fneutral\u002Fnone",[186,31,29,177,187,31],"23036702","hnta2522",[189,31,31,184,11,30],"23041539",[74,31,29,177,75,31],[192,31,31,168,11,30],"23040705",[130,30,31,194,131,31],"other\u002Fneutral\u002Fnone",[134,30,31,196,135,31],"commenter\u002Fneutral\u002Fnone",[141,164,31,194,142,31],[57,164,31,184,11,30],[113,37,31,194,114,31],[201,37,31,194,202,31],"23039326","tonyedgecombe",[149,37,31,194,150,31],[153,37,31,194,154,31],[206,37,31,207,11,30],"23040087","maker\u002Fpositive\u002Fnone",[],[210,215,219,224,228,233],{"id":211,"name":212,"points":213,"category":214},"23006794","Editly",429,"dev_tools",{"id":216,"name":217,"points":218,"category":214},"23021295","Insomnia Designer",317,{"id":220,"name":221,"points":222,"category":223},"22985055","Kanmail",271,"productivity",{"id":225,"name":226,"points":227,"category":214},"22996374","delta",261,{"id":229,"name":230,"points":231,"category":232},"22979288","exchangerate.host",249,"finance_crypto",{"id":234,"name":235,"points":236,"category":223},"22974380","Help Me Decide Please",194,7,false,"v2",{"id":241,"name":5,"line":6,"ai":238,"cat":20,"year":13,"points":14,"comments":15,"rec":26,"s":242,"top":18,"kw":243,"maker":11,"domain":10,"tier":19,"attempts":31,"strip":244,"url":9,"mix":245,"praise":66,"objection":86,"sub":5},23017085,0.42,[5,23,24,25],"0503050505050000000000",[29,30,31,31],1794036589728]