5 ms·
I’ve never had any direct experience with Pascal (though I remember my dad telling me a story of an assignment he had in college to write a queue of queues in P
by cnasc 6y ago
I’ve never had any direct experience with Pascal (though I remember my dad telling me a story of an assignment he had in college to write a queue of queues in Pascal).
From the perspective of the Alan Perlis quote “A language that doesn’t affect the way you think about programming is not worth knowing,” is it worth it for me to give FreePascal a try? Or if I have experience in other procedural languages have I pretty much seen what it has to offer already?
- andi999 6y agoIf you know C you 'know' Pascal. What the best thing about Pascal (and its successor Delphi) was the blazing fast compilation time and I am not sure that freePascal has that. Also what I really hate about Pascal is it is dishonest. It tells you it is very structured and your code will be better because of limited expressiveness. But then the 'writeln' 'function' needs to be intruduced at the compiler level - you cannot write such a function in the Pascal grammar. (maybe with freepascal you can nowadays) What I liked though is that it didnt have the empty statement ';' so you really had to understand the semantics. Sometimes you were not allowed to end you statements with ';' (since they were ended by the block, so this would require the emptystatement). I think freepascal does not have this feature anymore (which is the thinking changing). And just one more thing: Personally I would try to learn ADA before diving into Pascal.
- memsom 6y agoNo, sets. Sets are amazing. I still miss them to this day. Pascal also had sub ranges long before C# and the type system was very good. Delphi dereferenced its object model be default, so you could use dots rather than the awkward ^. Of pascal (-> in c++ and C)
- JoeAltmaier 6y agoImplementations sucked. They were bit vectors, limited to one machine word in length. So they were 16, 32 or 64 limited depending on where your program ran.
- ac42 6y agoI'm pretty sure sets supported up to 256 elements (32 bytes) in Turbo Pascal on 16 bit systems, because you could manage ASCII characters with them. Yes, didn't scale. Yes, tons of use cases nonetheless.
- benibela 6y agoThat is always so in Pascal It has the best possible ideas, and then fuck up the implementation. Recently, I tried to use a set on a three valued enum. With three values it should have worked perfectly. But no, the set was not allowed. Because the values were -1, 0, 1 and FPC apparently only can create set on non-negative integers
- hsitz 6y ago> What the best thing about Pascal (and its successor Delphi) was the blazing fast compilation time and I am not sure that freePascal has that. I'm not sure how FreePascal compares to Delphi in compilation speed, but I expect both are blazing fast. The compilation speed is a result of the language design of Pascal, and the fact that compilation can use a "single pass compiler". Go is another language that has this feature. Compilation times are so fast that development can feel similar to using an interpreted language.
- yawaramin 6y agoOCaml has this compilation speed heritage too through its roots in Modula-2: https://dev.to/yawaramin/ocaml-interface-files-hero-or-menace-2cib https://dev.to/yawaramin/ocaml-interface-files-hero-or-menac...
- jonsen 6y ago> ... it didnt have the empty statement ';' ... > Sometimes you were not allowed to end you statements with ';' (since they were ended by the block, so this would require the emptystatement). Pascal has empty statements. They are exactly that - empty. In C syntax ; is a statement end token, so the empty statement is ‘;’. In Pascal ; is a statement separator token, so the empty statement is ‘’, and ‘;’ is two empty statements. So the typical error is to write “....... ;” where only one statement is syntactically allowed. Example: if x > y then x := y ; else ... Syntax error. Only one statement allowed between then and else. then { x := y ; } else ... is Ok. The blocking makes two statements into one.
- andi999 6y agothanks.
- 7thaccount 6y agoAda and Pascal have some syntactic similarities, but I'm not sure they cover the same kind of niche enough for someone to say "I'd learn Ada prior to Pascal". Today, Delphi is used in some shops the same way C# or Java is used in others. Free Pascal with Lazarus is kind of like a free version of that. You can quickly build desktop apps. Ada is nothing like that. It's almost exclusively used in the defense industry and others like aviation and infrastructure where the code is likely to be embedded and can NOT fail. One is for standard business and one for critical infrastructure.
- andi999 6y agoI agree, but then you wouldnt start new programs with Delphi these days, would you? (To me Delphi is the Cobol of GUI, will be still around forever, but less and less new projects)
- 7thaccount 6y agoI don't think many start new projects in Ada either unless you're working for Lockheed Martin or another contractor and even then, they've largely gone the C++ route. What do people use today? Java, C#, C, C++, Python, R, JavaScript, Php. What might become popular someday? Rust.
- andi999 6y agoYes, which worries me. I talked to a guy working in safety related software design (safety like car breaks), and they are going to C++, since there are not enough Ada/Spark developers. Which is a pity, since Spark allows you to prove correctness (in a special sense)
- idiocrat 6y agoWhy don't you try out and see what it is about? Any experience is just a plus.
- TurboHaskal 6y agoFrom such perspective it won't teach you anything new if you already know C. I would say Pascal's killer app today is Lazarus. An open source, multi platform GUI RAD IDE. https://www.lazarus-ide.org https://www.lazarus-ide.org
- zyxzevn 6y agoThe modules (called units) are a huge improvement for managing large projects. Also extremely fast in compilations. The string handling are much better than C. Most is just automatically. You would not even encounter any difficulties until you start to interface with C libraries. And then it is still easy. Due to this and strong typing and bounds-checking you automatically avoid most memory errors that you get in C. But you can make it as complicated as C, with pointers to pointers to arrays, disable bounds-checking/type-checking, etc. There are some limited parametric type possibilities. The disadvantage is the absence of closures/lambdas. Instead you have to make pointers to functions, like in C. Or use Objects like in Java. But with manual memory management. The manual memory management and type declarations give extra overhead. Like in C. A lot would be avoided with inline variable declarations with automatic typing.
- tangentstorm 6y agoIn some ways, pascal had such an impact that many of its revolutionary ideas (structured programming) are now so commonplace as to be unremarkable. The way primitive sets and enumerated types fit together is still a rarity, as far as I know. (You can accomplish the same things in any low-level language, but the pascal syntax make it really nice.) Interfaces in pascal are fairly interesting because they allow you to implement your own addref/decref routines for automatic reference counting. This was made for COM, but you can plug it into whatever reference counting scheme you like (say if you want to write python extensions or whatever). The main thing is still probably the component system though, and the tight integration with the development environment. It's kind of a trip the first time you configure an IDE plugin and realize it just recompiled the whole IDE for you.
- benibela 6y ago>Interfaces in pascal are fairly interesting because they allow you to implement your own addref/decref routines for automatic reference counting. This was made for COM, but you can plug it into whatever reference counting scheme you like (say if you want to write python extensions or whatever). Free Pascal now has a new way for that, stack objects/record with custom init/cleanup code. Real RAII. But not if used with inheritance
- megameter 6y agoPascal is unsurprising in a mostly good and sometimes frustrating way. The syntax will be the primary barrier. Things like nested if-else with multiple conditionals are just a little more persnickity if you've been using C braces for decades. But the language, in the Borland dialects that most are using now, is somewhere in between C and C++ in terms of power overall: it's a little safer by default, still manual memory, but without needing to fling around quite so many pointers. And those compile times! A pretty well-suited language for game coding, actually. And in terms of writing production code, libraries may or may not be a barrier. Basically, Pascal's current ecosystem exists in the shadow of one of the best RAD environments of the 90's - Delphi. That's where a lot of the code got written, and there's a definite focus on native desktop apps that remains. There are certainly good libraries available, but many are old, Delphi-centric, and lack polish - haphazard accumulations from developers that are very "get-er-done" and unconcerned about reuse. You can always bind C code, of course, but today it's easy to end up saying, "well, but I could just get a working library in (Go/Python/Node/etc) and be done" and thus end your Pascal journey before it starts.