程序员思想单纯_进入程序员的思想

程序员思想单纯

If you are interested in how programmers think or in becoming a programmer yourself then this article is for you; it doesn’t matter if you’ve ever written a single line of code, buckle up because I’ll take you on a journey into and through the programmer’s mind. The hope is for you to leave this article with a better understanding of what programming is and how programmers think.

如果您对程序员的想法或自己成为程序员感兴趣,那么本文适合您; 无论您是否编写过一行代码,都不要紧,请系好安全带,因为我将带您进入并深入程序员的脑海。 希望您对本文有所了解,这是什么是编程以及程序员的想法。

Programming is the term I’ll be using, some people call it coding, and others call it software engineering; different people use different terms, and despite the minor differences in definitions they’re all pretty much the same thing. So, what is programming?

编程是我将要使用的术语,有人将其称为编码,而另一些人将其称为软件工程。 不同的人使用不同的术语,尽管定义稍有不同,但他们几乎都是同一回事。 那么,什么编程?

Programming is the abusive non-consensual act of commanding a stupid piece of hardware to do math for you so that you can relax and sip on your coffee instead; that of course is the purest of definitions for programming, but let’s try a nicer definition. Programming is the act of talking to a piece of hardware to have it do something for you. For the sake of simplicity moving forward I’ll use the word computer instead of a piece of hardware; personal computers, mobile phones, and smart fridges are examples of what I mean by computers.

编程是指命令愚蠢的硬件为您做数学,以便您可以放松和饮咖啡的一种滥用行为。 当然,这是最纯粹的编程定义,但是让我们尝试一个更好的定义。 编程是与硬件对话以使其为您做某事的行为。 为了简单起见,我将用“ 计算机 ”一词代替硬件 ; 个人计算机,移动电话和智能冰箱就是我所说的计算机的例子。

Computers, unluckily, can understand one and only one language; that language is called Machine Language, which consists of 1’s and 0’s. Fret not my friends, you won’t have to speak that language.

不幸的是,计算机只能理解一种语言。 该语言称为机器语言 ,由1和0组成。 不用担心我的朋友们,您不必讲这种语言。

What you do have is hundreds of languages to choose from instead, because unluckily again, people realized machine language is too difficult to master so they invented new languages, many new languages mostly using the English alphabet but are not English, and then introduced many translator programs (called compilers or interpreters) that will translate that language for you to machine language.

您所拥有的是数百种语言可供选择,因为不幸的是,人们再次意识到机器语言很难掌握,因此他们发明了新的语言,许多新的语言大多使用英语字母,但不是英语,然后引入了许多翻译器。程序(称为编译器解释器 ),可以将语言翻译为机器语言。

That, of course, wasn’t enough for some people, so they decided to write more translators on top of translators, creating a complex chain of translations down to machine language. Some people went so far as to create virtual machines that understand completely different languages with their own chain of translators on top that will eventually translate whatever they’re running into machine language. This of course proved to be extremely beneficial, but we’ll leave that topic for another day.

当然,对于某些人来说这还不够,因此他们决定在翻译人员的基础上再写更多的翻译人员,从而创建了复杂的翻译链,包括机器语言。 有些人甚至创建了虚拟机,这些虚拟机可以完全理解完全不同的语言,并拥有自己的翻译器链,这些翻译器最终会将他们正在运行的任何内容翻译成机器语言。 当然,这被证明是极其有益的,但是我们将把这个话题再留一天。

This pattern of constantly trying to figure out and refine things is a very important commonality between programmers; it’s also one of the most important things to keep in mind as you start your own journey as a programmer. Nothing is perfect, and the path between you and your goal is far from being straight.

这种不断尝试找出和完善事物的模式是程序员之间非常重要的共性。 当您开始自己的程序员生涯时,这也是要记住的最重要的事情之一。 没有什么是完美的,而您与目标之间的道路也并非一帆风顺。

Programmers try to solve problems all the time; it’s not perfect, and there’s no one right way to do something.

程序员一直试图解决问题。 这不是完美的,没有正确的方法来做某事。

Throughout my time as a programmer I met so many people who gave up on themselves because they didn’t think they were smart enough; this misconception is partially because of the way we test students in our education system, and how far that happens to be from real-life programming. The other side of that coin is the way our education system makes it seem like there’s only one way to solving a problem.

在成为程序员的整个过程中,我遇到了很多人放弃自己,因为他们认为自己不够聪明。 这种误解部分是由于我们在教育系统中测试学生的方式,以及与现实编程之间的距离有多远。 硬币的另一面是我们的教育系统使人们似乎只有一种解决问题的方法。

I remember when I was taking my bachelor’s degree in Computer Science in one of the exams we were given a question with most of the solution code written, and we only needed to fill in the blanks, on paper. Not only were we required to remember how to perfectly write code in a given language, but we were also expected to know how the professor was thinking when he wrote the partial solution.

我记得当我在其中一项考试中获得计算机科学学士学位时,我们遇到了一个问题,其中大部分解决方案代码都写了,而我们只需要在纸上填写空白即可。 我们不仅需要记住如何以给定的语言完美地编写代码,还希望我们知道教授编写部分解决方案时的想法。

In my own journey as a professional programmer I found that if you understand logic, then you’re good to go; it won’t be easy, but you’ll be able to do it. If you don’t have a great understanding of logic then luckily you can practice as you go. In summary, you can do it no matter how smart you think you are.

在我作为专业程序员的旅途中,我发现,如果您了解逻辑,那么您就很好了; 这并不容易,但是您将能够做到。 如果您对逻辑没有很好的理解,那么幸运的是您可以边实践边练习。 总之,无论您认为自己有多聪明,都可以做到。

To battle those thoughts, just keep in mind that we created the machines, not the other way around. Machines are not smart, they’re just efficient. We are here to take advantage of that however we see suitable.

要与这些想法作斗争,请记住我们是创建机器的,而不是相反。 机器不是智能的,它们只是高效的。 我们在这里可以利用它,但是我们认为合适。

Computers are stupid, and you’re boss.

电脑很愚蠢,你是老板。

Expecting to perfectly remember how to do everything in any programming language is absurd, and even expecting to perfectly remember how to write code to do simple things, such as creating a button that does something upon clicking on it, is not always reasonable.

期望完全记住如何用任何编程语言来完成所有事情都是荒谬的,甚至期望完全记住如何编写代码来完成简单的事情,例如创建单击按钮后会执行某些操作的方法也不总是合理的。

That might come as a surprise to a lot of aspiring programmers such as yourself; the truth is, programming languages come to life and drastically evolve very often. Luckily you have documentations to refer to whenever you feel the need to do so.

对于像你这样的许多有抱负的程序员来说,这可能是一个惊喜。 事实是,编程语言非常活跃,而且发展迅猛。 幸运的是,您有需要时可以参考的文档。

If that was true, I hear you ask, then what do you need to learn and remember? Well, you need to learn and remember the what, and not necessarily the how. You will naturally remember the how as you practice, but as you learn focus on the what, this way you can always look it up again.

如果是这样,我听到你问,那么需要学习和记住什么? 好吧,您需要学习并记住是什么 ,而不一定是如何 。 你自然会记得如何为你的做法,但你学习重点是什么 ,这样你随时可以重新查找。

For example, if clicking a button is initiating a time consuming computation that freezes your application’s user interface you have to understand that you’re dealing with a threading problem; you should know what a UI Thread is and that what you need is multi threading. Knowing how to implement those can easily be searched as long as you know what you’re looking for.

例如,如果单击一个按钮正在启动耗时的计算,从而冻结了应用程序的用户界面,则您必须了解您正在处理线程问题。 您应该知道什么是UI线程,而您需要的是多线程。 只要知道要查找的内容,就可以轻松地找到知道如何实现这些功能的信息。

As long as you remember the what, you can look up the documentation just by searching on Google. Yes, Google, and every programmer no matter how senior uses Google (or a similar search engine) to look up things all the time, and that’s fine.

只要您记住了what ,就可以通过在Google上进行搜索来查找文档。 是的,Google,以及每位程序员,无论高级程度如何都使用Google(或类似的搜索引擎)一直在查找内容,这很好。

Programmers don’t always know how to do something, but they know very well what to look for.

程序员并不总是知道如何做某事,但是他们很清楚该寻找什么。

Much of the difficulty of programming lies in translating our thoughts into code; it’s not the code that is difficult, it’s the translation.

编程的大部分困难在于将我们的思想转化为代码。 不是代码难,而是翻译。

To give you a simple example imagine yourself programming a calculator; more precisely let’s say you wanted to implement the division operator. You create three text boxes, A, B, and C, and a division button. You say C = A / B. Now you put 5 in A and 2 in B and click; lo and behold you get a 2 in C.

举一个简单的例子,想象一下自己编写一个计算器。 更确切地说,假设您要实现除法运算符。 您创建三个文本框,A,B和C,以及一个除法按钮。 你说C = A / B。 现在,将5放在A中,将2放在B中,然后单击; 瞧,您得到C的2分。

Image for post

Turns out, in that specific programming language you’re using, if you divide two integers such as 5 and 2 then the result will be an integer as well. You Google that and you quickly learn that you have to convert A and B to a Float first.

事实证明,如果使用特定的编程语言,如果将两个整数相除(例如5和2),则结果也将是一个整数。 您使用Google很快就知道必须先将A和B转换为Float。

Next you do C = A.toFloat() / B.toFloat(), you put 5 and 2 again and you get 2.5. So far so good.

接下来,执行C = A.toFloat()/ B.toFloat() ,再次输入5和2,得到2.5。 到目前为止,一切都很好。

Image for post

Now you put 5 and 0 and all of a sudden everything goes down in flames. Turns out computers are so stupid the only way they can tell you that you did something wrong dividing by 0 is by crashing your whole application. Great, now you have to manually make sure that B is not 0 before you actually do the division.

现在您将5和0放到了一起,突然之间一切都消失了。 事实证明,计算机是如此愚蠢,它们唯一可以告诉您除以0的错误处理方法是崩溃整个应用程序。 太好了,现在您必须手动确定B不为0,然后再实际进行除法。

You write, If (B != 0) Then C = A.toFloat() / B.toFloat(). You run your code, you put 5 and 0 and the application does nothing. Good start, but is that what you want? Maybe you want to show something to the user.

您写道, 如果(B!= 0)则C = A.toFloat()/ B.toFloat() 。 您运行代码,输入5和0,应用程序什么也不做。 一个好的开始,但这就是您想要的吗? 也许您想向用户展示一些东西。

Image for post

In your mind the problem was straightforward; divide A by B and put that in C, but to say that in a programming language you have to be super precise. That was a simple example; what if you want to do animations, with navigation, with interactivity? What if your code is too slow and you need to make it run faster?

在您看来,问题很简单。 用A除以B并将其放在C中 ,但是要说用编程语言,则必须非常精确。 那是一个简单的例子; 如果您想通过导航和交互来制作动画,该怎么办? 如果您的代码太慢并且需要使其运行更快怎么办?

The good thing to remember here is that trial and error is not a sin; you can do it as many times as you’d like until you feel confident in what you have created. A lot of the times other people have tried something similar to what you’re trying to do, and so again, Google and documentations are your best friends in this case.

这里要记住的一件好事是,反复试验不是罪过。 您可以随意进行多次,直到对自己创建的内容充满信心为止。 很多时候,其他人尝试了与您尝试做的事情类似的事情,因此,在这种情况下,Google和文档再次是您最好的朋友。

It’s difficult to translate human thoughts and processes into code that the computer understands.

很难将人类的思想和过程转化为计算机可以理解的代码。

So how do you translate an application from an idea in your mind into a computer program? One of the important things that programmers do when trying to solve a problem or write an application is to take the idea and chop it into smaller and simpler pieces.

那么, 如何将应用程序从您的想法转变为计算机程序呢? 程序员在尝试解决问题或编写应用程序时要做的重要事情之一就是将想法分解成更小和更简单的部分。

For example, let’s say you want to build a calculator; on which platform do you want to run it? Windows? Android? iOS? Next question is, which framework do you want to use? Do you want to do Native Android or Hybrid Web? Those options are things that you can Google after deciding on the platform.

例如,假设您要构建一个计算器; 您要在哪个平台上运行它? 视窗? Android? iOS? 下一个问题是,您要使用哪个框架 ? 您想做本机Android还是Hybrid Web? 这些选项是您在决定使用平台后可以使用Google进行的操作。

Once you have your mind made, you need to think of the smaller pieces that make up a calculator; buttons, text fields, and the actual code to do the math. How do you build a button using the framework you chose? How do you build text fields? How do you write the math code in the programming language that framework supports? How do you hook up the buttons to that math code? All those questions can translate into steps that you can take to build the entire calculator.

一旦下定决心,就需要考虑组成计算器的较小部分。 按钮,文本字段以及进行数学运算的实际代码。 如何使用所选框架构建按钮? 您如何建立文字栏位? 您如何用框架支持的编程语言编写数学代码? 您如何将按钮连接到该数学代码? 所有这些问题都可以转化为构建整个计算器所需采取的步骤。

For beginners, I recommend going from the visual to the unseen; in other words, I recommend building buttons and text fields that do nothing first, then write the math code, then hook up those parts together. As you advance in your journey and you become more confident, going the other way around would be a recommended approach.

对于初学者,我建议从视觉看不见 ; 换句话说,我建议先构建不执行任何操作的按钮和文本字段,然后编写数学代码,然后将这些部分连接在一起。 随着您前进的过程和变得更加自信,建议采用其他方法。

Programmers think of problems like a jigsaw puzzle; they are aware of the big picture but spend most of their time building the individual pieces, then they hook up those pieces together.

程序员将问题视为拼图游戏。 他们了解整体情况,但大部分时间都花在构建各个部分上,然后将这些部分连接在一起。

So you built all the pieces, you hooked them up together, and you ran the application…something goes wrong. Maybe the application crashes. Maybe it has unexpected behavior. You’re not alone; in fact, getting an application to work perfectly on the first run very rarely happens.

因此,您构建了所有部分,将它们连接在一起,然后运行了应用程序……出了点问题。 也许应用程序崩溃了。 也许它有意外的行为。 你不是一个人; 实际上,很少有应用程序能够在首次运行时完美运行。

I remember once I was asked to research making native iOS applications. Setting things up and running my first empty project was fairly simple, then I wanted to create a second page and navigate between the first and the second page. First day I couldn’t get it to work, second day I couldn’t get it to work, third day, fourth day, it took me a full week just to get a simple navigation back and forth working.

我记得曾经被要求研究制作本机iOS应用程序。 设置和运行我的第一个空项目非常简单,然后我想创建第二个页面并在第一和第二页面之间导航。 第一天,我无法正常工作,第二天,我无法正常工作,第三天,第四天,我花了整整一个星期的时间来进行简单的导航。

The moral of the story is, it is very much expected that things won’t work correctly at first, and it’s very much expected that you’ll have to deal with bugs and crashes that might take you hours, days, and sometimes months to fix. If you fail, learn and try again. Sleep on it, it helps; I can’t tell you how many times I spent a full day on a problem only to resolve it first thing next morning.

这个故事的寓意是,人们非常希望一开始会无法正常工作,并且非常希望您必须处理可能会花费您数小时,数天甚至数月的错误和崩溃。固定。 如果失败,请学习并重试。 睡在上面,有帮助; 我无法告诉您我在一整天中花了多少时间只是为了第二天早上解决这个问题。

Programmers realize that if they spend enough time on a problem, eventually it’ll be resolved.

程序员意识到,如果他们在问题上花费足够的时间,最终将得到解决。

After you finally get things working you need to test, then test again, then test some more. At some point you’ll venture into the world of unit testing and UI testing and all of that good stuff. No matter how much you test, however, it’s highly likely that you’ll get some users that have a bug or two. Maybe it’s that browser or that phone they’re using, and if you’ve set things up correctly you’ll be able to take a look at those crashes.

一切正常之后,您需要进行测试,然后再次进行测试,然后再进行其他测试。 在某个时候,您将冒险进入单元测试和UI测试以及所有这些好东西。 但是,无论您进行多少测试,您都很有可能会吸引一些拥有一两个错误的用户。 也许是他们正在使用的浏览器或手机,如果正确设置,您将可以查看这些崩溃。

No matter what it is, that kind of scenario should be expected and planned for. As a programmer surely you do need to have your applications tested before you send them out to the public, and you aim to give your users the best experience possible, but if bugs occur you fix them and move on. Programmers are not afraid of creating bugs but are eager to get them eliminated.

无论是什么情况,都应该预期并计划这种情况。 作为程序员,您肯定需要在将应用程序发布给公众之前对它们进行测试,并且力求为您的用户提供最佳体验,但是如果发生错误,请修复并继续进行。 程序员不怕创建错误,但渴望将其消除。

Programmers create and fix bugs all the time; it’s not just you.

程序员一直在创建和修复错误; 不只是你

Once you get the hang of one platform, one framework, and one programming language, a plethora of gates will open up to you; the technology might be different, but the process is pretty much the same for all other platforms, all other frameworks, and all other programming languages. If you did it once, you can do it again.

一旦掌握了一种平台,一种框架和一种编程语言,就会为您打开许多大门。 技术可能有所不同,但所有其他平台,所有其他框架和所有其他编程语言的过程几乎相同。 如果执行一次,则可以再次执行。

Programmers start their ideas with the problem they’re trying to solve, then move backwards to the technology they need to use to solve that problem; not the other way around. If you find yourself trying to figure out what you can do with a specific technology then you’re going in the wrong direction.

程序员从他们要解决的问题开始他们的想法,然后退回到解决该问题所需的技术。 并非相反。 如果您发现自己想弄清楚使用特定技术可以做什么,那您就走错了方向。

Programmers have confidence in their ability to learn and sometimes even create the technology they need to use in order to solve the problem at hand. That’s the attitude you need to have as an aspiring programmer, and it’s one hell of an attitude.

程序员对自己的学习能力有时甚至是创造出解决当前问题所需要使用的技术的能力充满信心。 这是作为有抱负的程序员需要具备的态度,这是一种态度。

Programmers can and will learn any technology they need to learn in order to solve the problem at hand.

程序员可以并且将学习他们需要解决的任何技术,以解决当前的问题。

Last but not least, programmers think of themselves as creators, writers, artists, and they enjoy being in control of their creations. They enjoy writing readable, beautiful, and efficient code that will add up to useful and stable creations, perhaps used by hundred, thousands, and even millions of people around the world.

最后但并非最不重要的一点是,程序员将自己视为创作者,作家,艺术家,他们喜欢控制自己的创作。 他们喜欢编写可读,美观,高效的代码,这些代码将加在一起,成为有用,稳定的创作,全世界可能有成百上千的人使用它。

This is the mindset of a programmer, so if you feel like that’s something you want to do, if you feel that you’d enjoy this type of life, then don’t let anything hold you back. You can do it, and all the obstacles you stumble upon are nothing but learning experiences that everyone else down that path goes through.

这是程序员的心态,因此,如果您觉得那是您想做的事情,如果您觉得自己喜欢这种类型的生活,那么就不要让任何事情阻碍您。 您可以做到,您遇到的所有障碍都不过是学习其他人所经历的经验。

Programmers are creators; they give birth to different applications and solutions, and they enjoy others using them.

程序员是创造者; 他们催生了不同的应用程序和解决方案,并且他们喜欢其他人使用它们。

I hope that you enjoyed reading this article and found it useful. Until next time, Dev Bites signing out.

我希望您喜欢阅读本文并发现它有用。 直到下次,Dev Bites才会退出。

翻译自: https://medium.com/swlh/into-the-programmers-mind-779bfd59390d

程序员思想单纯

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值