问题描述
ReasonML()和TypeScript( )?
What are the tradeoffs between ReasonML (https://reasonml.github.io/) and TypeScript (https://www.typescriptlang.org/)?
推荐答案
如今,有许多针对JavaScript的语言。
选择其中一项取决于您的需求和您感到满意。
There are lot of languages nowadays that target JavaScript.Choosing one of them depends on your needs and the idioms you're comfortable with.
JavaScript具有动态类型系统。一些开发人员更喜欢静态语言。
JavaScript has a dynamic type system. Some developers prefer a static one.
-
TypeScript或Haxe用一种静态类型的新语言解决了这一问题,该语言只能转换为JavaScript
TypeScript or Haxe solves this with a new language that is statically typed and only transpiles to JavaScript.
Flow是一个JavaScript预处理程序,它针对相同的问题,但无需学习新语言。如果您只需要类型系统,则我更喜欢这种方法。
Flow is a JavaScript preprocessor that targets the same issue but without the need to learn a new language. I prefer this approach if you only need a type system.
一些JS开发人员希望更多并且使用更多的函数式编程习惯(代数数据结构,不变性,模式匹配等)。许多编程语言都可以做到这一点(OCaml,Haskell,ReasonML,F#,Scala等)。
Some JS developers want more and use more functional programming idioms (algebraic data structures, immutability, pattern matching, ...). A lot of programming languages can do it (OCaml, Haskell, ReasonML, F#, Scala, ...).
- ReasonML是一种语法可以通过BuckleScript编译为本机或JavaScript的OCaml。使用Reason可以实现的所有功能,也可以使用OCaml来实现,除了ReasonML语法接受JSX。 ReasonML可以轻松地定位到node.js应用程序,react.js应用程序或本机应用程序。
如果您来自TypeScript,则很容易学习TypeScript。 Java或C#世界。
TypeScript is easy to learn if you come from the Java or C# world.
如果您从未使用过ML语言(OCaml或F#)进行开发,ReasonML就会更难学习
ReasonML is harder to learn if you never developed with an ML language (OCaml or F#)
我的建议:
-
如果只需要静态类型系统,则应考虑使用TypeScript
If you just need a static type system, you should consider TypeScript
如果您需要类型系统来执行react.js或react-native应用,则应考虑ReasonML,因为ReasonReact是对react.js的巨大改进
If you need a type system to do a react.js or react-native app, you should consider ReasonML because ReasonReact is a huge improvement over react.js
如果需要编译为js的功能编程语言,则应考虑ReasonML
If you need a functional programming language that compiles to js, you should consider ReasonML
这篇关于ReasonML与TypeScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!