* * *

Author Topic: Lazarus write once compile anywhere - what to expect when designing applications  (Read 2040 times)

Hansaplast

  • Sr. Member
  • ****
  • Posts: 373
  • Tweaking4All.com
    • Tweaking4All

With this topic, I'm not trying to start a flame war or endless discussion.
I'm just trying to find out what the Lazarus philosophy will be moving forward.


I've used and enjoyed Lazarus Pascal for several years now, and have developed several small applications for Windows, Linux and MacOS (Carbon). One thing I absolutely loved about Lazarus is that I code and design my application on one platform (write once) and simply move a project to another platform (compile anywhere) and hit compile to get the same application up and running just the way I designed it. Which matches the "identical products" in the Wiki statement "... you don't need to do any recoding to produce identical products for different platforms." (source)


With the recent changes on the macOS platform (Cocoa), I've been trying to force myself to work with Cocoa as much as I can, trying to create a 64 bit Cocoa application and report bugs in case I run into them. Since Cocoa in in alpha stage, issues will still be found of course.


One thing, in my opinion, that appears to be problem is that the "compile anywhere" does work, but the UI design is definitely not consistent anymore accross platforms.


I used to be able to design in Carbon, and it would look exactly the same in Windows and Linux.
With Cocoa this is (in it's current stage) no longer the case.


Instead the design is trying to match what XCode would do (macOS) which means that the IDE must be compiled in Cocoa as well, otherwise the design will simply not match up with the end product. Positions of TButton, size of TPanels, etc. most of it simply does not match. Some of these issues can be addressed by anchoring, but after 3 months of toying with this I can hoenstly say that this simply doesn't work to resolve these issues.


So what is the Lazarus philosophy moving forward?


- Write once (code and UI) and Compile Anywhere (reproduce identical products for different platforms)?
Or
- Try to match whatever UI design guidelines are set per platform?


I'd prefer to be able to build an application on one platform, and recompile it, looking identical, on another platform.
Or maybe an option should be defined allowing both (probably more complicated): "LCL Style" vs "Native Style"?

Thaddy

  • Hero Member
  • *****
  • Posts: 6529
This is a false statement and has never been the case:
Quote
Write once (code and UI) and Compile Anywhere (reproduce identical products for different platforms)?
What the "write once, compile anywhere" pretends and strives for is identical functionality, not look-alikes. The look and feel should always be based on the chosen widgetset, which differs from a platform.
Any problems are usually caused by stubborn programmers that use features that are specific to a certain widgetset and get caught out by doing so when they port to a different platform.
That's mostly thoughtless or even brainless. Lazarus still requires that you design your applications with the largest common subset in mind. If you don't you will get bitten.
« Last Edit: March 29, 2018, 11:02:24 am by Thaddy »
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

Hansaplast

  • Sr. Member
  • ****
  • Posts: 373
  • Tweaking4All.com
    • Tweaking4All
Thanks Thaddy.


I can see what you're saying, and I most certainly did not want to start a discussion, criticize or offend anyone - apologies if that is the case. I very much enjoy and respect all the hard work done by others, so I have a tool to develop with. I was just looking for a clear statement where we are and/or where we are going with Lazarus, so I can anticipate what to do when developing an application.


I guess there are 2 things to look at.


First the interpretation of the Wiki page stating:
"Lazarus and Free Pascal strives for write once compile anywhere. Since the exact same compiler is available on all of the above platforms it means you don't need to do any recoding to produce identical products for different platforms.".

Based on your input, this should probably be rewritten as it could be interpreted differently than intended. "Identical products" sounds a lot like that the appearance of the applications will very similar (assuming the use of standard components, and not platform specific features) - which has been the case in my experience (intentional or not) when developing for macOS(Carbon)/Windows/Linux.


Second thing is indeed platform specific limitations and/or features. I always stay away from platform specifics, if Lazarus doesn't support a function or feature on all platforms, then I will simply not use it. So you will not see me use MacOS or Window specific features or functions.
I agree with designing applications with the largest common divider in mind - don't use something specific for macOS and expect Windows to handle this correctly (or at all).


However, as an example, two standard TPanels or TPageControls placed next to each other, may look different (rounded corners versus square corners, or different looking caption) - which is not a big deal. This worked as described under Windows/Linux/Carbon. However when width, position and spacing between these 2 components appear very different (in Cocoa), then I'd say this could be a problem. I tried to solve this by anchoring things, but it does not solve this issue. Any recommendations are most welcome.


Another examples are buttons. I totally understand that Cocoa (for example) has limitations (natively) what a button can look like (height, etc). Again not a problem, but when positions are just different, then again this could be an issue as well.


So should the position and width of these two examples appear the same on all platforms? Neither are platform specific features (left, top, width). Or is it to be expected that they are different?

wp

  • Hero Member
  • *****
  • Posts: 4815
I have ignoried the AnchorEditor for a long time - now I'd say: it would have saved me from a lot of trouble. If you intend to write a cross-platform application use it whenever you can. The different font sizes, control sizes on different platforms, different text lengths in translated versions, are not a problem any more.

The only disadvantage is that is quite difficult to modify an existing layout, e.g. insert another control into a chain of controls anchored to each other, or to move controls to other containers.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Handoko

  • Hero Member
  • *****
  • Posts: 2443
  • My goal: build my own game engine using Lazarus
For most cases, we should use the OS native (style) controls. But if uniformity appearance is important, we can use OS-independent components:

http://wiki.freepascal.org/Lazarus_Custom_Drawn_Package
http://wiki.lazarus.freepascal.org/BGRAControls
http://wiki.freepascal.org/Eye-Candy_Controls
http://wiki.freepascal.org/User:Alextp#Components

Hansaplast

  • Sr. Member
  • ****
  • Posts: 373
  • Tweaking4All.com
    • Tweaking4All

Thanks for the replies!  :)


My main concern is that controls, even though they look slightly different on different platforms, at least should appear in the same place and adhere to the very similar dimensions (for example). This is how I have been working in the past cross-compiling applications for Windows, Linux and macOS (Carbon) without a hitch, and I never had to customize a single control for each platform.


As an example; When designing a form in a Carbon IDE, and compiling for Cocoa, a unexpected result will appear. The worst example is TPageControl, but I'm sure (since Cocoa is still in Alpha stage - with all respect for those working on Cocoa!) there will be more. Controls appear not in the right place, with more or less spacing than expected and a slightly different width.
So the question is; should we expect this to be so different, is this what fits the Lazarus philosophy? Or should we only expect minor differences (like rounded vs square corners - since native controls are slightly different per platform)?
I assume this will play an important role in bug reporting as well. I'd hate to report a bug, which actually isn't a bug.


Maybe I'm not asking my question correctly haha ...
I'd like to continue using Lazarus to design an application on one platform (UI included) and recompile it on another platform where the application then appears very comparable to the original UI design. Is this conform the Lazarus philosophy or is this just coincidence?

@wp;
I tried working with anchors, and it's quite powerful. Unfortunately, one can't fix all problems with this. For example, two TPageControls next to each other; no matter how I anchor them, they will not look (Cocoa) like the design view (Carbon).
And yes you're right; adding or removing a control that are linked can be a pain. :D


@Handoko;
I have played with BGRAControls and ECControls before - they are truly great!
The unfortunate part is that these sets of controls only cover a few controls - so either the normal controls should not be used or your UI will be a quite inconsistent mixed bag of styles.

garlar27

  • Hero Member
  • *****
  • Posts: 504
Just saying just in case.

I've red that High DPI sometimes can be troublesome if your app isn't DPI-Aware. did you check that?

Can you post an image of how the things are and one showing your expected layout? (or at least the one that you have and draw lines of where things should be)

Thaddy

  • Hero Member
  • *****
  • Posts: 6529
Just saying just in case.

I've red that High DPI sometimes can be troublesome if your app isn't DPI-Aware. did you check that?
You have to program your app to be high-dpi aware. Although it is now reduced to setting the proper properties.
Ada's daddy wrote this:"Fools are my theme, let satire be my song."

Hansaplast

  • Sr. Member
  • ****
  • Posts: 373
  • Tweaking4All.com
    • Tweaking4All
With or without DPI-awareness; it doesn't make a difference.


Here is an expample I slapped together - no anchoring or aligning used. Just a TForm with standard controls. Designed in Carbon (upper left corner), and the application is in Cocoa (bottom-left and top-right).
I tried to add some guides to make the differences clear.
« Last Edit: March 29, 2018, 05:35:58 pm by Hansaplast »

Hansaplast

  • Sr. Member
  • ****
  • Posts: 373
  • Tweaking4All.com
    • Tweaking4All
Another example (was just playing with different kind of tab controls).
Carbon design on the left, which matches extremely close (dimension wise) with Window and Linux.
Cocoa result on the right.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus