{"id":452,"date":"2025-06-08T18:33:42","date_gmt":"2025-06-08T18:33:42","guid":{"rendered":"https:\/\/permutationcity.co.uk\/bp\/?p=452"},"modified":"2025-06-08T18:33:42","modified_gmt":"2025-06-08T18:33:42","slug":"no-one-balance","status":"publish","type":"post","link":"https:\/\/permutationcity.co.uk\/bp\/2025\/06\/08\/no-one-balance\/","title":{"rendered":"No one balance"},"content":{"rendered":"\n<p>When I was starting this blog I had to come up with a name.\nI considered <em>Balanced<\/em> Programming but rejected it.\nTo me this suggested that there might be one <em>true<\/em> balanced way of programming and\nI just don&#8217;t think that&#8217;s right.\nThe balance depends on the circumstances:\nthe product, the people, the situation.\nGetting the right balance has to be a process in itself.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"access-control-syntax\">Access control syntax<\/h2>\n\n\n\n<p>I&#8217;ve talked about Bob Nystrom&#8217;s work before.\nHe wrote the book\n<a href=\"https:\/\/gameprogrammingpatterns.com\/\">Game Programming Patterns<\/a>\nwhich was\n<a href=\"https:\/\/permutationcity.co.uk\/bp\/2024\/04\/16\/game-programming-patterns\/\">impressive<\/a>.\nHe&#8217;s also written another book\n<a href=\"https:\/\/craftinginterpreters.com\/\">Crafting Interpreters<\/a>\nas he&#8217;s interested in language design.\nRecently he wrote a post about\n<a href=\"https:\/\/journal.stuffwithstuff.com\/2025\/05\/26\/access-control-syntax\/\">Access Control Syntax<\/a>\nwhich is about how to go about adding modules to his scripting language.\nSpecifically how to specify what&#8217;s internal and external to the modules.<\/p>\n\n\n\n<p>Different language go about this in different ways:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Modifier keywords are used by Java to explicitly mark the category for individual identifiers.<\/li>\n\n\n\n<li>Modifier sections are used by C++ to mark a series of identifiers as belonging to the category.<\/li>\n\n\n\n<li>Naming conventions are used by Python to suggest how the identifiers should be accessed.<\/li>\n\n\n\n<li>Export manifests are used by Lisp to list which identifiers should be exposed.<\/li>\n\n\n\n<li>Declaration markings are used by <a href=\"https:\/\/en.wikipedia.org\/wiki\/Oberon_(programming_language)\">Oberon<\/a> to mark the category for individual identifiers.<\/li>\n<\/ul>\n\n\n\n<p>He considers pros and cons for each:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Is the technique obvious? A keyword announcing something as <code>public<\/code> or <code>external<\/code> should be very easy for someone to work out or pick up. A special declaration symbol or a naming convention might well not be understood or even noticed.<\/li>\n\n\n\n<li>What should the default be? If everything is public by default then it&#8217;s easy to integrate but potentially dangerous. If everything is private by default then coding safely is easy but using it might be harder.<\/li>\n<\/ul>\n\n\n\n<p>I liked all this of this thinking.\nHe&#8217;s got a specific problem and he&#8217;s trying to find the right balance amongst conflicting goals.<\/p>\n\n\n\n<p>He considers the possibilities of modifiers:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>In Rust, <code>pub<\/code> is a really nice little keyword to flip to public when the default is private,\nbut there is no obvious converse.\n<code>private<\/code> would be the longest keyword in my language.\n<code>pri<\/code> doesn\u2019t read like anything.<\/p>\n<\/blockquote>\n\n\n\n<p>I don&#8217;t like the <code>pub<\/code> keyword.\nI&#8217;ve discussed my ideas about\n<a href=\"https:\/\/permutationcity.co.uk\/bp\/2024\/02\/27\/good-names\/\">good naming conventions<\/a>\nbefore.\nFor him <code>pri<\/code> doesn&#8217;t read like anything but, for me, <code>pub<\/code> <em>also<\/em> doesn&#8217;t read like anything.\nFor me the a good name should be a short word but no shorter than that.\nWhile I can guess what <code>pub<\/code> might mean in a new language from context it&#8217;s meaning doesn&#8217;t leap out at me.\nI suspect it strongly depends on what other languages you&#8217;ve used and\nwhat keywords they use.\nFor me the limiting factor with language isn&#8217;t how quickly I can type it out.\nIn the end there&#8217;s more reading than writing and\nclarity in reading is more important than speed in writing.<\/p>\n\n\n\n<p>This isn&#8217;t his final idea and \nhis article doesn&#8217;t conclude with a firm decision on what to go for.\nWhile I don&#8217;t like some of the options Bob is looking at that doesn&#8217;t mean he shouldn&#8217;t thinking about them and\neven pick them.\nThere is no one <em>true<\/em> balance.\nHe&#8217;s writing a hobby project and\nwants to make a language that encourages <em>getting things done<\/em>.\nHe acknowledges that for a systems critical language defaulting to private is the better choice.<\/p>\n\n\n\n<p>If I was making a language I would be tempted by a private by default and a <code>public<\/code> keyword.\nThat&#8217;s safe, explicit and only takes 6 characters.\nI would wonder about marking a section as well but\nperhaps not like C++ as the keywords don&#8217;t seem to have proper ownership there.\nIt would deserve proper thought.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"in-the-end\">In the end<\/h2>\n\n\n\n<p>While there might not be a single right way of doing things there <em>are<\/em> plenty of wrong ways.\nStopping to think about what you&#8217;re doing and why are a good way to avoid those.\nWhile I probably won&#8217;t be jumping to use his language I&#8217;ll be interested to see any other choices he makes for it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When I was starting this blog I had to come up with a name. I considered Balanced Programming but rejected it. To me this suggested that there might be one true balanced way of programming and I just don&#8217;t think that&#8217;s right. The balance depends on the circumstances: the product, the people, the situation. Getting [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[26],"class_list":["post-452","post","type-post","status-publish","format-standard","hentry","category-general","tag-languages"],"_links":{"self":[{"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/posts\/452","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/comments?post=452"}],"version-history":[{"count":1,"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/posts\/452\/revisions"}],"predecessor-version":[{"id":453,"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/posts\/452\/revisions\/453"}],"wp:attachment":[{"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/media?parent=452"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/categories?post=452"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/permutationcity.co.uk\/bp\/wp-json\/wp\/v2\/tags?post=452"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}