Recent

Author Topic: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?  (Read 16817 times)

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1315
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #15 on: December 08, 2015, 05:36:06 pm »
Yes.

I wrote a multi-platform threading library some time ago, that runs on Windows, Linux, OS X, iOS and Android, and while Apple does try to rewrite everything to their own standards, the whole POSIX model is intact and everything is surprisingly "Linux compliant" on that level.

Or perhaps it's the other way around, as I did find many things that originated with Apple. After all, they exist for 40 years, and they did write many of those low-level libraries that everyone uses.

If you browse far enough through the #includes, You'll still find all that code written 40-50 years ago buried underneath.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12693
  • FPC developer.
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #16 on: December 08, 2015, 06:01:56 pm »
Or perhaps it's the other way around, as I did find many things that originated with Apple. After all, they exist for 40 years, and they did write many of those low-level libraries that everyone uses.

As said it comes from FreeBSD.  POSIX is a whole different kind of beast. It is a set of requirements a Unix like OS must adhere to.

jack616

  • Sr. Member
  • ****
  • Posts: 268
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #17 on: December 09, 2015, 12:51:39 am »
Quote
The machine on which it runs is a JVM. The JVM 'processor' runs Java bytecode.

Once again I refer you to the answer  I gave previously.
The term "processor" relates to the hardware.
The jvm is a software abstraction that runs bytecode.

The 'processor' runs machine code - which it may or may not convert itself into microcode.
bytecode or pCode is an intermediate step toward this.


SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1315
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #18 on: December 09, 2015, 02:56:47 pm »
@marcov:

An OS kernel is basically something that does task scheduling and memory management. It has an interface to attach drivers and stuff, and an API for programs. If I build one for a microcontroller, it is at most a few kilobytes in size. There is an interesting anecdote between Tanenbaum and Torvalds about that.

BSD, Linux and Apple all write their own ones.

They are written in C, which requires a C compiler and runtime. Those C runtimes and the libraries that go with them are for the most part the same, and written long ago.

POSIX was a successful project to standardize the API of different OSes, and it is one of the highest level interfaces in the C runtimes and libraries (libc). Richard Stallman had a lot to do with that.

And that's what they all used to build that kernel and the rest of their OS. On that level, there is even little difference between Windows and Linux. Although their APIs are quite different. But as programmer, you tend to use the libc API in the first place, with all the platform SDK headers that go with it. And they are very much alike. They all use the same code underneath.


@jack616:

The binary code (machine code) that runs on many current processors, like all x86/AMD64 CPUs, is actually pCode as well. Those processors are actually VMs with a different CPU underneath. They have a tiny JIT compiler on board, that translates the x86/AMD64 CISC instructions into truly native RISC ones.

Even more so: they mostly have multiple, different processors tucked away on their die, all with their own instruction set. And with quite a complex scheduler and memory manager on top, to manage all the different instruction threads and all the available (on-die) memory, like the register files and the cache memory.
« Last Edit: December 10, 2015, 12:11:44 am by SymbolicFrank »

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1315
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #19 on: December 10, 2015, 11:45:40 pm »
Ok. *takes a deep breath*

Now that is all out of the way. And I do apologize for the aggressive mail I posted before (and deleted). I just had a really bad day. My mistake. It seems I'm human after all  :o

Anyway, let's discuss "web".


What is web? Anything that uses JavaScript, CSS and HTML? Or that runs in a browser? Or that uses the http(s) protocol? Perhaps to tunnel random stuff through firewalls and proxies? Any socket that provides SOAP/XML/JSON/REST/RAW?

Or are we discussing the server side? On what level? The http(s) server itself, CGI/PHP-alike page creating code, middle-ware, MVC/MVVM/WPF models or complete content generating frameworks?

Or perhaps the client-side (JavaScript) frameworks that do things like showing and zooming pictures, or client/server AJAX frameworks like JQuery?


Then again, nowadays we have "Cloud" as well. That tends to be the server side. Or perhaps only for non-web related things? Ssh/putty? NFS? Where do we draw the line? Where would an X-Server go? Or is that among what people call "Remote Desktop" (RDP)?


It generally takes me some time when talking to people to understand what they mean by terms like "mobile", "web" and "cloud". But when I find out, I can help them with it.


I do have to admit: I mostly (seriously) prefer automatic software distribution over webapps. Simply because webapps are very complex and very limited, and tend to be extremely chaotic. Mostly because almost nobody builds their own client and server, and knows what is actually send over the wire.

Well, I do, of course. It's not hard. But it makes the discussions hard, as you're coming from a vastly different abstraction level.
« Last Edit: December 10, 2015, 11:53:58 pm by SymbolicFrank »

jack616

  • Sr. Member
  • ****
  • Posts: 268
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #20 on: December 11, 2015, 01:12:40 pm »
My best guess is you have learned your terminology online from other people who were themselves
just a little confused on some topics. Not suprising given the many attempts by various people to
re-name various things. Microsofts absurd notion (to both justify and hide criminal behaviour)
that windows is an OS being the funniest perhaps.
You are repeatedly applying incorrect terminology and attempting to justify the missuse.
I applaud your obvious attempts to research online but suggest a bit more care with your sources.

Now you wish to discuss "the web"

What I suggest is that you use a blog or those "social media" things for that.
This is a forum - forums are not well suited to long abstract conversations.
This thread also has a different topic.

If you have specific questions or information about the suitability of lazarus
for web (or mobile) use that would be appropriate in this thread.
But do try to use technical terminology a bit better - or just accept it when corrected.


JanRoza

  • Hero Member
  • *****
  • Posts: 739
    • http://www.silentwings.nl
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #21 on: December 11, 2015, 10:32:52 pm »
Is there still any Lazarus connection in this discussion? As far as I'm concerned this discussion has no place on this forum.
OS: Windows 11 / Linux Mint 22.3
       Lazarus 4.6 RC FPC 3.2.2
       CodeTyphon 8.90 FPC 3.3.1

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12693
  • FPC developer.
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #22 on: December 11, 2015, 10:56:40 pm »
BSD, Linux and Apple all write their own ones.

Are you sure that BSD<>Apple here? With respect to libc I mean.

Quote
They are written in C, which requires a C compiler and runtime. Those C runtimes and the libraries that go with them are for the most part the same, and written long ago.

Two of the three targets you name use LLVM, which is not that old. And as you said, C runtimes are paired with compilers....

Quote
POSIX was a successful project to standardize the API of different OSes, and it is one of the highest level interfaces in the C runtimes and libraries (libc). Richard Stallman had a lot to do with that.

Mostly different Unices, with some extremist claiming it was universal (as long as the other OS was unix like or emulated it)

Quote
And that's what they all used to build that kernel and the rest of their OS. On that level, there is even little difference between Windows and Linux.

Yes. There is a very big difference. The Windows kernel is not POSIX, and only C apps use the C runtime, as on Windows there is a difference between the C language runtime (ms*crt) and the general application user library (user32.dll)

Quote
Although their APIs are quite different. But as programmer, you tend to use the libc API in the first place, with all the platform SDK headers that go with it. And they are very much alike. They all use the same code underneath.

This is not true for Windows at all. The Platform SDK headers are not on top of the C runtime. The C runtime uses the Platform SDK headers.



SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1315
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #23 on: December 12, 2015, 02:19:39 am »
@jack616:

You might want to research this a bit.


@JanRoza:

It certainly is! We'll get back to it.

SymbolicFrank

  • Hero Member
  • *****
  • Posts: 1315
Re: HOW POWERFUL IS LAZARUS FOR WEB AND MOBILE?
« Reply #24 on: December 12, 2015, 03:51:57 am »
BSD, Linux and Apple all write their own ones.

Are you sure that BSD<>Apple here? With respect to libc I mean.

It's not libc as such, it is the source code behind it.

Quote
Quote
They are written in C, which requires a C compiler and runtime. Those C runtimes and the libraries that go with them are for the most part the same, and written long ago.

Two of the three targets you name use LLVM, which is not that old. And as you said, C runtimes are paired with compilers....

Yes, they use LLVM.

The thing is: would you switch to LLVM if it couldn't compile your gcc project? Or with a minimum of fuss?

Those code bases are HUGE.
Quote
Quote
POSIX was a successful project to standardize the API of different OSes, and it is one of the highest level interfaces in the C runtimes and libraries (libc). Richard Stallman had a lot to do with that.

Mostly different Unices, with some extremist claiming it was universal (as long as the other OS was unix like or emulated it)

Quote
And that's what they all used to build that kernel and the rest of their OS. On that level, there is even little difference between Windows and Linux.

Yes. There is a very big difference. The Windows kernel is not POSIX, and only C apps use the C runtime, as on Windows there is a difference between the C language runtime (ms*crt) and the general application user library (user32.dll)

Windows is just as POSIX-compliant as the *NIXes, just in a slightly different manner. The threading model and the Inter-Process Communication are the main differences. But even those are based on partly the same source code on the lowest level.
Quote
Quote
Although their APIs are quite different. But as programmer, you tend to use the libc API in the first place, with all the platform SDK headers that go with it. And they are very much alike. They all use the same code underneath.
This is not true for Windows at all. The Platform SDK headers are not on top of the C runtime. The C runtime uses the Platform SDK headers.

It's both.

Let's start at the bottom.

Without a kernel, there is no memory management. So, no malloc. No variables, unless they're registers. And some CPU's have only a single, or a few usable registers. So, the first thing you have to do is make the memory manager.

But, how are you going to do that? Is your kernel going to hand out memory allocation for each variable? Or only for larger blocks?

The thing that interests the kernel is the prevention of conflicts. And perhaps the coherence, but that's a different discussion.

Like a subroutine might have to push the registers it wants to use on the stack, and pop them back before returning, it's up to the kernel to make sure all the memory a process can access is available when it is running. Or to have an interrupt in place to do that JIT, on the moment the process tries to access it.

Most current kernels that I know of use paging to do that, and almost all of those use 4kB pages. For the most part because the CPU can do that as well. So, the moment a process tries to access some part of memory, the kernel is going to make sure the right memory page is "loaded" at that location. And that's all most kernels do for memory management. (Well, there's drivers and other resources, but that's not relevant here.)

To your application (the process), it looks like you have kilobytes (for 16-bit applications), megabytes, gigabytes or even an almost limitless amount of memory (for 64-bit applications). But how you are going to make sure your variables, buffers and instances all have their own space is up to you.

And the same goes for the kernel, as it also needs space for those things. So, they both have their own, fine-grained memory manager as well. Which is probably the same one, if both are written in C. Or if you use cmem in Lazarus. Or a different one if you don't.

So, there are two (actually more, but not for now) different memory management schemes, of which the fine-grained one is probably the same for the kernel as well as many applications.


Another great example are sockets. Almost everyone still uses the same socket code, as written nearly 50 years ago by people from Berkley University, while the internet was still called ARPANET.


And all those things are part of the runtime and/or default library. The kernel needs to make sure that your average C application compiles, which requires that both of those are supported. And it needs that runtime itself as well to function.

Only Intel builds their own compiler and runtime, everyone else uses gcc. Even a new design like LLVM needs to have a functional compiler before it is able to build itself. And it should be compatible with it.

The same goes for FPC.


Next up the ladder has historically been C++, or Objective-C for Apple. Same thing, different implementation. The main difference is the event (messaging) model. You need a functional C compiler, with the "default" libraries and runtime to bootstrap it. Which expands the libraries and runtime available.

And you use THAT language to build the rest of your OS (driver and software management, userland, at least one (G)UI and the all-important API).   


When building a high-level application, you can stick to the high-level API for your interface. But that API is part of the OS, which uses all those lower-level interfaces itself. Which are included in the headers of the platform SDK. And the only reason you might not be able to use those as well is that they might run in (protected) kernel mode.

But even so, it all uses the same code underneath (for the most part).


If you want to make your code platform independent, you can either stick to the common demeanor, or you can research the header files and libraries to see where the different platforms diverge. And what the actual code underneath does.

On that level, even the threading model of Windows and *NIX is alike.


Then again, it was more different in the past. Or at least, it looked like it. Critical sections versus semaphores. But nowadays everyone uses the same, simplified mutexes for everything. Although spinlocks are still used by the kernel in some rare cases.

So, behind the screens, on the lowest level, Windows actually uses something that is very much alike the simplified pthread model that the *NIXes use as well.


And while Apple has become a bit less compliant with the changes originating by their move to make everything reference counted, and as they use a much simplified event model for their GUI (they skip the formal events and use messages for everything), that's only an issue if you use the top level API. Which you have to do if you want to use their GUI.

FPC is one of the few non-Apple development platforms which can do that. Delphi, for example, circumvents it.


TL;DR: almost everything is build on top of the same, huge library of code that was written about 40 years ago. Most of the differences are in the top levels, the actual runtimes and libraries are mostly the same.
« Last Edit: December 12, 2015, 05:06:28 am by SymbolicFrank »

 

TinyPortal © 2005-2018