Re: Interesting articles

2021-03-26 Thread John Gardner
Of course, *both* solutions are inadequate when you consider languages
other than English  (especially
agglutinative languages like Hungarian and Turkish). For example, how many
"words" are in "
*muvaffakiyetsizleştiriciveremeyebileceklerimizdenmişsinizcesine"…?*

Pedantry aside, good find! Next time I'm asked how Troff differs
philosophically from TeX, I'll cite this article as a condensed example.


On Fri, 26 Mar 2021 at 13:31, Larry Kollar  wrote:

> Sometimes, my Twitter feed coughs up some cool articles, like
> this one: "Performance comparison: counting words in Python,
> Go, C++, C, AWK, Forth, and Rust”
>
> https://benhoyt.com/writings/count-words/
>
> The Awk solution was by far the shortest by line count. Since
> the runtime for all the different solutions was a few seconds or
> less, Awk was probably the fastest because it took the least time
> to code. :D
>
> But there was a passage that made me laugh out loud:
>
> > Incidentally, this problem set the scene for a wizard duel
> > between two computer scientists several decades ago. In
> > 1986, Jon Bentley asked Donald Knuth to show off “literate
> > programming” with a solution to this problem, and he
> > came up with an exquisite, ten-page Knuthian masterpiece.
> > Then Doug McIlroy (the inventor of Unix pipelines) replied
> > with a one-liner Unix shell version using tr, sort, and uniq.
>
> I can imagine the shell pipeline also look less time to type in and
> run than it did to code the literate programming solution. For
> one-off things like this, less code is better.
>
> Then there was the article “Taco Bell Programming”
>
> http://widgetsandshit.com/teddziuba/2010/10/taco-bell-programming.html
>
> There were several good takeaways in this one, but my favorite
> line was “functionality is an asset, but code is a liability.” Not to
> mention the casual comment that xargs supports parallel processing
> (something I was totally unaware of!).
>
> — Larry
>


Re: Interesting articles

2021-03-26 Thread Ulrich Lauther
On Thu, Mar 25, 2021 at 10:30:57PM -0400, Larry Kollar wrote:
> Sometimes, my Twitter feed coughs up some cool articles, like
> this one: "Performance comparison: counting words in Python,
> Go, C++, C, AWK, Forth, and Rust”
> 
> https://benhoyt.com/writings/count-words/
> 
> The Awk solution was by far the shortest by line count. Since
> the runtime for all the different solutions was a few seconds or
> less, Awk was probably the fastest because it took the least time
> to code. :D
> 
What about "wc -w" ?

ulrich lauther



Re: Interesting articles

2021-03-26 Thread H.J. Oertel



Am 26. März 2021 09:03:41 MEZ schrieb Ulrich Lauther 
:
>On Thu, Mar 25, 2021 at 10:30:57PM -0400, Larry Kollar wrote:
>> Sometimes, my Twitter feed coughs up some cool articles, like
>> this one: "Performance comparison: counting words in Python,
>> Go, C++, C, AWK, Forth, and Rust”
>> 
>> https://benhoyt.com/writings/count-words/
>> 
>> The Awk solution was by far the shortest by line count. Since
>> the runtime for all the different solutions was a few seconds or
>> less, Awk was probably the fastest because it took the least time
>> to code. :D
>> 
>What about "wc -w" ?
>
>ulrich lauther
>

That's already a solution written in C. I assume.
Heinz



Can .substring be made to handle an empty result?

2021-03-26 Thread Jim Avera
I'm trying to use .substring to remove the first character of a string, 
leaving behind whatever follows, even if that is nothing (i.e. the 
string had only one character).


  .substring str 1

or

  .length n2 "\*[str]
  .nr n2 -1
  .substring str 1 \n[n2]

(if n2 is omitted, it appears to default to length-1 as you might expect).

The above works as long as the string originally had at least two 
characters.  If it only has one, so the desired result is the empty 
string, it does not remove anything, leaving behind the 0th character 
and emitting a warning (with -w all).


This seems like a corner-case bug.

Question: Is this intentional, to remain "bug compatible" with some 
older roff systems?


At first glance, it seems like it would be safe to fix this because the 
result is currently always wrong in this case, i.e. n1 equals the length 
of the string (so the result should be empty).


Thoughts?

-Jim