--eval mongo_这就是为什么您的read-eval-print-loop如此惊人的原因

--eval mongo

by IObert

由IObert

这就是为什么您的read-eval-print-loop如此惊人的原因 (This is why your read-eval-print-loop is so amazing)

One of the things that makes the tech community so special is that we are always looking for ways to work more efficiently. Everyone has their favorite set of tools which makes them run better. As a professional UI dev, the Chrome DevTools and the Node.js read-eval-print-loop (REPL) became my favorite tools early on. I noticed that they enabled me to work more efficiently and allowed me to learn new things more quickly.

使技术社区如此特别的一件事是,我们一直在寻找提高工作效率的方法。 每个人都有自己喜欢的工具集,可以使它们运行得更好。 作为一个专业的UI开发人员,Chrome DevTools和Node.js的read-eval-print-loop(REPL)早就成为我最喜欢的工具。 我注意到它们使我能够更有效地工作,并让我更快地学习新事物。

This actually made me curious to investigate why this tool is so useful. I could easily find plenty of blog posts which explained what REPLs are and how to use them, for example here or here. But this post here is dedicated to the why (as in why are REPLs such a great tool for developers).

实际上,这使我好奇地调查了为什么此工具如此有用。 我可以轻松地找到大量博客文章,这些文章解释 REPL是什么以及如何使用它们,例如herehere 。 但是这里的这篇文章专门讨论了为什么 (为什么REPL对于开发人员来说是一个很棒的工具)。

“The number one reason that schools move away from Java as a teaching language is the high bars to Hello-world programs.”
“学校放弃使用Java作为教学语言的首要原因是对Hello-world程序的严格要求。”
— Stuart Halloway
—斯图尔特·哈洛韦

什么是REPL? (What is a REPL?)

REPL stands for read-evaluate-print-loop and this is basically all there is to it.

REPL代表read-evaluate-print-loop ,基本上就是全部。

Your application runtime is in a specific state and the REPL helps you to interact with it. The REPL will read and evaluate the commands and print the result and then go back to the start to read your next input. The evaluate step might change your runtime. This process can be seen as an interview with your application to query its current state.

您的应用程序运行时处于特定状态,REPL可帮助您与其进行交互。 REPL将读取评估命令并打印结果,然后返回到开始以读取下一个输入。 评估步骤可能会更改您的运行时。 此过程可以看作是对您的应用程序的访问以查询其当前状态。

In other words, the REPL makes your runtime more tangible and allows you to test hypotheses about it.

换句话说,REPL使您的运行时更加有形,并允许您测试有关它的假设

According to Stuart Halloway, the absence of a REPL in Java is the most significant reason why schools started to move to other languages to teach programming. Some people even use the REPL to write better unit tests.

根据Stuart Halloway的说法, Java中缺少REPL是学校开始转向其他语言教授编程的最重要原因。 有些人甚至使用REPL 编写更好的单元测试

我今天是否已经使用过REPL(类似工具)? (Do I already use a REPL (-like tool) today?)

This basic explanation might have reminded you of some tools which you use every day. If you know and use one of the following tools, the answer is “yes”:

这种基本解释可能使您想起了每天使用的一些工具。 如果您知道并使用以下工具之一,则答案为“是”:

  • The dev tools of your browser (like Chrome DevTools)

    浏览器的开发工具(例如Chrome DevTools )

  • Your terminal/shell

    您的终端机/外壳
  • Jupyter Notebooks

    Jupyter笔记本
  • The REPL process in Clojure

    Clojure中的REPL流程
  • Repl.it, jsfiddle.net, or jsbin.com

    Repl.it,jsfiddle.net或jsbin.com
  • Online regex validators

    在线正则表达式验证器

为什么REPL如此有帮助? (Why is the REPL so helpful?)

This question kept me up at night because I didn’t understand what makes us inefficient in the first place. I started to research some common psychological effects and tried to link them to my daily interactions with the REPL. Here are my top three hypotheses:

这个问题使我彻夜难眠,因为我一开始不理解是什么使我们效率低下。 我开始研究一些常见的心理影响,并尝试将其与我与REPL的日常互动联系起来。 这是我的三个主要假设:

在流 (Being in the flow)

Flow is the mental state of operation in which a person performing an activity is fully immersed in a feeling of energized focus, full involvement, and enjoyment in the process of the activity. (source)

流动是一种心理状态,在这种状态下,从事一项活动的人完全沉浸在活动过程中充满活力的专注,全神贯注和享受的感觉中。 ( 来源 )

I think all of us are familiar with this state, it makes us extremely productive and time flies basically. Unfortunately, it’s fairly easy to “lose” the flow, for example when you get interrupted or when you have to wait for some period. I learned this can happen very fast: Researchers found out that one second is about the limit for the user’s flow of thought to stay uninterrupted.

我认为我们所有人都对这种状态很熟悉,它使我们非常高效并且时光飞逝 。 不幸的是,“丢失”流是相当容易的,例如,当您被打断或必须等待一段时间时。 我了解到这种情况很快就会发生: 研究人员发现 ,一秒钟的时间限制了用户保持不间断的思维流程。

The REPL doesn’t need to compile or deploy your code. This leads to a very short response time (<100ms). Thus, you are able to test your hypotheses without losing the flow.

REPL不需要编译或部署您的代码。 这导致响应时间非常短(<100ms)。 因此,您可以检验自己的假设而不会丢失流程。

积极强化 (Positive Reinforcement)

Positive reinforcement involves the addition of a reinforcing stimulus following a behavior that makes it more likely that the behavior will occur again. (source)

积极的强化包括在行为之后添加强化刺激,使行为更有可能再次发生。 ( 来源 )

This is the effect that appeals the most to me. Your brain learns to favor certain actions when they were rewarded in the past. This reward could be a bonus from your boss after an outstanding month or a simple “Great job!” from your skiing instructor.

这是最吸引我的效果。 当过去获得奖励时,您的大脑会学会偏爱某些行为。 奖励可能是您的老板在出色的一个月后获得的奖金,或者是简单的“出色工作!” 来自您的滑雪教练。

Every time your REPL experiment succeeds and you solved a puzzle/problem, your brain feels rewarded as well! This also takes place when you code in a common IDE. But the REPL responds way faster and allows you to iterate more often. So, more experiments lead to more reinforcement. This effect makes you use the REPL more often and keeps your eye on the ball (instead of distracting yourself by checking for emails).

每当您的REPL实验成功并且解决难题/问题时,您的大脑也会感到收获! 当您在通用IDE中进行编码时,也会发生这种情况。 但是REPL的响应速度更快,并允许您更频繁地进行迭代。 因此,更多的实验导致更多的强化。 这种效果使您可以更频繁地使用REPL,并保持警惕(而不是通过检查电子邮件来分散自己的注意力)。

数字失忆症 (Digital Amnesia)

The tendency to forget information that can be found readily online by using Internet search engines. (source)

倾向于忘记可以使用Internet搜索引擎在网上轻松找到的信息。 ( 来源 )

I have to admit, I often mix Java, Python and JavaScript syntax, because that information can be found all over the internet. I would ask myself “Do I need to use add(), append() or push() to add a new element to an array in JavaScript?”. Thus for me, an example of this effect is recalling method names of API and language references.

我不得不承认,我经常混合使用Java,Python和JavaScript语法,因为可以在整个Internet上找到这些信息。 我会问自己“我是否需要使用add()append()push()向JavaScript中的数组添加新元素?”。 因此,对我而言,这种效果的一个示例是调用API和语言引用的方法名称。

In the REPL, I can see the available functions immediately with autocomplete:

在REPL中,我可以通过自动完成功能立即看到可用的功能:

The great thing is, this works beyond the standard objects of programming languages. This works for all frameworks and modules, which makes the REPL more mighty than your IDE! There’s no need to compare the version numbers of modules and API references anymore:

很棒的是,这超出了编程语言的标准对象。 这适用于所有框架和模块 ,这使REPL比您的IDE更强大! 不再需要比较模块和API引用的版本号:

“Truth can only be found in one place: the code.”
“真理只能在一个地方找到:代码。”
– Robert C. Martin, Clean Code
–罗伯特·马丁(Clean Code)

I hope this article helped you to understand how your brain works and how the REPL can help you to be more productive.

我希望本文能帮助您了解大脑的工作原理以及REPL如何帮助您提高工作效率。

I’m curious to see if you agree with my hypotheses or if you know more tools to be a more efficient developer.

我很想知道您是否同意我的假设,或者是否知道更多工具可以成为更有效率的开发人员。

Update 2/13/2019:

更新2/13/2019:

I’ve also written a blog post about the usage of REPLs in Cloud Foundry Environments.

我还写了一篇关于Cloud Foundry环境中REPL用法的博客文章

Check out this video by DJ Adams if you’d like to see the REPL in action :)

如果您想观看REPL的操作,请观看DJ Adams的 这段视频 :)

翻译自: https://www.freecodecamp.org/news/this-is-why-your-read-eval-print-loop-is-so-amazing-cf0362003983/

--eval mongo

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值