From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: from minnie.tuhs.org (minnie.tuhs.org [IPv6:2600:3c01:e000:146::1]) by inbox.vuxu.org (Postfix) with ESMTP id 7CC12201A4 for ; Tue, 11 Mar 2025 00:12:42 +0100 (CET) Received: from minnie.tuhs.org (localhost [IPv6:::1]) by minnie.tuhs.org (Postfix) with ESMTP id 4223D4411B; Tue, 11 Mar 2025 09:12:38 +1000 (AEST) Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by minnie.tuhs.org (Postfix) with ESMTPS id D3FF044119 for ; Tue, 11 Mar 2025 09:12:33 +1000 (AEST) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3913b539aabso1426689f8f.2 for ; Mon, 10 Mar 2025 16:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741648352; x=1742253152; darn=tuhs.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=XExP+9JbKl0Uu7suXXKh+i/fwVBGu9x2N/f5tm0OI/I=; b=ilOIn60e31dS7JrFYRODZ7+ajXS8aR6i+QSIg5/IYXm05rhYiQ0moLhGyMH/Q9oJWM aR39T3VOMpv5glYCdD+5S0Leia96wIvmrMVGfJDoc4AR9nZuMeDAK2NspgoargI3VXCO qlIHiZubDZOfagkadyHxxq2H7uABM88TzYB+fXg0VZQEOsayqiVO4nJ5X8zbF3BoMuTG KZQHPHFZKXGW9OJ058kmaO0SlQDn50dAJNWsZ2l0yel19iWeg+VxsSa3ipja/cn1gVUO DoS/bfk30buczO6SVGz5169sVKFxQGhVKm00QwdJ87+ygFKOMVpuN8aP8eBWzo0naUiZ Bj8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741648352; x=1742253152; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=XExP+9JbKl0Uu7suXXKh+i/fwVBGu9x2N/f5tm0OI/I=; b=CdeCzKgOF2Vo0KBDbUSGJcn42r8Q12Es7l5/rbkeHrUcrI2M/5Zdus5es+JQwFO5+h Qghbl2mXpmv2uSGeaRnw6Uf/esyN0C6tHhQhK4hQKEneMiPs1oHQHCDhU0TVIk80aT8c 3516pXvkh1MbhjNPphnAfsKhl4fvzbKk2MMS5T2BTbdEy8diTWl9BdeQ/dCraFrh7LYo 1yPxx4CfjVvw0XAgEAqjdeIs2qLR4y5AUl980+fS5TBtPZod905vRegHU7exoU5d5KvA 4isBx/zFst1NPJPUKZJxikyLUux9JVbQNFgJqnRwJlaSvipnjnHxIPf5xsbeYVy0/yoe 525Q== X-Gm-Message-State: AOJu0Yy78TsjFUx8mD+6koVMXW/ymXSiDR1W3OXw4S2Z8uJNkMbGYREo PQ8oMLFIR7pGZlJfOUG/SLlYROCg4ZNnSwp8wf+kG18OQ4THXNBpN6ixSmL7RcOytzcRxSNGPF7 IcqUp+9xZJfUt3zbzCfUTTbuyHTep3Sg= X-Gm-Gg: ASbGnctESt9hMMjFN30BD/yxuMtEFC1ieDX1kLyhwS3o6KsP/M1Y7Df1k7Ze2qEJvSy HKz4WU9fNrxeEc1XX60wrz84IAxVUKXj7f91UdXfsic960sQAmDugvcC7AUTpM+cr+EU23YwtYW 9Wqw91OQEnCM1Dsjf0a8KEoxU2 X-Google-Smtp-Source: AGHT+IH4FEA2E+XRvV30Q/SaPQ63ow4HBBdeWwUZLbZNCJ5Y6Xzp0kxWiBWRpaplChJUZuH86Y3jVozif5vng1NYwgE= X-Received: by 2002:a5d:598c:0:b0:391:3bdb:af5d with SMTP id ffacd0b85a97d-3913bdbb534mr7467998f8f.28.1741648351719; Mon, 10 Mar 2025 16:12:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Marc Rochkind Date: Mon, 10 Mar 2025 17:12:20 -0600 X-Gm-Features: AQ5f1Jqn-THlbMYsDlLEGB9KdYNkhwZBtwkGODqFfGyG4jrm8gFcNNZupo7tEko Message-ID: To: TUHS main list Content-Type: multipart/alternative; boundary="00000000000053f8370630051b48" Message-ID-Hash: RCJIO3H4XRROARFCCQ5FHM6YN5DWPWA3 X-Message-ID-Hash: RCJIO3H4XRROARFCCQ5FHM6YN5DWPWA3 X-MailFrom: mrochkind@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-tuhs.tuhs.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.6b1 Precedence: list Subject: [TUHS] Re: What would early alternatives to C have been? List-Id: The Unix Heritage Society mailing list Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --00000000000053f8370630051b48 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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, *Algorith= ms + Data Structures =3D 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=E2=80=AFPM Bakul Shah via TUHS = wrote: > Perhaps the interviewer was looking for something dumb like the following > and not a full RD parser? > > int count =3D 0; > while (*cp) { > char c =3D *cp++; > count +=3D c =3D=3D '(' ? 1 : c =3D=3D ')' ? -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=E2=80=AFAM, John Cowan 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. > > --=20 Subscribe to my Photo-of-the-Week emails at my website mrochkind.com. --00000000000053f8370630051b48 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
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 e= ducation programming language introduced in the book, Algorithms + Data = Structures =3D Programs, by Niklaus Wirth in 1976. It's a great lan= guage for teaching compiler writing because it contains interesting concept= s, 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 comp= iler runs on it. Unfortunately, I can't verify that the compiled code r= uns on an actual 701, since I'm sure there haven't been any in oper= ation 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-blo= wn PL/0.

So there! ;-)

Ma= rc Rochkind

On Mon, Mar 10, 2025 at 2:49=E2=80= =AFPM Bakul Shah via TUHS <tuhs@tuhs.or= g> wrote:
Perhaps the interviewer was looking for something dumb like the following<= br> and not a full RD parser?

int count =3D 0;
while (*cp) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 char c =3D *cp++;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 count +=3D c =3D=3D '(' ? 1 : c =3D=3D = ')' ? -1 : 0;
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (count < 0) return -1; // FAIL: one too m= any )
}
if (count > 0) return -1; // FAIL: too many (
return 0; // SUCCESS

Though this will fall apart if you also want to also balance braces &/o= r
brackets and must catch invalid cases like "(..[..)..]"!

> On Mar 10, 2025, at 8:19=E2=80=AFAM, John Cowan <cowan@ccil.org> wrote:
>
> I was working at the whiteboard during a job interview once. I had bee= n asked to write a function to report if its input had balanced parentheses= .=C2=A0 No problem: I wrote an RD parser in Python (which I prefer for whit= eboarding) to detect balance and return True if the parse was successful an= d 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 w= ebsite mrochkind.com= .
--00000000000053f8370630051b48--