[{"data":1,"prerenderedAt":376},["ShallowReactive",2],{"project-46759520":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":28,"sentiment":29,"stance_mix":30,"scored_comments":35,"aspects":36,"strip":42,"post_text":43,"what":44,"said":67,"maker_in_thread":170,"shape":181,"grid":185,"attempts":338,"same_week":339,"maker_shows":38,"maker_hidden":368,"reader_version":369,"card":370},"46759520","Herd","A small programming language where everything is pass-by-value","title","Show HN: A small programming language where everything is pass-by-value","https:\u002F\u002Fgithub.com\u002FJcparkyn\u002Fherd","github.com","jcparkyn",1769382066,2026,91,61,752,4366,18,"notable","languages","programming language","other",[24,21,25,26,27],"pass-by-value","copy-on-write","value semantics","cranelift","curious",-0.072,{"positive":31,"neutral":32,"mixed":33,"critical":34},3,21,1,5,30,{"idea":37,"performance":39,"design":41},{"positive":38,"critical":31},2,{"positive":40,"critical":40},0,{"positive":33,"critical":38},[34,31,40,40,31,31,31,31,40,31,40,31,31,31,31,40,40,33,40,40,40,40,31,40,31,33,31,31,31,40,31,34,33,40,31,31,33,40,31,34],"This is a hobby project of mine that I started a few years ago to learn about programming language implementation. It was created 95% without AI, although a few recent commits include code from Gemini CLI.\n\nI started out following Crafting Interpreters, but gradually branched off that until I had almost nothing left in common.\n\nTech stack: Rust, Cranelift (JIT compilation), LALRPOP (parser).\n\nOriginal title: \"A small programming language where everything is a value\" (edited based on comments)",{"problem":45,"audience":45,"pricing":45,"motivation":46,"time_to_build":45,"stack":52,"openness":65,"stage":65,"team_size":66},null,{"value":47,"source":48,"evidence":49},"Hobby project to learn about programming language implementation.","maker",[50],{"id":51},"post",[53,57,61],{"value":54,"source":48,"evidence":55},"Rust",[56],{"id":51},{"value":58,"source":48,"evidence":59},"Cranelift (JIT compilation)",[60],{"id":51},{"value":62,"source":48,"evidence":63},"LALRPOP (parser)",[64],{"id":51},"unknown","solo",{"praise":68,"objections":84,"requests":109,"questions":122,"alternatives":137},[69,77],{"value":70,"source":71,"evidence":72},"Value semantics with copy-on-write gives data-race immunity without locks","commenter",[73],{"id":74,"by":75,"text":76},"46760723","augusteo","The threading story here is what grabbed my attention. Pass-by-value with copy-on-write means you get data-race immunity without any locks or channels. You just pass data to a…",{"value":78,"source":71,"evidence":79},"The pipe-equal operator is neat",[80],{"id":81,"by":82,"text":83},"46761261","zem","the pipe-equal operator is pretty neat, don't think I've seen any other language do that.",[85,96,102],{"value":86,"source":71,"evidence":87},"Pass-by-value is misleading since it is implemented by reference counting",[88,92],{"id":89,"by":90,"text":91},"46760959","sheepscreek","Hmm this is a bit like peeling a banana only to throw the banana and eat the peel. Pass by value reduces the true benefit of copy-on-write. Use immutable pass by reference. Make…",{"id":93,"by":94,"text":95},"46761174","jagged-chisel","Pass-by-value is already a copy.",{"value":97,"source":48,"evidence":98},"Atomic reference counting carries a performance cost",[99],{"id":100,"by":11,"text":101},"46761124","> Use immutable pass by reference. Make a copy only if mutability is requested in the thread. This is essentially what Herd does. It's only semantically a pass by value, but the…",{"value":103,"source":71,"evidence":104},"Hard to thread state through programs and build custom data structures without references",[105],{"id":106,"by":107,"text":108},"46765362","electroly","My hobby language[1] also has no reference semantics, very similar to Herd. I think this is a really interesting point in the design space. A lot of complexity goes away when…",[110,114],{"value":111,"source":71,"evidence":112},"Benchmark real workloads for copy-on-write performance",[113],{"id":74,"by":75,"text":76},{"value":115,"source":71,"evidence":116},"Use persistent immutable data structures",[117,118],{"id":106,"by":107,"text":108},{"id":119,"by":120,"text":121},"46764308","anacrolix","Nobody has heard of persistent data structures?!",[123,130],{"value":124,"source":71,"evidence":125},"How mutable references or passing mutation into functions work",[126],{"id":127,"by":128,"text":129},"46762363","Panzerschrek","But what if mutation is intended? How to pass a mutable reference into a function, so that it can change the underlying value and the caller can observe these changes? What about…",{"value":131,"source":71,"evidence":132},"Whether everything being a value is possible given reduction",[133],{"id":134,"by":135,"text":136},"46760245","discarded1023","At the risk of telling you what you already know and\u002For did not mean to say: not everything can be a value. If everything is a value then no computation (reduction) is possible.…",[138,145,149,156,163],{"value":139,"source":71,"evidence":140},"Euphoria",[141],{"id":142,"by":143,"text":144},"46760254","ekipan","(Edit: in the old post title:) \"everything is a value\" is not very informative. That's true of most languages nowadays. Maybe \"exclusively call-by-value\" or \"without reference…",{"value":146,"source":71,"evidence":147},"Standard ML",[148],{"id":134,"by":135,"text":136},{"value":150,"source":71,"evidence":151},"Haskell",[152],{"id":153,"by":154,"text":155},"46763232","tromp","This sounds quite similar to pure functional languages like Haskell, where a function call cannot have any side effect. But those go further in that they don't even have any…",{"value":157,"source":71,"evidence":158},"Nim",[159],{"id":160,"by":161,"text":162},"46762122","netbioserror","Nim has a similar, strong preference for value semantics. However, its dynamic heap types (strings, seqs, tables) are all implemented as wrappers that hide the internal…",{"value":164,"source":71,"evidence":165},"Swift",[166],{"id":167,"by":168,"text":169},"46789901","MetricExpansion","Swift actually does this copy-on-mutation strategy as well for its standard library’s container types like Array and Dictionary, and it does indeed make multithreaded programming…",{"comments":171,"answered":172,"key":173},16,10,[174,175,178],{"id":100,"text":101},{"id":176,"text":177},"46761167","> Have you benchmarked any real workloads? Nothing \"real\", just the synthetic benchmarks in the .\u002Fbenchmarks dir. Unnecessary copies are definitely a risk, and there's certain…",{"id":179,"text":180},"46761198","It's only semantically a pass-by-value, in reality a reference is passed and the data is only copied if needed (i.e. value is mutated while shared).",{"commenters":182,"max_depth":183,"maker_replies":171,"first_comment_mins":184,"lifespan_hours":184},34,8,88,[186,188,190,191,195,199,200,203,205,206,209,211,213,215,217,220,224,227,229,233,235,236,238,241,244,247,249,251,254,257,259,262,265,267,270,271,273,276,280,284,286,289,291,293,296,298,302,304,307,309,311,313,317,319,321,323,327,329,332,334,336],[74,40,34,187,75,40],"project\u002Fpositive\u002Fidea",[89,40,31,189,90,40],"project\u002Fneutral\u002Fperformance",[100,40,40,189,11,33],[192,40,40,193,194,40],"46761159","commenter\u002Fneutral\u002Fnone","doug-moen",[196,40,40,197,198,40],"46765141","other\u002Fneutral\u002Fnone","postepowanieadm",[176,40,40,189,11,33],[201,40,31,189,202,40],"46761752","wging",[93,40,31,204,94,40],"project\u002Fneutral\u002Fidea",[179,40,40,189,11,33],[207,40,31,204,208,40],"46761504","zahlman",[210,40,40,204,11,33],"46761600",[212,40,31,189,208,40],"46761851",[214,40,40,189,11,33],"46763531",[216,40,31,189,208,40],"46765932",[218,40,31,204,219,40],"46761227","rao-v",[221,40,40,222,223,40],"46762589","commenter\u002Fneutral\u002Fperformance","vbezhenar",[225,40,40,222,226,40],"46764873","gf000",[228,40,31,204,208,40],"46761487",[230,40,31,231,232,40],"46761670","project\u002Fneutral\u002Fdesign","ddtaylor",[234,40,40,193,208,40],"46761837",[167,40,31,204,168,40],[142,33,31,237,143,40],"project\u002Fneutral\u002Fnone",[239,33,40,197,240,40],"46760371","p1necone",[242,33,40,243,11,33],"46760629","maker\u002Fneutral\u002Fnone",[245,38,40,197,246,40],"46760483","fjfaase",[134,31,33,248,135,40],"project\u002Fcritical\u002Fidea",[250,31,40,204,11,33],"46760343",[252,31,40,193,253,40],"46762290","throwaway17_17",[255,31,40,256,194,40],"46760511","commenter\u002Fneutral\u002Fidea",[258,31,40,193,226,40],"46760892",[260,31,40,193,261,40],"46761626","bayesnet",[263,31,40,193,264,40],"46763110","DemocracyFTW2",[160,266,40,197,161,40],4,[268,266,31,204,269,40],"46811434","vrighter",[153,34,31,204,154,40],[272,34,40,204,11,33],"46763410",[106,274,31,275,107,40],6,"project\u002Fmixed\u002Fidea",[277,278,31,189,279,40],"46762369",7,"tylerhou",[281,183,33,282,283,40],"46765042","project\u002Fcritical\u002Fdesign","jasperry",[285,183,40,231,11,33],"46775419",[287,183,31,288,283,40],"46795822","maker\u002Fneutral\u002Fdesign",[127,290,31,204,128,40],9,[292,290,40,231,11,33],"46763595",[294,172,31,189,295,40],"46760692","jbritton",[297,172,40,189,11,33],"46760949",[299,300,31,204,301,40],"46761594",11,"travisgriggs",[303,300,40,193,253,40],"46762364",[81,305,34,306,82,40],12,"project\u002Fpositive\u002Fdesign",[308,305,33,282,253,40],"46762416",[119,310,33,248,120,40],13,[312,310,40,189,11,33],"46775371",[314,315,31,204,316,40],"46760259",14,"rvba",[318,315,40,231,11,33],"46760375",[320,315,31,231,316,40],"46784974",[322,315,40,231,11,33],"46805430",[324,325,33,248,326,40],"46760501",15,"drnick1",[328,325,40,204,11,33],"46760556",[330,325,31,231,331,40],"46761125","globalnode",[333,325,40,231,11,33],"46761676",[335,325,34,187,331,40],"46762382",[337,325,40,256,253,40],"46762470",[],[340,345,350,355,359,364],{"id":341,"name":342,"points":343,"category":344},"46721802","isometric.nyc",1325,"ai",{"id":346,"name":347,"points":348,"category":349},"46793693","HN Arcade",352,"consumer_social",{"id":351,"name":352,"points":353,"category":354},"46779522","one-agent-one-browser",324,"dev_tools",{"id":356,"name":357,"points":358,"category":349},"46802254","Moltbook",287,{"id":360,"name":361,"points":362,"category":363},"46731432","Whosthere",278,"infrastructure",{"id":365,"name":366,"points":367,"category":20},"46753301","Bonsplit",245,false,"v2",{"id":371,"name":5,"line":6,"ai":368,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":372,"top":18,"kw":373,"maker":11,"domain":10,"tier":19,"attempts":40,"strip":374,"url":9,"mix":375,"praise":70,"objection":86,"sub":21},46759520,-0.07,[24,21,25,26,27],"5300333303033330010000303133303510331035",[31,32,33,34],1794036691284]