[HN Gopher] Using the Free Pascal IDE for a Week
___________________________________________________________________
Using the Free Pascal IDE for a Week
Author : memorable
Score : 112 points
Date : 2022-10-14 12:44 UTC (10 hours ago)
(HTM) web link (cypherphunk.blogspot.com)
(TXT) w3m dump (cypherphunk.blogspot.com)
| GartzenDeHaes wrote:
| Someone mentioned the idea of a TUI VS Code the other day and I
| thought it was a great idea. Also, how about a text-only reboot
| of the web?
| mikewarot wrote:
| Project Gemini [1] did just that. It's been mentioned here a
| few times.
|
| [1] https://gemini.circumlunar.space/
| salmo wrote:
| In a lot of ways neovim can be a TUI VSCode. It supports the
| language server spec and all that. It does require (kinda
| complicated) config. But you can steal examples from the
| internet. There's also the ecosystem of plugins to do fancier
| stuff like code snippets, menus, status bars, etc.
|
| But I don't do things like jumping to declarations with it.
| That's likely a thing with some plugin, I just don't know. I
| generally try to avoid traditional OO languages when I can. I
| used to use IntelliJ for those, but I have actually switched to
| VSCode for them and some of the things I've always used
| vim/neovim for, like larger Go projects.
|
| I make any IDE act like vim because my hands want to do modal
| editing. That's a thing where my habits impact my perceived
| ergonomics. If it doesn't support that, I won't use it. It's
| just too frustrating.
|
| I don't use Javascript except when I have to. If that's part of
| a TUI VSCode for you, then this may not be helpful.
| zozbot234 wrote:
| The LSP, treesitter parsing, debug protocol etc. are good
| developments, but everything else in neovim is just way
| different from VSCode. And the vim modal editing pattern is
| nice for a basic text editor but has pretty poor
| extensibility compared to a menu-driven program - at some
| point you just can't do everything with single letters, you
| need actual, complex commands. So a real T-Vision/TUI
| conversion of VS Code might still be very worthwhile.
| hamburga wrote:
| Not exactly that, but Nyxt allows you to navigate the web from
| your text editor: https://emacsconf.org/2021/talks/nyxt/
| kwhitefoot wrote:
| We need a text mode browser that runs JavaScript properly. Are
| there any?
| haolez wrote:
| This would be very useful in a post-apocalipse scenario. Simple
| to use, simple to run, very powerful on what can be created with
| it :)
| Andrew_nenakhov wrote:
| The best feature I _loved_ about TurboPascal was built-in help.
|
| Press Ctrl+F1 on any function name, and you are instantly taken
| to a very good help page, often _with a working code snippet_
| example!!!
|
| I can't overstate how _insanely great_ it was, especially in pre-
| stackoverflow days!
| figital wrote:
| First learned programming in Turbo Pascal and have fond memories
| of that IDE. Thanks for posting this. Would love to learn of a
| framework for reconfiguring this UX to do whatever I want (menus,
| scripting, etc).
| knodi123 wrote:
| Ha, I remember ages ago, some guy in my computer science class
| was being a jerk to me, so when he wasn't looking, I leaned
| over to his Turbo Pascal IDE and spaced out past the right
| margin of the first line, and typed begin end. Which made
| everything below that in the entire file a comment. His program
| executed quickly, and never did anything, and you had to really
| pay attention to see the UI hint that suggested there was text
| to the right of whatever column was the edge.
|
| I thought it would be a good prank as a form of revenge, but he
| kept getting angrier and angrier and eventually I was too
| afraid to confess. The teacher had wandered over and was
| getting exasperated too. I think eventually they assumed he had
| a corrupted network drive and just nuked his entire network
| account and set up a new one with a new username, and now
| suddenly his compiler "worked" again. Heh.
| tomcam wrote:
| I love that entire story
| hurril wrote:
| I also did that (and Turbo C++). Very fond memories!
| glonq wrote:
| Ditto. Started with the fugly Turbo Pascal 3 IDE, but stuck
| with borland thru version 5 or 6, before moving on to mostly
| C/C++.
| Tozen wrote:
| Good to see Pascal/Object Pascal getting some renewed love, after
| all the C/C++/C# wars. Way too many act like "there can only be
| one", versus explore and appreciate what various languages and
| tools have to offer.
| jksmith wrote:
| Old days brought forward. Remember mark/release? With combo of
| code macros and open arrays using Lazarus/ FPC:
|
| mark_begin // after allocs,creates
|
| [parse1, sl1, sl2]
|
| mark_end
|
| ... lines of code ...
|
| release // end of proc, frees everything you marked allocated
| maupin wrote:
| I have a sudden nostalgia for my high school days using Turbo
| Pascal in the computer lab.
| jqpabc123 wrote:
| _I 'm not sure what the rationale is for maintaining the text
| mode FP IDE. It seems kinda quaint in 2022 to maintain a
| recreation of the old Turbo Pascal editor, but I'm so glad that
| it's there._
|
| I think you just answered your own question. It's there because
| it's functional and works on most if not all of the supported
| developer desktops. Of course, it won't win any beauty contest
| but I suspect most of those using it probably won't either.
| zozbot234 wrote:
| It handily wins a beauty contest among TUI IDEs, though. The
| only reasonable alternative that even supports a similar
| workflow (with CUA-style keyboard bindings and all) is Emacs,
| and text-mode Emacs while fully supported is quite clunky.
| moron4hire wrote:
| One of the things I found interesting about TUIs is that it
| forces your design to be on a grid, defined in units of
| characters. It's easy to make a column of fields that all
| line up on edge. If you want any spacing between fields at
| all, it forces you to make that spacing fit to character-
| width grid cells. So, in a way, it's a little easier to semi-
| accidentally end up with a clean, good-looking design in a
| TUI, if someone is being just a little thoughtful about their
| layout, than it is to be in a full raster-based GUI with
| pixel- or percentage-based positioning.
|
| What I'd like to see are TUIs that embrace terminals running
| on large, high-resolution displays. We don't need to be
| constrained to 80 columns by 25 rows, or whatever.
| mikewarot wrote:
| It expands to fit your terminal size when it starts. I just
| had 150+ columns in mine. It doesn't handle resizes well,
| though.
| kwhitefoot wrote:
| What stops you creating a text ui for more than 80x25?
| moron4hire wrote:
| I mean more that I would like people to remember that the
| terminal can resize larger and develop more apps as TUIs.
| buescher wrote:
| Every time I fire up fpc to fool around and think about
| whether I would actually do something non-trivial in Pascal
| (the answer is 'no') I also fantasize about a very
| opinionated, very non-standard, text-mode Linux distribution
| loaded with DOS-style TUI utilities and applications.
| Something like that would be fun to run on devices like old
| routers.
| anthk wrote:
| Grml is like that. And, before, the Ubuntu remix "Inx".
| marcodiego wrote:
| A long time ago, a guy created a theme for gtk+ which used
| text characters to draw all the widgets. He also created a
| text mode gdk backend. Combine both: you have gtk+ apps
| running on the terminal.
| kevin_thibedeau wrote:
| You can do that with any distro today that has an optional
| windowing environment.
| buescher wrote:
| I mean small and really opinionated - the goal would be a
| look and feel more like a bells-and-whistles DOS setup
| than like Unix. Inspired in part by
| https://prog21.dadgum.com/74.html
| anta40 wrote:
| Probably because not all of them are interested in setting
| their own vim/emacs/etc.
| falcolas wrote:
| This is your annual reminder than vim and eMacs are fully
| featured and extensible IDEs that support code completion,
| folding, and navigation by default.
|
| Or, no, you don't need to use a graphical IDE to develop code, as
| TFA states.
|
| Thank you for coming to my Ted talk.
|
| EDIT: Don't believe me that VIM is an IDE? Read the threads for
| elucidation. :)
| idoubtit wrote:
| > vim [...] extensible IDEs that support code completion,
| folding, and navigation by default.
|
| If "by default", you mean "with the default vim configuration",
| then this assertion is wrong.
|
| Vim does have a definition-search" feature, but it needs hand-
| made configuration for each language, and since it relies on
| regexp instead of parsing the language, it's useless outside of
| micro projects.
|
| To enable real code completion and navigation, vim needs
| plugins and external tools. The modern way is to use one of the
| LSP implementations for vim (I've tried ALE and CoC), but
| that's clearly not "out of the box" for vim.
| falcolas wrote:
| It works perfectly well with C by default - with no addons. I
| will agree, you do need a tags file (though it's is not even
| remotely hand-made (emacs uses these too)), but the rest is
| handled automatically, including code completion based on the
| contents of the tags file.
|
| Code completion, syntax highlighting, goto definition, goto
| tags... these are all core functions of VIM. Addons just help
| it work with languages other than C.
| hvis wrote:
| When the completion is not context-sensitive, it's not
| really what "code completion" is taken to mean these days
| (the last decade, at least).
| aidenn0 wrote:
| Don't forget :make and the tooling around the error-pane
| for navigating to locations emitted as compiler warnings
| and errors.
| ArtixFox wrote:
| bye bye emacs bye bye (n)vim
| rob74 wrote:
| In the case of Free Pascal, may I remind you that there is a
| fully featured IDE called Lazarus which offers all of that plus
| an intuitive user experience (i.e. you don't have to memorize
| all the keystrokes before you can be productive, you can find
| the available commands in them menu and if you use one
| particular command a lot, you can memorize the keyboard
| shortcut) and a graphical tool to build your UI and connect it
| to your code.
| genezeta wrote:
| Lazarus is already mentioned and explained in the first
| paragraphs of the article.
| gnarbarian wrote:
| I can see the argument for emacs being a IDE but isn't vim more
| of an editor?
| jhbadger wrote:
| Vi is just an editor, but vim is "Vi improved", and the
| improvements include the sorts of programmability that Emacs
| is known for, which allow modes to include syntax
| highlighting, code completion, and so on. It's not quite the
| same (the beauty of Emacs is that the executable is mostly a
| Lisp interpreter and the editor is written in the same Lisp
| you can write your extensions in), but close.
| coffeeblack wrote:
| Not if you add about half a million partially conflicting
| add-ons to it, no it isn't!
|
| Sorry. Yes, (n)vi(m) is great and useful and all, but it's
| not an IDE.
| falcolas wrote:
| Vim defaults to being a C IDE, no plugins required. The
| features I called out above are available with no plugins.
| pjmlp wrote:
| So the days of using ctags are long gone?
| falcolas wrote:
| No, you still need ctags to jump to sources outside of
| your current file. But within the same file, it works
| fine without it.
|
| C doesn't have a defined directory structure, and a lot
| of the source/header files you'd use are stored in places
| like /usr/lib and such.
| pjmlp wrote:
| Yeah, but that is the thing, an IDE works with more than
| one file.
| falcolas wrote:
| I feel like you're taking my words in bad faith.
|
| Vim works perfectly fine with multiple files out of the
| box, it just wants a tag file for _jumping_ between
| multiple files and letting autocomplete work with those
| tags.
|
| This is hardly unique to vim (and emacs) - you can't work
| on a project in IntelliJ without first setting up a
| workspace and letting IntelliJ index all those files. The
| only difference is how the index is generated.
|
| Oh, and `:help cscope` (again, thanks aidenn0). In vim
| >=9.0 a tagging tool is now incorporated into the base
| vim install.
| pjmlp wrote:
| Nope, just making the point that vim has lots of things
| to catch up with a proper C IDE in a default install.
|
| ctags was just the first example of many things I can
| refer to.
|
| For example any basic C IDE on a default install is
| expected to have debugging integration, project
| management, among other stuff.
| aidenn0 wrote:
| Note that cscope is significantly better than ctags and
| also built into vim.
| coffeeblack wrote:
| Interesting, didn't know, will try it. Does it do "jump
| to definition" out of the box?
| falcolas wrote:
| Sure does. :) `gd`
| aidenn0 wrote:
| probably "gD" is what you want unless you're looking for
| a local definition.
| coffeeblack wrote:
| :gd
|
| E492: Not an editor command: gd
|
| VIM 8.2
|
| Do I have to activate it somehow? :)
| aidenn0 wrote:
| Have the following file: int foo ()
| { return 3; } int bar()
| { return foo(); }
|
| put your cursor somewhere on the "foo" identifier in the
| second to last line and type "gD" (without the quotes).
| It should jump to the definition of foo. It's not perfect
| but works for much code without crazy preprocessor stuff.
| By default it's file-local, but you can give vim a list
| of include files to search as well.
| coffeeblack wrote:
| Ah, upper case D, yep that works! Thanks!
| aidenn0 wrote:
| yeah lower-case "d" is for local definitions (it just
| searches for the first appearance in the "[[" region if
| you are familiar with vim motions).
| falcolas wrote:
| What aidenn0 said.
|
| Specifically it's one of the 'g' commands (like gg which
| goes to the top of the file and gG goes to the bottom).
| Just put your cursor on an identifier and gD (goto
| definition is the mnenomic).
|
| :help g
| alwillis wrote:
| It's not an IDE but Neovim can do IDE-like things.
|
| And you can get Neovim with all batteries included:
| https://github.com/rockerBOO/awesome-neovim#preconfigured-
| co...
| pmontra wrote:
| > when you want to do more than quickly update a few files, you
| need a full Integrated Development Environment (IDE).
|
| I remember that when I was developing with compiled languages
| ages ago (C and Java) I had an emacs configuration to compile and
| debug from within the editor. Eventually I gaved up emacs when
| writing Java and switched to Netbeans and Eclipse. Then I
| switched to interpreted languages (Ruby, Node, Python) and I'm
| using emacs again. Plain modes for those languages, no
| autocompleters except a very basic language indipendent one and
| it works like a charm. It also works like that with Elixir and
| Phoenix, which autocompiles itself. It's been probably 10 years
| since I installed an IDE on one of my computers.
| tmtvl wrote:
| I think the main problem with trying to program Java in a text
| editor is the fact that we need to import every single package
| separately, or even worse: every class seperately.
|
| Doing Java programming in, say, Emacs would be fine if it
| weren't for import hell.
| wirrbel wrote:
| star imports exist, don't they? its just that they are
| discouraged by the linters
| renewedrebecca wrote:
| It's kind of weird that the text mode IDE won't run on macOS.
| FPC/Lazarus themselves run fine there.
| memsom wrote:
| Something to do with their TurboVision replacement I think.
| memsom wrote:
| Welcome to Delphi 1. My first job was using Delphi and it was 1.0
| we used to do most of the dev till we managed to go 32bit (circa
| 1998) and the IDE had _absolutely_ no autocompletion nor did it
| have any suggestions. You needed to know what you were typing. I
| think it was Delphi 3 that introduced Borland 's version of code
| completion (I want to say it was called "Code Sense", but that
| might be the Microsoft tools.) Even that was terrible till Delphi
| 5.
|
| I think a lot of modern coders really forget how much you used to
| need to know. Even stuff like "jump to definition" wasn't a thing
| IIRC back then.
| donretag wrote:
| Autocomplete requires CPU cycles for the lookup and "jump to
| definition" requires an index to be built somewhere (CPU again,
| but also mem/disk space). Modern computers can handle both
| efficiently nowadays, but not a simple task back then.
| int_19h wrote:
| My memories of circa 1998 are rather different from OP.
| That's the year when Visual Basic 6 shipped, and that IDE had
| code completion working perfectly. Delphi 5 was out in 1999,
| and also worked great in that regard. Even C++ IDEs had code
| completion which worked decently well so long as templates
| weren't in the picture.
|
| Pascal/Delphi is actually almost a perfect language to write
| a smart editor around: the grammar is highly regular and
| requires minimal lookahead to parse, and definitions always
| precede usage.
| noir_lord wrote:
| > I think a lot of modern coders really forget how much you
| used to need to know. Even stuff like "jump to definition"
| wasn't a thing IIRC back then.
|
| Also came through that era, I don't miss it, modern tools are
| abstractions for the brain (and a logical progression from what
| we had before).
|
| Everything is so much bigger and more complex than it was
| (mostly because things are bolted together from a large number
| of libraries from different places with their own subtle or not
| so subtle conventions).
|
| In days of you had the languages standard libraries and
| libraries you wrote yourself and _very_ rarely some Hallowed
| Third Party Library that was handed down on stone tablets by
| the Prophets of the Finance Department.
|
| Some stuff I miss, most I don't.
| marcodiego wrote:
| Sometimes I intentionally use primitive tools to force myself
| to write simple code.
| pascal_wizzard wrote:
| Even working with the 'modern' delphi ide makes intellij feel
| like advanced alien technology.
| Double_a_92 wrote:
| Yeah it's horrible. Autocomplete randomly doesn't work.
| Debugging symbols randomly disappear, and you get thrown into
| an assembler view. Or even if it works, you can't see the
| values of variables sometimes. Sometimes it gets better by
| restarting the IDE...
| dbsmith83 wrote:
| I used to hack away with Delphi back in the day. I tried getting
| back into it with Lazarus, but I really find Pascal syntax
| painful to work with again for some reason. It just has some
| strange conventions and I feel like I'd have to actually read a
| book to become proficient. A very different experience than
| learning, say, Kotlin where I could essentially pick it up
| knowing other OO languages and having a good IDE
| squarefoot wrote:
| I also worked with Delphi many moons ago and loved it,
| therefore also like Lazarus a lot, although I agree Pascal
| syntax could be made more modern. I recall one day I had to
| access data packets using the equivalent of C unions; the
| language allowed them, but the syntax was quite odd. Should one
| day Lazarus and the LCL be converted to other more popular
| languages, it would easily become a killer product.
| unnouinceput wrote:
| Pascal equivalent of C union is a variable record. Nowadays
| in Delphi (Free Pascal still doesn't have that) records can
| be used as classes, with their own members and just like
| classes, their functionality can be expanded using some sort
| of inheritance mechanism called "helper". Actually, in
| Delphi, the only difference between a class object and a
| record object is that classes allow dynamic allocation while
| records are instantiated on stack from beginning all the way
| to the end of the program.
|
| You should try Delphi nowadays, it has plenty of modern
| languages concepts implemented. Not to mention the compiler
| speed and the cross platform capability for all OS'es that
| matter.
| speed_spread wrote:
| I just looked it up. The lowest-priced package is $1,599. A
| "Free Demo" doesn't interest me. I assume Embarcadero has
| some really good customers who are very satisfied with what
| they deliver. But they're not exactly cultivating a new
| user base with those terms.
| raydiatian wrote:
| Wow, I haven't seen bright teal prompt text since MS DOS.
| badsectoracula wrote:
| Some notes. I assume this is for Linux, based on the beginning of
| the article.
|
| > It used to be possible to run a terminal session 'attached' to
| Lazarus, so that it could be debugged from the IDE, but since a
| previous update this always seems to fail on my PC.
|
| There could be some lingering settings. In my Lazarus build (from
| git, so it has the latest and greatest features and bugs) it is
| possible to run a program using a separate "launcher" from Run ->
| Run Parameters -> Check the "Use launching application" and then
| type something like "xterm -e some command that runs your app".
| In fact in my PC it pre-fills "/usr/bin/xterm -T 'Lazarus Run
| Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"
|
| This should allow for debugging terminal programs from Lazarus.
|
| > I'm not sure what the rationale is for maintaining the text
| mode FP IDE. It seems kinda quaint in 2022 to maintain a
| recreation of the old Turbo Pascal editor.
|
| It provides a basic IDE wherever Free Pascal is available. Note
| that, e.g., Free Pascal runs on DOS, OS/2, AmigaOS, etc and the
| IDE works in those environments too (DOS support is also why the
| IDE "embeds" the compiler instead of calling out fpc.exe).
|
| It also works as a showpiece for Free Vision (also part of Free
| Pascal) which provides a TUI framework. Sadly, as it is based on
| the original Turbo Vision, it uses the old "object"-based types
| instead of "class"-based types, so it misses a lot of useful
| functionality for programming - but from a user's perspective it
| is IMO a perfectly fine TUI.
|
| > I'm not sure why this is the default setup, but you need to
| tell the IDE where to find the Free Pascal files on your system.
|
| This might be some installation problem, on a fresh install FP
| should be able to work out of the box. Perhaps some distro issue?
| Try to use the generic tar-based installer from the Free Pascal
| site and install it system-wide.
|
| > One of the main differences in the interface, compared to
| Lazarus, is that instead of a tabbed interface it has a series of
| windows. With the right font size, I actually prefer this
| interface as it means that I can see several related files on
| screen at once.
|
| Note that you can have multiple source windows with Lazarus too,
| right click on any tab and select "Clone in new window" and it
| will create a new source window you can have side by side with
| other windows (sadly you can't use Alt+number to switch between
| them though - but your window manager might be able to do that
| for you). This way you can have both tabbed and floating windows
| if you want.
|
| > The biggest thing that I'm missing so far is a good auto
| complete. The IDE will offer suggestions for completing Pascal
| keywords but, unlike Lazarus, it won't try to autocomplete your
| own variables or procedure names.
|
| And auto-completing function/procedure definitions, etc in
| interfaces section to the implementation section, and symbol
| renames, and a quick jumps to declarations or between the
| interface and implementation section for a function/procedure,
| and a bunch of other stuff :-P. It'd be neat if those were added
| at some point though.
|
| But i'm not sure how many people really work on the IDE nowadays,
| IIRC it used to be an external project that was merged with Free
| Pascal early in Free Pascal's history. I think nowadays even main
| FPC developers use Lazarus instead (note that despite being
| joined at the hip, Free Pascal and Lazarus are technically two
| different projects with each having its own development team).
|
| But having said that and regardless of the limitations, i wrote a
| very large part of Post Apocalyptic Petra[0]'s code in Free
| Pascal and the game can be compiled and debugged from the IDE
| just fine. I did eventually switch to using Lazarus when i
| started working on the editor though (since i needed the GUI
| bits) and the standalone "Petra Engine"[1] (which contains only
| the engine part of the game, slightly modified) is really meant
| to be used with Lazarus for development (you can build the
| standalone example game with just FPC though).
|
| [0] https://bad-sector.itch.io/post-apocalyptic-petra
|
| [1] http://xtra.runtimeterror.com/petra
| kuu wrote:
| * _University flashbacks_ *
| forinti wrote:
| All the reference material I needed back then was a little
| folder with the grammar and and a list of the built-in
| functions.
___________________________________________________________________
(page generated 2022-10-14 23:01 UTC)