<html><head><meta http-equiv="content-type" content="text/html; charset=us-ascii"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">Hi Richard,<div><br></div><div>Wise words.</div><div><br></div><div>That fact the code was still useful after so long is impressive in and of itself. As to "if my game is any good", did make me chuckle, it will probably join the long list of other games and unfinished sci-fi stories that litter my cloud drives, and have done so for decades. I think I missed my vocation in life, writing games. As a lad, I wanted to work for Atari, I mean who didn't?</div><div><br></div><div>I was born in '65 and in the UK, I grew up around computers and computing, I feel somehow intimately connected to the very fabric of home computing, god alone knows why but I do and almost every day I've hacked code, started things, learned things and every now and then, finished things. I once wrote a corking good version of hangman in Squeak Smalltalk, made 30 copies on CD along with printed instructions, mailed them to 30 schools in my home town and... nothing happened. I don't know if the Royal Mail lost them all or the schools junked them for not being a preferred supplier but that was the start and end of any notions I may have harboured about selling software I'd written.</div><div><br></div><div>I shall be 58 this year, along the way I have learned almost every language I've ever read about, and in recent years I learned APL then J, FORTRAN, COBOL, ADA. Back in the day I remember being quite impressed by MODULA-2, possibly on an Apricot Zen, but, distant memories!</div><div><br></div><div>The irony is the modern software industry seems to have gone backwards in terms of real progress, at least the way I see it. We have more and more tools but less and less discipline, and even more worryingly, the barrier to entry has been wiped out with the likes of JavaScript where every man and his dog has an opinion on how to make next weeks must-have framework-de-jour.</div><div><br></div><div>As for maintainability, well, I Love Mercury more and more, I wish I'd encountered it much further back. It absolutely DEMANDS understanding and discipline from the author, I doubt it will ever be mainstream for those reasons: large software projects require bums on seats and as such, the lowest common denominator languages and tool chains win out; mostly PHP and JavaScript. I was involved for almost three years on the UK MOT replacement programme, it was PHP and Zend2, I couldn't believe it when I arrived. So much code, we did digging: on a single page, we had 700,000+ lines of code going through the byte cache and that was BEFORE the page specific code, it was all ZF2 and extensions.</div><div><br></div><div>OK, I will stop, I can talk for hours, and frequently do and get told to shut up.</div><div><br></div><div>The funny thing is, I think my copy of 'The Craft of Prolog' is some kind magical summoning tool because in my life at least, this is at least the second time you have crossed paths with me within a few days of me reading it, this time it was Chapter 9. Prolog Macros, specifically expand_term/2, as mercury has a sample folder containing something similar i.e. code expansion, the very best of health to you sir!</div><div><br></div><div>:)</div><div>Sean</div><div><br></div><div><br></div><div><br></div><div><div><br><blockquote type="cite"><div>On 29 Aug 2023, at 02:16, Richard O'Keefe <raoknz@gmail.com> wrote:</div><br class="Apple-interchange-newline"><div><div dir="ltr"><div class="gmail_default" style="font-family:monospace,monospace">It doesn't answer your question, but if your game is any good,</div><div class="gmail_default" style="font-family:monospace,monospace">some day it will need maintaining. I have recently done some</div><div class="gmail_default" style="font-family:monospace,monospace">maintenance work on code I wrote 20 years ago, and it was as</div><div class="gmail_default" style="font-family:monospace,monospace">if it had been written by someone else. (I guess I'm just not</div><div class="gmail_default" style="font-family:monospace,monospace">smart to keep the structure and justification of several hundred</div><div class="gmail_default" style="font-family:monospace,monospace">thousand lines of code in my head for decades.) So readability</div><div class="gmail_default" style="font-family:monospace,monospace">is an issue, even if you never expect anyone else to read it.</div><div class="gmail_default" style="font-family:monospace,monospace">And for me, the first version is just so much more readable than</div><div class="gmail_default" style="font-family:monospace,monospace">the second version that I'd prefer it even if it was slower.</div><div class="gmail_default" style="font-family:monospace,monospace">You can tell at a glance what is the same every time and what</div><div class="gmail_default" style="font-family:monospace,monospace">is not the same.</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div><div class="gmail_default" style="font-family:monospace,monospace">There's a rule of thumb I picked up from the Smalltalk</div><div class="gmail_default" style="font-family:monospace,monospace">community: if all the branches of a conditional have a</div><div class="gmail_default" style="font-family:monospace,monospace">common pattern, move it out so that you can see it and</div><div class="gmail_default" style="font-family:monospace,monospace">make sure it *has* to be the same. It's a rule of thumb.</div><div class="gmail_default" style="font-family:monospace,monospace">There can be reasons to violate it. But I find that it</div><div class="gmail_default" style="font-family:monospace,monospace">generally makes my code better. (And boy do I need help</div><div class="gmail_default" style="font-family:monospace,monospace">with that.)</div><div class="gmail_default" style="font-family:monospace,monospace"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 26 Aug 2023 at 22:13, Sean Charles (emacstheviking) <<a href="mailto:objitsu@gmail.com">objitsu@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>I started out with this:</div><div><br></div><div><font face="Courier New"> get_random_value(0, 2, V, !IO),</font></div><div><font face="Courier New"> ( if V = 0 then</font></div><div><font face="Courier New"> Speed = 0.25, Color = color(gray)</font></div><div><font face="Courier New"> else if V = 1 then</font></div><div><font face="Courier New"> Speed = 0.75, Color = color(skyblue)</font></div><div><font face="Courier New"> else</font></div><div><font face="Courier New"> Speed = 1.25, Color = color(beige)</font></div><div><font face="Courier New"> ),</font></div><div><font face="Courier New"> Star = star(X, StarY, Speed, to_rgba(Color)).</font></div><div><br></div><div>end then, for some half0baked reason regarding not creating Speed and Color but instead directly returning Star...</div><div><br></div><div><font face="Courier New"> get_random_value(0, 2, V, !IO),</font></div><div><font face="Courier New"> ( if V = 0 then</font></div><div><font face="Courier New"> Star = star(X, StarY, 0.25, to_rgba(color(gray)))</font></div><div><font face="Courier New"> else if V = 1 then</font></div><div><font face="Courier New"> Star = star(X, StarY, 0.75, to_rgba(color(skyblue)))</font></div><div><font face="Courier New"> else</font></div><div><font face="Courier New"> Star = star(X, StarY, 1.25, to_rgba(color(beige)))</font></div><div><font face="Courier New"> ).</font></div><div><br></div><div><br></div><div>So, is there any real difference, or did I do something good / bad / indifferent at best?</div><div>Yes, I know it's a nit picking question but I am curious to know the relative speed / efficiencies , I am writing a game after all so being 1980-s paranoid, every cycle counts. I have '-O4' level optimisation in my build.</div><div><br></div><div>:D</div><div><br></div><div>Thanks</div><div>Sean.</div><div><br></div></div>_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.mercurylang.org" target="_blank">users@lists.mercurylang.org</a><br>
<a href="https://lists.mercurylang.org/listinfo/users" rel="noreferrer" target="_blank">https://lists.mercurylang.org/listinfo/users</a><br>
</blockquote></div>
</div></blockquote></div><br></div></body></html>