10 ms·
WebSharper: Make web apps in F#
- gagege 12y agoThis looks super interesting. I don't think I've ever seen anything like it. At first I thought it was similar to Classic ASP or JSPs, but after looking at some the examples, it's more like a JS framework in that it generates HTML dynamically with client side code. But, the thing that really looks cool to me is the interop between client and server that you can do. You can use the exact same "type Person = {Name:string; DOB:DateTime;}" on the server and client. That's about as DRY as you can get, I think.
- LeonidasXIV 12y agoThat reminds me strongly of what the Ocsigen[1] project has been doing for years: Eliom as a web framework that generates both server and client side code via js_of_ocaml. Unfortunately, it kinda suffers from a not so shiny website, cluttered documentation and high complexity. I kinda dream of those things being solved, then it would be a really appealing option. [1] http://ocsigen.org/ http://ocsigen.org/
- gagege 12y agoThat does look very similar. Thanks for sharing. What's really different about these is that you don't need all the ceremony of designing routes and controllers for anything other than navigation. Need to add a phone number to a contact? Don't make a whole controller and route. Just write a function that updates the database and call that function from the client code. And, if you care about separation of concerns, I think you can just put the RPC calls in a separate module. But, really, it's so little code, I might not even do that.
- nickknw 12y agoIt looks similar to Elm[1] to me. Which is great as far as I'm concerned, I'm a big fan of that approach - the more exposure it gets, the better! [1] - http://elm-lang.org/ http://elm-lang.org/
- zem 12y agoopa [http://opalang.org/ http://opalang.org/] does something very similar too
- MichaelGG 12y agoIt's a F#-to-JS compiler, a UI framework, and an RPC system all built into one. Script# is similar, for C#, but I don't think it got that far? MS did start "Project Volta" IIRC but then gave up on it. There's also FunScript: http://funscript.info/ http://funscript.info/ but that seems more focused only on the JS generation part. I don't know why Micrsoft doesn't buy these guys and deliver this as a core solution. I'd guess it's because it's not on C#, and MS marketing doesn't know what to do with F#. They want to pigeonhole it as "F# is a special language for like, scientists and stuff. Don't worry, it ain't got nothing on C#." And hey, with enough time and resources, C# may catch up on some of the things. With Rosyln, I think it'd be easier to make a C# WebSharper thing.
- kevingadd 12y agoThere are already a few approaches out there for compiling C# to JS, like my JSIL (http://jsil.org/ http://jsil.org/) and Script#'s unofficial successor, Saltarelle (http://www.saltarelle-compiler.com/ http://www.saltarelle-compiler.com/). I believe there is a new Roslyn-based C#->JS compiler in the works as well. I'm not aware of anything that approaches WebSharper's level of integration, though. It's a really impressive piece of work.
- MichaelGG 12y agoAny idea why Microsoft isn't doing this as a first-class thing, instead of creating half-fixes like TypeScript?
- MichaelGG 12y agoWebSharper is really fantastic. F#'s a great language, and not having to leave it and deal with JavaScript is a great boon. So many problems simply disappear due to type checking.
- superfunc 12y agoI wanna knit that last sentence on a sweater for myself. Okay, maybe not, but I really liked it.
- theoutlander 12y agoThis is everything I wish Script# could've been!
- hderms 12y agoWow this looks awesome. Always wanted to give F# a try, now I have no excuse!
- solomatov 12y agoThe project is really great, however license is really bad. A modern framework, should be open source under liberal license. Licenses like this worked in 90s, but currently they don't work.
- FraaJad 12y agoHow do you propose they make money to pay salaries?
- solomatov 12y agoPaid support, tools, there're plenty of companies which follow this business model. Extjs, Vaadin, Typesafe, etc. I understand that they want to make a money, however, using their license is unacceptable risk, especially taking into account there're comparable alternatives. I'd rather use GWT/TypeScript/Scala.js, than proprietary framework which I won't be able to work with if they changed license to something unacceptable (for example, charge per server or whatever).
- _stephan 12y agoIf you worry about such hypothetical licence or price changes, you could also contact the company and negotiate a custom licence/contract.
- solomatov 12y agoUsually, such companies have quite high price for such contracts and I think it's not worth is. While technically it might be superior, it has small user base, smaller talent pool to hire from, less books/documentation. All this happens because people want to make money in an old fashioned way. The better option is to use, the most popular open source tool which in this area is GWT or TypeScript.
- deleted 12y ago[deleted]
- macca321 12y agoIt's well intentioned, but this project is destined to go nowhere fast. Abstracting away web development and http has been tried again and again, and always ends up being more hassle than plain ol' HTML+JS+HTTP. Then you've limited yourself to interop with the js libraries they've provided leaky wrappers over, or you can write your own leaky wrapper if you want to use coolnewthing.js you saw on github. And to cap it all, this framework requires commercial licensing for closed source projects!
- zastrowm 12y agoI don't really think requiring commercial licensing for closed source projects is really a con. Seems like a logical way to make money, yet still allow open source projects to benefit.
- MichaelGG 12y agoIt's been around for a few years. I was able to use it to quickly whip up some sorta-complicated UIs for some internal tools. I despise JS, and have spent hours of time fixing simple casing errors or other things that static typing would fix. Plus F# the language is quite superior to JS, so I don't feel icky while working on it. The other benefit is that I can use all the same type definitions, so I don't need to write some generator or wrapper around my XHR functions - it just works. It's quite easy to just drop out into pure JS if you feel the need. And defining wrappers is actually very very simple. For example: [<Direct "foo($a, $b)">] let foo (a: string) (b: int) = () Doesn't Google use a Java-based system to do essentially the same thing (GWT)? But you're right that if you are already happy with JS then there's a lot less reason to pick it up.
- n72 12y agoIs this an arms length Jetbrains thing? If not, it seems awfully odd that its name is so close to Resharper and the parent company is called IntelliFactory, which is so close to IntelliJ. I guess there's nothing wrong with that. Just odd.
- lstamour 12y agoIgnoring, of course, that (a) they've probably used or heard of ReSharper and (b), both F# and C# pronounce the hash as "sharp"? ;-) I suppose it could be confusing but it wasn't the first thing I thought of...
- kgwxd 12y agoExactly what I thought when I saw xSharper then Intellix. First thing I did was look to see if JetBrains had anything to do with it since that would have +1'd my interest. Quickly realizing they didn't -1'd it :/
- purpletoned 12y agoThey're either related to Jetbrains in some way or really lack creativity or maybe they're trying to unduly profit off the good reputation Jetbrains generally has in the community.
- hamxiaoz 12y agoDoes anybody know what's the 2 chrome extensions displayed in the screenshot?
- JosephRedfern 12y agoThe first is "Google Hangouts" (https://chrome.google.com/webstore/detail/hangouts/nckgahadagoaajjgafhacjanaoiihapd?hl=en https://chrome.google.com/webstore/detail/hangouts/nckgahada...), the second is "Awesome Screenshot" (https://chrome.google.com/webstore/detail/awesome-screenshot-captur/alelhddbbhepgpmgidjdcjakblofbmce?hl=en https://chrome.google.com/webstore/detail/awesome-screenshot...).
- iamleppert 12y agoAnother monolithic framework that will likely catch some unsuspecting CTO or director and ultimately be his demise, or someone who doesn't want to learn javascript (such people still exist, sadly).
- zoomerang 12y agoOut of curiosity, have you tried F#? It's a substantially nicer language than Javascript, and there's a lot of problem domains that are far easier solved in it. People wouldn't use it because they don't want to learn Javascript. They'd use it because they don't want to use Javascript, on account of knowing better.
- RichardFord 12y agoSadly? If COBOL was the lingua franca of the web would it be sadly?
- nbevans 12y agoNobody really "wants" to learn JS. It's a hateful little language and the sooner it gets nuked from orbit or at least abstracted away to become merely the "assembly language of the web", the better. While I don't agree WebSharper is monolithic - it's anything but that. I do agree that it is a bear trap. They could go bust at any moment and leave you with a big headache. Even as a F# dev I have deliberately avoided using it because yes I agree with some of the sentiment here that the licensing model is a bit odd, but also the thought of needing to write a Binding for basically any JS library it doesn't support out of the box is quite a burden that will never go away. And can really slow down a new project that wants to iterate fast. I firmly believe in using the best tools for the job at hand. So that means a F# back-end and a AngularJS front-end. It's a PITA maintaining two domain models in each, and similar validation logic etc, but such is life sometimes. What I lose in the domain model side, I gain back in a rich and vibrant set of available AngularJS modules and JS libraries.
- _random_ 12y agoYes, but can you believe there exist people who think using just a few legacy ill-designed languages negating the years of progress is not just OK but dare to call this approach "open" as in "open web"?
- zzen 12y agoI might be missing a point, but how is this different from tried-and-failed GWT? Apart, obviously, in language of choice.
- ianlevesque 12y agoTo be fair, F# vs. Java is more than a trivial difference.
- _random_ 12y agoYes, the approach is a dead-end but the language is awesome.
- cromwellian 12y agoBy what measure has GWT failed? It compares favorably with usage numbers to most popular JS frameworks. 130,000 monthly active developers, used on 20,000+ domains, outside of Google, it's used by many large companies, for example, Apple's iAds uses GWT, AWS console uses GWT, major financial institutions and banks are using it. It has it's niche just like every other framework. Google is now using it to share code between Web, Android, iOS, and Server (shared client side business logic). Google Sheets is the newest example of such Hybrid apps, and the gains are substantial, 60-70% code sharing between platforms, only the UI needs to be reimplemented natively. Just because something is not monopolizing a particular area of development doesn't mean it's "failed". The ecosystem is large number for many different frameworks to remain vibrant.
- Rapzid 12y agoThis looks very interesting in the same way as Clojurescript but with F# and potentially a smoother experience. Has anyone used this that can provide some insight into it? Does it work with entity framework? OWIN? What's the story with the F# to javascript compilation; did they invent that or is it another project? Who are these people? I think it's a shame that the C#/.NET ecosystem can't seem to have FOSS nice things because it really hampers stuff gaining traction. However I find the open source license for this is very clear and generous; I still can't seem to figure out if ServiceStack is safe to use :| This should allow for learning the framework and providing nice things to the community, and then the licensing seems reasonable compared to the value proposition for working on commercial software.
- tarmil 12y ago"Does it work with entity framework?" -> It works with whatever .NET db tool you want to use, it's entirely agnostic in this regard. "OWIN?" -> It can, with WebSharper.WebAPI [1]. "What's the story with the F# to javascript compilation; did they invent that or is it another project?" -> It's an in-house developed compiler. "Who are these people?" -> A Hungarian company called IntelliFactory. (full disclosure, I work at IntelliFactory.) [1] https://github.com/intellifactory/websharper.webapi https://github.com/intellifactory/websharper.webapi
- DennisP 12y agoPerhaps worth mentioning, I recently saw a presenter say his company is moving away from Entity Framework in favor of F# type providers. Agree on FOSS. It's nice this company will license to me for opensource projects, but what happens if they go out of business?
- Rapzid 12y agoI'm not sure TBH, but most of their stuff is appears to be on github as well.
- sudowhodoido 12y agoThat's interesting. I appear to have actually accidentally written a chunk of this in C# for a product a couple of years back. The approach is pretty much identical.
- zackmorgs 12y agoDo you have this hosted somewhere I could take a peek at this?
- davidgrenier 12y agoI've been using WebSharper in production for 20 months now and I wouldn't consider doing web development any other way. People have mentionned that such abstraction generally become more trouble then they are worth but I completely disagree. In particular the question would be what are the corner cases that will make the abstraction more difficult to use and ruin your overall productivity and I haven't found anything so far. What I find difficult though isn't creating wrappers around existing external javascript libraries but rather learning the quirks of each of them. For instance, I happen to maintain a WebSharper wrapper around the Kendo Web library (see here https://github.com/davidgrenier/Kendo https://github.com/davidgrenier/Kendo) with the goal of abstracting away the complexity from my code base and where I spend most of my time is trying to figure out how to properly use any new control we've yet to use in production. This process is tedious and error prone because the examples on the Kendo website aren't exhaustive, the documentation isn't specific about the semantics of the library and just the brittle nature of javascript development. I spend lots of time in the chrome debugger and their online tool figuring out how things work. The productivity gain from isolating that from my code base is significant. F# as a language is quite understated, more companies are using it than it seems (many of which in stealth mode) and so is the case for WebSharper. IntelliFactory has been selling licences to many of their closed-source clients, my employer being an example but also I'm aware that MSR uses it internally on a few projects and was told the developpers there love it. The fact that my employer continues to pay the licence, gives me work on the project and has recently hired another developer working full time with WebSharper indicates that they consider the value to be at least on par with everything else we do. Over the 3+ years I've been using WebSharper, I've had to report only a single bug Monday of last week (see here https://bitbucket.org/IntelliFactory/websharper/issue/288/systemdatetimenow-on-ie8 https://bitbucket.org/IntelliFactory/websharper/issue/288/sy...) in the WebSharper core libraries related with compatibility issue in old version of IE and the bug was fixed within the week and had access to an updated WebSharper package from nuget. WebSharper isn't just an F# to JavaScript compiler, they also offer powerful, paper-worthy abstractions to improve developer productivity: -Transparent RPC calls from client to server (combined with static typing this is one of my preferred feature). -Combinators for composing pages and managing routes in an elegant typesafe way. -The ability to create standard server-side markup and yet SPA page building is even better as you get to pick what you carry over the wire and simply create all your markup on the client. -Tools to create extensions around external javascript libraries (I've personally used WIG and works really well and I learned a few things about design while using it to boot). -If you have access to Libraries that offer TypeScript bindings (like Kendo does) IntelliFactory can generate the wrappers for you. -Tons of precreated wrapper for you to simply use -Combinators to compose data/UI controls/event flow handling like Formlets/Piglets and now UI.Next which is excellent, I've come to appreciate all three and we're using Piglets in production though UI.Next should go a long way to allow you to do anything you need. -Use existing abstractions in the standard F# development experience which would be hard to get otherwise (async workflows is an example). I don't have strong opinions one way or another on licencing but as been mentionned before IntelliFactory generates revenues and as such I'd be skeptical of someone claiming that such and such model "doesn't work". Besides most of the concerns I've seen here seems philosophical rather than about direct impediments the licencing creates on what they had to do. Indeed the licencing cost my employer has to be is insignificant compared to the benefits and I personally do not pay for a licence on my own stuff. Microsoft's position around the .NET ecosystem is sound, they provide the CLR, Base Library and a world class development environment. The rest is open to the community to drive the libraries/toolset they need, after all Microsoft can't do everything and it seems to me would tie in the community to Microsoft. You can see the latest open sourcing of the Roslyn compiler as a reflection of that. Likewise, the F# compiler service project and the direction taken by the F# Power Tools and the way Microsoft supports this initiative to enhance the VS development experience sends the same message. Speaking with Don Syme he indicated that technically there wouldn't be anything standing in the way of doing the equivalent of what IntelliFactory did with the new C# compiler, though you can be sure of two things: Microsoft won't be doing it and it's likely a tremendous amount of work. I haven't played with any other similar toolset (ClojureScript/Purescript/GWT comes to mind) and as such I will not comment on those. But I will advise against listening to advice from anyone who hasn't used any of those specific libary. Even better, sit down and spend the time required to make it familiar and then you'll be a better judge. If you are already using F#, I urge you to put 10-20 hours on it, you will thank yourself. If you aren't using F#, in my mind, WebSharper is just another wonderful reason to start doing so.
- shamney 12y agowhat are the standard tools for working with databases with f# and websharper?
- tarmil 12y agoWebSharper is completely agnostic in this regard, so the question boils down to what is available for F#. The idiomatic way to deal with databases is using one of the available type providers. Basically, a TP generates types at compile time, in a way that actually plays quite nicely with IntelliSense [1]. In the case of db TPs, they're parameterized by a connection string and connect to the db to extract the schema and generate the appropriate types. Several exist [2]; SqlDataConnection and SqlEntityConnection are built-in, FSharp.Data.SqlClient and FSharp.Data.SqlProvider are community contributed. They all use query expressions (basically, F#'s extensible version of LINQ syntax) except SqlClient which directly uses SQL in a string (but still checks the query at compile time and passes arguments cleanly, thanks to the TP) and is therefore more like a (safer) micro-ORM. [1]: http://msdn.microsoft.com/en-us/library/hh156509.aspx http://msdn.microsoft.com/en-us/library/hh156509.aspx [2]: http://fsharp.org/guides/data-access/ http://fsharp.org/guides/data-access/