Recent

Author Topic: Cloning the Windows API  (Read 7180 times)

LazaruX

  • Hero Member
  • *****
  • Posts: 597
  • Lazarus original cheetah.The cheetah doesn't cheat
Cloning the Windows API
« on: August 26, 2008, 02:03:35 pm »
Hi everybody, a problem me and a lot of users expirience is when we try to compile an application that uses the WIndows api in windows. We need to find other solutions and convert procedures, change the code,... to let everything work.
My auggestion is to clone the Windows API, create a library with the exact names the WinAPI uses, but the code should then be crosscompatible.

What do you think about it?

bee

  • Sr. Member
  • ****
  • Posts: 393
RE: Cloning the Windows API
« Reply #1 on: August 26, 2008, 02:55:28 pm »
I disagree with this. This idea sounds good, only for windows developers that intend to jump to other platforms. But for other developers who originally come from non windows platforms, this idea is obstructive since they also have to learn windows API which is actually doesn't exist on other platforms. This would also make windows API become "de facto" API for FreePascal/Lazarus, which I think is bad.

If you do really need that "feature" then I suggest you to build your own units which map windows API to theirs cross platform counterparts (if exists). :)
-Bee-

A long time pascal lover.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Cloning the Windows API
« Reply #2 on: August 26, 2008, 03:38:58 pm »
Quote from: "bee"
I disagree with this. This idea sounds good, only for windows developers that intend to jump to other platforms. But for other developers who originally come from non windows platforms, this idea is obstructive since they also have to learn windows API which is actually doesn't exist on other platforms. This would also make windows API become "de facto" API for FreePascal/Lazarus, which I think is bad.


What BPsoftware suggests is actually a very effective technique for porting Delphi apps to Lazarus. Lazarus already provides a subset of common Win API functions in the LclIntf unit. All he's suggesting is that interested parties either add to the LclIntf unit or develop additional units with more of the Win API functions implemented. The alternative is to rework the code to avoid calling Win API functions, which can be a recipe for disaster, particularly when you're not the original developer of the code.

There's absolutely nothing "obstructive" about adding Win API compatibility units. No one has to use them if they want to write purer, higher-level code. But for porting existing Delphi apps and controls, it's a lifesaver.

Not sure what you mean by "only for windows developers". Currently almost all Pascal developers are working on Windows.

BPsoftware: See the mymisc.pas unit that I developed for porting some of the Orpheus controls for an example of how I used this technique:

http://wiki.lazarus.freepascal.org/OrphPort

Thanks.

-Phil

bee

  • Sr. Member
  • ****
  • Posts: 393
RE: Re: RE: Cloning the Windows API
« Reply #3 on: August 26, 2008, 04:44:54 pm »
> What BPsoftware suggests is actually a very effective technique for porting Delphi apps to Lazarus.

Agree, only for that purpose.

First off all, IMO, as programmers we should open our mind and realize that other OSes is not Windows. By expecting Windows features available on other platforms would make us (still) think that other OSes is (like) Windows while in fact is not. This is not good in the long run because everybody will keep thinking in Windows' way.

If Windows API compatibility units exist, it's good. But, please don't encourage the usage of those units other than porting purpose. Instead, encourage the usage of FPC/Laz cross platform units (e.g. RTL, FCL, LCL, etc.) which will be mapped to the corresponding targeted platform API. This will make sure our codes would be cross platform in pascal's way.

> Currently almost all Pascal developers are working on Windows.

Perhaps. But it doesn't mean that pascal developers should keep thinking in Windows way. If we want to go cross platform, then we should start to think in cross platform way. This would also help FPC and Lazarus project to be a true native cross platform dev tool, not just Windows API translator for other platforms. :D

Thank God, I kept using VCL and rarely called Windows API directly when I was using Delphi. It helped me a lot when I migrated my Delphi project to FPC/Lazarus. :)
-Bee-

A long time pascal lover.

LazaruX

  • Hero Member
  • *****
  • Posts: 597
  • Lazarus original cheetah.The cheetah doesn't cheat
Cloning the Windows API
« Reply #4 on: August 26, 2008, 07:03:22 pm »
This idea came in my mind, because often I look on the internet for Delphi example codes, and sometimes I want to test them, but since I am trying to totally migrate to Linux, and mostly use Linux now, I have trouble in testing them.
Some times removing a bit of code directly compiles, and everything is good and fixable.
Bu t mostly removing the code is like if I didn't look at all for that program, because it will not compile.
The purpose of this WinAPI clone in my mind is just for porting Delphi projects to Lazarus under Windows and other platforms.
My intent is not to create this API to develop apps with it.
Maybe we could call it: WindowZ, so just changing one letter in the code will lode this clone unit and prevent all the other problems.

I wait to hear what other programmers think about this idea.

Thanks to who already replied.

 

TinyPortal © 2005-2018