Talk:Letter frequency: Difference between revisions

(AppleScript "generic" alternative)
Line 108:
 
Well. Although the "composition of generic functions" AppleScript alternative is cryptic, obfuscated, and not usefully commented, and therefore practically impossible to assess before running, I took a chance and ran it, trying it with a shorter text file which the first script handles in just under one and a quarter seconds. "Composition of generic functions" was still going after an hour, which is when I stopped it. It was more successful with the text of this comment, although it counts non-letters too and treats different cases of the same letter as different letters. --[[User:Nig|Nig]] ([[User talk:Nig|talk]]) 20:12, 12 April 2020 (UTC)
 
: I do, of course, understand your puzzlement and exasperation :-)
 
: Our two examples are complementary: mine is much faster to write (10 new lines of code, just clicking together existing Lego bricks, yours is inevitably slower to write and debug, but demonstrably faster at run-time, especially with larger samples.
: Mine is perfectly serviceable for the small text I wanted a count of, and cost me no effort or time to write.
 
: For me (and for anyone familiar with the tradition of composing pure functions, and with that well-established ML tradition of function names, subsequently adopted by various other languages) my version is familiar and easy to read, with a good ratio of signal-to-noise. We can glance at it and see how it defines the problem. Referring to the detail of how each familiar abstraction is implemented, can give the curious some useful insight into the paricular quirks and data structures of AppleScript.
 
: Your version is clearly more legible to you, but do remember that to others it may also look like a cloud of squid ink, spreading densely and noisily past the Rosetta code 80 character limit, and folding a bit wildly, while tracing through a series of state mutations which, in formal terms, is very much more complex, and very much less safe and predictable, and much harder to model, than any composition of pure functions.
 
: The distinction between these two approaches is usually formulated in terms like ''Procedural'' (or ''Imperative'') vs ''Functional'' (or ''Declarative''), and something like that might be a little more helpful to readers than the slightly more private 'Straightforward' vs 'Weird' which seems, understandably, to express your own experience :-)
 
: The right tool for a job depends on the moment and the context - sometimes we need much more efficient use of our own time – swift writing, easy refactoring, less debugging. Something quick for a small data sample.
 
: And sometimes we can afford to spend more of our own time, and want to build something that we can use with larger sets of data, optimized for run-time rather than write-time.
 
:Yours works very well for the latter context (possibly at the cost of how much time it take to write and debug) though I personally might reach for another language when performance or scale are what I need. (In a macOS scripting context, the same composition of pure functions runs very fast in JavaScript for Automation, for example. I hardly need to tell you that AppleScript records are not famous for their speed or powers of introspection). By the time we have to reach for ObjC Foundation classes to get some usable performance at any scale, AppleScript has really rather lost the bloom of its charm and claims to accessibility, and may be an implausible or inappropriate instrument to reach for anyway.
 
To avoid the risk of a faintly comic impression, might it make sense for us to find a slightly more illuminating, and more widely understood alternative to "straightforward" ? My approach obviously seems more "straightforward" to me – that's a symmetrical relationship :-) Perhaps ''Imperative'' ? ''Procedural'' ? Something else which has some precedent and familiarity on Rosetta Code, and will immediately be intelligible ? [[User:Hout|Hout]] ([[User talk:Hout|talk]]) 10:17, 13 April 2020 (UTC)
9,655

edits