6 ms·
Not a surprise to anyone familiar with pascal's grammer.
by skeptical 15y ago
Not a surprise to anyone familiar with pascal's grammer.
- baddox 15y agoA language's grammar wouldn't necessarily be a good indicator of implementation size, would it?
- groovy2shoes 15y agoNot necessarily. Some grammars can be parsed with simpler code than others, but optimizations can make a compiler larger. Also of note is that Turbo Pascal was written by hand in assembly language, and the executable wasn't likely to have been linked with any libraries.
- MatthewPhillips 15y agoInteresting, I didn't know this but Turbo Pascal was written by Anders Hejlsberg (of Delphi and C# fame).
- bhangi 15y agoIndeed TP did not have any linking step. I still recall trying to fruitlessly find "Link" on the menu for quite some time until it hit me -- oh, no linking needed. But TP did include a run-time with each of the generated executable. This run-time was part of the compiler and it was approximately 10K (from memory, so I could be wrong). That makes the compiler about 22Kbytes worth of code, which is even more impressive.
- groovy2shoes 15y agoI wasn't aware that the runtime was included in the executable. Oh, the things we did in the DOS days!
- barrkel 15y agoPascal's grammar is so simple by design that it can be parsed and codegenned in a single recursive descent pass. Not many languages are like that, especially these days.
- tluyben2 15y agoThere are a billion Lisp parsers in a few lines of Python, C, Lisp, etc. Any Pascal ones like that? Edit; not meant sarcastic, I would really like to see such a simple parser as was implied.
- colanderman 15y ago"parsed and codegenned" he said. Any Lisp compilers like that?
- groovy2shoes 15y agoI believe that's how the Clojurescript compiler currently works (though I haven't looked at the code in detail). Compilers that don't do it that way usually have optimizations going on in between the parse and codegen phases, not because it's impossible to do with Lisp syntax.
- fogus 15y agoClojureScript has a two-pass compiler; more if you consider GClosure a step.
- xyzzyz 15y ago"because it's impossible to do with Lisp syntax." The problem is not with Lisp syntax. The problem is with Lisp's semantics, which makes it much more difficult (if at all possible) to compile in one pass. Things like closures, conditions or macros are absent in Pascal.
- ajross 15y agoNo, but only by definition. Passing through an s-expression representation is a requirement for a lisp compiler, because the tree to be compiled might have been built at runtime. Certainly lisp's grammar is no more complicated than pascal's. Nor, frankly, is K&R C, which is is also a very simple representation. The ANSI process added some edge cases that complicated it, but really it's pretty simple.
- skeptical 15y agoYes it would. Not a bullet proof one (is there any?) but a good indicator.
- gecko 15y agoI cut my teeth with two programming languages, Smalltalk and Delphi (basically Turbo Pascal for Windows), and was actually just screwing around with Free Pascal (http://freepascal.org/ http://freepascal.org/) on a nostalgia kick. I ended up learning Delphi mostly by happenstance--I ended up getting gifted a free copy of Delphi 3, whereas VisualBasic and Visual C++ were comparatively expensive at the time--but I am incredibly, incredibly glad that I learned that first. Where C++'s grammar is convoluted, confusing, and contradictory, Turbo Pascal's and Delphi's manage to be very simple and straightforward with comparable power. I spent a lot less time coming to terms with syntax, and a lot more time familiarizing myself with machine code, calling conventions, and libraries. Having a straightforward grammar doesn't just help the compiler use less space. It helps your brain use less space on raw syntax.
- throwawayday 15y agoit also helps you logically deduce stuff you don't know. I remember that after a while, I could almost guess the names of functions that I didn't really know - that's what having a naming convention and regular syntax do for you
- Roboprog 15y agoYeah, I don't think that C++ killed Delphi. Java killed Delphi. Java may kinda look like C++, but Java 1.1 acted a lot like Borland Pascal plus a UCSD pcode-system. Nested blocks, strong typing, easy string manipulation, portable interpreter. And support for strings over 255 chars long, too! :-)