155 points · by galfarragem · 9y ago · 73 comments
Crystal and Rust are good examples of language homepages that give you an idea of what you're getting into up front. Or for a transpiled language, PureScript.
For alert(), you'll find it in Fable.Import.Browser.window.alert()
(In case you're wondering, the Fable convention is that the Fable.Import.* namespace is used for pure JS bindings with no business code, while libraries with an actual translation layer are placed in the Fable.Helpers.* namespace.)
Though one area I think it's quite nice is parsing, I like FParsec
Fable lets one use F# for both frontend and backend, and being able to share the code (models in particular, but really anything) while maintaining clear separation of tiers reduces your code base and dramatically improves quality w/o the need for elaborate tests.
Fable-elmish lets one use the same frontend code and architecture to write Native and Web apps. Again, YMMV, but at our company being able to transition an entire team between completely different types of projects avoids expertise silos and makes truly cross-functional teams possible.
We have OSSed a lot of our backend tech that helps building event-driven system in F# as well, in case anyone's interested: https://prolucid.github.io.
As Tomas said, just like Lisp in Paul Graham's "Beating the Averages" has been his secret weapon, F# is ours.
We are a small team working on it, and we try to constantly improve it.
I will provide you some links here if you can find them useful:
- File explorer using electron: https://github.com/fable-compiler/samples-electron#samples
- Pixi.js samples (quite new we are working on them): https://github.com/fable-compiler/samples-pixi/
- Elmish central website: https://fable-elmish.github.io/
- Bulma wrapper for Elmish: https://mangelmaxime.github.io/Fulma/
- A demo of Fulma + Elmish
- Live demo: https://mangelmaxime.github.io/fulma-demo/
- Source code: https://github.com/MangelMaxime/fulma-demo
And also, a really cool place is Fable awesome: https://github.com/kunjee17/awesome-fableI think Fable strikes the right balance. There are some leaky aspects of how it compiles to JS, but this means that you can quite well use it with existing JS libraries and for things like parsing JSON (you can just cast JSON object to F# records and it'll work).
So, you need to think about something about the JS part when you want to do JavaScript-y things, but you still get plenty of nice help from the F# compiler when writing the logic that the functional-first style makes so much easier.
In my experience with Fable, this pragmatic approach is what makes it great.
Isn't a "JSON object" just a string?
Their isn't actually much of an abstraction in one direction, valid ES6 is valid TS and the types are inter-operable.
Throw in better typing, proper classes, down compiling of async/await to ES3/ES5 (still magic to me) and the ability to progressively port from one to the other (and you can even get a lot of the TS benefits just by annotating your existing JS as a good first step to moving to TS) and for me it was a no-brainer.
I don't think TS is a pretty language but it's a fantastic approach to getting from shitty-A to less shitty-B.
Pragmatism wins for me as much as I'd love to just write everything client side in something else.
Coming from a C# and Python fan, TS hits the mark pretty solidly on all levels.
This is an exact example of what GP was talking about with leaky abstractions though. You don't have to just learn TS to use TS, you need to learn TS and JS.
IMO a proper, strict typed language; and plain Javascript; are both much better options than TS.
A Server-Client full-stack scaffold: https://github.com/SAFE-Stack/SAFE-BookStore
A React-Native scaffold: https://github.com/SAFE-Stack/SAFE-Nightwatch
I have tried a few tutorials but the syntax is so foreign to me that I've found it hard to grasp.
What would be awesome with a project like Fable would be to have a tutorial for existing JavaScript devs to learn F#. For example, have JavaScript and F# code side-by-side.
And try the https://fsharpforfunandprofit.com/ site too.
Why significance does that have in javascript?
let (heart) x y = x + " loves " + y
EDIT: I guess Hacker News doesn't support unicode characters. (Not a bad thing)https://np.reddit.com/r/fsharp/comments/6tdrwq/after_so_many...
If it comes to be, lets see how long F# survives without Microsoft support.
https://np.reddit.com/r/csharp/comments/75mc1m/announcing_uw...
All this FUD and hostility from the F# community (including the Fable devs) towards UWP, or anything that's of interest to most Windows and C# developers making the switch, is why F# will never be popular.
And for most people who need to have their code running on anything else than Windows, F# and .NET wouldn't be their first choice anyway, given that there are plenty of better alternatives around, like Haskell, Scala, ReasonML, OCaml etc.
F# is a wonderful thing for the ecosystem, but practically of no importance regards priorities.
IMHO: To make UWP and F# a thing, UWP need to be remodeled to a primary react like system. That however will never be a story, considering the state driven UI development MS is doing for decades.
F#, even if used as a better C#, is still a win. C# has improved a ton since F# appeared, but it's still clunky. Microsoft should have had a push, F# for everyone, but this is the company that had to be dragged into generics (by the F# people) so I don't know what we'd expect.
All F# needs is real committment to level tooling. Instead it's an afterthought. It's enough to give even me pause when starting a project.
And I can go pretty far - I have one working spouse, no major commitments, and have lived in one spot long enough I would prefer that my next role be elsewhere.
Admittedly, any other comparable (or even better?) language could lure me just as readily.
It's all true ;) Enjoy the sharp!
I don't expect to convince anyone in a HN discussion, because that's not how arguments about programming languages work, but have a look at testimonials (http://fsharp.org/testimonials). You'll see that many people who started using F#, are very happy with it because it lets them solve problems faster with fewer bugs and they enjoy it more.
Except that for the most part, that's subjected, and even more importantly, there are plenty of reasons to prefer OCaml over SML even if you don't like the syntax.