We started work on WebSharper 4 more than a year ago, open-sourced it in May and published first beta packages in August. It is a project with a big scope and still some features are planned before we would call it stable. This article is an introduction and also a status report.
What is WebSharper 4?
- Write client and server code in a single language, or now with a mix of C# and F#. Communication between the client and server is transparent and type-safe.
- Metaprogramming: compile-time type information is used to generate output. Generating or transforming output code with custom logic is also possible with just a type definition and an attribute.
What is currently available?
WebSharper 4 beta packages are available under the codename
Zafir on NuGet.
Go to try.websharper.com to explore, write, test and share code snippets and mini-applications easily in both C# and F#.
New documentation is under work, hosted on GitHub and browsable at websharper.com/docs. First full tutorial for C# newcomers presents a small CRUD application.
- Many new .NET framework features are usable client-side, including delegates, Tasks (usable for remote calls too), Linq methods.
- Code dependency exploration for smaller output for single-page applications, with optional source mapping.
Track new releases on GitHub.
F#-specific new features
- Not relying on ReflectedDefinition produces smaller .dll files and have improved compilation running time.
- All F# language features are now supported, including object expressions,
&operator, inner generic functions, pattern matching on arrays, statically resolved type parameters.
letvalues now work as in .NET, not all initialized in arbitrary order on page load, only on first access of a value from a single file.
- Better error reporting, translation failures are reported at the exact location of the expression.
For upgrading your WebSharper 3 projects, check out the update guide.
There are a couple major features planned for the final release sometime in 2017, and also general quality improvements like API cleanup, more documentation and tutorials.
- C# 7 and F# 4.1 support. These include better interoperability between the two languages (newly added implicit conversions) which would simplify using from C# even those libraries in the WebSharper ecosystem or older projects which were not updated by hand to have C#-friendly overloads.
- Support for .NET Core by the WebSharper server runtime and libraries.
- TypeScript interoperability, including a code generator to generate C# or F# code from
.d.tsoutput for WebSharper projects.
- Generated code optimizations for performance. For example transforming curried and tupled F# function arguments into multi-argument functions. The proxies for standard .NET classes are implemented in F# in WebSharper, so less function object creation by them would benefit C# WebSharper projects too.
- Compiler and server runtime performance. For example better metadata format that allows partial deserialization which would reduce compiler running time and server startup time.
- More .NET coverage, including client-side support for collection interfaces like
IDictionaryand better translation of type checks and conversions of value types.