The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Larry McVoy <lm@mcvoy.com>
To: TUHS main list <tuhs@tuhs.org>
Cc: rob@bolabs.com
Subject: [TUHS] Re: What would early alternatives to C have been?
Date: Mon, 10 Mar 2025 18:35:02 -0700	[thread overview]
Message-ID: <20250311013502.GF24601@mcvoy.com> (raw)
In-Reply-To: <CAMP=X_=mVs6YcVf-6O0ak3xWeEE9LhuPm9E9Ho2kKbAQfv2ueQ@mail.gmail.com>

I'm guessing this is because yacc makes it easy to fiddle with the grammar?
Does performance factor in?

I'm actually curious because BitKeeper has what we call a dspec language
which lets you wander through the revision history and print it out in
a sort of awk/printf like language.  If my memory serves me, we had a 
version in yacc (really flex but same thing) and Rob (cc-ed) rewrote 
it in a recursive-descent parser for performance reasons.  If you are
curious, this is a dspec that spits out history in JSON format that 
I wrote because one of my engineers said it was impossible (it wasn't):

http://mcvoy.com/lm/bkdocs/dspec-changes-json-v.txt

$0 .. $9 are variables.  We used $if as a way to get an if statement
rather than just say "if", :whatever: is a way to fish some field out
of the history, Marc will get it, it's SCCS's :D: that means date, we
just took it a lot further.

I don't remember how much faster the RD version was but it was a lot,
for sure more than a factor of 2 and maybe much more than that.  All
I remember is at some point the dspec parser was a performance issue
and after Rob rewrote it, it wasn't.

On Mon, Mar 10, 2025 at 05:06:13PM -0700, Ken Thompson wrote:
> re yacc vs RD
> 
> i agree that they are about the same,
> where the edge would tilt based on the parsed language.
> BUT when the parsed language (like go) is not yet defined,
> yacc is the only option.
> 
> 
> 
> On Mon, Mar 10, 2025 at 4:50???PM Clem Cole <clemc@ccc.com> wrote:
> 
> > Marc - check out OpenSIMH( https://opensimh.org)
> > Check out over 40 different simulators including the I7000 which
> > supports IBM 701,7010,7070,7080, 7090 - https://opensimh.org/simulators/
> >
> >
> > ???
> >
> > On Mon, Mar 10, 2025 at 7:12???PM Marc Rochkind <mrochkind@gmail.com> wrote:
> >
> >> This thread started to be about what I thought were system programming
> >> languages (e.g., C, BLISS) and seems to have meandered into a general
> >> discussion of languages that were around in the 1960s and 1970s, so, what
> >> the heck, I'll add my own story.
> >>
> >> PL/0 is an education programming language introduced in the book, *Algorithms
> >> + Data Structures = Programs*, by Niklaus Wirth in 1976. It's a great
> >> language for teaching compiler writing because it contains interesting
> >> concepts, such as recursive functions, yet isn't overly complicated. I
> >> wrote a PL/0 compiler for the IBM 701 (
> >> https://github.com/MarcRochkind/pl0compiler).
> >>
> >> Yeah, that's not a misprint. I wrote perhaps the world's only 701
> >> emulator (https://www.mrochkind.com/mrochkind/a-701.html), and my PL/0
> >> compiler runs on it. Unfortunately, I can't verify that the compiled code
> >> runs on an actual 701, since I'm sure there haven't been any in operation
> >> for many decades. For those of you who haven't had the pleasure,
> >> programming the 701 is really hard. It had no index registers, and the sign
> >> bit didn't participate in shifts. Still, my compiler compiles full-blown
> >> PL/0.
> >>
> >> So there! ;-)
> >>
> >> Marc Rochkind
> >>
> >> On Mon, Mar 10, 2025 at 2:49???PM Bakul Shah via TUHS <tuhs@tuhs.org>
> >> wrote:
> >>
> >>> Perhaps the interviewer was looking for something dumb like the following
> >>> and not a full RD parser?
> >>>
> >>> int count = 0;
> >>> while (*cp) {
> >>>         char c = *cp++;
> >>>         count += c == '(' ? 1 : c == ')' ? -1 : 0;
> >>>         if (count < 0) return -1; // FAIL: one too many )
> >>> }
> >>> if (count > 0) return -1; // FAIL: too many (
> >>> return 0; // SUCCESS
> >>>
> >>> Though this will fall apart if you also want to also balance braces &/or
> >>> brackets and must catch invalid cases like "(..[..)..]"!
> >>>
> >>> > On Mar 10, 2025, at 8:19???AM, John Cowan <cowan@ccil.org> wrote:
> >>> >
> >>> > I was working at the whiteboard during a job interview once. I had
> >>> been asked to write a function to report if its input had balanced
> >>> parentheses.  No problem: I wrote an RD parser in Python (which I prefer
> >>> for whiteboarding) to detect balance and return True if the parse was
> >>> successful and False if EOF was reached.
> >>> >
> >>> > I was starting to write some tests when the interviewer interrupted me.
> >>> >
> >>> > "What is that?"
> >>> >
> >>> > "It's a recursive descent parser. It detects if the input is
> >>> well-formed."
> >>> >
> >>> > Blank look.
> >>> >
> >>> > I started to walk him through the code.
> >>> >
> >>> > He interrupted me. "Excuse me, I'll be back in a few minutes."
> >>> >
> >>> > Long wait, maybe 15-20 minutes. Someone else comes in. "Thank you, the
> >>> recruiter will get back to you." That's the last I hear from them.
> >>>
> >>>
> >>
> >> --
> >> Subscribe to my Photo-of-the-Week emails at my website mrochkind.com.
> >>
> >

-- 
---
Larry McVoy           Retired to fishing          http://www.mcvoy.com/lm/boat

  reply	other threads:[~2025-03-11  1:35 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-10  2:03 Douglas McIlroy
2025-03-10  2:28 ` Charles H. Sauer
2025-03-11  2:26   ` [TUHS] Re: uphill both ways, was " John Levine
2025-03-10  4:10 ` [TUHS] " Rob Pike
2025-03-10 15:19   ` John Cowan
2025-03-10 19:56     ` Dave Horsfall
2025-03-10 20:49     ` Bakul Shah via TUHS
2025-03-10 23:12       ` Marc Rochkind
2025-03-10 23:49         ` Clem Cole
2025-03-10 23:58           ` Marc Rochkind
2025-03-11  0:06           ` Ken Thompson
2025-03-11  1:35             ` Larry McVoy [this message]
2025-03-11  5:07               ` Ken Thompson
     [not found]         ` <CAKH6PiW8J8=uFbadUTSaC9VcLGUJMFZaSFWOFDyCM3MpMTSayw@mail.gmail.com <CAMP=X_mchJuVgdpc4-AYHASwEVzUcJXMmqSDv_UvX6y0o0+LBQ@mail.gmail.com>
2025-03-12  1:36           ` [TUHS] Re: parsing tools, was What would early alternatives John Levine
2025-03-12  2:22             ` Rich Salz
2025-03-12  3:35               ` Larry McVoy
2025-03-12 16:35               ` John R Levine
2025-03-12  5:11             ` Greg A. Woods
2025-03-11  5:15       ` [TUHS] Re: What would early alternatives to C have been? John Cowan
2025-03-10 15:12 ` Clem Cole
2025-03-10 15:24   ` Dan Cross
     [not found] <174154718981.615624.15831772136951719489@minnie.tuhs.org>
2025-03-09 21:01 ` Paul McJones
2025-03-10  0:38   ` Ken Thompson
  -- strict thread matches above, loose matches on Subject: below --
2025-03-09  3:46 [TUHS] " Dan Cross
2025-03-09  6:14 ` [TUHS] " George Michaelson
2025-03-09 12:29 ` Clem Cole
2025-03-09 13:18   ` G. Branden Robinson
2025-03-09 17:29     ` Clem Cole
2025-03-09 19:06       ` Ken Thompson
2025-03-09 19:41       ` G. Branden Robinson
2025-03-09 19:57         ` Bakul Shah via TUHS
2025-03-09 22:47         ` Dave Horsfall
2025-03-09 22:58         ` Clem Cole
2025-03-09 23:12           ` Larry McVoy
2025-03-09 23:18             ` Steve Nickolas
2025-03-09 23:39             ` Lawrence Stewart
2025-03-10  0:55               ` Stuff Received
2025-03-10  1:19                 ` Rob Pike
2025-03-10  3:06                 ` Larry McVoy
2025-03-10  9:12                   ` arnold
2025-03-10 14:41                     ` Larry McVoy
2025-03-10 14:52                       ` Clem Cole
2025-03-10 15:06                         ` Larry McVoy
2025-03-10 15:27                           ` Dan Cross
2025-03-10 15:46                             ` Larry McVoy
2025-03-10 15:47                             ` Warner Losh
2025-03-10 14:57                       ` Dan Cross
2025-03-10 15:09                         ` Larry McVoy
2025-03-10 16:30                           ` arnold
2025-03-10 18:18                             ` segaloco via TUHS
2025-03-10 18:39                             ` Stuff Received
2025-03-10 18:56                             ` Bakul Shah via TUHS
2025-03-10 23:25           ` Greg A. Woods
2025-03-10 23:35             ` segaloco via TUHS
2025-03-11  1:14               ` Dan Cross
2025-03-11  0:01             ` Clem Cole
2025-03-11  2:18             ` John Levine
2025-03-11  4:00               ` G. Branden Robinson
2025-03-11  4:14                 ` George Michaelson
2025-03-11 15:18                   ` Ron Natalie
2025-03-11 21:52                     ` Rob Pike
2025-03-09 20:13 ` John Levine
2025-03-09 20:35   ` Luther Johnson
2025-03-09 20:58     ` Clem Cole
2025-03-09 21:12       ` Luther Johnson
2025-03-09 22:57       ` Warner Losh
2025-03-10  1:51     ` John Levine
2025-03-10  2:54       ` Luther Johnson
2025-03-10  1:31 ` Bakul Shah via TUHS

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250311013502.GF24601@mcvoy.com \
    --to=lm@mcvoy.com \
    --cc=rob@bolabs.com \
    --cc=tuhs@tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).