11 ms·
Guide to modern Object Pascal for programmers
- randcraw 10y agoWonderful! I've long been a fan of end-of-life Turbo Pascal and Object Pascal thereafter. I love the language's simplicity, type safety, and speed. To my eye, Object Pascal is the goto language for minimalist OOP. In the spirit of C, it's short, sweet, and sufficient.
- crypt1d 10y agoThis is like a blast from the past. My first interaction with programming was with Borland Delphi 6 which had its own dialect of Object Pascal. Poor internet connection and no stackoverflow had me figuring out programming on my own, mainly by using Delphi's help books and looking at code examples. Which is probably why I eventually lost interest - I couldn't figure out complex OP concepts on my own at that age. Fast forward to the present, I really envy the people learning programming today for the first time. The amount of possibilities and resources now is many orders of magnitude bigger, making learning so much more enjoyable. Edit: grammar
- agumonkey 10y agoI had a memory lane trip few months ago. Got to run turbopascal 7.0 in dosbox. It's an amazing piece of software. The included help is great. And the language was deceptively simple. I didn't understand the value of intervals, set types, even ordinals (succ and prec)... Pretty neat. Small sidenote: even QBasic was amazing for a free code environment in these days. The language is bare, but QBasic had some form of modularization. I thought nothing of it at the time, but it feels they tried to make people think in terms of isolated "objects" not large source files full of global variables.
- nickpsecurity 10y agoQBasic was what I started on. Built my original hacking tools and 4GL prototype in it. The semi-memory safety, simple syntax, and rapid compilation let me iteratw stuff out quickly.
- SmokyBorbon 10y agoI learned Pascal in 1999 and it had classes then. I don't know why the author pretends otherwise.
- philippeback 10y agoFreePascal has indeed a lot of good stuff. I wrote a ton of Pascal a long time ago and always liked OWL for Windows development. Compared to MFC, well, that was much better to they eye. The main issue to wider adoption is that there are lots of integrations to do in modern applications and I am not sure that FreePascal can catch up. Still, it is great for coding, as compilation is super fast and one can pretty much understand what's going on.
- leledumbo 10y agoI assure you, it can. Be it through API, custom socket protocol, bindings, no problem. When one doesn't exist yet, creating yourself is not a big deal.
- hudell 10y agoI worked with different versions of Delphi for 7 years. I miss it sometimes. The language was quite good, but people would always judge it because of the IDE that made it "too easy"
- r00fus 10y agoDelphi was years ahead of it's time. I remember coding a patient data entry system (for the VA) and submitting machine learning college courses. Always got pushback, but it was quite maintainable code and it ran fast.
- voltagex_ 10y agoI'm a programmer today because someone gave me a pirated copy of Delphi (6?). Sorry Borland! See also another interesting discussion on Delphi here: https://news.ycombinator.com/item?id=7613543 https://news.ycombinator.com/item?id=7613543
- bunnybender 10y agoI started programming "for real" with Turbo Pascal (5.5 probably) while in high school. It was easy to copy it for personal use from there. Although later I actually went and bought Borland Pascal 7.0, a big and fairly expensive box with the disks and lots of books inside. I think I wanted it to be able to create Windows applications, but ended up hating Windows, so really only utilized a little of its potential..
- tjl 10y agoI saved my money and bought a copy of Turbo C. Before that, I used both Basic (first on the TI 99/4A then on QBasic) and Pascal (on computers in schools) with some Logo, Icon, and later AutoLisp (for AutoCAD). I really liked Pascal and I always thought it was somewhat unfortunate it didn't survive outside of a small programming niche.
- boznz 10y agoNice little intro, everything there would compile fine with Free Pascal on Linux, Windows or OSX BTW Shoutout to the FreePascal/Lazarus team, the improvements over the past 12 months have been great and finally convinced me to make the move from Delphi. I even created my first Real Linux desktop program two months ago to replace an XP status display screen in a factory.. A real big step for me :-)
- e12e 10y agoThis is interesting - I knew work was ongoing on FPC/Lazarus - but not so much that it might draw people away from Delphi. Could you say something more about what you used to miss, that's now available - and how you use Delphi/Pascal?
- mamcx 10y agoDelphi is the MOST mismanaged language ever produce on earth! and have survive several changes of owner. Currently, this is the storm, where a large team on charge of the IDE and other stuff is fired: https://plus.google.com/105481197125997414290/posts/FnLvMteQ4dU https://plus.google.com/105481197125997414290/posts/FnLvMteQ... The gossip now is that only 8 people are left on charge of it: Paul said >2016/06/24 at 21:14 >Yes and here some hot news. >Delphi and C++Builder Team now is only 8 developers >IDERA contract free lance developers without experience in >Delphi and pay per job Is ironic, but in one of the oldest forums of Delphi (where I'm moderator) some of us have left the language long ago (or more exactly, use it sparly), yet still are there! And this one was our discussion (spanish) http://clubdelphi.com/foros/showthread.php?t=90494 http://clubdelphi.com/foros/showthread.php?t=90494 --- So yes, Delphi love is strong, but this was the start of the trouble: https://www.quora.com/Why-did-Borland-fail?share=1 https://www.quora.com/Why-did-Borland-fail?share=1 --- So the thing is Delphi improve a lot, yet is mismanaged, cost too much, the only way to get bugs fixed is buy next version and each few months yet another company buy it. The thing is so crazy that some people are considering seriously do a buy from the community (ie: Pay money to buy the product)...
- wila 10y ago
- Animats 10y agoIf only programming had gone that way. It almost did. The original Macintosh was programmed mostly in Apple Pascal. Wirth's original Pascal had some serious limitations, which led to far too many Pascal variations. Unfortunately, none of them won out over C.
- solidsnack9000 10y agoDo you think device drivers or servers like Nginx could ever have been written in Pascal?
- mamcx 10y agoOf course. And the "limitations" of pascal is a larger-than-life myth! Is like judge C from how it was at the first release. By the time of TurboPascal the things was great. The peak was around Dephi 3 and it was possible to circle around C/C++ all day long, barring, obviously that the market share and ecosystem was bigger for C/C++ so that answer why you "cant'" do some stuff. Because was not implementation or library for it, NOT BECAUSE THE LANGUAGE.
- pjmlp 10y agoOf course. In CP/M, MS-DOS and a few other home systems, Pascal used to have more compiler variants available than C. Pascal dialects like Turbo Pascal had all the features of C, plus modules, OOP, type safe enumerations and many other features. If it wasn't for the rise of FOSS in the late 90's, widespreading the UNIX culture and thus C, Pascal derived languages might have been kept around.
- int_19h 10y agoLet me give you just one example adding to the other comments. In Turbo/Borland Pascal, you could declare global variables (including arrays) allocated at a specific memory address, e.g.: var video: array[0..4000] of byte absolute $B800:0000; It also had a special modifier for functions, that made them work as interrupt handlers. And inline assembler with nice, readable syntax that allowed addressing variables directly. Consequently, it was actually easier to do most low-level DOS hackery in Pascal rather than C. So yes, I'd expect it do just fine for drivers, as well.
- johnthuss 10y agoManual memory management is the weak point of Pascal. It limits functions to never returning newly constructed objects, which really limits the expressiveness of APIs both in the standard library and in custom code. The manual reference counting system in old objective-c provides a better solution which while still cumbersome, doesn't prevent good powerful APIs. The automatic reference counting capability of Delphi interfaces always seemed like a good idea to me, but seems to be rarely used.
- deleted 10y ago[deleted]
- clouddrover 10y ago> It limits functions to never returning newly constructed objects, which really limits the expressiveness of APIs both in the standard library and in custom code. How? Set the return type of the function to be the object type you want, then result := TYourObjectType.Create; and you'll return a newly constructed object.
- badsectoracula 10y agoNote that Free Pascal does have automatic reference counting for interfaces, although it is not a good idea to use it for memory management because (like with Delphi) it is very easy to pass around an instance that isn't counted and end with memory leaks. However one of the compiler's designers has an experimental branch which allows you to mark classes as being automatically managed and any instance and use of those classes becomes reference counted. So at some point it might become part of the main compiler (although it is probably far from now since AFAIK it isn't something people really ask for from FPC and there are other things to do).
- revanx_ 10y agoIt limits functions to never returning newly constructed objects No it doesn't. The automatic reference counting capability of Delphi interfaces always seemed like a good idea to me, but seems to be rarely used. You mean rarely used by people who are amatures, developers have always been pushed towards programming against interfaces.
- alayne 10y agoBut why. I don't understand why you'd use Pascal today when you could use C++. I jumped over 25 years ago and never missed Pascal the language, only the Turbo Pascal development environment. Many languages later I still have never wanted to go back and write in any Pascal variant. It's a verbose, weak, and inexpressive language.
- visarga 10y agoI agree about the IDE of Turbo Pascal, but Delphi 1.0 was pretty RAD too. Only thing I don't like about Pascal of 20 years ago was the lack of proper lists and dictionaries, and the tedium of writing long keywords like begin and end all over the place.
- ViktorasM 10y agoAh, the days when I typed "begin" and "end" at the speed of puting a curly brace. Don't actually feeling the need to go back though. It's not about language properties anymore, but the library ecosystem. I hated when anything useful in Delphi was a C dll port. You're never a first class citizen.
- leledumbo 10y agoGood to know that many things are native Pascal nowadays, even some great Pascal people choose to either write from scratch or native porting instead of writing wrappers. Personally I don't mind using wrappers, but having native Pascal counterpart is better in the long run since no 3rd party implementation dependency required, things can be fixed and improved right away.
- clouddrover 10y ago> I don't understand why you'd use Pascal today when you could use C++. Here are some "whys": 1. https://news.ycombinator.com/item?id=11005203 https://news.ycombinator.com/item?id=11005203 2. http://ian.hixie.ch/programming/ http://ian.hixie.ch/programming/ 3. http://ziotom78.blogspot.com/2015/01/lfi-data-analysis-with-fpc.html http://ziotom78.blogspot.com/2015/01/lfi-data-analysis-with-... 4. http://freepascal.org/advantage.var http://freepascal.org/advantage.var 5. https://www.embarcadero.com/products/delphi/features https://www.embarcadero.com/products/delphi/features Object Pascal has changed a lot in the last 25 years. You should check out modern Object Pascal. It's pretty nice.
- ivan_gammel 10y agoLast time I've been programming on Pascal was almost 20 years ago, just before I've learned Java. The Delphi was a breakthrough in 90s, but today, when we have MLoC-size apps, this language is just too outdated, fighting the wars of the past and preserving some unnecessary legacy. Memory management? Dependency management? Reflection and generative programming support? There are some things, of course, that are still nice to have in languages like Java (I liked the class helpers), but, thinking about development productivity and code quality, I'm not sure this can be called anything else but a steampunk toy, as modern as contemporary replica of some Art Nouveau thing.
- vidarh 10y agoThe vast majority of apps today are still small, and certainly nowhere near MLoC-size. It certainly lacks features many of us takes for granted. But people e.g. still write C, that is far more primitive, so if people want to do Object Pascal, why not. Though it's a shame to see it effectively win over a language like Oberon (if one first is to stay in the Pascal lineage).
- mhd 10y agoOr Modula-3, if you're not going the minimalistic route of the Wirthian tradition.
- ivan_gammel 10y agoThanks to lots of available 3rd party frameworks, modern web portal can be just 50-100KLoC, but add all the dependencies and you may become really close to million lines. All these dependencies have to be resolved, loaded and processed in order to compile your code, namespace and version conflicts must be avoided, test dependencies separated from production ones etc, so you cannot ignore it as some magic on the back stage. Of course, there's still some room for low-level utilities or one-time scientific calculations, for which Pascal can be used (hell, I remember that times, when we, the kids, hacked our school network to get super user access by writing keyloggers and simple viruses on TP6), but should it be a language of first choice for that today?..
- vanilla-almond 10y agoDoes anyone use Pascal for web development (cgi, dynamically generated web sites)? I would love to use a fast, low-memory, natively-compiled, strongly typed language with a clear, readable syntax. Pascal meets all these requirements. Golang is the other language I'm considering. It has many web-related libraries, excellent documentation and a lot of momentum. Free Pascal, unfortunately suffers from fragmented documentation (the wiki is often out-of-date and hard to navigate). Despite that, I still prefer Pascal syntax over Go (yes, really). So, if you are using Pascal for web development, what has been your experience? Would you recommend it?
- sevo 10y agocheck out mormot docs: http://synopse.info/files/html/Synopse%20mORMot%20Framework%20SAD%201.18.html http://synopse.info/files/html/Synopse%20mORMot%20Framework%... forum: http://synopse.info/forum/viewforum.php?id=2 http://synopse.info/forum/viewforum.php?id=2
- edwinyzh 10y agoAgreed, I couldn't recommend mORMot more! Several more notes: - The docs for mORMot is very much lengthy and is not written by a native English speaker, you might feel overwhelmed getting started by reading it, but actually it's very simple to start, with the supplied 33 samples: https://github.com/synopse/mORMot/tree/master/SQLite3/Samples https://github.com/synopse/mORMot/tree/master/SQLite3/Sample... - with Lazarus/FreePascal, mORMot supports almost all Linux distros, check this forum post: http://synopse.info/forum/viewtopic.php?id=3319 http://synopse.info/forum/viewtopic.php?id=3319 - Check the commit logs of its github repository, see how active the development is. - The FPC/Lazarus foundation (http://foundation.freepascal.org/ http://foundation.freepascal.org/) was launched several days ago, check the Projects menu - you can expect a lot of modern language features would be added. - The newpascal.org site was launched recently to get you started easily for Linux web development with mORMot/Lazarus
- Artlav 10y agoWell, yes and no. I used Pascal to write some web apps, i.e. computer graphics explanations [0], visual philosophy [1], and simple games [2]. It's a nice ability to have - being able to share complex programming as you share written text. However, i wrote my own compiler that among other things output C, which is then Emscripten-translated to asm.js you see. This is the complete opposite of an easy, low friction path you'd want for web development. [0] http://orbides.org/apps/superslow.html http://orbides.org/apps/superslow.html [1] http://orbides.org/apps/motion.html http://orbides.org/apps/motion.html [2] http://orbides.org/apps/the_bits.html http://orbides.org/apps/the_bits.html
- regularfry 10y agoI wonder, if they'd added some sort of concurrency primitive to the language a few years ago, whether it might have stolen Go's crown.
- vanilla-almond 10y agoIt's a nice thought, but Pascal's age and its verbose (but highly readable) syntax means that many programmers will never give it more than a passing glance (regardless of the modern features it has to offer).
- chappi42 10y agoAge and verbosity has imho no influence. I'd rather say the following points are important: - the project is not on github, issue tracker looks like from 2 centuries ago, ditto website, several different forum (maillists) instead of e.g. one discourse instance for the 'whole pascal project' - the granularity of the code libraries is difficult (compiler, rtl, component sets (ui and non-ui), tools, lazarus, web, ...). You cannot just clone one of these parts and work on it - no (fully supported) Cocoa support and thus the Mac platform is a bit handicapped (32bit Carbon), too many obscure legacy platforms, too many options, too complicated - no modern defacto standards, e.g. md/rst formatted docu, different syntaxes/dialects (fpc, delphi, mse, oxygene, smartpascal, etc...) - iirc license situation is a bit 'chaotic' (some LGPL 2.1 (with exception), some GPL 2 (3?), some MPL 1.1/2, more?) and in comparision to newer languages, e.g. go/rust (MIT, APL) the licenses are more (copyleft) restrictive. I like that more modern environments dropped ideological for pragmatic - afaik no big company/organization invests money into the pascal ecosystem (if this were the case, probably most of the points above would be different) This is just to say why I think it is not more popular, I very much appreciate the project/work, it's great!
- samuell 10y agoThe forums (and I think wiki) etc are astonishingly up-to-date though in my experience, and I have mostly got a useful answer in the forum within an hour or so, so I would say, don't judge the book by the cover :)
- samuell 10y agoI was tasked with building a small utility for copying out a few GB of files from a super-complicated folder structure, and convert it into a different structure, with the requirement that it should have an interactive GUI (to do various selections interactively), and run natively on Windows and Mac. Couldn't have found an easier route than to build this in FPC with Lazarus. Even though I had hardly coded a line in the language before, it was built from scratch to "happy end-user" in 80 hours, including learning the language. I built it on Xubuntu, then imported it on my Windows VM and compiled, WITHOUT A SINGLE CHANGE! On Mac, I needed to add a missing import statement or so. Simply an outstandingly productive tool for open source, cross-platform GUI development. (The tool: https://github.com/NBISweden/mdc-file-export https://github.com/NBISweden/mdc-file-export )
- samuell 10y agoBtw, a shoutout to the awesome OmniPascal project, which allows you to write Delphi and FreePascal in the Visual Studio Code editor (when you are not building GUI apps, and and/or don't need a full blown visual IDE, or just for navigating around in legacy code bases): http://www.omnipascal.com http://www.omnipascal.com Unfortunately, code completion is so far only available on Windows [1], but will hopefully come in due time (you can vote for the issue in [1]). [1] https://bitbucket.org/Wosi/omnipascalissues/issues/6/add-rich-language-support-for-mac-and https://bitbucket.org/Wosi/omnipascalissues/issues/6/add-ric...
- girvo 10y agoIt's amazing to see how fast VS: Code is picking up extensions with full autocomplete, go-to definition, and other IDE-styled features. Atom's equivalents are rarely as nice, unless you're using Nuclide because they wrote their own damned framework inside the editor to achieve those features! I think it's because VS: Code's APIs are built around exposing those sorts of features nicely and simply. - OCaml [0]: IntelliSense, go-to-definition, interactive debugging. This plugin is so well done that I feel VS Code is the best editor for my OCaml work now! - Nim [1]: IntelliSense, go-to-definition, linting, Nimble building integration - Purescript [2]: IntelliSense, compilation, linting, quick fixes for common errors, and type inspection Seriously, more and more are added every day, which is just awesome. I'm still annoyed at small UI parts of VS: Code, but honestly the functionality and speed make it second to none in my opinion. --- [0] https://marketplace.visualstudio.com/items?itemName=hackwaly.ocaml https://marketplace.visualstudio.com/items?itemName=hackwaly... [1] https://marketplace.visualstudio.com/items?itemName=kosz78.nim https://marketplace.visualstudio.com/items?itemName=kosz78.n... [2] https://marketplace.visualstudio.com/items?itemName=nwolverson.ide-purescript https://marketplace.visualstudio.com/items?itemName=nwolvers...
- samuell 10y agoInteresting with the new FreePascal and Lazarus foundation, which was just started a week ago, to support development of it as an alternative to Delphi [1] (Source [2]) [1] http://foundation.freepascal.org http://foundation.freepascal.org [2] https://plus.google.com/105481197125997414290/posts/FnLvMteQ4dU https://plus.google.com/105481197125997414290/posts/FnLvMteQ...