-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Base compileTime on dotnet-script CLI tool instead of Roslyn scripting #118
Comments
I wasn't aware of this tool before, but I just downloaded it and gave its interactive mode
Next I tried writing a full script with a namespace: #!/usr/bin/env dotnet-script
namespace X {
public class Y {
public static void Main(string[] a) {
Console.WriteLine("Hello, world!");
}
}
} No luck:
There are a couple of key reasons I used interactive mode. One is that the input comes as a series of separate invocations of the A second reason is that C# interactive allows mixing of instructions and declarations (e.g. I doubt I will find the time to do this myself in the immediate future, but if you really need features like namespaces, you could write a macro that would compile a set of source files (*.cs and even *.ecs) into an assembly using Roslyn or csc or msbuild, and then add that assembly as a reference to the current ecs file. I imagine a macro like
This, of course, would allow SourceFile1.cs and SourceFile2.ecs to contain namespaces and extension methods, and it wouldn't be hard to also support inline blocks of code that contain namespaces and extension methods, as shown.
|
Thanks for looking.. I am not interested in namespaces so much, but rather in extension methods and more simple folder references, and other goodies e.g. I will check your suggestions. Thanks for your time! |
I just checked again. dotnet-script matches C# interactive (and LeMP): it does not support extension methods but it does support |
Hmm, this is the full script which works for me: public static string Bang(this string x) => x switch { { Length : 6 } => x + "!!!", _ => "nah" };
var sailor = "Sailor".Select(char.ToUpper).Aggregate(new StringBuilder(), (s, c) => s.Append(c)).ToString().Bang();
WriteLine($"Hi, {sailor}");
Yep, this is a win for quick prototyping or trying things (and probably much more - because you can wrap script in .exe or publish to nuget): #r "nuget: FsCheck, 2.14.3"
using FsCheck;
Prop.ForAll<int[]>(x => x.Reverse().Reverse().SequenceEqual(x)).QuickCheck(); |
Ahh, I misunderstood the situation. C# interactive actually does support extension methods if they are not within a |
Currently, there is a trend to provide minimal (or single file) solutions to the historically big entreprizy problems. I think it is a good opportunity to demonstrate LeMP. Or at least test it features on something small and complete. Here are two threads:
ExpandingMaybe for removing the solution and project out of the picture, generating the dotnet-script The first obvious Ecs thing is warping the multiple Others? TBD |
I have published LeMP 2.8.2 which allows extension methods directly inside Are they really adding top-level statements to the main language (not C# interactive)? Ever since C# 1.0 I always wanted top-level functions. I wouldn't complain if they add top-level statements... but what would happen if multiple source files have top-level statements? I've always thought that the build system should be based on the same syntax as the programming language itself... this makes the most sense if the syntax is very generic, like LES, but imagine if, in C#, top-level statements were actually commands like There are a ton of angles that can be can taken to make software development better - whether the problems are "enterprizey" or not. The people at Future of Coding tend to focus on highly experimental "visual" software development prototypes, for example, or interesting debugging experiences; I tend to be interested more in the theoretical side of "how to make a better programming language' - and there are so many ways to improve languages, but C# and .NET have a lot of historical baggage that I wish I could break free from. MS of course has thousands of times more resources than one unemployed developer (=me) and thanks to .NET Core they are finally breaking free from some of it - like it was a pleasant surprise that they added non-nullable reference types (though unfortunately they designed What EC#/LeMP really needs is more and better tooling, I think. Not having IntelliSense is a pretty big limitation, among other things. But, I kind of need a stronger indication that people want to use LeMP before I invest a huge amount of free time in tooling. And even then, I may still prefer to work on an entirely new language (which of course would also include LeMP) - I'd probably make it compatible with C# syntax, and maybe other popular syntaxes (TypeScript?) but it might not be mainly targeted at .NET, nor would C# be the main syntax. Plus, I think cross-platform support is important so I've been thinking about supporting VS Code, but on the other hand VS is the most popular IDE for C#. But VS Code and VS have totally unrelated APIs, so supporting both would be irritating work. |
Thanks for release!
Yes.. and while it is a bonus feature, honestly I would like them to spend the time on something else. Probably I don't like that features in the latest C# releases are not designing to play together. Seems like the feature inclusion solely decided on its creation effort, plus ASP team request, plus marketing. I would love to see more coherence like it was with Linq, which was a bigger thing built out of the smaller things being useful on its own. |
Agree. I was liked the idea of build system, packaging, and the whole infra done in the same language. It both minimizes the cognitive load and simplifies the system, given that you are already have tooling for the language. This is done in other spaces where it was not an afterthought, Elm for instance takes that in a Web space including everything you need for dev and deploy. Jai (in closed beta) has a very rich compile time capabilities - you may run a graphical game at compile-time written in the same language. I highly recommend to watch the series of videos of the Jai author, Jonathan Blow https://www.youtube.com/playlist?list=PLmV5I2fxaiCKfxMBrNsU1kgKJXD3PkyxO Back to C# I would like my build script to be as simple as possible and better is not existent. But sometimes you don't have a choice. Then it would be cool to not learn a new language and even better if I can develop and debug the build system the same as the rest if the program. There is a Nuke-build which has a similar ideas. But I did not like its UX. Neither I like the Cake. Some time ago I was looking at Nake which has a pleasant simple API but never have a chance to try it out. Btw, the is another closely related space of configuration-as-a-program (example is Dhall - https://github.com/dhall-lang/dhall-lang) and much bigger cloud-infra-as-a-program (see Pulumi - https://www.pulumi.com/docs/intro/languages/dotnet). |
It is understandable. Documentation, tooling and support is rarely an interesting thing to do in your free time. I will just add my feedback regarding the lack of tooling, as I see it in LeMP. I would've want intellisence as well, syntax highlighting and debugging.. in this order. Important thing here is the usage environment too.
Regarding Visual Studio - it is still a biggest player and the begemoth :). But Today you have an escape path and not the only one, there is JB Rider as well. I have a feeling that going forward (with fast start and cross-plat in mind) VS Code will play more and more prominent role, especially when trying the new things |
Good point,
... but for now you can use precompute() to output strings into the output file. Just remember that if you |
Knowing that the current
compileTime
directive is based on Roslyn scripting (C# interactive - CSI), I have started to look into other scripting limitations.What I found is a modern scripting alternative -
dotnet-script
CLI tool https://github.com/filipw/dotnet-script. Here is the detailed article of the C# scripting tools comparison https://itnext.io/hitchhikers-guide-to-the-c-scripting-13e45f753af9As for
dotnet-script
, it is cross-platform, works with .NET Core v3.1+, allows referencing of NuGet packages, allows packing, and referencing other scripts from the NuGet.It also seems to support more broad C# sub-set including C# 8, for comparison, CSI even does not support
using static
, not talking about extension methods.Additionally, there are goodies to access the script path:
So my question, is it possible to consider dotnet-script for the next version LeMP templating?
The text was updated successfully, but these errors were encountered: