A Newbie Post lazarus / 61-Beginners ---------------------------------------------------------------------- MrPink · 2024-06-17 10:39 Greetings, Per the subject line, I’m a first-timer here -- though I’ve had longtime exposure to Turbo Pascal. In fact, I have reams of programs generated in an earlier life (1985-2014). I’ve hopped around to different forum postings enough to learn that I’ll have a learning-curve for the Free Pascal model. So, please be patient with me in that regard. I’m quietly hoping there’s a go-to primer available to highlight the differences..... Like many, my personal learning mode is seeing operational code and having it click in my brain. So, in my early-going I’ll be pursuing some copycat code examples. Open to suggestions, I also need to purchase a worthy FP textbook to support that learning mode. For the record, I’m a number cruncher; not so much into the text aspect (char strings, etc.). In true newbie form, I need to dive into (explore) the forum and see what I can learn. In the meantime, I am glad to be here and hope I’ll be able to actually-contribute at some point in the future. Thanks for having me, MrPink ---------------------------------------------------------------------- 440bx · 2024-06-17 10:47 welcome to the forum MrPink. ---------------------------------------------------------------------- MarkMLl · 2024-06-17 10:50 Welcome to the community :-) Particularly since you've already got Pascal experience, I think the really important thing is to familiarise yourself with the layout of the documentation which, for the "current" version of FPC, you'll find at https://www.freepascal.org/docs.html You should find a high level of compatibility with TP etc. in appropriate modes. MarkMLl ---------------------------------------------------------------------- Handoko · 2024-06-17 11:06 Welcome MrPink. We are now in 2024, computer graphics has improved a lot. Maybe you want to try Lazarus. You can build GUI and graphics programs much easier using Lazarus, and it can be used for generating text- based/console programs too. If you interested to learn about Lazarus IDE click the link below and scroll down, there you can find many animated screenshots showing the IDE features of Lazarus: https://wiki.freepascal.org/New_IDE_features_since And in the link below, you can find plenty of short demos that you can download and try: https://wiki.freepascal.org/Portal:HowTo_Demos Also try this link, which cover various of topics: https://wiki.freepascal.org/Lazarus_Documentation ---------------------------------------------------------------------- MarkMLl · 2024-06-17 11:23 Quote from: Handoko on June 17, 2024, 01:06:35 pmWe are now in 2024, computer graphics has improved a lot. Maybe you want to try Lazarus. You can build GUI and graphics programs much easier using Lazarus, and it can be used for generating text-based/console programs too. I'd like to apply a caution to that, for everybody's benefit. OP has already said "For the record, I’m a number cruncher; not so much into the text aspect (char strings, etc.)." hence it's likely that he's even less into the GUI element. However the thing worth emphasising is that even though Lazarus is (obviously) a GUI-based program, one can ignore the fact that it can be used to implement graphical programs and use it simply as an Integrated Development Environment (IDE) for text-based programs writing to the console or a file. In effect, 1990s Codeview on steroids (with a nod to comparable software of that era, i.e. Logitech Multiscope and similar). FPC does have its own text-based editor etc., but it gets far less TLC from the community than does Lazarus. It's also possible to use other comprehensive editors (akin to Emacs, or MultiEdit back in the day), in fact I believe that Thaddy mentioned Geany recently. However I would suggest that there are massive advantages to using something preconfigured rather than spending ages fighting ones tools: the subcommunity that is happy to discuss the overlap between (e.g.) Emacs and Pascal is vanishingly small. MarkMLl ---------------------------------------------------------------------- MrPink · 2024-06-18 18:59 I much appreciate these welcoming posts -- in the grand effort to help me get off to a good start. The short-demo link provided was intriguing, but clicking same threw me into an unrelated forum message to check my original post for added posts (???). So, it was a no-go. I’m thinking though, that a truly good/fresh start for me should incorporate the latest editor. That sounds like Lazarus, and its GUI attributes. I am accustomed to the old text-based editor that came with my recent FPC download, but my inner best-self says I should bust out of the old -- and embrace the newer landscape. The compelling part of that likely better-direction was the insightful comment that the old “gets far less TLC from the community than does Lazarus.” Okay then. In classic newbie mode, I think that maybe I’m looking for a comprehensive standard download; if it exists. If appropriate, can you direct me to a combo where I’d get both Lazarus and the FP compiler? Once in hand, I’m generally thinking I would then be “forced to learn” all that I need to. A leg-up in my case -- would be old-dog familiarity with the code (TP). From there I’d just be (occasionally) pestering you kind folks for additional direction..... Thanks, MrPink ---------------------------------------------------------------------- MarkMLl · 2024-06-18 19:16 Quote from: MrPink on June 18, 2024, 08:59:18 pmI’m thinking though, that a truly good/fresh start for me should incorporate the latest editor. That sounds like Lazarus, and its GUI attributes. I am accustomed to the old text-based editor that came with my recent FPC download, but my inner best-self says I should bust out of the old -- and embrace the newer landscape. The compelling part of that likely better-direction was the insightful comment that the old “gets far less TLC from the community than does Lazarus.” Comment there: GUI programs aren't particularly good at accommodating "green screen" output, so think about what you actually need to do before deciding on a UI. QuoteOkay then. In classic newbie mode, I think that maybe I’m looking for a comprehensive standard download; if it exists. If appropriate, can you direct me to a combo where I’d get both Lazarus and the FP compiler? Once in hand, I’m generally thinking I would then be “forced to learn” all that I need to. Depends on your OS of choice. Not so much because of the tools themselves which you can get from https://www.lazarus- ide.org/index.php?page=downloads (or https://www.freepascal.org/download.html if you only want FPC itself) but because of potential prerequisites. MarkMLl ---------------------------------------------------------------------- Handoko · 2024-06-18 19:23 Quote from: MrPink on June 18, 2024, 08:59:18 pmThe short-demo link provided was intriguing, but clicking same threw me into an unrelated forum message to check my original post for added posts (???). So, it was a no-go. Sorry, my mistake. This is the correct link: https://wiki.freepascal.org/Portal:HowTo_Demos ---------------------------------------------------------------------- cdbc · 2024-06-18 19:56 Hi QuoteIf appropriate, can you direct me to a combo where I’d get both Lazarus and the FP compiler?Yes, there's a tool called 'FpcUpDeluxe' on github https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases That lets you do just that  Regards Benny ---------------------------------------------------------------------- dseligo · 2024-06-18 20:33 Quote from: cdbc on June 18, 2024, 09:56:28 pmHi QuoteIf appropriate, can you direct me to a combo where I’d get both Lazarus and the FP compiler?Yes, there's a tool called 'FpcUpDeluxe' on github https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases That lets you do just that  Regards Benny Or, (if you are on Windows) you can just press "Download Now" on main Lazarus page (https://www.lazarus-ide.org/). Lazarus installation has Free Pascal compiler already included. ---------------------------------------------------------------------- MarkMLl · 2024-06-18 20:42 Quote from: dseligo on June 18, 2024, 10:33:48 pmOr, (if you are on Windows) you can just press "Download Now" on main Lazarus page (https://www.lazarus-ide.org/). Lazarus installation has Free Pascal compiler already included. The thing that concerns me is that if he's not on Windows but is instead a Linux user (in which case I'd hazard either Arch or Debian/Ubuntu) it's necessary to download a couple of prerequisite library packages before FPC/Lazarus- even from fpcupdlx- will run reliably. Unashamed numbercrunchers are a rare breed, and I'm reminded of a friend of a former associate who (when I last heard) was methodically working through historical scientific calculations to ensure that they were actually correct. I don't know the gritty details, but I've a vague recollection that a whole lot of things that had been computed using Monte Carlo were tainted by a poor (FORTRAN?) random number generator. MarkMLl ---------------------------------------------------------------------- TRon · 2024-06-18 22:43 fwiw: there is nothing wrong with keep/still using the old terminal IDE or whatever editor floats your boat in case you do not wish to get distracted by all the graphical violence. I myself prefer it over using the Lazarus IDE (but that is because I get easily distracted by all bells and whistles). ---------------------------------------------------------------------- Thaddy · 2024-06-19 04:17 Quote from: MarkMLl on June 18, 2024, 10:42:05 pm but I've a vague recollection that a whole lot of things that had been computed using Monte Carlo were tainted by a poor (FORTRAN?) random number generator.That is correct. Not only FORTRAN, but also TP and originally C had/have very simple LCG's that - on larger amounts of data can have a very noticable bias. I believe that was one of the reasons the FPC developers chose a Mersenne twister (and now xorshiro++) instead of a Delphi compatible one, because of better properties. To use such old data collections you need to know how to interpret the prng that is used to interpret them as the collector saw them. One of the reasons I wrote a Delphi compatible LCG and a FPC mersenne twister that can be used in both Delphi and Lazarus. The mersenne twister is now a life saver because the core developers assume the prng to be "implementation detail" which of course it isn't. Both prng's are in the wiki as well as a gaussian one that is not written by me but is actually more appropiate for monte carlo simulations. E.g. in social sciences gaussian is better because of the central limit theorem. many people know I absolutely love prng's. ---------------------------------------------------------------------- egsuh · 2024-06-19 04:32 Once installed Lazarus, Simply create a new project, drop a button on form, and then write code that sums from 1 to 100 and showing it. All the comments here are really valuable, but first you need some time to get familiar with Lazarus, before thinking anything (based on my first encounter with Delphi from my Turbo Pascal experiences  ). You can use Delphi books at first, as Lazarus is simulating Delphi. https://www.learndelphi.org/wp- content/uploads/2020/03/DelphiProgrammingForBeginners_ENG- CreativeCommons-LearnDelphi.org_.pdf ---------------------------------------------------------------------- Thaddy · 2024-06-19 04:38 @MrPink On the original subject: any book on Delphi will help, even second hand ones. For number crunchers I'd recommend The Tomes of Delphi, algorithms and data structures. It is still available as an e-book or in print from kindle. Firmly founded in theory and with 100% Freepascal compatible code. This book is less suited for UI design. You may want to have a look at one of the books by Marco Cantu for that.(not one of the books that refer anywhere to fmx) Have fun, Thaddy ---------------------------------------------------------------------- 440bx · 2024-06-19 04:54 @MrPink, Julian Bucknall's Tomes of Delphi: Algorithms and Data Structures is an excellent book in more ways than one. In addition to what @Thaddy mentioned, you can get a copy "directly" from the author along with errata and the source code for the book at: https://secondboyet.com/FixedArticles/DADSBook.html HTH. ---------------------------------------------------------------------- MarkMLl · 2024-06-19 07:21 Quote from: Thaddy on June 19, 2024, 06:17:04 amThat is correct. Not only FORTRAN, but also TP and originally C had/have very simple LCG's that - on larger amounts of data can have a very noticable bias. I know, but we're talking high-end fundamental physics here. Not tacky languages designed by people who didn't understand the application areas they would be used in. MarkMLl ---------------------------------------------------------------------- Thaddy · 2024-06-19 07:46 That's the same as the core developers interpreting a prng as implementation detail  (Tragically they used to understand the issue while still students. Jonas? Care to answer on this?) ---------------------------------------------------------------------- MarkMLl · 2024-06-19 08:16 Quote from: Thaddy on June 19, 2024, 09:46:55 amThat's the same as the core developers interpreting a prng as implementation detail  (Tragically they used to understand the issue while still students. Jonas? Care to answer on this?) Don't worry, I had a run-in with them when I complained that their "Mersenne Twister" emitted the wrong sequence because the internal representation was wrong (signed rather than unsigned?). That was when the docs were changed to say "similar to". I remember a comms lecturer using the internal random number generator from TP1 or 2 for a lab simulation. Until one of his students pointed out that it first produced a stream of odd numbers, then switched to a stream of even numbers... So as somebody said, "Random numbers are too important to be left to chance". And that's particularly significant when using something like Monte Carlo to provide an approximate solution to a problem that is intractable in practice. MarkMLl ---------------------------------------------------------------------- Thaddy · 2024-06-19 08:53 Mark, The same is the case with C++, as I showed before on this forum. The standard is mt19937 and fpc - used to, not in trunk - conform to that. As does my implementation on the wiki.Code: C  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #include #include // for std::mt19937 int main() {    std::mt19937 mt; // Instantiate a 32-bit Mersenne Twister     // Print a bunch of random numbers    for (int count { 1 }; count <= 40; ++count) {        std::cout << mt() << '\t'; // generate a random number         // If we've printed 5 numbers, start a new row        if (count % 5 == 0)            std::cout << '\n';    }     return 0;}That code is probably not mine, I believe I posted a similar example but can't find it. Given the same seed, this generates random values compatible to Freepascal <= 3.2.2. For others, casual readers: this is important to share data between the two languages. You are right about the quote  It is important. Your quote is attributed to Robert Coveyou ---------------------------------------------------------------------- Thaddy · 2024-06-19 09:25 Btw Mark, You are wrong in making the comparison between signed and unsigned. That is because prng's operate on the bit level and should not care about sign. So most prng algorithms use unsigned values and cast - or scale - back to signed when required. ---------------------------------------------------------------------- Thaddy · 2024-06-19 09:32 Quote from: 440bx on June 19, 2024, 06:54:10 am@MrPink, Julian Bucknall's Tomes of Delphi: Algorithms and Data Structures is an excellent book in more ways than one. Thanks for mentioning the author. My mistake. ---------------------------------------------------------------------- MarkMLl · 2024-06-19 09:51 Quote from: Thaddy on June 19, 2024, 11:25:06 amYou are wrong in making the comparison between signed and unsigned. I am talking about the specific case of FPC's Random() circa 2016. I'm not going back looking for my bug report, but the fundamental problem was that even though it was described- at the time- as "Mersenne" you couldn't get 32-bit values out of it because the internal representation was wrong. MarkMLl ---------------------------------------------------------------------- Thaddy · 2024-06-19 10:29 i never noticed that and I should have.... Now back to books... ---------------------------------------------------------------------- DavidL · 2024-06-19 12:11 Quote from: TRon on June 19, 2024, 12:43:30 amfwiw: there is nothing wrong with keep/still using the old terminal IDE or whatever editor floats your boat in case you do not wish to get distracted by all the graphical violence. I myself prefer it over using the Lazarus IDE (but that is because I get easily distracted by all bells and whistles). Hahaha!  Yeah, as one who violently detests the gamification of software development, if I wanted to play video games I'd get a Nintendo.  But such is "progress". ---------------------------------------------------------------------- MarkMLl · 2024-06-19 13:22 Quote from: DavidL on June 19, 2024, 02:11:28 pmHahaha!  Yeah, as one who violently detests the gamification of software development, if I wanted to play video games I'd get a Nintendo.  But such is "progress".  I sympathise with that, but the bottom line is that the work on- to pick just one example- ensuring that the debugger displays information in the format most useful to the high-level construct being examined is being done in Lazarus, not in the text-mode IDE. Part of the reason for that is that the GUI facilities provided by Lazarus's LCL make design and implementation of such things far easier, but that has absolutely no bearing on the type of program being worked on by the end user. And I assure you that no OS (using the broad term to include the desktop environment etc.) has ever really provided a decent TUI design environment: except possibly for MS's Visual Basic for DOS in the early 90s. MarkMLl ---------------------------------------------------------------------- Thaddy · 2024-06-19 15:23 Mark, are you very sure you did not attempt to write a pong clone? I don't believe that... ---------------------------------------------------------------------- MarkMLl · 2024-06-19 16:07 Quote from: Thaddy on June 19, 2024, 05:23:29 pmMark, are you very sure you did not attempt to write a pong clone? I don't believe that... You'd use some 555s for that... MarkMLl ---------------------------------------------------------------------- Thaddy · 2024-06-19 16:34 I will add them to my phone book. For others: https://www.businessinsider.nl/555-phone-number-tv-movies- telephone-exchange-names-ghostbusters-2018-3?international=true&r=US ---------------------------------------------------------------------- MarkMLl · 2024-06-19 20:23 Looks like I have to explain the joke. These days, the average hacker will reach for an Arduino, but somebody of the old-school persuasion would say "I'd use a 555 for that". In fact back when I was an undergrad one of the lecturers grmbled about virtually all student dissertation projects being described as "741 op-amp blah blah phase- locked loop blah blah 555 timer...". The 555 was a supernally flexible timer chip, implemented in an 8-pin package using a small number of transistors https://www.righto.com/2022/01/silicon-die-teardown-look-inside- early.html . As an example of what it could be used for, see https://hackaday.com/2022/05/30/practical-wireless-tele-tennis-build- after-only-34-years/ . Look at the photo at the bottom of that article. There's no microcontrollers in there, no firmware. Just a small number of monostable timers, responsible for both playing the game and generating the video. Hence, "I'd use a 555 for that". MarkMLl ---------------------------------------------------------------------- dbannon · 2024-06-20 00:26 Quote from: MarkMLl on June 19, 2024, 10:23:12 pmLooks like I have to explain the joke. These days, the average hacker will reach for an Arduino, but somebody of the old-school persuasion would say "I'd use a 555 for that"... I'd still use a 555 for that !  But I'd use an LM324 instead of the 741, far more stable .... Davo ---------------------------------------------------------------------- MrPink · 2024-06-20 13:00 Feels like I need to briefly re-insert myself – if for nothing else; some clarification. Make no mistake though, I very much appreciate everyone’s input. Plus, glad to have inadvertently created a convenient small-platform for some friendly banter. My highlights: My OS is Win 10. However, not a user eager for Win 11. My number crunching intent is considerably less formidable than Monte Carlo. Think – rows of numbers and me analyzing same for certain patterns. Relatively simple stuff, with my recent programming reemergence related to a large sort endeavor. You may get a taste of those task details, once I get knee-deep. I can relate to the characterization “graphical violence,” which was spoken-to more than once here. A case that Lazarus may be more than I need, and for me staying bare-bones on the IDE. Also, less of a learning curve for MrPink..... For the moment, your input has talked me out of the GUI. Rather than take that jump, I’ll stick with the base model and see how it goes. Translation: I will get my feet wet with some actual coding, using my fresh 3.2.2 download and that editor. I will keep you posted, peppering you with newbie questions along the way. Thank you, MrPink