Live data from Hacker News

G# – A modern .NET language with Go, Kotlin, and Swift ergonomics

davidobando.github.io

101–107 of 107 posts

Re: G# – A modern .NET language with Go, Kotlin, and Swift ergonomics

#101
why doesn't anyone just jump the gun and introduce proper parallelism primitives? SML/NJ got it right in 1991. ocaml5.0 has domains and effect handlers.

why do people still accept CSP? It is simple to do some things in it, bit please just give me concurrentML with "simple" channels for that kind of work , and proper channels for any kind of hard stuff. I have had to write things in go that took me days to get straight that would have been 20 trivial lines in any concurrentML implementation.

Re: G# – A modern .NET language with Go, Kotlin, and Swift ergonomics

#102
post #82

Earlier quoted context omitted.

It works through the new UnsafeAccessorAttribute [1]. This provides the information needed for AOT to know what needs to be in the final binary and not trimmed. It also removes the lookup overhead associated with normal reflection which is very nice. [1] https://learn.microsoft.com/en-us/dotnet/api/system.runtime....

This attribute makes the compiler generate IL code as if the target member was accessible to the user code. It's orthogonal to AoT and reflection. This works perfectly fine with AoT: var writeLine = typeof(Console).GetMethod("WriteLine", [typeof(string)]); writeLine.Invoke(null, ["Hello world"]); As you can see, there are no UnsafeAccessorAttribute's. Plain old reflection that just works (why should it not?) https://…

> Plain old reflection that just works (why should it not?)

I definitely don't fully understand the landscape, so I could certainly be wrong, but I assumed that normal reflection didn't work in AOT because after trimming that method may or may not be there. If it was never called in a normal way then the compiler doesn't know that `Console.WriteLine` was being used as `GetMethod` may have a runtime value as a string rather than a constant value known at compile time. If the compiler didn't know it was being called then it will be trimmed out of the final binary whereas with `UnsafeAccessorAttribute` it provides the information required to not trim it.

Edit: I tried the following https://sharplab.io/#v2:D4AQTAjAsAUCAMACEEB0AlApgMwDaYGMAXAS... and it fails when I provide the type and method for Console.WriteLine as arguments. If I was to add `typeof(Console).GetMethod(args[1], [typeof(string)])!.Invoke(null, ["dummy"]);` to it before the `Type.GetType` call it seems to be enough to not trim out the `Console` type and the `WriteLine` method. The compiler seems to at least be smart that way.

Re: G# – A modern .NET language with Go, Kotlin, and Swift ergonomics

#103
post #99

- stupid question: how do you make a programming language like this from scratch? - what is the thought process that goes into making a programming language - what is this field of study or discipline called? - why do we have so many programming languages? what purpose do they intend to solve and how do we know what purpose a programming language was made for? - for example, why was swift made if objective c exists a…

i have made a language that xompiles to c#. I wrote a lexer. then a parser. then a type checker (hindley milner, function local so that top level functions must have type signatures) a match compiler. the hardest part was what came next: the code generation. despite producing c# instead of MSIL. The features I use are: static and dynamic traits, pattern matching, and a concurrentML. It is actually quite simple when y…

I've done that for transpilation from SAOL (an MPEG 4 historically curious language) to C++. It does make it incredibly easy to write the compiler.

The big drawback that I never managed to sort out is how to integrate with visual debuggers. How to generate GDB source mappings (or .PDB source mappings) that reference the original LanguageX source files.

So you end up with a toy language that is un-debuggable. Which is not nearly as much fun as it should be.

Re: G# – A modern .NET language with Go, Kotlin, and Swift ergonomics

#104
post #74
post #69

Earlier quoted context omitted.

F# is nice, i like it.

Interesting, I have been skeptical about .net as a platform, is it really open and doesn't lock you with microsoft in any way?

You can infer direction from observable actions, and Microsoft is visibly going for dev mindshare with e.g. Typescript and VS Code. They recognise that they lost the battle for the dev desktop and the server OS, hence the pivot to xplat.

You can code in strictly vim or JetBrains with no friction, and run on mono with no friction in the happy case. It is possible for the SDK to be the only Microsoft product in your stack.

I don't see a way for Microsoft to return to funnelling users to their own ecosystem via dev-ex, and they seem to recognise that.

Re: G# – A modern .NET language with Go, Kotlin, and Swift ergonomics

#105
post #16

Here I am wanting the opposite. I want C# compiled into a static binary like with the GoLang toolchain! Maybe .NET AOT will get there one day..

What's missing in .NET AOT?

Lots of replies to this comment but a simple answer from my side: compatibility with ASP.NET attribute routing.

Re: G# – A modern .NET language with Go, Kotlin, and Swift ergonomics

#106

Here I am wanting the opposite. I want C# compiled into a static binary like with the GoLang toolchain! Maybe .NET AOT will get there one day..

You don't need AOT for a single self-contained binary. This already works with C#, but it's still JIT-based.

Self-contained != static compilation though. The self-contained binaries still have pretty poor startup time and are large since they contain the whole JIT.

Re: G# – A modern .NET language with Go, Kotlin, and Swift ergonomics

#107
post #99

Earlier quoted context omitted.

i have made a language that xompiles to c#. I wrote a lexer. then a parser. then a type checker (hindley milner, function local so that top level functions must have type signatures) a match compiler. the hardest part was what came next: the code generation. despite producing c# instead of MSIL. The features I use are: static and dynamic traits, pattern matching, and a concurrentML. It is actually quite simple when y…

I've done that for transpilation from SAOL (an MPEG 4 historically curious language) to C++. It does make it incredibly easy to write the compiler. The big drawback that I never managed to sort out is how to integrate with visual debuggers. How to generate GDB source mappings (or .PDB source mappings) that reference the original LanguageX source files. So you end up with a toy language that is un-debuggable. Which is…

if you compile to c# you can use #line directives to get integration with debuggers. it is really simple. for debug builds you can do an ANF pass and generate debugging locations for every different expression.
Post reply on HN