TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Selecting a platform: JavaScript vs Elm vs PureScript vs GHCjs

68 点作者 g4k超过 8 年前

14 条评论

floatboth超过 8 年前
BuckleScript (OCaml) <a href="https:&#x2F;&#x2F;github.com&#x2F;bloomberg&#x2F;bucklescript" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;bloomberg&#x2F;bucklescript</a> is the only one that produces reasonable output that doesn&#x27;t require large runtime libraries all the time.<p>Koka <a href="https:&#x2F;&#x2F;github.com&#x2F;koka-lang&#x2F;koka" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;koka-lang&#x2F;koka</a> is a very interesting research language that focuses on explicitly specifying effects in types. It even deconstructs Haskell&#x27;s notion of purity into &quot;throws exceptions&quot; + &quot;may never terminate&quot;. Unfortunately, the code generation (which BTW exists for both JS and C#) is uh… not very good.<p>But honestly, I haven&#x27;t felt the need to use a functional language in frontend development. JavaScript (ES6) is good enough, and it&#x27;s actually supported in browsers, so you can develop without any compiling, and only use Babel to make production builds. If the project is not small, use TypeScript to add some type safety.
评论 #13431025 未加载
评论 #13430144 未加载
hongbo_zhang超过 8 年前
It is very cool to see different type safe Alt-JS compared, I made a gist here which includes Elm, PureScript, BuckleScript and ClojureScript, add your favorite one here: <a href="https:&#x2F;&#x2F;gist.github.com&#x2F;bobzhang&#x2F;9f27a5a0bd730e8d3503bf5d058a58a7" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;bobzhang&#x2F;9f27a5a0bd730e8d3503bf5d058...</a>
评论 #13429911 未加载
leshow超过 8 年前
&quot;TEA is not composable, but through brute force. ... you are stuck building and maintaining some giant types, and writing a ton of boilerplate. The ways around this problem are fairly weak, and amount to, “don’t write components” ...&quot;<p>This has basically been my experience with Elm. But don&#x27;t say that Elm is boilerplate heavy to any elm-acolytes, they will stick their fingers in their ears and go &quot;nananananana&quot;
评论 #13430433 未加载
评论 #13429431 未加载
boubiyeah超过 8 年前
Happy user of typescript here. imo, pure FP is just like pure OO: it&#x27;s just not very good. Why constraint ourselves? The world is not pure, our programs don&#x27;t become ANY better because of the IO monad (Task in Elm); Let&#x27;s stop wankering or at least, just do it for the math and the research value but let&#x27;s not kid ourselves it&#x27;s very useful.
评论 #13429796 未加载
评论 #13429437 未加载
评论 #13433162 未加载
评论 #13429541 未加载
评论 #13429573 未加载
评论 #13430054 未加载
wmfiv超过 8 年前
In addition to the options identified in the article definitely take a look at ScalaJS and ClojureScript. I&#x27;ve used ScalaJS quite a bit and it&#x27;s a more or less flawless experience.
评论 #13429274 未加载
chrislloyd超过 8 年前
I&#x27;d be very curious to hear about the OPs specific experience with Flow. I&#x27;ve found the opposite to be true of Flow vs Typescript with the added benefit that Flow is easy to integrate into an existing codebase.
评论 #13430077 未加载
评论 #13430096 未加载
boothead超过 8 年前
Purescript does have very workable solution for client and server sharing code:<p><a href="https:&#x2F;&#x2F;hackage.haskell.org&#x2F;package&#x2F;servant-purescript" rel="nofollow">https:&#x2F;&#x2F;hackage.haskell.org&#x2F;package&#x2F;servant-purescript</a><p>I&#x27;m using this with Halogen and it works great
tomphoolery超过 8 年前
&gt; Here are some reasons to not choose JavaScript: It’s JavaScript.<p>Was this really necessary? I stopped reading your post after I saw this because I got bored and no longer take you seriously.
评论 #13431867 未加载
评论 #13433243 未加载
sk1pper超过 8 年前
&gt; I’m not even going to consider a system valid without managing IO in some way. So yes, all flavors of Lisp are off the table as well.<p>We&#x27;re talking functional in the context of JavaScript, I think ClojureScript deserves more of an explanation on why it doesn&#x27;t even qualify. That is, if you&#x27;re trying to hold to the &quot;neutral as possible&quot; thing in the beginning.
评论 #13433186 未加载
评论 #13433194 未加载
评论 #13431580 未加载
paulddraper超过 8 年前
When did every blog start having 22pt body and 62pt headers?<p>Those are the font sizes I used as a 4th grader trying to write a four page essay with 500 words.
评论 #13430010 未加载
nilkn超过 8 年前
I&#x27;ve recently used Elm for a real-world internal tool and was looking over the PureScript documentation today to see whether it&#x27;d be worth looking at PureScript in the future. I was disillusioned with the boilerplate of writing JSON decoders and encoders in Elm.<p>I quickly stumbled across this:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;slamdata&#x2F;purescript-halogen&#x2F;blob&#x2F;master&#x2F;GUIDE.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;slamdata&#x2F;purescript-halogen&#x2F;blob&#x2F;master&#x2F;G...</a><p>This is pretty much the Elm Architecture, except fully understanding every detail there requires the reader to be conversant with some pretty hairy concepts, including free monads and the Free functor. That&#x27;s not just something that&#x27;s under the hood. It&#x27;s built right into the user-facing API, and the user even has to tend to this free construction when writing `eval` functions by manually writing lines like `pure next` or `pure (continue value)`, which occur in the first example.<p>It seriously concerns me that the user will have to write lines that they couldn&#x27;t truly understand without understanding free monads, because frankly nobody new to Haskell and PureScript is going to be comfortable with free monads until they&#x27;ve spent some serious time with the language.<p>I happen to be very well-versed in Haskell so this stuff is not an issue for me -- in fact the use of Free here is not only clever but kind of beautiful -- but I wouldn&#x27;t really want to onboard someone onto a PureScript project who&#x27;d never used Haskell or PureScript before and didn&#x27;t even know what a functor was. &quot;Why do I have to write this `pure (continue value)` line? What does that mean?&quot; -- &quot;Oh boy... grab a seat and clear your schedule.&quot;<p>Some boilerplate for JSON decoding looks pretty tame in comparison, to be honest.
评论 #13468200 未加载
ruethewhirled超过 8 年前
Can anyone explain what is meant by &quot;managing IO&quot; in the statement &quot;I’m not even going to consider a system valid without managing IO in some way. So yes, all flavors of Lisp are off the table as well.&quot;? Is that like monads?
评论 #13432547 未加载
Vinnl超过 8 年前
Excellent overview. I wonder if the author also had a reason for skipping tslint, other than perhaps not knowing about it?<p>Edit: Also, why do fewer and fewer sites have an RSS feed? :(
评论 #13431710 未加载
banashark超过 8 年前
I&#x27;d like to put forth Fable as a recommendation.<p>It was briefly mentioned in another comment, but was written off for it&#x27;s lack of momentum, community, and libraries.<p>I&#x27;ll respond to these important concerns one by one:<p>Momentum: The fable project began last year. There are still active discussions about tweaks getting it to v1.0, but already there is enough there to make complete applications. There isn&#x27;t hackernews&#x2F;reddit hype, but the gitter is busy and there are some using it in production already.<p>Community: I assume that the concern with the community is that it isn&#x27;t large. F# has never had as large of a community in any of its incarnations compared to mainstream OO-first languages, but the community has always been there to help me out and I&#x27;ve never gone more than a day or two waiting on an answer to a library&#x2F;language question (most fable related questions are answered very quickly on gitter). The latter fact alone makes it more impressive to me than some other communities. Community is also important because of the amount and variety of libraries that are created for a language. I&#x27;d argue that this isn&#x27;t as important for transpiled languages as it is for separate compiled languages, where for example a ruby library can&#x27;t be used in python, but I can use any javascript library in fable.<p>Libraries: Library usage is interesting when talking about transpiled languages, and mostly depends on the Dynamic and Foreign interfaces available. Because of Fable&#x27;s dynamic abilities, I can dynamically call any javascript code I need to. I use this for a couple of libraries in the React-Native application I&#x27;m building using Exponent. The other method is Foreign interfaces, which is fantastic in fable because of how the F# type system (and inference) works in the first place. There is a utility to convert from typescript definitions to fable definitions (some will need tweaking afterwards for greater type safety) which adds a ton of libraries itself. I&#x27;d argue because of that fact that Fable has more libraries than any other functional-first transpile-to-js language!<p>Here is a example repo I put up earlier with full-stack F# with live-reloading on the client and server. <a href="https:&#x2F;&#x2F;github.com&#x2F;Banashek&#x2F;Universal-FSharp-Samples" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Banashek&#x2F;Universal-FSharp-Samples</a><p>I&#x27;m using a setup like this on a current project deployed with docker-compose to digitalocean.<p>Full-stack F# has been nice to work with so far.<p>One really nice experience I had was being able to reuse viewmodels and their validators.<p>Android&#x2F;iOS -&gt; Exponent<p>Web -&gt; Fable-Elmish<p>Server -&gt; Suave<p>I had viewmodels and partial validation functions which could sit in a shared folder and be referenced by all of the projects.<p>I change it in one place, and I can update all 3 instantly. All of the rest calls depend on the types definition, so I didn&#x27;t have to do anything after adding a new property to the type and saving the document. The server reloaded, the frontend reloaded, the mobile app reloaded.<p>I&#x27;m not sure If I&#x27;ll keep it that way, as coordinating production updates is something I haven&#x27;t fully figured out yet, but for now it&#x27;s neat to explore.<p>Would I recommend someone who doesn&#x27;t know functional programming to switch their applications to fable? No. Would I recommend fable to someone familiar with functional programming looking for a better way to manage their ui? Yes.