框架和库有什么区别_框架和库之间有什么区别?

框架和库有什么区别

Buy a house, or cautiously build your own.

买房子,或谨慎建房。

What's the difference between a framework and library? I've had this discussion with developers at work and meetups, and the core idea boils down to this.

框架和库之间有什么区别? 我在工作中和聚会中与开发人员进行了讨论,其核心思想可以归结为这一点。

You tell libraries what to do, frameworks tell you what to do.

您告诉图书馆该做什么,框架告诉您该做什么。

框架优势 (Framework Upsides)

Generally speaking a framework tells you what to do. It has a "right way" of doing things and provides tooling to support you.

一般来说,框架会告诉您该怎么做。 它具有“正确方法”来做事,并提供了支持您的工具。

Two perfect examples are Angular and Vue.

AngularVue是两个完美的例子。

框架和库有什么区别_框架和库之间有什么区别?

所有工具都在这里 (All the tools are here)

These are frameworks created by dedicated teams, and ship with everything you need to build large-scale applications.

这些是由专门团队创建的框架,并随附了构建大型应用程序所需的一切。

  • Components

    组件
  • Basic state management

    基本状态管理
  • Directives

    指令
  • Handling forms

    处理表格
  • Routing

    路由
  • HTTP

    HTTP
  • Testing

    测试中
  • More (UI libraries, animations, etc.)

    更多(UI库,动画等)

官方风格指南 (Official style guides)

The respective teams then provide official style guides, depicting their framework's best practices. Once you learn that you're immediately productive.

然后,各个团队提供官方的样式指南,描述其框架的最佳做法。 一旦了解到您将立即提高工作效率。

框架和库有什么区别_框架和库之间有什么区别?

简化的入职 (Streamlined onboarding)

If you believe in the structure and wish to invest, a framework is perfect for your project. Training new teammates becomes easier too, as they only need to learn one core tool.

如果您相信结构并希望投资,那么框架就是您项目的理想选择。 培训新队友也变得更加容易,因为他们只需要学习一种核心工具即可。

明确的升级路径 (Clear upgrade path)

On top of that your upgrade path is super clear. Just follow the team's release schedule, read up on their breaking changes, and upgrade when you're ready.

最重要的是,升级路径非常清晰。 只需遵循团队的发布时间表,阅读他们的重大更改,然后在准备就绪时进行升级即可。

框架的缺点 (Framework Downsides)

This is just in my experience. I'm sure I've missed something.

这只是我的经验。 我确定我错过了一些东西。

性能下降(的一种) (Decreased Performance (sort of))

By necessity a framework is comprised of a lot of code. More code means longer download times and decreased performance.

框架必须包含许多代码。 更多的代码意味着更长的下载时间和降低的性能。

As frameworks become compilers, however, I suspect this will be less of an issue.

但是,随着框架成为编译器 ,我怀疑这将不再是一个问题。

小型应用程序不需要它 (Small applications don't need it)

A scalable architecture must address many concerns like we discussed above. Some applications are so simple that using an entire framework makes things more complicated. You end up with tons of boilerplate without a ton of payoff.

像我们上面讨论的那样,可伸缩体系结构必须解决许多问题。 有些应用程序是如此简单,以至于使用整个框架会使事情变得更加复杂。 您最终将获得数不清的样板,而没有一吨的收益。

违反框架可能很困难 (Going against the framework can be difficult)

This reared its head at my first job out of college, where we tried to compile some content outside of Angular's awareness. The result wasn't pretty, but we got the job done after some trial and error, and lots of bruises.

这在我大学毕业后的第一份工作中引起了人们的注意,在那儿,我们试图在Angular的意识之外编写一些内容。 结果不尽人意,但经过反复试验和大量挫伤,我们才完成了工作。

框架和库有什么区别_框架和库之间有什么区别?

Although I hear Vue lets you incrementally adopt it to your existing application. This sounds promising!

尽管我听说Vue允许您逐步将其应用于现有应用程序。 这听起来很有希望!

有很多东西要学 (It's a lot to learn)

This point applies to any architecture, though. Whatever tool(s) you use, learning all of it takes time. It's either one big tool or many small ones.

这一点适用于任何体系结构。 无论您使用什么工具,学习所有工具都需要时间。 它要么是一个大工具,要么是许多小工具。

框架和库有什么区别_框架和库之间有什么区别?

你太舒服了 (You get too comfy)

This applies to anything in life–sometimes we get too comfortable doing things in a particular way. This totally depends on your career goals though. Maybe this tool helps you keep a steady job or run an efficient business building applications. If that's what you want, keep doing it!

这适用于生活中的任何事物,有时我们会以一种特定的方式过分自在地做事。 这完全取决于您的职业目标。 也许此工具可以帮助您保持稳定的工作或运行高效的业务构建应用程序。 如果那是您想要的,那就继续做吧!

But if you're like many of us, the same tech every day gets a bit stale. Experimenting with other frameworks and libraries is key to keeping your skills sharp.

但是,如果您像我们中的许多人一样,那么每天使用相同的技术就会有些陈旧。 对其他框架和库进行试验是保持技能精湛的关键。

图书馆的好处 (Libraries Upsides)

In direction opposition to frameworks, libraries are utilities built for a singular purpose.

在与框架相反的方向上,库是为单个目的而构建的实用程序。

  • React creates UIs

    React创建UI

  • Redux provides state management

    Redux提供状态管理

  • JQuery provides cross-browser DOM manipulation

    jQuery提供跨浏览器DOM操作

The list goes on. Let's zoom in on React. What does it do?

清单继续。 让我们放大React。 它有什么作用?

框架和库有什么区别_框架和库之间有什么区别?

A JavaScript library for building user interfaces - Official React website

一个用于构建用户界面JavaScript库-React Official网站

单焦点 (Single focus)

That's all it does. Their guides show you how to use React and that's mainly it. The team doesn't officially appoint libraries for global state management, routing, HTTP, services, or forms.

这就是全部 。 他们的指南向您展示了如何使用React,主要就是它。 该团队并未正式任命用于全局状态管理,路由,HTTP,服务或表单的库。

And that's their design choice! It's a great position depending on what you're looking for.

这就是他们的设计选择! 根据您要寻找的位置,这是一个很好的位置。

你在掌控中 (You're in control)

A library is 100% in your control. You determine how it's used, and you're sailing smooth after investing some time to learn it.

一个库在您的控制之中100%。 您可以确定如何使用它,并花一些时间来学习它,然后才能顺利进行。

框架和库有什么区别_框架和库之间有什么区别?

仅添加您需要的内容 (Add only what you need)

If your application is small, a single library may be enough! No need to complicate things. As the app grows, you can mix and match libraries to build your own architecture. It's a great learning experience!

如果您的应用程序很小,那么一个库就足够了! 无需使事情复杂化。 随着应用程序的增长,您可以混合和匹配库来构建自己的体系结构。 这是一次很棒的学习经历!

学习许多不同的工具 (Learn many different tools)

And speaking of which, using many different libraries will keep your JavaScript skills nice and sharp. You'll always be reading documentation, trying out new things, and expanding your technical horizons.

谈到其中的情况,使用许多不同的库将使您JavaScript技能保持精益求精。 您将始终在阅读文档,尝试新事物并扩展您的技术视野。

It's not all perfect though...

虽然还不完美...

图书馆的缺点 (Libraries Downsides)

自定义架构可能会破坏您的应用 (Custom architecture can ruin your app)

Custom architectures are fun at first, but can be very costly down the road. I advise extreme caution if it's your first time building one.

定制架构起初很有趣,但是在将来可能会非常昂贵。 如果您是第一次建造,我建议格外小心。

A good architecture increases developer productivity and minimizes the pain of adding, modifying, and deleting code.

好的架构可以提高开发人员的生产率,并最大程度地减少添加,修改和删除代码的麻烦。

框架和库有什么区别_框架和库之间有什么区别?

A bad architecture causes fear and suffering whenever someone touches it.

糟糕的架构会在有人触摸时引起恐惧和痛苦。

框架和库有什么区别_框架和库之间有什么区别?

People choose Angular and Vue because they don't want to risk time and money building their own rules. They simply learn the framework's rules and focus on playing the game.

人们选择Angular和Vue是因为他们不想冒时间和金钱来建立自己的规则。 他们只是学习框架的规则,并专注于玩游戏。

While in the React world, any two large-scale applications will vary in their structure. It all depends on what the team thought best.

在React世界中,任何两个大型应用程序的结构都会有所不同。 这完全取决于团队的最佳想法。

瘫痪分析 (Paralysis analysis)

Sometimes too many options is a bad thing, and we're struck by the dreaded analysis paralysis. Instead of picking a library and moving forward, we spend countless hours comparing different libraries that pretty much do the same thing.

有时候,太多的选择是一件坏事,而我们却被可怕的分析瘫痪所震惊。 我们没有选择图书馆而是继续前进,而是花了无数小时来比较几乎可以完成相同工作的不同图书馆。

框架和库有什么区别_框架和库之间有什么区别?

还有很多东西要学习 (It's still a lot to learn)

Framework or not, a big application still takes time to understand. This is another reason why strong architecture's important, because it'll ease the learning curve.

不管是否有框架,大型应用程序仍然需要时间来理解。 这就是强大的体系结构之所以重要的另一个原因,因为它可以简化学习过程。

潜在的升级路径 (Potentially hectic upgrade path)

If I got paid every time two libraries in my package.json weren't compatible after an upgrade, I'd be retired. Enough said.

如果升级后每次我的package.json中的两个库不兼容都可以得到报酬,我将退休。 说够了。

框架和库有什么区别_框架和库之间有什么区别?

需要免费辅导吗? (Want Free Coaching?)

If you'd like to schedule a free call to discuss Front-End development code, interviews, career, or anything else follow me on Twitter and DM me.

如果您想安排免费电话讨论前端开发代码,面试,职业或其他事宜,请在Twitter和DM me上关注我

After that if you enjoy our first meeting, we can discuss ongoing coaching to help you reach your Front-End development goals!

之后,如果您喜欢我们的第一次会议,我们可以讨论正在进行的教练,以帮助您实现前端开发目标!

谢谢阅读 (Thanks for reading)

For more content like this, check out https://yazeedb.com!

有关更多内容,请访问https://yazeedb.com!

Until next time!

直到下一次!

翻译自: https://www.freecodecamp.org/news/frameworks-vs-libraries/

框架和库有什么区别