Recent

Author Topic: Lazarus – Crawling Before The Walk  (Read 3374 times)

MrPink

  • New Member
  • *
  • Posts: 16
Lazarus – Crawling Before The Walk
« on: November 20, 2024, 03:45:04 am »
Starting a new thread on the subject; leaving behind my prior thread which served to convince that Lazarus would be my best path. Basically, a new trick for an old dog. For me, it felt like finding a right-sized tutorial would be a good start.

The thing is, and said prior, I want the benefit of the GUI environment, but I’m not keen on the Object Oriented Program (OOP) aspect. So, I bounced around to quite a few YouTube tutorials, but invariably encountered the box that would be populated with the functional buttons. The box seems like a purposeful base for programmers with a long horizon; just not for me.

Anyway, I stumbled on a tutorial series by Tom Needham (2015) that might be tailored to my psyche (???). I’m going to invest in Mr. Needham, and report as I go. It’s early, so my above subject line is applicable. I’ll do the enter-code “Hello World” thing, with the hope of graduating to the load & use of familiar prior-written functional programs. Wish me luck but, if you would, please also share any similar-design tutorials.

A first very-early question. When progressively writing code, my longtime MO is to regularly engage the compile to make sure I’m solid at that write level. Tom seems to exclusively use the run button. Is there still a compile button, or is it somehow obsolete?
Thank you,
MrPink

Lazarus 3.4;  FPC 3.2.2

440bx

  • Hero Member
  • *****
  • Posts: 4908
Re: Lazarus – Crawling Before The Walk
« Reply #1 on: November 20, 2024, 05:16:56 am »
A first very-early question. When progressively writing code, my longtime MO is to regularly engage the compile to make sure I’m solid at that write level. Tom seems to exclusively use the run button. Is there still a compile button, or is it somehow obsolete?
You can configure the coolbar to include a "compile" button.  Personally, I use Shift-F9 to do a build (faster than clicking on a button)

I recommend building and debugging/testing every few lines of code, less surprises at the end that way.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

srvaldez

  • Full Member
  • ***
  • Posts: 117
Re: Lazarus – Crawling Before The Walk
« Reply #2 on: November 20, 2024, 05:41:32 am »
MrPink, do you have a goal in mind?
what kind of program are you planning on writing?
as far as I know a responsive GUI application is event driven and OOP is well suited for that

Handoko

  • Hero Member
  • *****
  • Posts: 5386
  • My goal: build my own game engine using Lazarus
Re: Lazarus – Crawling Before The Walk
« Reply #3 on: November 20, 2024, 11:18:03 am »
The thing is, and said prior, I want the benefit of the GUI environment, but I’m not keen on the Object Oriented Program (OOP) aspect.

If you just want to use components created using OOP approach, that is much easier than you think. OOP is hard only when you want to write components/programs using OOP approach. I believe what you want is the the first one.

Anyone but newbies only, you can contact, PM, email or WA me if you have problem learning Lazarus. I can even set up a remote access to help you.

silvercoder70

  • Full Member
  • ***
  • Posts: 126
    • Tim Coates
Re: Lazarus – Crawling Before The Walk
« Reply #4 on: November 20, 2024, 11:51:23 am »
You can PM me also.

I am a little unsure about what you consider the crawling phrase, vs walk or run but putting that aside, I have started a new series on YT (you will find link in signature) on the fundamentals in (what I refer to as modern) pascal.

Now what I describe as fundamentals is all that stuff just after "hello world". Once you have an understanding of that part, doing the GUI side becomes easier. And even when do GUI stuff, it does not have to be "OO".

Crawl -> Walk -> Run

Enjoy the journey.
Explore the beauty of modern Pascal programming with Delphi & Free Pascal - https://www.youtube.com/@silvercoder70

TRon

  • Hero Member
  • *****
  • Posts: 3822
Re: Lazarus – Crawling Before The Walk
« Reply #5 on: November 20, 2024, 09:37:17 pm »
@MrPink:
(yes, sorry me again with more or less the same message)

I understand you predicament but OOP isn't exactly magic (or difficult).

Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. {$mode objfpc}{$h+}
  4.  
  5. uses
  6.   classes;
  7.  
  8. var
  9.   lines : TStringList;
  10.   line  : string;
  11. begin
  12.   lines := TStringList.Create;
  13.   lines.LoadFromFile('test.pas');
  14.   for line in lines
  15.     do writeln(line);
  16.   lines.Free;
  17. end.
  18.  

And that use of TStringList is in basics what OOP is. Nothing more, nothing less (the example makes use of an already existing OOP class but you could create your own classes/objects as well if that peaks your interest).

Unfortunately, I only was able to locate 3 video's from Tom's tutorials so that would not provide too much information for you I'm afraid.

The Lazarus IDE can be used in exactly the same way as FP-IDE, the only difference is the GUI vs TUI environment.

So, in case you do not wish to use OOP then by all means do not use it and keep on programming the way you were used to with FP-IDE. And also in FP_IDE you could use the same code as per example and you would have been using OOP. There literally is no difference.

The only thing I can add to that is that most Lazarus related tutorials do not emphasis on this but rather focus on designing GUI applications, e.g. how the object inspector works , how certain (visual) component behave how to add different forms etc.

Why I repeat the same again ? It seems that you (still) have the idea that using Lazarus means that you need to use GUI components and per default you are using OOP. Let me try with writing that: OOP <> GUI

OOP is but a programming concept and a GUI /can/ be implemented using that concept. In case of Lazarus the IDE itself consists out of GUI components that are implemented using classes and objects (thereby using the OOP concept). At the same time the Lazarus IDE allows you to make use of all these classes and objects in order to create your own GUI applications (but only if you want to do so).
« Last Edit: November 20, 2024, 09:40:06 pm by TRon »
I do not have to remember anything anymore thanks to total-recall.

MrPink

  • New Member
  • *
  • Posts: 16
Re: Lazarus – Crawling Before The Walk
« Reply #6 on: November 23, 2024, 11:50:40 pm »
Apologies for my dipping in and out of the forum with robust time gaps. But first and foremost, I need to say how impressed I am with the genuineness of everyone’s helpfulness. It’s like with librarians – they never wither. And like a basketball held-aloft, they never hold their sphere of knowledge out of your reach......

I caught another post where someone was seeking help in an ongoing FP/Lazarus class. All three of my old-dog learned languages (Basic, Fortran, Pascal) came via a formal classroom, so it made me yearn for a local community college to offer same. Unfortunately, not available. Though I wish it were.

In the meantime, I am learning from your comments. Condensing TRon’s last paragraph, it makes sense to me that: “OOP is a concept, and a GUI can be implemented using that concept. As to the Lazarus IDE, it allows the use of classes and objects in order to create your own GUI applications.”

Indeed. Which brings me to srvaldez, pertinently asking what kind of program I am planning to write (???). Answer:  Research programs, whereby (1) a data file is loaded into a matrix and (2) sorted for outcomes. Simple tasks in conjunction with a personal hobby; nothing remotely close to having a user base or creating GUI applications.

At the top I referenced a lack of time, which makes me the bottleneck here. Bottom line; I need to do some hands-on Lazarus-environment programming. I will then see where I encounter difficulty, and kick out a few questions for you good folks to answer. Please stay tuned for that......
Thank you,
MrPink

carl_caulkett

  • Hero Member
  • *****
  • Posts: 649
Re: Lazarus – Crawling Before The Walk
« Reply #7 on: November 24, 2024, 01:05:31 am »
Maybe when you are starting, it's better to just treat Lazarus as a tool for "Event-Driven Programming". The fact that OOP underlies a lot of the software technology behind that "Event-Driven Programming" doesn't really matter at first. That said, it's a good idea to keep your mind open to the use of classes, then you will find that a lot of OOP principles can be absorbed like osmosis. Eventually you will, hopefully begin to join the dots, as it were, and start to actively learn OOP principles.
« Last Edit: November 25, 2024, 04:17:44 pm by carl_caulkett »
"It builds... ship it!"

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1296
Re: Lazarus – Crawling Before The Walk
« Reply #8 on: November 25, 2024, 03:46:34 pm »
Speaking of I’ve been trying to get better at oop design. Doing it right can be rather challenging. Having a class within in a class that isn’t Always used is a big no no . I created abstract virtual methods to be overridden when I need the functionality.  Does anyone here use abstract methods?
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

Handoko

  • Hero Member
  • *****
  • Posts: 5386
  • My goal: build my own game engine using Lazarus
Re: Lazarus – Crawling Before The Walk
« Reply #9 on: November 25, 2024, 03:55:38 pm »
I created abstract virtual methods to be overridden when I need the functionality.  Does anyone here use abstract methods?

Rarely, but I did.

Joanna from IRC

  • Hero Member
  • *****
  • Posts: 1296
Re: Lazarus – Crawling Before The Walk
« Reply #10 on: November 25, 2024, 04:11:37 pm »
Abstract methods cause a lot of warnings but I think they will be ok so long as they are not used incorrectly.
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  #pascal Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

MrPink

  • New Member
  • *
  • Posts: 16
Re: Lazarus – Crawling Before The Walk
« Reply #11 on: November 25, 2024, 06:39:55 pm »
Okay then. I’ve done a bit of dabbling, but struck out. In short, I wrote a simple program and had no luck in even running it. I have numerous long-ago years of writing Turbo Pascal code (1984-2012), but the Lazarus IDE vehicle has me stuck at the starting gate. Per my earlier old-dog comment, I’m handicapped by the lack of that formal classroom.

However, I am determined to learn because I’m confident my forward programming life will be smoother with the Lazarus IDE. I just need to step-up the level of my currently-ineffective learning environment. In fact, I’d like nothing better than to pay for a short course from the person next door if s/he were so equipped and available....

Going down that TBD resource road, I was intrigued with, but not understanding, the above Mr. Handoko help post: “Anyone but newbies only, you can contact, PM, email or WA me if you have problem learning Lazarus. I can even set up a remote access to help you.“

If someone would, please clarify the acronyms and what avenue I might take.
Thank you,
MrPink

Handoko

  • Hero Member
  • *****
  • Posts: 5386
  • My goal: build my own game engine using Lazarus
Re: Lazarus – Crawling Before The Walk
« Reply #12 on: November 25, 2024, 07:07:09 pm »
PM = send personal message
WA = contact via WhatsApp

If you want to contact me, do this:
1. Click Handoko
2. Send personal message
(See the screenshot pictures below)

After sending personal message to me, I can give you my email, phone number and WA. So we can communicate using email, phone or WA.

For you information, the time zone where I live is UTC+7. It's midnight here in my country, I'm going to sleep now. I can be contacted whenever you like, but if I'm sleeping, I won't respond.

Bart

  • Hero Member
  • *****
  • Posts: 5497
    • Bart en Mariska's Webstek
Re: Lazarus – Crawling Before The Walk
« Reply #13 on: November 25, 2024, 07:34:54 pm »
The thing is, and said prior, I want the benefit of the GUI environment, but I’m not keen on the Object Oriented Program (OOP) aspect. So, I bounced around to quite a few YouTube tutorials, but invariably encountered the box that would be populated with the functional buttons. The box seems like a purposeful base for programmers with a long horizon; just not for me.

<snip>

 I’ll do the enter-code “Hello World” thing, with the hope of graduating to the load & use of familiar prior-written functional programs. Wish me luck but, if you would, please also share any similar-design tutorials.

You can do plain old simple TP style functional programming using Lazarus as your IDE.
Use: Menu->Project->New Project and then choose "Simple Program".
Now it's just like in the old TP days.
Code: Pascal  [Select][+][-]
  1. program Project1
  2.  
  3. begin
  4.   writeln('Hello World');
  5. end.



However, for writing GUI (Windows/Linux/macOSX) applications, you better get used to the "event-driven" approach.
And even the, for simple enough programs, the IDE can create the skeleton for the event's code for you.

Just do it  :)

Bart

speter

  • Sr. Member
  • ****
  • Posts: 356
Re: Lazarus – Crawling Before The Walk
« Reply #14 on: November 26, 2024, 03:31:14 am »
...  Does anyone here use abstract methods?

If you'd like some entertainment :) have a look at the attached project. It is a simple drawing program, and definitely a work-in-progress (lots of stuff is not implemented and there are bugs to fix). I wrote (some years ago) 3 "draw" programs - (1) not using OOP; (2) using objects; and (3) using classes. The attached project is the "descendant" of (3). :0

If you look at the code, checkout "shapeu.pas" it includes the (fairly) abstract parent class; then the pXXX.pas units each implement a primitive.

Note that the project (on my computer :)) saves drawings in a "drawings" folder which is located under the exe's folder (so this may not work with some OS's). I have included one drawing with the project; zoom in on the white "star"! If you keep zooming in the program will eventually crash (I *think* that is caused by the world coordinate routine that converts drawing coordinates to pixels).

Enjoy
S.
:)
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

 

TinyPortal © 2005-2018