Category:Phix: Difference between revisions

m
no edit summary
m (caps)
mNo edit summary
Line 30:
Phix applies the principle of least surprise, for instance in some languages <tt>myproc(list)</tt> or <tt>res = myfunc(list)</tt> can mangle list, whereas in Phix if you actually want that to happen you would code <tt>list = myproc(list)</tt> (and myproc would need to become a function) or <tt>{res,list} = myfunc(list)</tt>. Likewise 1/2 is 0.5 (not 0, unless you explicitly ask for the floor()) and 0-1 is -1 (not +MAXINT). A core tenet is that for any line of code there is one and only one possible interpretation of it, and said meaning is utterly intuitive. True fact: the given answer for the question "describe what f(a++) does" in "More Exceptional C++" lists 4 possibilities for f, and 3 for a (so 12 in total) and uses the phrase "could mean just about anything" not once but twice - shudder.
 
Phix is not inherentlysupports object orientatedorientation, but achievesdoes not enforce it, and can achieve many of the claimed benefits, yet in a much simpler way. In fact I have been looking for <i><b>proof</b></i> that object orientation actually improves productivity compared to other paradigms for decades, and never found it. Not to say that I won't support it, but I certainly won't enforce it. One other thing I have never found is a "good object orientated design", and reached the conclusion that mythical creature simply does not exist, at least not as a separate entity as opposed to some ethereal quality of the finished code. Feel free to argue that one on [[User_talk:Petelomax]]. Phix offers perfectly decent encapsulation at the file level, proving that is not the sole purview of oo, implements polymorphism far more elegantly than C-based languages and far safer than duck-typed languages, and as for the third pillar of oop, inheritance, well isn't the current mantra "favour composition over inheritance"?
 
The fundamental goal of Phix is to make debugging easier, a whole subject area that does not seem to get the attention it deserves, despite several studies finding that most programmers actually spend between 70 and 90% of their time debugging. (Most of us tend to think that getting just-written code to work is somehow not debugging, but that bloke with a clipboard stood behind you would disagree.)
 
Since 1.0.0 you can also run (many/most) Phix programs in a browser, by using pwa/p2js (as included in the distro) to transpile the program to JavaScript (plus a bit of standard HTML and CSS). If you see "'''with javascript_semantics'''" it means the program has been tested and works fine, both on the (Windows/Linux) desktop/Phix and in a browser via pwa/p2js, and in fact unix_dict() has been added to avoid reading unixdict.txt. Conversely, "without js" being present on a rosettacode entry means that (for instance) it uses the local file system, and is therefore desktop/Phix only. It is worth pointing out that "with js" and deep_copy() have proved ''staggeringly'' effective and nowhere near as painful as first feared. In just a few months (1.0.0 was released in July 2021) I have tested, fixed where necessary, and marked as javascript compatible ''[https://www.rosettacode.org/mw/index.php?title=Special%3ASearch&search=phixonline some 650 rosettacode entries]'' for Phix, and only ''[https://www.rosettacode.org/mw/index.php?title=Special%3ASearch&search=notonline one tenth]'' of that have as yet been marked incompatible. The [https://rosettacode.org/wiki/Category:Phix/online Phix/online] subcategory lists just shy of 50 entries deemed interesting enough to bother (manually) uploading to the Phix website, and the next goal is to get pwa/p2js itself runnning online, but obviously without using file i/o directly.
7,804

edits