Script# Update - v0.5.5.0

The long-awaited event (by some) ... an updated script# build, along with next steps, new channels for Q&A and staying up-to-date via @scriptsharp on twitter...

Finally, an updated Script# build. Woohoo!

Its been all too long since the last update, leading folks to wonder if the project is still alive. I liked to think that the project had simply reached a temporary plateau of a stable release that was functional and usable for a core set of scenarios. Indeed some of the largest Ajax applications at Microsoft like the Office 2010 Web Applications and many others are now built from C# source code compiled to JavaScript, helping large teams of engineers work everyday with large codebases over the course of long product cycles. However, what I am learning is that it is also essential to continually have some set of updates to ensure there is sign of life and progress.

So this post will provide an update of where things are at. First and foremost, the project is by no means dead. In fact the interest level in the project has only just picked up a bit.

Build 0.5.5.0

This is mostly a bug fix release, but there are some interesting fixes, and a couple of small changes. I'll list a few notable ones (the release history page has more details).

  • Removed the $ shortcut, which was conflicting with prototype and jQuery.
  • Fixes to scriptlet code editor inside Visual Studio so code is no longer truncated (scriptlet code is now persisted as sibling .scriptlet files - eg. Foo.aspx.scriptlet represents the script code-behind for Foo.aspx). Scriptlets only depend on sscorlib.js now (don't depend on ScriptFX framework anymore - first step in making them work more broadly with fewer dependencies)
  • Fixes to bitwise comparison expressions, and equality/inequality checks
  • Fixes to release minimization in a variety of scenarios

If you're new to Script#, check out the project site, and the readme. Download the bits and give it a shot. And be sure to check out the samples that get installed as well for more concrete ideas.

If you've been using Script#, feel free to send me more information about what you've built, esp. if it qualifies for showcase material (I need to revamp that), or comments about what you'd like to see. I'll also use a poll from time to time to guage interest and guide future developments. In fact, I've got one now about what sort of IDE support you'd like to see - Visual Studio 2008, 2010, or Visual C# Express? Right now it seems folks most want 2010 support. I wasn't planning on 2010 support until VS2010 was out of beta, but looking at the early results of the poll so far, I've decided to go ahead and add an installer for that in addition. So with 0.5.5.0 you also get 2010 support!


Got questions?

I am planning to use stackoverflow rather than spending time building a dedicated forums. Lets see how that experiment goes, and whether it works out. Simply post your questions tagged with scriptsharp. I'll try to monitor them, and hopefully there will be folks in the community who can also pitch in with their experience.


Next Steps - Build 0.6.0.0 and beyond

The next build will see some bigger changes. This is sort of an heads up. From a functionality perspective you're going to see two things happen:

  1. The MSAjax support will grow to include support for all the new APIs coming out as part of ASP.NET Ajax. Aacorlib.dll (the equivalent of mscorlib) will be called mscorlib.dll (which should make FxCop happy), and MicrosoftAjax.dll will be broken out to match the different individual script files making up ASP.NET Ajax.
  2. The MSAjax mode of script# has been less functional than the native Script# mode (using sscorlib). Using an extension script to add missing functionality on top of the ASP.NET Ajax scripts, in 0.6, the modes will be nearly identical. So if you're using the MSAjax mode, you'll benefit from array instance methods, delegates, ability to use foreach etc.

Beyond 0.6, the list is interesting and long - generics, scriptlets for ASP.NET MVC, jQuery support, polishing up the unit testing infrastructure couple of teams have built, and streamlining the IDE experience etc. etc.


On-going updates and communication

I've been on twitter now for some time, and it makes it much easier for quick updates than the blog posts. As such, I've set up a twitter account for Script# specifically, that I'll use for announcements, quick updates, as well as the direct or brief conversations, and occasionally post a question targeted at Script# users. Follow @scriptsharp to stay up-to-date ... oh and feel free to follow @nikhilk too while you're at it :-).

If you've got a deeper question that isn't suitable for twitter or for stackoverflow-style Q&A, then please use my contact form to reach me. I'll get back as soon as possible.


Enjoy! And if you hit any unexpected issues, do let me know... in case I need to put out an incremental quick fix release...

Posted on Sunday, 11/29/2009 @ 10:19 PM | #Script#


Comments

25 comments have been posted.

Robert Byrne

Posted on 11/30/2009 @ 3:27 AM
I've got an interesting bug regarding using chained methods with the same name (for a JQuery wrapper)

eg foo.Css("..").Css("..")

In this case, the scriptsharp compiler dies in the middle of generating a function when it reaches that point in code, without raising any errors. I'll check the latest version to see if its still there, but would be great to get that fixed as it ruins the flow of JQuery when you have to break it down into multiple method call statements.

Marcus Baffa

Posted on 11/30/2009 @ 5:31 AM
Great !!!

I will download 2010 version and check it out. Thanks

Jeff Lewis

Posted on 11/30/2009 @ 7:33 AM
Great news! We based a VERY large project in Script# (nearly 50K lines of C# code that gets converted to JS by Script#) a few years ago and have been very happy with it. But when contemplating a new major release, I was being leaned on to drop it due to the lack of updates. This update makes me very happy... The only things that could make me happier are: 1) an open source release - even with a restrictive license that doesn't allow forking or 2) a commercial license where we could pay for support, etc.

Edison M. Castro

Posted on 11/30/2009 @ 8:38 AM
We have the same issue with a large application base (about 40K) and the update makes things a little more interesting. The fact that the project is now in CodePlex is a life saviour. This is a great project with so many possibilities (yum, yum).

Nikhilk

Is there any way of also getting the web develpment helper in CodePlex also. I just love it and from IE perspective there is nothing better. It just that it would be great to add some custom features and without the source code is very difficult.

Nikhil Kothari

Posted on 11/30/2009 @ 8:51 AM
@Robert Byrne
I'd appreciate if you could try your scenario with the latest build, and report back. I'd certainly expect that to work as expected.

@Jeff Lewis
Still on the back of my mind to figure out what to do here, explore the possibilities - will certainly share when something new and concrete appears.

Shiva

Posted on 11/30/2009 @ 10:17 AM
Awesome! Have been looking out for this for quite a long time. Eagerly awaiting generics support!!

Shiva

Posted on 11/30/2009 @ 10:26 AM
And hey, if you can add support for object initializer syntax, it would be excellent, especially in the world of jQuery...

Nikhil Kothari

Posted on 11/30/2009 @ 11:50 AM
@Shiva,
Just so expectations are in line with reality, those features are on the roadmap, but unlikely to happen soon, as they require fairly big parser/compiler updates and work... well at least the object initializer syntax. I am looking at what are the options to evaluate, but its a background activity as there is much more to focus on and get done based on the current infrastructure.

Robert Byrne

Posted on 12/1/2009 @ 2:58 AM
@Nikhil
I'll try to set up the error using the latest version this afternoon.

Another possibility for ScriptSharp would be to open up the 'back end' of the compiler, ie the AST and script generation aspects, so they can be built up manually. This way someone can implement their own parser (or use one of the existing ones on Codeplex). It might make it easier to keep in sync with C# features.

Even if a source code release is still a way off, I think many people (myself included) who have made investments are looking for any way to contribute.

Ernesto

Posted on 12/2/2009 @ 6:53 AM
I agree with with Robert about opening the project. I'm trying using it, but there are some limitations that are stopping me immediatly. For example, why the keyword "extern" is admitted only for alternate signature methods? It can be usefull also for importing the signature of a function defined in another javascript file.

Nikhil Kothari

Posted on 12/3/2009 @ 7:52 PM
@Ernesto
Write a class with an [Imported] attribute on it, and you can import APIs defined in a javascript file. In fact, look at the script# readme, and you'll see examples of importing existing script APIs or native APIs.

Erik Källén

Posted on 12/5/2009 @ 5:19 AM
Great to hear that this project is back on track! It's the best thing that has happened to web development with MS technologies since the release of Asp.NET 2.0! I'm currently using Script# to build a 30kloc (and growing) project and the amount of time it saves is tremendous. There are a few issues that I'd like to report, though (no showstoppers, not even close, but some are a bit annoying).

How do you want defect reports? I'd also be more than willing to help fix them.

Software development india

Posted on 12/6/2009 @ 11:14 PM
Awesome man going to try it out practically soon.

Nikhil Kothari

Posted on 12/7/2009 @ 2:35 AM
@Erik
If they're quick little things, feel free to post here or if you think they better off as a discussion, for now just use my contact form until something more structured shows up. If they're more Q&A oriented, you post using the scriptsharp tag on stack overflow.

Erik Källén

Posted on 12/7/2009 @ 4:18 AM
As I'm finding problem phrasing my issues as questions suitable for SO, I give you my thoughts here instead:
Bugs:
* Array.extract() does not support extracting an empty slice by passing 0 as the count.
* A few issues with partial classes:
- If the different partial definitions implement different interfaces, there is a risk that Script# will just die silently.
- The non-debug script doesn't work with partial classes. The issue is that all private variables are replaced with $1 etc, and it seems that each partial definition has the counter reset so different variables will get the same name.
* When different overloads of a method has different return types, the compiler might die when chaining calls (causes quite an annoyance with jQuery, already noted by Robert Byrne).
* IMO, a character literal (e.g. '\n') should be translated to an integer and not to a string in JavaScript. This has bitten me a few times, and I have not encountered a case where the current behaviour works.
* Function.prototype.invoke should return the result of the invokation.

Things I'd love to see:
* I'd love to have a -dont-mess-with-my-case switch that prevents the automatic conversion of methods and variables to camel-case.
* More supported methods on [Record] types (unvaluable for JSON): Instance methods (which would, of course, be translated into static methods with an explicit this parameter), is/as (using duck typing). Btw, I think it is a bug that if you define methods on a Record type, you will not receive an error, but the method will just silently be ignored.
* Support for C#'s var keyword (not that important, but I guess it would be quite easy to implement).
* Interface inheritance.
* [AlternateSignature] on constructors.
* The ability to use fully namespaced type names everywhere. This would really help in code generation scenarios.
* (of course generics, but you already know that, and I guess it's complicated).

Metadata:
* DOMAttributeCollection is missing the item method (index by integer)
* I don't know whether this is a good idea to include, but in JS you can compare strings for less-than, greater-than and such. These operators are not in the metadata.
* TableCellElement is missing the CellIndex property.
* I think that it would be a good idea to be able to index a System.Dictionary by an integer key. I do this all the time: x = dict[(string)(object)intKey].
* This mehtod is incredibly handy when working with jQuery, so I think it should go into sscorlib:
public static Delegate Wrap(Delegate d) {
return (Delegate)Script.Literal("function(){{var x=[this];for(var i=0;i<arguments.length;i++)x.push(arguments[i]);{0}.apply({0},x);}}", d);
}
It allows you to create a wrapping delegate whose this parameter is passed as the first argument to another delegate.

That's it for now. Feels bad to complain, but these are pretty much the only issues I have encountered after working with the product for half a year. And for everyone who reads this: Even with these defects, Script# is the best thing that has happened to web development since Asp.NET 2.0

Sergey

Posted on 12/8/2009 @ 1:55 PM
Hey, just starting out with S#. Where can I find a tutorial on building a Win7 Gadget with this?

Daniel Pamich

Posted on 12/8/2009 @ 6:17 PM
Hi, Thanks heaps for the update. Glad to hear the project is alive and well!! :-) Been looking at using it for a number of projects and was wondering about the projects status. Can't wait for some of the beyond 6.0 features.

Jerry

Posted on 12/15/2009 @ 10:05 PM
This allows adding jQuery support in your Script# project before 0.6.0.0 comming out.

http://www.springsys.com/blog/

Kirill Bondar

Posted on 12/25/2009 @ 7:49 AM
@Eric:
* [PreserveCase] attribute should prevent compiler from messing with the name's case.

* Dictionary (JS Object) stores values under string keys. If you pass an object as the key it will be converted to string via .toString() call. So, I think, Dictionary class design is close to reality - and, instead of using type case you can use dict[intKey.ToString()].

@Nikhil
* Dictionary constructor complains if the key does not comply with identifier syntax - but it does not have to. You can simply enclose the key in quotes in this case.

* Array instance methods are the root of evil: they got enumerated in JavaScript for..in statement and this can introduce the problems when using third-party frameworks. I guess, that's the reason MicrosoftAjax.js defines all of Array extensions as a class methods. Moreover, most of Array's utility functions use only indexer and length property and can be used with DOM collections of different sort.

S# compiler could translate some instance methods to static methods with "this" as a first parameter - as it is done for Object.GetType(), or even better, let it be controlled via an attribute - but I guess extension methods are not applicable for this case.

* We were playing with the replacement of the S# core library and it turns out that imported types have limited support generics: while generic classes and interfaces are not supported, generics delegates and methods are:

delegate void Action<T>(T x);

class Array
{
public static void ForEach<T>(T[] array, Action<T> predicate) { }
...
}

The following definition is successfully imported and you can use ForEach() unless you try to specify generic parameter; in most cases compiler can infer it from usage.

As most of DOM node manipulation methods return the same object passed as an argument, they could be defined in the same manner, to save extra typecasts:

T AppendChild<T>(T node)

if only you can specify "where T: HtmlNode" constraint. But as soon as you do it, the S# compiler starts to complain about unsupported feature. Is far as I understand it's more like sanity check - any chance to have it fixed?

Anyway, thanks for the excellent product :)

Bruce

Posted on 1/3/2010 @ 12:04 AM
The forum at stackoverflow do not allow me to create a new tag scriptsharp, so I am posting here.
It seems that retrieving environment variable values is not yet supported. Using System.Gadgets.EnvironmentService.GetEnvironmentVariable to produce "System.Environment.getEnvironmentVariable(..)" in JS gives a compilation error
"Check that your C# source compiles and that you are not using an unsupported feature."

Also I see that the implementation just returns null. If not supported, can I somehow embed this JS in the code?

Cheers
Bruce

Bruce

Posted on 1/3/2010 @ 1:59 PM
I was playing around with my problem and it compiled when I changed from my code 'System.Gadgets.EnvironmentService.GetEnvironmentVariable' to 'EnvironmentService.GetEnvironmentVariable' since I had added a using namespace already for Gadgets. I found this very strange. It works now though. Thanks.

Erik Källén

Posted on 1/19/2010 @ 2:43 PM
@Kirill: Yes, but it is quite cumbersome to declare every single member with a [PreserveCase]. I don't care if my generated script doesn't follow JS conventions, but I want my source C# code to do it.
Regarding the key/int storage issue of Dictionary, sure in theory you're right. However, until we get some kind of generics, I would prefer to be able to index by an integer key.

Mark Phillips

Posted on 1/21/2010 @ 4:56 PM
I know the question about future support for Generics has been answered but will there be support for Lambda Expressions in the future too? What this would convert to in JS syntax I have no idea but I'd like to be able to write some validation expressions as lambda expressions in C# and have this converted into JS.

Also, is there support for a shared assembly concept or a way of generating a sscorlib dependent assembly from a mscorlib assembly based upon some sscorlib compliance? I'm thinking I could have 2 projects, one references sscorlib and the other references mscorlib but they share the source in someway?


Thanks.

parvesh

Posted on 3/13/2010 @ 10:47 PM
i have an existing webapplication in VS2010, Can someone please give me a pointer on how to use it in an existing application?

parvesh

Posted on 3/13/2010 @ 10:53 PM
i have an existing webapplication in VS2010, Can someone please give me a pointer on how to use it in an existing application?
Post your comment and continue the discussion.