Recent

Author Topic: What I love about Lazarus' features  (Read 1352 times)

_Antares_

  • New Member
  • *
  • Posts: 13
What I love about Lazarus' features
« on: November 17, 2024, 11:07:30 am »
I posted improvement requests, so I figured I also should mention what is awesome in Lazarus already as well. Even compared to Delphi 12 which I recently installed as community edition :-X

♥ First of all: The Lazarus-IDE itself provides advanced levels of customizing syntax highlighting, editor colors, code formatting and key mappings! This is soooo am-a-zing!
Delphi 12 must rely on tools like MMX Explorer and still does not reach that level of customizability. Delphi does not even have options to change individual key bindings at all, only presets.

♥ The Object Inspector allows changing more stuff than average Delphi.
For example the BorderSpacing feature is so neat! I use it a lot.
Delphi has Margins which also allow negative numbers to align things. But a BorderSpacing.around:=8 and be done is so mighty.

♥ Also when it comes to colors, Lazarus just provides those properties to be directly accessible in the inspector (like Delphi in the old days did), including all the clBtnFace-and-whatnot constants. That's the way it should be!
In Delphi 12 you do not have any coloring or style options in the inspector anymore - they are "outsourced" to StyleBooks which I still did not figure out how to use them for even a simple thing like changing the background color of a panel. Also color properties are restricted to a palette not involving any "dynamic" cl... constants (or they are hidden somewhere). But the available predefined colors are very pretty and well named.

♥ Autocomplete features are so neat! Changing the signature and propagate back to the interface/implementation in both ways. Also I like that you can have auto complete not overwriting partial text that follow the line at the completion spot. Seems minor, but it feels so smooth.

♥ The Object Inspector allows a Favorites section. So handy!

While I am at it, now some credit to Delphi 12:
♡ The debugger is awesome compared to Lazarus. It provides all information and presents it nicely colored and browsable. No "This field is not available due to compiler optimizations" and stuff. You can inspect anything, even if not directly in scope of the current method and properties/fields are named like in the inspector, not like in the source code.

♡ Minor quality of life things involve changing all the caption/text properties to just a text property for all components.

♡ The Filter/Effect-components are cool. Adding 3D shadow or blur effects just by adding it with a click.

♡ A very mighty feature is the option to use any control as a container like a TPanel to build the layout hierarchy. Having a TLabel allows having a TButton "inside" of it without needing to wrap them into a TPanel first. Especially useful for integrating buttons into a TEdit for various options like open dialog or clear field etc. Even allows auto-alignment with alTop/alRight etc.

Do you have some favorite features? 8-)
« Last Edit: November 17, 2024, 12:22:21 pm by _Antares_ »

Handoko

  • Hero Member
  • *****
  • Posts: 5376
  • My goal: build my own game engine using Lazarus
Re: What I love about Lazarus' features
« Reply #1 on: November 17, 2024, 11:32:15 am »
Interesting.
Thank you for sharing your thought on Lazarus vs Delphi.

These are the things I like about Lazarus:
  • Lazarus allows me to easily write cross platform programs.
  • Online Package Manager (thanks GetMem)
  • Lazarus Android Module Wizard (thanks jmpessoa)
  • Very helpful community
What I don't like about Delphi:
  • It cannot run on Linux

Dzandaa

  • Sr. Member
  • ****
  • Posts: 390
  • From C# to Lazarus
Re: What I love about Lazarus' features
« Reply #2 on: November 17, 2024, 11:35:35 am »
Hi,
Like Hadoko,
an important possibility is to be able to write code that is compatible with Windows Linux and MacOS, without much modification.
OLM, code completion, and The community is pleasant and helpful.

B->
Regards,
Dzandaa

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: What I love about Lazarus' features
« Reply #3 on: November 17, 2024, 12:31:51 pm »
While I am at it, now some credit to Delphi 12:
♡ The debugger is awesome compared to Lazarus. It provides all information and presents it nicely colored and browsable. No "This field is not available due to compiler optimizations" and stuff. You can inspect anything, even if not directly in scope of the current method and properties/fields are named like in the inspector, not like in the source code.

True... Unfortunately.  Properties are a problem with FPC debugging.

Though a couple of notes for all those who need workarounds. And some advice.

In many (most) cases (with Lazarus 4.0 / with 3.6 only a small subset works) you can call the getter method of a property. However, you have to know the method name, and type it "MyStringList.GetText()". And enable function calling (global, and on each watches' properties).

You can also (use the "debug inspect" to assemble the watch) watch this
Code: Text  [Select][+][-]
  1. (MyStringList.FList)^[0..MyStringList.FCount-1].FString
And it shows you all entries of a stringlist, without having to call the getter function.
See https://wiki.freepascal.org/FpDebug-Watches-Intrinsic-Functions#Array_slice_MyArray[n..m]_with_mapping




A word (warning) on function calling.
And a word on what (afaik) Delphi does. At least it did, back in the day of Delphi 5, and it is still the same underlying issue.

This was the first thing, that Delphi burnt me with. Really burnt me good.

I had an app that crashed (as I later found because of "Handle" not being created). I debugged it in Delphi, and added "TheControl.Handle" as watch.
And it wouldn't crash in the debugger.
I lost a good bit of time, till I found the answer.

Because "Handle" is a property with getter, the only way for the debugger to show the value, is to call the getter method. But that getter method would actually create the Handle. (unlike my crashing code, that somehow called something that used the handle, but bypassed creation).

So watching any property with getter in Delphi (at least older Delphi, but afaik any Delphi) can modify the state of your debugged app. And the app may behave different in the debugger, and you may not be able to find your bug.
And when this will have been added to FPC then the same danger will be there.

That said, it is still a feature that would be good to have. But anyone using it should be aware, that it is a dangerous feature.




Other than that, I wasn't aware that Delphi colors watches. What is it used for? Some pattern in the data? Or "changed during last step/run"?
"changed during last step" is an my Todo.

And (in a feeble attempt to even the balance):

- Have you tried to watch a long array in Delphi (say 1000 entries)? What happens if you "unfold" it? Last I asked someone (I don't have Delphi), they got the full list with 1000 rows. Happy scrolling down, if you have more watches below. Lazarus has pagination.

- And we now (4.0) have :flatten (see intrinsic link above) to display linked lists and tree structures. Though again, you have to enter the expression by hand. (maybe in future that can be automated for known types)
I don't know what/if Delphi has for this.

- For types like
Code: Pascal  [Select][+][-]
  1. TModalResult = low(Integer)..high(Integer);
  2.   mrNone = 0;
  3.   mrOK = mrNone + 1;
  4.  
you can now create a value formatter https://wiki.freepascal.org/IDE_Window:_IDE_Options_-_Debugger_Value-Formatter#Convert_Ordinal_to_name to display the names, instead of numbers.

(Actually, probably could add a pre configured one for TModalResult..., just had not yet thought of that / well, maybe if I find some time)


VisualLab

  • Hero Member
  • *****
  • Posts: 571
Re: What I love about Lazarus' features
« Reply #4 on: November 17, 2024, 01:11:00 pm »
♥ Also when it comes to colors, Lazarus just provides those properties to be directly accessible in the inspector (like Delphi in the old days did), including all the clBtnFace-and-whatnot constants. That's the way it should be!
In Delphi 12 you do not have any coloring or style options in the inspector anymore - they are "outsourced" to StyleBooks which I still did not figure out how to use them for even a simple thing like changing the background color of a panel. Also color properties are restricted to a palette not involving any "dynamic" cl... constants (or they are hidden somewhere). But the available predefined colors are very pretty and well named.

Maybe you mean applications using the FireMonkey (FMX) library? In this situation, you need to use styles to handle color. However, if you choose a VCL application, then color handling in the Object Inspector works as before and similarly to Lazarus. I just checked it in Delphi 12 (Professional with Mobile).

_Antares_

  • New Member
  • *
  • Posts: 13
Re: What I love about Lazarus' features
« Reply #5 on: November 17, 2024, 01:11:30 pm »
Other than that, I wasn't aware that Delphi colors watches. What is it used for? Some pattern in the data? Or "changed during last step/run"?

@Martin_fr: It is used like syntax highlighting (integers having a different color than strings etc.), purely cosmetic I suppose. Also, I must have dreamed about the identifiers being like in the inspector and not in code. I cannot reproduce something like that in my current project at least. See attached screenshot for a small example (inspecting on form.filelist: TListView).

Highlighting changed data during debugging steps sounds like an awful lot of usefulness! I am looking forward to this feature. I don't know how Delphi handles this or a 1000 items list, tho. Didn't setup a testcase to check it, sorry.

Also thank you so much for the insight on how to improve the debugging experience, I'll try some of that!

_Antares_

  • New Member
  • *
  • Posts: 13
Re: What I love about Lazarus' features
« Reply #6 on: November 17, 2024, 01:15:07 pm »
@VisualLab: Oh thank you for your input! I have made a FMX project indeed.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: What I love about Lazarus' features
« Reply #7 on: November 17, 2024, 01:28:37 pm »
See attached screenshot for a small example (inspecting on form.filelist: TListView).

Ah, grouping fields by class. Interesting. Need to remember that as a todo. (though got some other stuff before I can even think about it).

The "debug inspector" does show the class as column, and orders fields accordingly. But it is only one watch at a time.

Also the "debug inspector" has a filter, to search for fields (it matches field-name and data).
I often use that: Open a watch in the inspector, filter, find, double click, and then "add watch" to create a watch for the field.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11939
  • FPC developer.
Re: What I love about Lazarus' features
« Reply #8 on: November 17, 2024, 01:41:14 pm »
  • Lazarus/FPC trunk support AVX2, which is sometimes important, my Delphi Seattle does not
  • If you choose a local configuration , installations are easily cloned to other machines
  • To illustrate codefolding/highlighting etc: I had to do some verilog FPGA work, and I could customize it to properly follow nesting with colouring
  • I like the package dependency bit, to avoid global paths in .lpi, which is nice when you have your projects in a version system, and use them on multiple computers. I have one local package that contains all paths. I only haven't figured out how to flag such packages for rebuild when I rebuild lazarus

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: What I love about Lazarus' features
« Reply #9 on: November 17, 2024, 01:45:35 pm »
You can inspect anything, even if not directly in scope of the current method and properties/fields are named like in the inspector, not like in the source code.

I am not entirely sure about what you mean.

If you mean "FORM1" all uppercased => then switch to Dwarf-3. And you get nice names. Make sure to also set that for packages, if you debug packages.

Dwarf-2 variants are mostly useful if you - for some reason - use GDB. E.g. if you are on arch or other non-Intel. => In that case, many of the features I mentioned will not work either. GDB brings down debug experience by miles. And FpDebug is currently only Intel (or AMD) / On Mac, FpDebug works in combination with LLDB, and 95% of the features are avail.


Quote
even if not directly in scope of the current method

Example? (Other than properties)

You can switch stack and thread.
You can view global vars.

You can view globals from other units.
However, if you got more than one other unit with a variable of the same name, then there is no way of telling which one is used. The compiler does not supply wich other units are in scope of the current unit.

And "current unit" is always the unit in which you are paused (or more exactly: The unit containing the code that is selected by your stack/thread selection, if you changed those).
If you open another source edit, and hover over a variable (global, or local in another function) it will just take the name, and eval it in the scope of the "current unit".

Obviously, if you are paused in "function foo", and hover over a local var "abc" of "function bar" => then it can not be evaluated in "bar", because that funciton isn't active.
If it was a global var, that would be possible. But isn't currently done.

In watches you should be able to enter MyUnit.SomeVar
(of course if MyUnit is also the name of a local var in the current sub, then that screws things up)
« Last Edit: November 17, 2024, 01:51:43 pm by Martin_fr »

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: What I love about Lazarus' features
« Reply #10 on: November 17, 2024, 01:50:51 pm »
Highlighting changed data during debugging steps sounds like an awful lot of usefulness! I am looking forward to this feature.
In Delphi / in your image, it is probably that tiny blue dot after "form1.filelist". It either appears or changes color or something.

In Lazarus: todo.

440bx

  • Hero Member
  • *****
  • Posts: 4732
Re: What I love about Lazarus' features
« Reply #11 on: November 17, 2024, 05:01:43 pm »
Highlighting changed data during debugging steps sounds like an awful lot of usefulness! I am looking forward to this feature.
In Delphi / in your image, it is probably that tiny blue dot after "form1.filelist". It either appears or changes color or something.

In Lazarus: todo.
This feature is present in Visual Studio and one of the things I miss there is being able to hover over the variable(or register name) to have the _previous_ value shown in a popup.  There are times being able to look at the previous value can be very useful.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: What I love about Lazarus' features
« Reply #12 on: November 17, 2024, 06:17:14 pm »
I miss there is being able to hover over the variable(or register name) to have the _previous_ value shown in a popup.  There are times being able to look at the previous value can be very useful.

Also a good idea to have it in a hint.

You can see the previous value by using the "debug history" window.

440bx

  • Hero Member
  • *****
  • Posts: 4732
Re: What I love about Lazarus' features
« Reply #13 on: November 17, 2024, 08:26:46 pm »
You can see the previous value by using the "debug history" window.
I didn't realize the "history" applied to the watches.  Nice feature.

I just tried it and now have a request/suggestion please refer to the snapshots.

The "0" attachment shows the active/current watches at the breakpoint.
The "1" attachment shows the active watches at the previous history snapshot
The "2"  attachment shows the active watches at the current line (just after the breakpoint)

The "problem" is that once a snapshot is selected (say "1"), there does not seem to be a way of going back to the current set of watches.  That is, going from the state in attachment "1" to the state shown in attachment "0" (other than single stepping one instruction as shown in attachment "2" which shows the active/current watches again)

Did I miss a way of getting back to the current watches without having to single step a line ?
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10553
  • Debugger - SynEdit - and more
    • wiki
Re: What I love about Lazarus' features
« Reply #14 on: November 17, 2024, 09:55:23 pm »
I don't think you selected the snapshot, when you said you did...

There should be an arrow (left to right / pointing to the line) in front of the selected snapshot. => double click to select.

And then double click to deselect. (or double click another to select that other).

TODO: I want to add a line for the "current" pause.

Or use the lightbulb to toggle the highlighted (after single click) entry.

The window reacts to F1 => https://wiki.lazarus.freepascal.org/IDE_Window:_Debug%20History

Mind, there are the last 30 (IIRC) automatically.

And the camera (with the "+") can add it to the permanent list / getting more than 30.

The clock vs camera (no "+") can toggle between the 2 lists.


Breakpoints have an "Add snapshot". You can set breakpoints to not "break" but "add snapshot". That allows collecting data while the app runs.

However that only collects the local/watches of the top frame. And only 5 entries for the callstack (that will be more if the callstack window is open, and set to more).

If you are normally paused, then locals/watches are also collected for any thread/frame to witch you switch.



Overall this feature is still very basic. There are just to many things that need to be done...

« Last Edit: November 17, 2024, 09:58:57 pm by Martin_fr »

 

TinyPortal © 2005-2018