[{"data":1,"prerenderedAt":544},["ShallowReactive",2],{"project-42311031":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":21,"format":22,"keywords":23,"reception":27,"sentiment":28,"stance_mix":29,"scored_comments":33,"aspects":34,"strip":40,"post_text":44,"what":45,"said":84,"maker_in_thread":163,"shape":170,"grid":174,"attempts":497,"same_week":505,"maker_shows":42,"maker_hidden":536,"reader_version":537,"card":538},"42311031","30cc","My C compiler compiled itself","title","Show HN: My C compiler compiled itself","https:\u002F\u002Fgithub.com\u002Fkeyvank\u002F30cc","github.com","keyvank",1733258124,2024,275,128,243,3515,7,"legend","languages","c compiler","cli",[21,24,25,26],"self-hosting compiler","bootstrapping","compiler construction","loved",0.467,{"positive":30,"neutral":31,"mixed":32,"critical":32},11,9,1,22,{"execution":35,"design":38,"idea":39},{"positive":36,"critical":37},2,0,{"positive":32,"critical":37},{"positive":37,"critical":32},[41,37,37,37,37,37,37,37,41,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,37,41,41,42,43,41,41,41,43,32],5,3,4,"One of the most challenging projects of my life :)",{"problem":46,"audience":55,"pricing":55,"motivation":56,"time_to_build":55,"stack":63,"openness":81,"stage":82,"team_size":83},{"value":47,"source":48,"evidence":49},"Builds a small C compiler that compiles itself","maker",[50,52],{"id":51},"post",{"id":53,"by":11,"text":54},"42316237","i learnt that building a c compiler isn't that hard, just takes time :)",null,{"value":57,"source":48,"evidence":58},"Challenge and fun; wanted something small and self-hosting",[59,60],{"id":51},{"id":61,"by":11,"text":62},"42316250","i think it just supports smth like 70% of C. I didn't bother supporting floating-point operators, or arrays (I mean, malloc and pointers are fine) or etc. I just wanted smth…",[64,76],{"value":65,"source":66,"evidence":67},"C","inferred",[68,72],{"id":69,"by":70,"text":71},"42316165","unwind","Very cool, congratulations! I took a 2-second peek at the code, and just wanted to offer a small piece of advice that I think makes it better. Or two, really. Counting is hard.…",{"id":73,"by":74,"text":75},"42313135","yjftsjthsd-h","> Then run .\u002Fbuild.py. This will use the bootstrapped 30cc-compiler to compile 30cc itself. It then again uses the 30cc-compiled compiler to compile 30cc once again. The final…",{"value":77,"source":78,"evidence":79},"Python (build script)","commenter",[80],{"id":73,"by":74,"text":75},"open_source","launched","unknown",{"praise":85,"objections":113,"requests":124,"questions":136,"alternatives":148},[86,102],{"value":87,"source":78,"evidence":88},"Congratulations and impressive achievement",[89,90,94,98],{"id":73,"by":74,"text":75},{"id":91,"by":92,"text":93},"42312633","jesse__","Congratulations!",{"id":95,"by":96,"text":97},"42313625","anyfoo","Congratulations! That's no small feat.",{"id":99,"by":100,"text":101},"42319959","rangerelf","Congrats!!",{"value":103,"source":78,"evidence":104},"Interesting bootstrapping project",[105,109],{"id":106,"by":107,"text":108},"42334418","pabs3","Sounds like you might be someone interested in the Bootstrappable Builds project: https:\u002F\u002Fbootstrappable.org\u002F https:\u002F\u002Flwn.net\u002FArticles\u002F983340\u002F",{"id":110,"by":111,"text":112},"42313181","michael-online","What a fun project, thanks for sharing. I've dreamed of projects like this. What did you expect to learn from this project? Did you learn anything unexpected?",[114,118],{"value":115,"source":48,"evidence":116},"Supports only about 70% of C; no floating-point or arrays",[117],{"id":61,"by":11,"text":62},{"value":119,"source":48,"evidence":120},"Cannot compile some syntax like void* casts without type errors",[121],{"id":122,"by":11,"text":123},"42316225","thanks man! yes that makes sense. unfortunately 30cc is not able to compile that syntax, and will probably give type-checker errors when passing a void* to pointer of another…",[125,129],{"value":126,"source":78,"evidence":127},"Use Makefile instead of Python build script",[128],{"id":73,"by":74,"text":75},{"value":130,"source":78,"evidence":131},"Explain why three compilation steps",[132],{"id":133,"by":134,"text":135},"42315280","teo_zero","Nice job! But why 3 steps of compilation? The first step merely shows that you wrote valid C code that gcc can compile. It doesn't prove that the program actually does what…",[137,141],{"value":138,"source":78,"evidence":139},"Were you constrained in C usage to allow self-compilation?",[140],{"id":73,"by":74,"text":75},{"value":142,"source":78,"evidence":143},"Would the two compiled binaries be identical?",[144],{"id":145,"by":146,"text":147},"42319296","mizzao","Out of curiosity: would .\u002F30cc_gcc (30cc complied by gcc-hosted 30cc) and .\u002F30cc (30cc complied by self-hosted 30cc) be identical binary files, if 30cc was operating as expected?",[149,156],{"value":150,"source":78,"evidence":151},"Small-C compiler by James E Hendrix",[152],{"id":153,"by":154,"text":155},"42319765","euroderf","Similar: \"A Small-C Compiler\", by James E Hendrix (not Jim E, not Jimi). Modify source, compile self, repeat. This repo claims to have the code: https:\u002F\u002Fgithub.com\u002FDosWorld\u002Fsmallc",{"value":157,"source":78,"evidence":158},"cp2 compiler-compiler",[159],{"id":160,"by":161,"text":162},"42313449","jheriko","nice work. if you want more of a challenge try a compiler compiler that can compile itself... :) i got pretty far with this myself, although it doesn't work for weirdo languages…",{"comments":31,"answered":43,"key":164},[165,166,167],{"id":122,"text":123},{"id":61,"text":62},{"id":168,"text":169},"42334449","that’s why i love HN. tnx for the links!",{"commenters":171,"max_depth":30,"maker_replies":31,"first_comment_mins":172,"lifespan_hours":173},69,147,140,[175,177,179,182,186,189,192,195,199,203,206,209,211,214,217,219,222,225,228,231,234,236,238,240,242,245,248,250,253,255,258,260,263,266,269,272,275,277,280,283,285,288,291,293,295,297,299,301,303,306,308,310,312,314,316,319,321,324,327,329,332,335,337,339,342,344,346,348,350,352,354,356,359,362,364,366,369,372,375,377,380,383,385,388,391,393,396,398,401,402,403,405,406,408,411,413,416,418,421,423,425,427,430,432,435,437,439,442,444,446,448,451,454,456,458,460,462,464,466,468,470,474,478,483,485,488,492,494],[69,37,41,176,70,37],"project\u002Fpositive\u002Fexecution",[122,37,37,178,11,32],"maker\u002Fneutral\u002Fexecution",[180,37,42,181,70,37],"42316253","project\u002Fneutral\u002Fexecution",[183,37,37,184,185,37],"42317280","commenter\u002Fneutral\u002Fnone","nar001",[187,37,37,184,188,37],"42317366","hollerith",[190,37,37,184,191,37],"42322610","quuxplusone",[193,37,37,184,194,37],"42317354","dataflow",[196,37,37,197,198,37],"42326562","other\u002Fneutral\u002Fnone","Gibbon1",[200,37,37,201,202,37],"42319575","commenter\u002Fneutral\u002Fexecution","KerrAvon",[204,37,37,201,205,37],"42319715","munch117",[207,37,37,201,208,37],"42319937","cataphract",[210,37,37,201,202,37],"42319611",[212,37,37,201,213,37],"42320834","dcuthbertson",[215,37,37,184,216,37],"42316244","gizmo",[218,37,37,184,70,37],"42316625",[220,37,37,184,221,37],"42317489","solarengineer",[223,37,37,184,224,37],"42317556","williamdclt",[226,37,37,184,227,37],"42319558","cschep",[229,37,37,184,230,37],"42317000","dominicrose",[232,37,37,201,233,37],"42317545","peterfirefly",[235,37,37,201,213,37],"42321093",[237,37,37,201,191,37],"42322728",[239,37,37,184,213,37],"42327799",[241,37,37,201,134,37],"42337070",[243,37,37,184,244,37],"42319738","tetha",[246,37,37,184,247,37],"42325216","_proofs",[73,32,41,249,74,37],"project\u002Fpositive\u002Fdesign",[251,32,37,197,252,37],"42313409","__alexander",[254,32,37,197,96,37],"42313608",[256,32,37,184,257,37],"42313807","aleph_minus_one",[259,32,37,184,96,37],"42313855",[261,32,37,197,262,37],"42315041","3836293648",[264,32,37,197,265,37],"42315583","Tor3",[267,32,37,197,268,37],"42316261","robinsonb5",[270,32,37,197,271,37],"42316482","pm215",[273,32,37,197,274,37],"42314018","unclad5968",[276,32,37,197,96,37],"42314086",[278,32,37,197,279,37],"42314414","IgorPartola",[281,32,37,184,282,37],"42319843","fuzztester",[284,32,37,184,279,37],"42325056",[286,32,37,197,287,37],"42314672","CJefferson",[289,32,37,197,290,37],"42314760","fuhsnn",[292,32,37,197,96,37],"42314800",[294,32,37,197,74,37],"42314982",[296,32,37,197,287,37],"42315061",[298,32,37,197,96,37],"42315817",[300,32,37,197,287,37],"42316121",[302,32,37,197,96,37],"42316264",[304,32,37,197,305,37],"42317194","dezgeg",[307,32,37,197,96,37],"42314785",[309,32,37,197,287,37],"42315670",[311,32,37,197,96,37],"42315800",[313,32,37,197,287,37],"42316135",[315,32,37,197,96,37],"42316260",[317,32,37,197,318,37],"42318847","exe34",[320,32,37,197,287,37],"42335696",[322,32,37,197,323,37],"42315189","saghm",[325,32,37,197,326,37],"42315587","mturmon",[328,32,37,197,96,37],"42315874",[330,32,37,197,331,37],"42316992","mschuster91",[333,32,37,334,323,37],"42320985","commenter\u002Fneutral\u002Fdocs",[336,32,37,334,96,37],"42321717",[338,32,37,334,233,37],"42317590",[340,32,37,197,341,37],"42317034","dzaima",[343,32,37,197,96,37],"42321579",[345,32,37,197,341,37],"42322474",[347,32,37,197,96,37],"42322849",[349,32,37,334,233,37],"42317888",[351,32,37,184,96,37],"42320667",[353,32,37,197,233,37],"42323002",[355,32,37,197,134,37],"42337269",[357,32,37,334,358,37],"42314729","akira2501",[360,32,37,197,361,37],"42316567","yodsanklai",[363,32,37,197,274,37],"42319754",[365,32,37,184,323,37],"42315062",[367,32,37,197,368,37],"42314143","bluGill",[370,32,37,197,371,37],"42313508","dbcurtis",[373,32,37,197,374,37],"42316730","abirch",[376,32,37,197,224,37],"42317573",[378,32,37,197,379,37],"42317645","atq2119",[381,32,37,197,382,37],"42318851","swiftcoder",[384,32,37,197,107,37],"42334385",[386,32,37,197,387,37],"42317694","mbreese",[389,32,37,197,390,37],"42318251","norir",[392,32,37,197,107,37],"42334393",[394,32,37,197,395,37],"42318880","wqweto",[397,32,37,197,244,37],"42319934",[399,32,37,197,400,37],"42317729","ijustlovemath",[61,32,37,178,11,32],[106,36,37,197,107,37],[168,36,37,404,11,32],"maker\u002Fpositive\u002Fnone",[160,42,37,197,161,37],[407,42,37,184,96,37],"42313620",[409,42,37,184,410,37],"42314013","Koshkin",[412,42,37,184,96,37],"42314027",[414,42,37,184,415,37],"42314682","downboots",[417,42,37,184,96,37],"42314838",[419,42,37,184,420,37],"42314952","ModernMech",[422,42,37,184,96,37],"42316123",[110,43,42,424,111,37],"maker\u002Fneutral\u002Fidea",[53,43,37,426,11,32],"maker\u002Fneutral\u002Fnone",[428,41,41,404,429,37],"42317415","p0w3n3d",[153,431,37,197,154,37],6,[433,18,41,404,434,37],"42312634","pjdkoch",[436,18,37,404,11,32],"42312757",[145,438,42,181,146,37],8,[440,438,42,181,441,37],"42319413","actionfromafar",[443,438,42,181,146,37],"42361584",[445,438,42,181,441,37],"42367733",[447,438,37,181,11,32],"42321134",[449,31,41,404,450,37],"42313124","disqard",[133,452,42,453,134,37],10,"project\u002Fmixed\u002Fexecution",[455,452,37,178,11,32],"42315313",[457,452,41,176,379,37],"42317792",[459,452,37,404,11,32],"42317936",[461,30,42,424,233,37],"42317926",[95,463,41,404,96,37],12,[99,465,41,404,100,37],13,[91,467,41,404,92,37],14,[469,467,37,404,11,32],"42312758",[471,472,41,404,473,37],"42313034",15,"ajxs",[475,476,41,404,477,37],"42313165",16,"hasheddan",[479,480,42,481,482,37],"42313587",17,"project\u002Fneutral\u002Fidea","DrNosferatu",[484,480,42,481,96,37],"42313596",[486,480,37,487,482,37],"42322990","commenter\u002Fneutral\u002Fidea",[489,480,32,490,491,37],"42313945","project\u002Fcritical\u002Fidea","mananaysiempre",[493,480,37,197,96,37],"42314021",[495,480,37,197,496,37],"42318295","ksk23",[498,501,504],{"id":499,"t":500,"points":42,"comments":37},"41857427",1729073934,{"id":502,"t":503,"points":36,"comments":37},"42086137",1731066899,{"id":4,"t":12,"points":14,"comments":15},[506,511,516,521,526,531],{"id":507,"name":508,"points":509,"category":510},"42289690","Markwhen",912,"productivity",{"id":512,"name":513,"points":514,"category":515},"42284412","Privastead",551,"security_privacy",{"id":517,"name":518,"points":519,"category":520},"42320032","Outerbase Studio",356,"dev_tools",{"id":522,"name":523,"points":524,"category":525},"42270389","Vince",283,"infrastructure",{"id":527,"name":528,"points":529,"category":530},"42261909","Voice-Pro",271,"creative",{"id":532,"name":533,"points":534,"category":535},"42295792","SeekStorm",245,"data",false,"v2",{"id":539,"name":5,"line":6,"ai":536,"cat":20,"year":13,"points":14,"comments":15,"rec":27,"s":540,"top":18,"kw":541,"maker":11,"domain":10,"tier":19,"attempts":42,"strip":542,"url":9,"mix":543,"praise":87,"objection":115,"sub":21},42311031,0.47,[21,24,25,26],"5000000050000000000000000000000553455541",[30,31,32,32],1794036665313]