--- title: "Some Thoughts On Programming Style" type: "article" slug: "some-thoughts-on-programming-style" url: "http://localhost/article/some-thoughts-on-programming-style/" markdown_url: "http://localhost/article/some-thoughts-on-programming-style.md" published_at: "2025-12-18T20:16:23+00:00" modified_at: "2026-06-21T23:26:13+00:00" featured_image: url: "http://localhost/wp-content/uploads/2022/04/20230809-041332.jpg" excerpt: "In QHJ #24 Tim talks about a colleague's style of writing Perl and contrasts it with his own. I have spent several years as a programming and system development lecturer within my company's internal training department and nothing seems to cause more grief/criticism/etc., etc., as differences of programming style. I tend to use procedure calls…" category: - name: "QL Hacker's Journal" slug: "ql-hackers-journal" taxonomy: "category" url: "http://localhost/category/periodicals/ql-hackers-journal/" post_tag: - name: "Full Text" slug: "fulltext" taxonomy: "post_tag" url: "http://localhost/tag/fulltext/" - name: "QL" slug: "ql" taxonomy: "post_tag" url: "http://localhost/tag/ql/" - name: "Superbasic (programming language)" slug: "superbasic-programming-language" taxonomy: "post_tag" url: "http://localhost/tag/superbasic-programming-language/" model: - name: "Sinclair QL" slug: "sinclair-ql" taxonomy: "model" url: "http://localhost/model/sinclair-ql/" publication_r: id: 33686 title: "QL Hacker’s Journal" type: "periodical" url: "http://localhost/periodical/ql-hackers-journal/" authors: "Peter Tillier" issue: "25" issues_articles: - id: 61561 title: "QL Hacker’s Journal 25" type: "issue" url: "http://localhost/issue/ql-hackers-journal-25/" pubdate: "July 1996" archive_link: true --- # Some Thoughts On Programming Style In QHJ #24 Tim talks about a colleague’s style of writing Perl and contrasts it with his own. I have spent several years as a programming and system development lecturer within my company’s internal training department and nothing seems to cause more grief/criticism/etc., etc., as differences of programming style. I tend to use procedure calls in preference to the use of deep nesting of ‘if..then..else..endif’ structures as does Tim’s colleague. I do this for a number of reasons and even if the procedure may only be called once in the entire program (incidentally this approach is taken by Kernighan and Ritchie in ‘The C Programming Language’ and by Kernighan and Plauger in ‘Software Tools in Pascal’). My reasons are these: - it is sometimes inconvenient to read deeply nested ‘if..else..endif’ or ‘while..endwhile’ constructions; - this approach works very well with the program design method that I prefer to use (Jackson Structured Programming, aka. JSP); - if suitable procedure names are chosen the clarity of the code is often improved; - the style is closer to the object-oriented programming approach that I would prefer to use; - the arguments about inefficiency (“It’s wasteful to set up a stack frame and call code that could have been inline.”) take little account of the maintenance benefits that can accrue from well-designed and named procedures. I find something like this much easier to follow (and debug!), ``` procedure DoLotsOfThingsTo(var A : AType); var i : integer; procedure DoOneThingTo(var A : AType ); begin A.A := ...; A.B := ...; end {DoOneThingTo}; begin for i := 1 to SizeOfAType do DoOneThingTo(A); ... end {DoLotsOfThingsTo}; ``` (the above also shows one reason that I like Pascal – the ability to nest procedure declarations – I miss it a lot when I use C, C++ or things like Visual Basic). Incidentally, Question: can you nest procedure definitions in SuperBasic? Answer: Yes you can: ``` 1000 define procedure testa 1010 : 1020 define procedure testb 1030 print "In testb" 1040 end define testb 1050 : 1060 print "In testa (1)" 1070 testb 1080 print "In testa (2)" 1090 : 1100 end define testa ``` works perfectly, printing out, ``` In testa (1) In testb In testa (2) ``` as expected. As I said in my article on parameters and parameter passing mechanisms I think that most languages would be better if they were designed so that procedures and functions (in the SB or Pascal sense) could only access local variables or parameters – even for read access only.