4 ms·
I used to have a job writing Pascal code. I liked it; it was easy to predict how it would behave. It was verbose, but in exchange it was easy to read stuff writ
by denton-scratch 7y ago
I used to have a job writing Pascal code. I liked it; it was easy to predict how it would behave. It was verbose, but in exchange it was easy to read stuff written by other people. And I've long thought it was a mistake to abandon strong typing. It's good if the compiler (or interpreter, or whatever) can report silly mistakes at the earliest possible stage. (I knows most people disagree, stop with the rock-throwing!)
I never tried to write a Pascal compiler, but I think it is pretty easy - I wrote a source-code debugger for one implementation of the language, which I think involved reverse-engineering the targeted compiler (can't really remember - too long ago). I had never before encountered a source-code debugger for any language at all (other than 8086 Assembler, which only just counts).
I just thought it was a cool idea, and one that would help me in my work. It was a "hobby" task, and I had a full-time job, a young wife, and kids. It can't have taken more than a handful of weekends.
- folkhack 7y agoI was a kid learning programming languages and after QBASIC I struggled to find a language that I could grok as a 10-12yr old right before the turn of the millennium. I shared with my uncle that C and C++ were difficult for me and he gave me a whole bunch of Turbo Pascal books... And I fell in love =) Pascal was an approachable language and was exactly what I needed at the time to push forward, revisiting C in my highschool years. I built dumb Dragon Warrior clones, homework helpers, etc. It was super readable for me too. Of course I look back with rose tinted glasses on but Pascal was a huge part of my programming growth - I will always remember it fondly!!
- badsectoracula 7y agoI also went from BASIC to Turbo Pascal (though in my case it was GW-BASIC) which i learned from a thick book - that book was my treasure for a long time as a kid. I remember being annoyed initially because i had to declare my variables before using them, but it was worth it since unlike GW-BASIC, Turbo Pascal was able to create EXE files (which was the only reason i decided to use it :-P).
- pjmlp 7y agoTo join my voices to the choir. Timex 2068 Basic, Z80, GW-Basic, Turbo Basic, 80x86 and then came to learn Turbo Pascal (started with 4.0 and did all of them up to Delphi 2). Thanks to this path I got to learn systems programming in high level mostly safe languages, modules, OOP and my very first framework experiences, Turbo Vision (OWL, VCL as well). For me this was a very lucky path, because I never got tainted that C and C++ were the only God sent programming languages for systems programming. And best of all, I never had any issues to deal with pointers in C and C++.
- sehugg 7y agoThe original Turbo Pascal was a pretty simple one-pass recursive-descent compiler: https://www.pcengines.ch/tp3.htm https://www.pcengines.ch/tp3.htm It looks like this one has a lot of constraints for easy 6502 code generation, like only allowing 8-bit variables in a FOR loop.
- vidarh 7y agoCompiling most languages for 6502 boils down to either adding lots of constraints, or conceding the compiled code will end up being awfully slow. E.g. allowing 16 bit types => slow in most cases; passing things on the stack => slow or horribly restricted (because the hardware stack is tiny, so you end up emulating one at high cost if you want to be able to have more than 256 bytes on the stack). The problem is you really wouldn't write code for these machines the same way you write code for a bigger machine. Not least because most of them had so little memory that keeping track of an assembly program that size was not really a big deal. A lot of C64 demos were written in machine code monitors with no labels, no macros, no variable declarations, that just assembled/disassembled line by line, and saved by just saving the memory regions to disk - no separate source-code. It was a revelation to get a proper assembler... But that meant self-modifying code (often seen used for 16 bit loops...) and effectively global variables all over the place (= data in fixed memory locations...) was extremely common as well. Trying to shoehorn that into a language like Pascal means basically writing everything in the main block and not call any functions, and even then you're unable to use most of the dirtier tricks..
- gdy 7y ago"And I've long thought it was a mistake to abandon strong typing... I know most people disagree" How do you know that?
- jchw 7y agoI, for one, disagree that most people disagree. Strong typing effectively enforces variants, and the stronger and more powerful the type system, the more it can do, with the trade off of added complexity (though not necessarily verbosity, at least not linearly with complexity.) Strongly typed enums are a great example of a big value add. Not to mention the improvements types add for developer experience and the added implicit documentation they provide!
- denton-scratch 7y agoWell OK, I don't know what "most people" think, and I'm glad to be contradicted on this matter. Most of the people I've worked with in the last decade have favoured weakly-typed languages, and Pascal in particular has been a target for ridicule (among the small proportion of my colleagues who have ever looked at the language). The version of Pascal on which I was raised was an Intel Pascal; I can't find a link just now. It was definitely not Turbo Pascal, which I think was Borland. But both versions had this restriction on the size of a compiled module, complete with stack and data - 64K, the size of a 8086 memory "segment". These 8086 vices have genes that survive in Intel architectures to the present day. I also did some work with PL/M ("Programming Language for Microprocessors", I think), a much nicer language than Pascal, targeted at those same 1980s 8-bit chips. Pascal was invented as a teaching language; PL/M was an IBM product designed for production work - a cut-down version of PL/1, which was a heavy-duty mainframe language. Pascal and PL/M are similar, and they're all children of ALGOL. I taught college classes using Turbo Pascal; I had barely any experience with that compiler, and the students were a nightmare (it was not by any measure a "top school"). I faked it, and I got away with it.
- Narishma 7y agoI think only the first few versions of TP were limited to 64k binaries (.COM files), and that may have been because they were mainly aimed at Z80 CP/M systems more than the IBM PC.
- 29athrowaway 7y agoDynamic typing is more work: adding code that validates types at runtime, validating types of variables in unit tests, validating types manually while refactoring, documenting types of variables...