Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So they had three tools to choose among. One was broken, one was wildly unsuitable, and one was unpopular. They chose the second for (apparently) purely cultural reasons. I think it's not so surprising that they ran into problems.

Don't discard unsexy solutions out of hand; choose the right tool for the job.



Was assembly really the right tool for this either? It seems like the difficulty of translating Fortran to Pascal due to Fortran's lack of many of Pascal's higher-level features would still apply to assembly.


I think so. Wirth called out Fortran's lack of pointers, records, and recursion. You have (or can fake) all of these things in assembly. Recursion is particularly important for building a compiler, since much of it involves manipulating trees.

Also, consider the stated goal of the project. They wanted to write a throwaway compiler so that they could bootstrap a Pascal version. In this case, it's a bad choice to use a language (Fortran) that's so different from Pascal. On the other hand, assembly is very flexible, so you can use whatever idioms you think will apply in the Pascal code you later intend to write. This will make the translation much simpler.


Writing in assembler, it's easy to construct linked records, and recursion works correctly, since you have a stack.

It might take awhile, but it doesn't seem like it would be as hard to macro up some higher-level routines for parsing and code-generating a simple PASCAL.

I'd expect that most Beta-machines (nowadays virtual machines) would have been written in assembler back then, including lots of expertise running compiled Algol amongst other things.


I think writing it in (perhaps a subset of) Pascal, then translating to assembler either manually or by interpreting the Pascal source by hand would have been the Right Thing To Do (tm). Writing in the high-level language makes it easier to get the algorithms and data structures right. Translating to a lower level language later is easier with that framework in hand -- the Pascal source would serve as a sort of spec for the ASM translation. I know that when I write code in Python and translate to C, it's frequently easier than starting off writing in C, partly for that reason.


Assembly allows you to use pointers and recursive methods, which were specific problems with Fortran. You can do anything in assembly, it just takes a lot of lines. Programming languages, especially early ones, can place major limitations on how computations are expressed, even if they are nominally as turing-complete as any other language.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: