[Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

silvioprog silvioprog at gmail.com
Tue Jan 26 02:09:16 CET 2016


On Mon, Jan 25, 2016 at 7:02 PM, Dmitry Boyarintsev <
skalogryz.lists at gmail.com> wrote:

> On Mon, Jan 25, 2016 at 3:08 PM, Michael Van Canneyt <
> michael at freepascal.org> wrote:
>
>> On Mon, 25 Jan 2016, silvioprog wrote:
>>
>>>
>>> Many units in Free Pascal and Delphi uses C libraries... when aren't
>>> using
>>> a C library (an API system call, an third party library call, etc.), are
>>> using assembly, ie, mostly time Pascal is used as a high-level language
>>> to
>>> consume some low-level code written in C or assembly.
>>>
>>
>> There is a simple reason: Debugging and bugfixing is a lot easier if all
>> the code is in pascal.
>>
>
> Here's another reason - cross-platform availability.
> FPC is cross platform. To some extent (Java?) is more cross-platform that
> C is.
>

Indeed. But the one of the basic steps before chosing a library (from any
language) is read its specification, and know if it provides the needed
features, works in the expected SOs, and provides a good documentation with
a stable support. I need to make a device and it need a microcontroller, so
I found that the best choice is a PIC16F64A because its datasheet shows all
the features and the basic hardware that I need.
Well, the mostly C libraries work fine in many OSs. One that I use works in
the popular systems (currently I need it just for Windows and Linux) like
GNU/Linux, FreeBSD, OpenBSD, NetBSD, Android, OS X, Win32/64 and special
systems like Symbian and z/OS, and it's already available in some tools
like apt, yum, npm, maven, pacman... :-) ... (and if I have a chance from
FPC team, I can make it also installable via fppkg tool too! :-D )


> When using an external library, there might be a risk that the library is
> not *easily* available for another platform that is targeted. It's common
> for open-source projects, not to provide any binary builds, requiring a
> library user to build the library themselves. Luckily, the most common
> projects do have some satellite projects that actually provide binaries.
>

That was the main problem that I also had, unfortunatelly. :-(

For example:

https://github.com/libharu/libharu/issues/118

Mostly Pascal programmers don't like C libraries they get boring because of
the bugs like this, and can't fix the problem (lack time; doesn't have a C
environment, or doesn't know C etc.). But, why not try to understand the
problem? Is C so hard that a Pascal programmer can't understand that? I
don't think so, if you already use pointers and played with low-level
programming in standard Pascal, you can learn C too.

Building C (C++) library could be a real pain for some Pascal users.
> (Pascal spoils!)
>

Sad but true. :-(

But they should try to get support from the library list. Some days ago I
fixed a lot a problems in a C library (that's already a FPC/Delphi header)
and now it works like a charm on Windows, Linux and OS X. But first time, I
thought: "oh ktulu, why it doesn't compile plz..." ... but after trying to
fix it by myself, finally I can fix common bugs in any C library, because
complex bugs usually are already fixed by its maintainers.

Building C/C++ library for a desired target platform, could be even more
> painful, specifically if some sort of cross-tools required or when building
> configuration needs to be changed.
>

Well, in mostly cases I just use the ./configure && make && make
install-strip hehehe... On Windows I use MinGW, so I can compile C
libraries easily, and when I got any problem to compiled that, I solve it
easily too, by myself or getting support in the Pascal or C communities. :-)


> Thus a pure pascal library would be a number one choice for most users.
> With though it might be outdated and/or slower than its C-counterpart (i.e.
> paszlib vs zlib)
>

I agree, but I can't find a hard problem that makes a Pascal programmer
(beginner or veteran) not to use a C library even if it has already a
solution that's not implemented in Pascal yet. :-)

These days I took a look at FPC/Laz examples finding some solution to
control keyboard/mouse remotely, something like a VNC, but just the
control, without the server, and I found that, the
components/MouseAndKeyInput package, that uses external libraries. On
Windows and OS X it uses theirs APIs (they are external libraries), on
Linux it uses the libxTst library, and I don't have problem to use this
component just because it's using a third party external GNU library. After
installing it via apt, the only problem that I got was create the library
link on the /lib folder.

But, unfortunatelly, even with this pros, Pascal programmers avoid to use
external libraries, that's a real fact. :-/

--
Silvio Clécio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20160125/db2d3ab0/attachment-0003.html>


More information about the Lazarus mailing list