[HN Gopher] C# for Systems Programming
___________________________________________________________________
C# for Systems Programming
Author : pjmlp
Score : 88 points
Date : 2021-09-01 06:45 UTC (3 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| xanth wrote:
| I cant find any benchmarks comparing AOT to non AOT and ideally
| C, C++, or Rust. Anyone aware of any?
| akmittal wrote:
| All benchmark you mentioned(and lot more)
| https://benchmarksgame-team.pages.debian.net/benchmarksgame/...
| Traubenfuchs wrote:
| Isn't non-AOT C# (and java) "cheating" here, by warming up?
|
| And isn't not needing warm up one of the AOT selling points?
| unnouinceput wrote:
| Quote: "Cross-building is possible but requires extra steps, so
| just use the platform you're running on to avoid errors"
|
| Meanwhile in Delphi you just select the target OS from the list
| of supported OS'es and just "build and deploy". Why is that every
| single other IDE that I've tested it's an adventure to create
| cross-building, to the point where you need to give blood from
| your fingers to the God of that OS before you finally make a good
| build.
| bayesian_horse wrote:
| Mainly because C/C++ libraries/build environments/compilers
| just don't sit still and continue to evolve/devolve/diverge.
|
| If you have a single language with a single compiler,
| presumably with a smaller user base, chances are that is less
| of a problem.
| sharikone wrote:
| That cross-compiling is still so thorny in 2021 is in my
| opinion a big failure of software engineering.
|
| The creator of Zig is maintaining a very accessible and
| immediate cross compilation infrastructure for Zig and C alike
| (zig cc). It's a secondary thing to him, but I practically use
| it very often since it just works, in contrast to the other
| stuff. Unfortunately even zig cc has often issues with less
| tested platforms like 32 bit ARM
| jcelerier wrote:
| Delphi does not have the problem that it's illegal to
| redistribute e.g. macOS headers on a non-mac machine according
| to Xcode license. Likewise, until very recently the MSVC C++
| standard library was under a proprietary license which you
| could not redistribute, only use in your own software. It's a
| social issue, not a technical one.
| orbifold wrote:
| There was a research operating system by Microsoft
| https://en.wikipedia.org/wiki/Midori_(operating_system), which
| used a dialect of C#, with some interesting extensions specific
| to operating system / driver development.
| vnorilo wrote:
| Joe Duffy has blogged about it, excellent read.
|
| http://joeduffyblog.com/2015/11/03/blogging-about-midori/
| Avery3R wrote:
| Also singularity,
| https://en.wikipedia.org/wiki/Singularity_(operating_system)
| maxloh wrote:
| Aren't operating systems written in non-garbage-collecting
| languages?
|
| Do OS written in C# have good performance?
| Rerarom wrote:
| If an OS runs on bare metal, who does the garbage collecting?
| Ain't this a paradox?
| messe wrote:
| There's nothing inherently contradictory about running on
| bare metal, and being garbage collected. As long as you can
| manipulate memory directly, the garbage collector could
| potentially be implemented in the language itself. See the
| Boehm[1] GC as an example of a GC implemented in C for
| C/C++.
|
| [1]: https://www.hboehm.info/gc/
| [deleted]
| pjmlp wrote:
| The kernel obviously.
|
| http://www.projectoberon.com/
| kryptiskt wrote:
| No, because there is no reason an OS couldn't have an
| integrated garbage collector. The garbage collector would
| have to be written in a non-garbage collected language or
| using a subset of the language that doesn't allocate on the
| GC heap, the no-runtime sample here shows that it would be
| possible to do one in C#. But there is no reason the rest
| of the OS couldn't use automatic memory management. Linux
| is a heavy user of refcounted data already, and there is no
| fundamental difference between that and other garbage
| collection strategies.
| maxloh wrote:
| Aren't operating systems written in non-garbage-collecting
| languages?
|
| Do OS written in C# have good performance?
| pjmlp wrote:
| A side effect of history.
|
| Check any of XEROX PARC workstations OSes, namely Smalltalk,
| Interlisp-D and Mesa/Cedar.
|
| Oberon, EthOS, Oberon-2 and A2 at ETHZ.
|
| TOPAZ at Olivetti.
|
| Singularity and Midori at Microsoft.
|
| Or have some fun digging through Android sources to see outside
| Linux kernel and ART, what is Java and what is C++.
| wheresmycraisin wrote:
| Last I checked NativeAOT is not F# friendly, hopefully that's
| improved recently.
| pharmakom wrote:
| Isn't there a problem with bootstrapping .NET? Can I truly build
| from source?
| kevingadd wrote:
| The C# compiler for example is written in C# so you need a
| functioning .NET runtime in order to compile the compiler and
| standard library. That doesn't mean you can't build from source
| though, there aren't any special binary blobs you need to build
| .NET. For example, a csc (C# compiler) built using the open
| source Mono runtime will work just as well as one built using
| an open source build of .NET Core or one built using the .NET
| Framework binary blobs.
| MarkSweep wrote:
| The C# compiler and parts of the supporting .NET runtime are
| written in C#, so yes there is a bootstrapping issue. Other
| languages like Rust or even C compilers written in C have this
| problem.
|
| For initial porting to a new system or processor architecture,
| the C++ part of CoreCLR (the main runtime for .NET) can be
| built with CMake and LLVM on the target system. The libraries
| can be cross-compiled on another system that already supports
| .NET and copied to the target system. Some Details are here:
|
| https://github.com/dotnet/runtime/blob/main/docs/design/core...
|
| For building from source to satisfy requirements Linux
| distributions, Microsoft has a system to build from source. My
| understanding from the last time I closely looked at it is some
| binary dependencies are decompiled to MSIL (the bytecode used
| by .NET). Since CoreCLR includes a MSIL assembler written in
| C++ (ilasm), it can bootstrap using these MSIL sources. But I
| have not looked at this project closely in a while and it
| evolved quite a lot while I was watching it. The system for the
| source build is here:
|
| https://github.com/dotnet/source-build
| radicalbyte wrote:
| The "old" compiler which is written in C/C++, I don't think
| that it's open source though.
|
| The modern compiler - Roslyn - was explicitly re-written in
| C#, and is currently the main compiler (and has been for
| about three years now).
___________________________________________________________________
(page generated 2021-09-01 10:00 UTC)