什么是Angular.js主场迎战榆树的优势和劣势? [英] What are the advantages and disadvantages of Angular.js vs. Elm?

查看:96
本文介绍了什么是Angular.js主场迎战榆树的优势和劣势?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待在浏览器中做一些反应式编程和比较angular.js( http://angularjs.org/ )与榆树( http://elm-lang.org/ )。

I'm looking into doing some reactive programming in the browser and comparing angular.js (http://angularjs.org/) with Elm (http://elm-lang.org/).

什么是相对利益/每个问题?

What are the relative benefits / problems with each?

推荐答案

我认为他们是不同的东西,海事组织,虽然他们共同具有的声明尽可能的目标,以及嘿,让我们做事情的态度他们的方式,我们应该做他们的。

I think they are different beasts, IMO, although they do share the goal of being as declarative as possible, and an attitude of "hey, let's do things They Way We Should Be Doing Them".

现在,是 AngularJS 你仍然在熟悉的领土。意思是,你写的一些标记在这里,写一些JS那里,然后为它服务。相同的工作流程和往常一样。该AngularJS的创新,据我所知道的是,它的扩展的HTML额外的元素类型,这样就可以的声明的很多方面和行为的应用右标记,然后将其JS LIB包含了必要的机器给你模板化,路由,数据绑定,表单验证,本地化等(...写这使我怀疑可能是AngularJS从有点臃肿而蒙受。),这是个非常完整的Web应用开发框架。它推动你写你的code以声明的风格。

Now, with AngularJS you're still in "familiar" territory. Meaning, you write some markup over here, write some JS over there, and then you serve it. Same workflow as usual. The "innovation" of AngularJS, as far as I can tell, is that it extends HTML with additional element types so that you can declare a lot of aspects and behavior of your app right in the markup, and then its JS lib contains the necessary machinery to give you templating, routing, data binding, form validation, localization, etc. (...writing this makes me wonder if perhaps AngularJS suffers from a bit of bloat.), which makes for a very complete web app dev framework. And it pushes you to write your code in a declarative style.

榆树你真正进入新的(如果你有一个典型的HTML / JS前端开发背景)的领土。这是一个不同的方式做(思)GUI开发。专门为功能性反应的编程方式创建图形用户界面做 - - 你会在一个完全新的语言写的,最好你永远不会处理(至少不是直接)与任何传统的DOM API的。榆树配有那种让你的工具来创建,并通过操纵时间的图形/文本/等标准库的。

With Elm you're really getting into new (if you have a "typical" HTML/JS frontend dev background) territory. It's a different way to do (and think of) GUI development. You will write in a completely new language – made specifically for creating GUIs in a functional reactive programming way – and ideally you'll never deal (at least not directly) with any of the traditional DOM APIs. Elm comes with a sort of "standard library" that gives you tools to create and manipulate graphics/text/etc through time.

您榆树语言code来形容,在一个完全声明的方式,你希望你的图形用户界面的外观和行为像随着时间的推移和事件(用户输入等)会发生什么。然后,它会编译所有的HTML / JS / CSS在浏览器中运行秩序。

Your Elm language code will describe, in a totally declarative way, what you want your GUI to look and behave like as time goes by and events (user input, etc) occur. Then, it will compile it all to HTML/JS/CSS in order that runs on the browser.

榆树很年轻,太。这取决于你和你的需要来决定是否这是一个缺点或没有。

Elm is very young, too. It's up to you and your needs to decide whether that's a disadvantage or not.

我猜我选择AngularJS是一样的老嘿,让我们试试这个JS的lib /框架的事情我们在JS世界用于-Process。你抢的lib文件,将它们添加到您的项目,并开始使用其API。而用榆树,你要开始不同的接近你的工作流程和解决问题的方法。

I guess to me choosing AngularJS is just the same old "hey let's try this JS lib/framework thing"-process we're used to in the JS world. You grab the lib files, add them to your project, and start using its API. Whereas with Elm, you have to start approaching your workflow and solutions to problems differently.

AngularJS给你很多的结构,它是从,比如说,Backbone.js的不同,但在这一天结束时,如果你想要做一些先进的图形用户界面和图形的行为,与AngularJS你回来写作一吨的管道样板东西,你不会有,如果你正在使用榆树来写。

AngularJS gives you a lot of structure, and it's different from, say, Backbone.js, but at the end of the day, if you want to do some advanced GUIs and graphic behaviors, with AngularJS you're back to writing a ton of plumbing boilerplate stuff that you wouldn't have to write if you were using Elm.

在另一方面,如果你要开发和发布大型Web应用程序的现在,与我们一直在使用网络上迄今通常的GUI窗口小部件,我会倾向于说去AngularJS,因为它更稳定。

On the other hand, if you have to develop and release a large web app right now, with the usual GUI widgets we've been using on the web so far, I'd be inclined to say go for AngularJS because it's more stable.

说了这么多,我觉得榆树是最有趣和最有前途的事情,此刻在前端开发世界上发生。而且,如果我不得不开发并发布今天一些图形,沉重的东西,我的将会的去榆树,因为人们可以在code非常几行用它做非常复杂的图形用户界面的东西。但我不得不进入它的第一个心态,并处理的事实,这是非常年轻的,并与现有的JS前端codeBase的整合可能并不容易,甚至可能大气压。

Having said that, I think Elm is the most interesting and promising things happening in the frontend dev world at the moment. And, if I had to develop and release some graphics-heavy stuff today, I would go for Elm, since one can do very complex GUI stuff with it in very few lines of code. But I'd have to get into its mindset first, and deal with the fact that it's very young and integrating it with an existing JS frontend codebase might not be easy or even possible atm.

编辑:

自2015年3月,榆树是很多更健壮,而且也为它(时间旅行调试想到的)伟大的工具。

As of March 2015, Elm is a lot more robust, and there's great tooling for it (time-traveling debugger comes to mind).

角仍然存在,那么,更多的相同。我要指出,角的做法,与一吨的上的东西,发生的 - 每当-A-模型变化的方法(双向数据绑定),使得它完全不适合的东西,如基于浏览器的游戏,而榆树擅长的游戏和需要执行以及高级GUI的东西。此外,榆树现在有一个快速(使用虚拟DOM diff'ing方法)HTML库,当你需要在HTML说话。

Angular remains being, well, more of the same. I should note that Angular's approach, with its a-ton-on-things-happen-whenever-a-model-changes approach ("2-way data binding") makes it totally unsuitable for things such as browser-based games, whereas Elm excels at games and advanced GUI stuff that needs to perform well. Additionally, Elm now has a fast (using the virtual dom diff'ing approach) HTML library, for when you need to speak in HTML.

我的骨榆树挑的是,它的类型系统并不如前pressive作为例如Haskell的。有些人可能会认为这是要求奢华,但与此相反,它是关于失去能力前preSS的基本功能。尤其是美国,经验丰富的程序员JS从没有-EX pressive-足够的静态类型系统受到影响,因为这意味着多态性$ C​​ $ C,我们已经习惯了在JS轻易前preSS,成为一个类型错误在榆树,由于缺乏如的秩-2类型。

My bone to pick with Elm is that its type system isn't as expressive as e.g. Haskell's. Some may think that this is asking for luxury, but on the contrary, it's about losing the ability to express basic functions. Especially us, seasoned JS programmers, suffer from not-expressive-enough static type systems, because it means that polymorphic code that we're used to easily express in JS, becomes a type error in Elm, due to lack of e.g. rank-2 types.

幸运的是,所有的愿望清单的功能,缺少在榆树,是不是有因的正在进行的讨论的有关他们和他们的替代品。所以这是一个安全的赌注,他们(或最佳替代品),最终将使它的语言。

Fortunately, all the "wishlist" features that are missing in Elm, are not there because of ongoing discussion about them and their alternatives. So it's a safe bet that they (or the best alternatives) will eventually make it to the language.

这篇关于什么是Angular.js主场迎战榆树的优势和劣势?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆