动态库 隐式调用和显式调用_关于键入显式,隐式和静态与动态的所有内容
动态库 隐式调用和显式调用
Although programming often gets a reputation as a very complex activity, in the simplest definition it is relatively easy to understand. All programming centers around moving data and processing data, with no exceptions. Even at the lowest level of programming, writing machine code, the objective is to move data back and forth between registries and memory addresses. I personally like to separate these programming objectives into four different categories.
尽管编程通常因其非常复杂的活动而享有盛誉,但按照最简单的定义,它相对容易理解。 所有编程均以移动数据和处理数据为中心,没有例外。 即使在最低级别的编程(编写机器代码)下,目标也是在注册表和内存地址之间来回移动数据。 我个人喜欢将这些编程目标分为四个不同的类别。
- Obtaining data 取得资料
- Using data使用数据
- Modifying data修改资料
- Sending data传送资料
Most of the time when programming, one of these four operations is being used. While loops and conditionals are the tools that allow us to manipulate and work with this data, it is types that allow us to store and create the data in the first place. While types are an easy concept to grasp, there is a lot that goes on behind the scenes of a programming language that can factor in on how types are created, handled, and used inside of a particular language. For the most part, these observations include the way the language handles errors regarding types (Type Errors,) and how types are handled within the execution of the language.
在编程的大多数时候,这四个操作之一正在使用。 循环和条件条件是允许我们处理和使用此数据的工具,而类型则是允许我们首先存储和创建数据的类型。 虽然类型是一个易于理解的概念,但是编程语言的幕后工作仍然很多,这些因素可以考虑在特定语言内部如何创建,处理和使用类型。 在大多数情况下,这些观察结果包括语言处理有关类型的错误的方式(类型错误)以及在语言执行过程中如何处理类型。
静态与动态打字 (Static Vs. Dynamic Typing)
One huge distinguishable difference that a lot of programming languages have is the way that types are processed by their compiler. It is likely that most programmers are familiar with the terms ‘ static’ and ‘ dynamic’, but what do these two terms infer about types?
许多编程语言都有一个巨大的明显区别,那就是它们的编译器处理类型的方式。 大多数程序员很可能熟悉术语“静态”和“动态”,但是这两个术语对类型有何推论?
Static typing refers to types that are created at execution. This means that before the language has even ran through its code, it has an idea of what kind of types it is going to be using and how they are going to interact with one another. Static typing has the advantage of making types immutable, which means that your data can safely reside within said types, and the work typically needs to be done to retrieve data out of said types. This can be great for code that requires this application of types. However, whenever you need types that will constantly be altered and used in different scenarios, it might be wise to look towards dynamically typed languages for a solution.
静态类型是指在执行时创建的类型。 这意味着在该语言甚至没有遍历其代码之前,它就已经知道了它将要使用哪种类型以及它们将如何彼此交互。 静态类型化具有使类型不可变的优势,这意味着您的数据可以安全地驻留在所述类型内,并且通常需要完成工作才能从所述类型中检索数据。 这对于需要这种类型的应用程序的代码可能非常有用。 但是,每当您需要不断更改并在不同情况下使用的类型时,明智的做法是使用动态类型的语言作为解决方案。
Dynamic typing refers to compilers that deal more with the types during runtime, rather than when the program is compiled. Like static typing, this certainly has applications, but can also create problems — specifically if the programmer is not aware of how types are used within the language. It might be foolish to say that either statically typed languages or dynamically typed languages are better, but for most applications in Data Science, dynamic typing will likely be the best choice. That being said, there certainly are benefits to using a statically typed language for Data Science, as well.
动态类型化是指在运行时(而不是在编译程序时)处理更多类型的编译器。 像静态类型一样,它当然具有应用程序,但也会产生问题-特别是在程序员不了解语言中如何使用类型的情况下。 静态类型的语言或动态类型的语言会更好,但对于数据科学中的大多数应用程序来说,动态类型可能是最佳选择。 话虽如此,将静态类型的语言用于数据科学当然也有好处。
隐式vs. 明确输入 (Implicit Vs. Explicit Typing)
Another very important concept programmers should become familiar with is the idea of implicit and explicit type declarations. This is probably even more important to be aware of when working with a new language than whether or not it is static or dynamically typed. Of course, this is subjective, but I remember I had a hard time starting JavaScript early on because it would constantly assume what type I wanted to use — seemingly at random. Implicit and explicit typing, also known as strong or weak typing, is the amount of assumption that a programming language will apply to type assertion.
程序员应该熟悉的另一个非常重要的概念是隐式和显式类型声明的概念。 当使用一种新语言时,要意识到这一点甚至比它是静态还是动态类型更为重要。 当然,这是主观的,但是我记得我很难尽早启动JavaScript,因为它会不断假设我想使用哪种类型-似乎是随机的。 隐式和显式类型(也称为强类型或弱类型)是一种编程语言将应用于类型断言的假设量。
Implicit typing can get you out of a pickle, and make programming a little more smooth in many situations. The downside to this, however, is that there is a very serious downside to having a programming language that guesses what you try to do behind the scenes. It can be hard to troubleshoot errors when your response to them is
隐式键入可以使您摆脱困境,并使编程在许多情况下更加流畅。 但是,这样做的不利之处在于,使用一种编程语言来猜测您试图在后台进行的工作有一个非常严重的弊端。 当您对错误的答复是
“ It’s not even a string! Why is it a string all of the sudden?!”
”“它甚至都不是弦! 为什么突然间变成一串?!”
Explicit typing on the other hand might make it more difficult to convert types and work with them, but will yield much more predictable results. Explicit is the key word here, as type declarations aren’t assumed, and types aren’t going to magically transform without explicit instructions to do so.
另一方面,显式键入可能使转换类型和使用它们变得更加困难,但是将产生更可预测的结果。 明确是这里的关键词,因为不假定类型声明,并且没有明确的说明也不能对类型进行魔术转换。
分类某些语言 (Categorizing Some Languages)
Finally, to give an idea of what these concepts mean and where they sit with types, it might be a good idea to look at where your language fits into the bigger picture. Starting with many Data Scientist’s weapon of choice, Python is a very dynamically-typed language. This is especially valid since Python is an interpreted language that is ran by C. Despite this, Python does not assume what you want to do with your types, and is for the most part pretty strict and explicit. While this is not an exact science, I imagine that Python would land about here on a compass between these two factors:
最后,要弄清楚这些概念的含义以及它们在类型中的位置,最好考虑一下您的语言在哪里适合更大范围。 从许多数据科学家的选择武器开始,Python是一种非常动态类型的语言。 这是特别有效的,因为Python是C语言运行的一种解释语言。尽管如此,Python并不假定您要对类型进行处理,并且在大多数情况下是相当严格和明确的。 虽然这不是一门精确的科学,但我认为Python会在这两个因素之间落在指南针上:
This wouldn’t be an article written by me if I didn’t include the love of my life, Julia in the discussion. While Julia is certainly dynamically typed, it takes advantage of methods to create immutability and incompatibility between types impossible in certain situations. That being said, although within the realm of the conventional definition of static typing Julia is not, given its Just-In-Time compiler that compiles the code as it is executing, Julia also could be considered a little more static than something like Python. In terms of being implicit or explicit, Julia is very serious with types and really does not play around otherwise. This is something I have really admired about Julia, as this is something I personally prefer.
如果我在讨论中没有包括我一生的爱,Julia,那将不是我写的文章。 尽管Julia是动态类型的,但它利用方法在某些情况下无法实现类型之间的不变性和不兼容性。 话虽这么说,但是尽管在常规的静态类型定义范围内,Julia并非如此,但鉴于其Just-In-Time编译器可以在执行时编译代码,Julia还可以被认为比Python更具静态性。 在隐式或显式方面,Julia对类型非常重视,否则就不会发挥作用。 这是我对Julia(Julia)真正敬佩的东西,因为这是我个人更喜欢的东西。
While we are running through the languages of scientific computing, R is certainly a language that is notable to categorize. R is similar to Python in terms of being very dynamic, however hits a lot further down the scale on how it handles type assertion. More specifically, R can be an incredibly implicit language to work with.
当我们浏览科学计算的语言时,R当然是值得一提的语言。 R在动态方面与Python类似,但是在处理类型断言的方式上却远远落后。 更具体地说,R可以是一种难以置信的隐式语言。
Another language that many might have experience in, and most are likely familiar with is a little language called JavaScript. JavaScript is a language that I actually had a really hard time adapting to because of its implicit nature early on. Though there are certainly some examples of more implicit languages that could be pointed out, I would say that of the languages I have used it is probably one of the most.
许多人可能有经验并且最熟悉的另一种语言是一种称为JavaScript的语言。 JavaScript是一种语言,由于早期的隐式本质,我实际上很难适应。 尽管肯定有一些更隐式语言的例子可以指出,但是我要说的是我使用过的语言中可能是其中之一。
Lastly let’s look at a statically typed language one might use for Data Science. Among the most popular in this field is C++. C++ is a great object-oriented option for those who seek to work in that paradigm because of its speed, age, and reach in both scientific and other computing fields. C++ Is a statically-typed, and explicit language — as you might have expected.
最后,让我们看一下一种可能用于数据科学的静态类型语言。 在该领域最受欢迎的是C ++。 对于那些希望在该范式中工作的人来说,C ++是一种出色的面向对象的选择,因为它的速度,时代以及在科学和其他计算领域中的影响力。 正如您所期望的那样,C ++是一种静态类型的显式语言。
结论 (Conclusion)
The ideas of typing are something that is certainly vital to a programming languages character. While it can be said that some activities might be better done with one or the other, this is usually subjective, and most languages regardless of where they fall on the compass I illustrated above can usually perform the same tasks — without taking performance or level into consideration, that is.
键入的思想对于编程语言而言无疑是至关重要的。 可以说,某些活动最好与另一种活动一起完成,但这通常是主观的,并且大多数语言,无论它们落在上面的指南针上,通常都可以执行相同的任务,而无需考虑性能或水平考虑,就是。
That being said, while these factors might not necessarily limit a programming languages ability to do something, it can make a big impact on productivity if the one using the language is not aware as to the nature of their programming language. It is important to know how to use and manipulate your programming language correctly, which is even more true when your language wants to assume something, or you want to say edit types on the go. Furthermore, when choosing a programming language these factors could also apply to your choice and be a huge part in the decision making process. Maybe you want to do Data Science, and strongly dislike weakly-typed languages, knowing this difference between R and Python could be a huge factor in driving you to make a conclusion.
话虽这么说,虽然这些因素可能不一定限制编程语言执行某项功能的能力,但如果使用该语言的人不了解其编程语言的性质,则可能对生产率产生重大影响。 重要的是要知道如何正确使用和操作编程语言,当您的语言想承担某些任务或在旅途中说出编辑类型时,这一点尤其重要。 此外,在选择编程语言时,这些因素也可能适用于您的选择,并且在决策过程中起着很大的作用。 也许您想做数据科学,并且强烈不喜欢弱类型的语言,所以知道R和Python之间的这种差异可能是促使您做出结论的重要因素。
Another important thing to remember is that — specifically with explicit and implicit typing, these determinations are on a scale. While the same can be said when taking an unconventional view at static and dynamic typing, typically those are just a boolean yes or no. Thanks to generics, however, I would say that anything is possible. There are so many creative language compilers out there that some may do a little bit of both, or you might run into something like Julia which is able to harness the advantages of both whenever one might want them.
要记住的另一件重要事情是-特别是对于显式和隐式键入,这些确定是成比例的。 尽管在静态和动态类型上采用非常规视图时可以说相同,但通常这些只是布尔型的是或否。 但是,由于使用了泛型,我可以说一切皆有可能。 那里有很多创造性的语言编译器,有些可能会两者兼而有之,或者您可能会遇到类似Julia的东西,它可以在需要时利用两者的优势。
动态库 隐式调用和显式调用