News for hackers. Stuff that matters.
Re:Things That Turbo Pascal is Smaller Than by skeptical on Sunday October 30, 2011 @07:51PM (#3175750)
Not a surprise to anyone familiar with pascal's grammer.
Re:Things That Turbo Pascal is Smaller Than by gecko on Sunday October 30, 2011 @08:25PM (#3175835)
I 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/) 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.

Re:Things That Turbo Pascal is Smaller Than by throwawayday on Sunday October 30, 2011 @11:46PM (#3176283)
it 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
Re:Things That Turbo Pascal is Smaller Than by Roboprog on Monday October 31, 2011 @04:11PM (#3178821)
Yeah, 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! :-)

Re:Things That Turbo Pascal is Smaller Than by baddox on Sunday October 30, 2011 @08:05PM (#3175783)
A language's grammar wouldn't necessarily be a good indicator of implementation size, would it?
Re:Things That Turbo Pascal is Smaller Than by barrkel on Sunday October 30, 2011 @08:13PM (#3175804)
Pascal'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.
Re:Things That Turbo Pascal is Smaller Than by tluyben2 on Sunday October 30, 2011 @08:33PM (#3175863)
There 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.

Re:Things That Turbo Pascal is Smaller Than by colanderman on Sunday October 30, 2011 @08:51PM (#3175902)
"parsed and codegenned" he said. Any Lisp compilers like that?
Re:Things That Turbo Pascal is Smaller Than by ajross on Sunday October 30, 2011 @11:08PM (#3176203)
No, 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.

Re:Things That Turbo Pascal is Smaller Than by rayiner on Sunday October 30, 2011 @11:55PM (#3176306)
I don't know any practical algorithm for handling closures that'll let you code-gen Lisp in one pass, but in general writing Lisp compilers is frightfully easy: http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf
Re:Things That Turbo Pascal is Smaller Than by groovy2shoes on Sunday October 30, 2011 @10:29PM (#3176128)
I 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.
Re:Things That Turbo Pascal is Smaller Than by xyzzyz on Monday October 31, 2011 @07:05AM (#3176995)
"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.

Re:Things That Turbo Pascal is Smaller Than by fogus on Monday October 31, 2011 @07:02AM (#3176988)
ClojureScript has a two-pass compiler; more if you consider GClosure a step.
Re:Things That Turbo Pascal is Smaller Than by silentbicycle on Monday October 31, 2011 @09:31AM (#3177283)
No, but Lua works that way.
Re:Things That Turbo Pascal is Smaller Than by barrkel on Monday October 31, 2011 @10:01AM (#3177368)
It's easy to write very small interpreters, even ones that JIT code. So much so that some approaches to shrinking software have historically been to write a little VM interpreter, and compile the source code to target that rather than the actual CPU. A compiler that produces code that no longer requires a runtime (in the VM sense - inverted control) is slightly more work.

Turbo Pascal's code generation was simple and naive. It had little optimization. It literally output the machine code as it parsed. There was no AST, not even an expression tree.

(I have the source code to the final version of the Turbo Pascal compiler on my disk. It was used for Delphi 1.)

Re:Things That Turbo Pascal is Smaller Than by outworlder on Monday October 31, 2011 @10:51AM (#3177523)
>(I have the source code to the final version of the Turbo Pascal compiler on my disk. It was used for Delphi 1.)

Is that still under copyright? And chance it could be released?

Re:Things That Turbo Pascal is Smaller Than by barrkel on Monday October 31, 2011 @11:33AM (#3177714)
As far as I know it is still under copyright. Anders Hejlsberg's name is in the comment headers; it was largely rewritten in 1986 and 1987 for TP4. I believe it belongs to Embarcadero, the company I work for, after they bought the developer tools division from Borland.

I have no idea about releasing it. I'm entirely the wrong end of the company to ask about it.

Re:Things That Turbo Pascal is Smaller Than by groovy2shoes on Sunday October 30, 2011 @10:37PM (#3176143)
Those billion Lisp implementations primarily exist because Lisp is fashionable; Pascal is not. In the past, toy Pascal compilers have actually been a popular project (especially in introductory compiler courses).
Re:Things That Turbo Pascal is Smaller Than by 4ad on Monday October 31, 2011 @05:38AM (#3176858)
Go can be parsed in one pass without a symbol table.
Re:Things That Turbo Pascal is Smaller Than by sjs on Sunday October 30, 2011 @09:36PM (#3176015)
Here's a Pascal-ish parser: http://compilers.iecc.com/crenshaw/
Re:Things That Turbo Pascal is Smaller Than by groovy2shoes on Sunday October 30, 2011 @08:10PM (#3175796)
Not 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.
Re:Things That Turbo Pascal is Smaller Than by bhangi on Sunday October 30, 2011 @09:17PM (#3175970)
Indeed 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.
Re:Things That Turbo Pascal is Smaller Than by groovy2shoes on Sunday October 30, 2011 @10:21PM (#3176106)
I wasn't aware that the runtime was included in the executable. Oh, the things we did in the DOS days!
Re:Things That Turbo Pascal is Smaller Than by MatthewPhillips on Sunday October 30, 2011 @08:38PM (#3175876)
Interesting, I didn't know this but Turbo Pascal was written by Anders Hejlsberg (of Delphi and C# fame).
Re:Things That Turbo Pascal is Smaller Than by skeptical on Sunday October 30, 2011 @09:26PM (#3175988)
Yes it would. Not a bullet proof one (is there any?) but a good indicator.