8 ms·
Write your own Excel in F# (2018)
- xixixao 7y agoHow does F# on Fable compare to Elm and Purescript, and how is each doing these days?
- tpetricek 7y agoI don't have much experience with Elm or Purescript, but one nice thing about F# with Fable is that it's a pretty flexible language that let's you do things in many ways and integrates well with libraries that use different styles. For example, the Excel blog post is using virtual-dom directly (without higher level libraries like React) and getting that to work was a few lines of simple code with one mutable variable, but that's all you need to get a nice declarative Elm-style architecture.
- Risord 7y agoUnlike Elm, F# is 'functional first' but supports OO and impurity (with good and bad). Biggest clear plus is maybe full stack development support. Checkout SAFE stack (Saturn + Azure + Fable + Elmish). There is also Bolero, an alternative for Fable how to run F# in client side. Where Fable compiles F# to JS, Bolero relies on Microsoft Blazor project which has a whole .Net runtime on WebAssembly allowing to run .net binaries directly on browser. I think this is still quite experimental but if you need/want some dependencies from .net ecosystem it might be easier than you think.
- jimbob45 7y agoThe coolest part is that it's in F#. Add that to the title. How many F# samples do we get around here anymore?
- melling 7y agoF# was in the title when I upvoted. Someone changed it.
- marmaduke 7y agoThat's pretty yucky since anything written in Rust gets to keep that detail in its title
- dragonsh 7y agoRewriting code in rust is new fashion, so for the purpose of publicity anyone writing anything in Rust will put the language name in headline. But I believe this trend started with Go lang and later picked up by rust community. It's nice to see some F# code. I am happy a lot of new programming language innovations happening, I did not pick up rust, because the programming paradigm is similar to other programming language with focus on memory safety. I will try F# may be later, these days more busy with learning lisp as many people recommend it to become a better programmer even though it's not popular as Go and Rust.
- dtech 7y agoF# is in the title, but it was changed after posting on HN
- FridgeSeal 7y ago> But I believe this trend started with Go lang I thought it started with JavaScript, there was a while there where everything was getting done in JS, and that’s arguably more egregious than Rust.
- dragonsh 7y agoYou might be right, when node js was becoming popular. Personally I observed it only when I myself started programming in go, at one point in time in the early 1.0 version.
- fortran77 7y agoThe Rust people have taken over YCombinator. It's sad.
- yitchelle 7y agoTotally agree with this. We, (folks working in tech), needs to get away from click-baity titles like this, and write more factual titles.
- Nelkins 7y agoFable/Elmish is a cool combo, I'm writing really simple admin tool for work with it now and really enjoying it.
- enz 7y agoThanks for sharing. I'll try to write an equivalent code using Rust for learning purposes. Since it has algebraic datatypes too, it should be fine.
- slx26 7y agomy typical experience with these kinds of things: I start looking at the source code, and the code is actually simple and short, the logic is easy to follow (make a grid, allow and process formulas in cells, display the grid and some additional edit-mode display if you are editing a cell)... but then I start seeing dependencies, references to other frameworks and multiple languages, libraries... and all that looks so confusing! the dependencies require at least an order of magnitude more knowledge to be understood or used effectively than what we are being shown in the post; that's the really tricky part to me. don't mean to criticize that, those are probably very powerful tools that in most cases you want to know about and use (if you are working in that specific environment), but it's like... are those 100 lines of F# even that important? writing your own excel sounds nice, but I feel it's more "how to glue a bit of F# logic to a web-compatible UI" (well, yeah, one could argue those are really the same things). > "The final spreadsheet application is quite simple" Is it? I easily understand the logic of the F# code, but I couldn't make another "similar" application so easily unless I was just copying the dependencies. I wouldn't really know what I'm doing, maybe it's not so simple! (this isn't meant to be a criticism to the article itself, I just wanted to share this uneasiness I get when checking some code I don't know much about that's presented as "simple"/"short"/...)
- aardvark291 7y agoI remember feeling this in regards to some early "rapid application development" software in the 90's (Visual Basic or Borland Delphi or something). "Look how easy it is to make a text editor!" - Drag the "text editor component" over a blank form. Look how easy it is to make a web browser! - Drag the "web browser component". Or, maybe it was in PHP, "As an example, here's code to format an integer as Roman numerals." Oh, that sounds interesting... Expecting a cool algorithm, then discover it's (for some reason) a standard library function.
- empath75 7y agoWhy solve problems other people have already solved?
- 7y ago
- aardvark291 7y agoHow does F# compare to OCaml or Haskell?
- fsloth 7y agoF# started as Ocaml for .Net and then added all sorts of pragmatic language constructs. I'm not an expert - F# AFAIK misses some of the higher level type theoretic stuff, but you can write 'basic' Ocaml that would be isomorphic with F#. The key high level features that F# inherits from Ocaml is a succint syntax due to type inference and 'if it compiles it's bug free' development.
- lolinder 7y agoDoes "if it compiles it's bug free" actually work in practice? I've heard a lot of advocates for Haskell and Rust use similar lines to this, but it seems to me like it can only be true for a limited subset of all bugs. Elm's "no runtime errors in production" claim has a more reasonable-sounding scope.
- fsloth 7y agoSure, it's limited to a subset of all bugs but with a proper typesystem the category of bugs you can remove from code by just encoding the semantics and algebra into the types is quite large. So if you know how to formulate the problem so it leans heavily on the type system, you can implement something like a binary tree container, and presume it is correct when it compiles. Following the same parameters bestows rest of the codebase with this robustness. See for example the ACM article "Ocaml for the masses" by Yaron Minsky of Jane Street for very lucid practical examples https://queue.acm.org/detail.cfm?id=2038036 https://queue.acm.org/detail.cfm?id=2038036
- fsloth 7y ago... to be fair, it takes a bit getting used to a compiler that is as strict, but, when you learn how you need to implement various things, it increases your velocity since you can type stuff and not bother with too much intermediary testing because you can trust you've pretty much typed as you meant.
- jeanmichelx 7y agoFantastic example of how to structure a real life (ish) application with functional programming. I don't know any F#, but I can see how to apply this to imperative languages and make them easier to debug
- donatj 7y agoI was lead developer for a company ten years ago who developed tools for industrial companies. We had a steel rack manufacturer approach us with a panic inducing spreadsheet of the calculations they needed. It was 8 very full worksheets and included everything you could think of, including seismic data by zip code. To build this proper was going to take our small team at least a couple months. The sales people didn’t like this. I had an idea however to extend a SpreadsheetML parser I’d written a few years prior with a formula evaluator. I had a prototype working within a couple days, I reimplemented a large number of Excel functions warts and all, and since Excel saved all the last computed values along side the formulas it was easy to automatically test. It was the first project that really taught me the value of unit testing. It was a fun project and took around a month in the end, which was still over the amount of time sales had given us. The client actually sent us a fair number of revisions to the spreadsheet such that had we built it out any other way would have been a major project, but was as easy as swapping the spreadsheet the tool read. I left the company a few months later but I was sad to hear from coworkers they never did anything else with the tool. I thought it was a really neat hack.
- zwkrt 7y agoIt is always satisfying when you can knock out an entire class of problems in one go. Interestingly, this almost invariably involves writing either a parser or an interpreter
- flashgordon 7y agoDamn It. Where are these problems today? Or is it a matter of just choosing between getting paid vs passion? As a hirer in a FANG, I feel ashamed at how much we put some of the smartest and hard-working people to work on yet-another-crud-rest-api.
- samstave 7y agoSee my other answer... Cannabis tech is where these problems are.... And i have a big network and some amazing work being developed....
- deleted 7y ago
- iddan 7y agoI implemented a React component with a subset of Excel features and additional customisation features: https://github.com/iddan/react-spreadsheet https://github.com/iddan/react-spreadsheet
- ape4 7y agoValue of this cell = formula which may depend on other cells
- rishav_sharan 7y agoIf anyone is interested in gamedev in F#, try Xelmish. Its F# + the elm architecture + monogame