Recent

Author Topic: What are main differences between free pascal and c#?  (Read 3614 times)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11384
  • FPC developer.
Re: What are main differences between free pascal and c#?
« Reply #30 on: January 31, 2023, 09:51:11 pm »
Thank you for the answer. So I am right. And at my Windows 10 ver. 22H2 the option to use UTF-8 is still beta-version.
Only the  option to do it default for all apps is beta. The per app option isn't.

Quote
And as you wrote about manifest, I have one question about it. There are lines in manifest for supportedOS ID from Windows Vista to Widows 10. May be you know, what about Windows 11? I'm just curious. Sorry for offtopic.

Usually windows is backwards compat,  and 10 options also work for 12. And versions older than 10 are out of support for a while now.

Warfley

  • Hero Member
  • *****
  • Posts: 1499
Re: What are main differences between free pascal and c#?
« Reply #31 on: January 31, 2023, 10:17:11 pm »
All you need to know about the the shift to UTF-8 for the windows API is here: https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page

Windows internally still uses UTF-16 (for legacy and performance reasons), but they upgraded all of the old -A functions to UTF-8, and also introduced -A variants of functions which previously only had a -W option.

A bit of the history. Microsoft was very early on with the unicode integration and went for the 16 bit route, because it is easy (and more importantly, very fast). Problem was that it turns out that 65k codepoints is not enough to archive internationalization (thinking about the fact that chinese already has over 100k, it's amazing how MS did not see that coming), so MS went the route of adding unicode planes, basically repeating the same problem of codepages that unicode tried to solve.
The rest of the world looked at that and thought that this is quite stupid, so they chose to go a different route, which was UTF-8, it has many advantages, mainly that it supports up to 32 bit codepoints, therefore every character can be uniquely represented, so unlike UTF-16 it actually solves the problem of codepages instead of repeating it, as well as being compatible with 7bit ANSI strings, making it a perfect fit for backwards compatibility.

This is why this was the major standard adopted by the Web, and as today most of the computer usage is using web applications, this became the dominant standard.

So in 2019, Microsoft decided to also enable UTF-8 in their API and add all the missing -A functions as in the previous years they opted for only the -W versions.

Today most of Microsoft products are using UTF-8. If you create a file with notepad, it's now UTF-8. .Net Framework and .Net Core have been switched to use UTF-8 by default. Even the Document format of Microsoft Office now uses UTF-8 by default.

UTF-8 is the de-facto standard encoding around the world now. The only thing where I found that Microsoft still does not use UTF-8 is for console applications. But thats for backwards compatibility, because Windows needs to be backwards compatible to the 90s and probably even earlier. But everything new that MS made in the past 5 years or so now uses UTF-8
« Last Edit: January 31, 2023, 10:19:14 pm by Warfley »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11384
  • FPC developer.
Re: What are main differences between free pascal and c#?
« Reply #32 on: January 31, 2023, 10:34:39 pm »
Today most of Microsoft products are using UTF-8. If you create a file with notepad, it's now UTF-8. .Net Framework and .Net Core have been switched to use UTF-8 by default. Even the Document format of Microsoft Office now uses UTF-8 by default.

So .NET's String type is now 1-byte rather than two byte ? Or are you referring to default document formats of the editors?

Your story has echoes of Spolky's article which is widely considered a Western centric view pandering to sentiments that eschewed any form of radical change. Regardless of what was better in the long run, short term profits were on the line.


tetrastes

  • Sr. Member
  • ****
  • Posts: 473
Re: What are main differences between free pascal and c#?
« Reply #33 on: January 31, 2023, 11:07:47 pm »
All you need to know about the the shift to UTF-8 for the windows API is here: https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page

Thank you, it was informative. But why did you decide that Win API "switched to UTF-8"? There is only the ability to "use UTF-8 code pages in Windows apps" is added, for the main goal
Quote
Use UTF-8 character encoding for optimal compatibility between web apps and other *nix-based platforms
And moreover:
Quote
As Windows operates natively in UTF-16 (WCHAR), you might need to convert UTF-8 data to UTF-16 (or vice versa) to interoperate with Windows APIs.

I have nothing against UTF-8, but I won't need this ability for a long time, because some of my programs are still running at WinXP boxes, not to say about Win7.
« Last Edit: January 31, 2023, 11:09:32 pm by tetrastes »

Warfley

  • Hero Member
  • *****
  • Posts: 1499
Re: What are main differences between free pascal and c#?
« Reply #34 on: January 31, 2023, 11:25:03 pm »
So .NET's String type is now 1-byte rather than two byte ? Or are you referring to default document formats of the editors?
I was talking about the Encoding.Default class, which is used for any String I/O like reading and writing to files or other streams. What it uses internally, I don't know.

The source code might depend on the language, but I think that at least C# is at least per default UTF-8.

I have nothing against UTF-8, but I won't need this ability for a long time, because some of my programs are still running at WinXP boxes, not to say about Win7.
Sure backwards compatibility is often quite important, but if you start writing a new program today and read files, or use the LCL to get user input through a GUI, like 99% of the time you will encounter UTF-8. So my point about the original question, how to iterate a string was, that just iterating char by char won't work in many cases, and you need to consider UTF-8.

Sure there are edge cases, but for most developers, especially those that start a new project today, they will probably only come across UTF-8 or sometimes maybe UTF-16, but thats it. So it is quite essential to know how to handle these strings

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11384
  • FPC developer.
Re: What are main differences between free pascal and c#?
« Reply #35 on: February 01, 2023, 04:09:17 pm »
All you need to know about the the shift to UTF-8 for the windows API is here: https://learn.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page

Thank you, it was informative. But why did you decide that Win API "switched to UTF-8"? There is only the ability to "use UTF-8 code pages in Windows apps" is added, for the main goal
Quote
Use UTF-8 character encoding for optimal compatibility between web apps and other *nix-based platforms

MS didn't  switch, it just additionally added UTF8.  I think the main reason is the subsystem for linux work (WSL) that cleared out old cobwebs in the console to make it unicode aware for Linux compat. Dos emulation is also not as important as it was for e.g. Windows XP.

So basically they had done the work, and it was more a case of "why not?".
 

Dzandaa

  • Full Member
  • ***
  • Posts: 249
  • From C# to Lazarus
Re: What are main differences between free pascal and c#?
« Reply #36 on: February 06, 2023, 12:42:39 pm »
Hello

I've been programming in C# for years since the beginning of .NET and Visual Studio.

My problem was portability.

A windowed program created by Microsoft's Visual Studio worked well only in a Windows environment.
There was of course Mono, but the interface was not as intuitive.

I discovered by chance the Pascal Lazarus and the miracle, a development environment that works without too much change on Windows, Mac and Linux, happiness.

At the beginning, this link help me a lot:

https://wiki.freepascal.org/Pascal_for_CSharp_users

Have a good day.
Dzandaa

Bogen85

  • Hero Member
  • *****
  • Posts: 595
Re: What are main differences between free pascal and c#?
« Reply #37 on: February 06, 2023, 12:53:38 pm »
At the beginning, this link help me a lot:

https://wiki.freepascal.org/Pascal_for_CSharp_users

That should be updated for what it says the equivalent of return is. It only has function_name := and result :=, but does not show that neither of those returns immediately (that either a flow rework or exit would be required).

Thaddy

  • Hero Member
  • *****
  • Posts: 14215
  • Probably until I exterminate Putin.
Re: What are main differences between free pascal and c#?
« Reply #38 on: February 06, 2023, 01:14:47 pm »
It should is now also be updated for multi-platform support: Mono! , (which I use quite a lot on nixes) well maintained too. So "was" is an unfortunate phrasing.
So I removed that part. It was simply not true.

I am trying to rephrase it, so that it shows that FPC supports more platforms, then again, Mono C# is available on many exotica too. You can't really count and compare the two.
« Last Edit: February 06, 2023, 01:39:36 pm by Thaddy »
Specialize a type, not a var.

Thaddy

  • Hero Member
  • *****
  • Posts: 14215
  • Probably until I exterminate Putin.
Re: What are main differences between free pascal and c#?
« Reply #39 on: February 06, 2023, 01:25:10 pm »
That should be updated for what it says the equivalent of return is. It only has function_name := and result :=, but does not show that neither of those returns immediately (that either a flow rework or exit would be required).
Return is also context sensitive and not equivalent to exit() in C# and closer to setting a result, either by function name or by result. So the entry is correct.
« Last Edit: February 06, 2023, 01:33:59 pm by Thaddy »
Specialize a type, not a var.

 

TinyPortal © 2005-2018