Hacker News new | ask | show | jobs
by dandotway 1622 days ago
Ancient FORTRAN, as opposed to complicated modern Fortran/C++/Rust, has a huge advantage if you ever crash your spaceship on a resource rich alien world and have to build a programmable computer from scratch from first principles using only knowledge that a single human could memorize. Modern languages require nontrivial compiler theory to parse a sequence of language symbols into an Abstract Syntax Tree (AST), etc. But Ancient FORTRAN is essentially designed to be read in and translated just a few 80 column punch card lines at a time, much like assembly languages. Compilers were written that could fit inside computers with only a few thousand words of 16 or 18 bit memory. Magnetic Core memory from that era was often made by hand, by little old ladies weaving it in factories I've been told, and was used for the Apollo moon spacecraft and was extremely reliable:

  https://en.wikipedia.org/wiki/Magnetic-core_memory
Ancient LISP and BASIC variants also stand out in this regard of not requiring you to undergo years of training and theory to implement and fully understand.

Fabrice Bellard's minimalist but complete quickjs.c Javascript interpreter is presently about 54,000 lines of C:

  https://github.com/bellard/quickjs/blob/master/quickjs.c
Javascript is an enormous, complicated, designed-by-committee language, as are essentially all other languages we are forced to use. I do hope there is a renaissance of simpler technology, technology not driven by competitive egos but by a desire for the joy of simplicity and understanding. But such simpler technology won't be useful for building backend infra for Big AdTech ad-bidding exchanges so that we can be bombarded with ads for One Weird Trick to burn belly fat or whatever.
3 comments

I would disagree on that. Parsing theory made it easier to write parsers, not harder. Separating the process into lexical and syntactic analysis makes for a much clearer structure than some ad-hoc parser. And writing a recursive descent parser for a language with an appropriate grammar is not hard and can be quite enjoyable.
I don't think recursive decent parsers is what people think of when it's about "parsing theory". In my mind the theory is more about classifying arbitrary languages that were not necessarily designed to be easily parsed by machines, and about models to parse them nevertheless.

If you write a recursive descent parser, you're probably parsing a language that was explicitly designed to be parsed with straightforward code, and that can mean the language is compromising on brevity and expressivity sometimes.

OTOH parsing with a recursive descent parser requires either a machine with a stack and the approriate calling conventions OR a lot of work to fake it. FORTRANs before F90 had no recursion (and you still have to explicitly declare that a function is recursive), and many early and easy architectures have no hardware stack.
If you like simple language cores look at chapter IV in "Early History of Smalltalk" for the one pager that became Smalltalk-72. http://worrydream.com/EarlyHistoryOfSmalltalk/
I’d Love to see you try given no resources other than what’s in your brain to build a Fortran punchcard interpreter from scratch.
In my undergrad computer science program, I implemented the rudiments of a very simple CPU using AND, OR, and NOT logic gates. I learned how to program microprocessors in assembly language. I learned how to implement a programming language interpreter. I implemented a compiler with a lex that tokenized its input stream and had a parser that built an AST from said tokens, and had a code generator that walked the AST and output a sequence of instructions. This was all covered in an undergrad CS program, not a Masters or PhD, so you don't have to be a genius at the level of John von Neumann to design programmable computational machinery from scratch using only the resources in your brain, because the geniuses like von Neumann already invented it in their brains instead, and good teachers at universities have found gentle ways to pass it from their brains into your brain.

The original FORTRAN '57 did not even have SUBROUTINE, FUNCTION, CALL, etc., for implementing subroutines. Those came with FORTRAN II in 1958, which was the main language Kemeny's original BASIC was based on in the early 1960s, but Kemeny changed FORTRAN II's DO loop to the easier to remember 'FOR I = 1 TO 42 ...'.

Knuth designed his original 1960s MIX computer using just pencil and paper, designed it to be easy to run programs using just pencil and paper.

If you yourself could not build a rudimentary BASIC or cut-down FORTRAN using only the resources in your brain and a sheet of paper with a pencil, you might be spending too much time working with overcomplicated programming tools that do not bring joy to your life.