julia 编程语言

A bird’s eye view of Julia as a Programming language, it’s capabilities and shortcomings

鸟瞰Julia作为一种编程语言,它的功能和缺点

“Julia”, which got the limelight in the recent years is considered as the Programming Language of the future. Although we have awesome languages in market such as R, Spark, C++, etc., Julia was able to create such impact.There are a bunch of reasons for it. We shall discuss few main points among them.

近年来引起人们关注的“ Julia”被认为是未来的编程语言。 尽管市场上有R,Spark,C ++ 出色的语言, Julia能够创造这样的影响力,原因有很多。 我们将在其中讨论几个要点。

About me … What can you expect from this article?

关于我……您对本文有什么期望?

I’m an Analyst at a start-up, where we use various Statistical, Machine Learning Techniques to leverage the Client performance by empowering them in decision making. From the inception of my journey in analytics domain, I am curious about learning the concepts of Statistics and Machine Learning Algorithms and implement them in platforms such as R, Python. My team extensively works on Python to build the Base ML framework. After a considerable exposure to Python, I was amazed with the ease of coding & numerous libraries available out there in Python. But when we wanted to run high scale jobs , we had to approach Spark. As part of exploring the alternatives out there, we found some solutions such as using Parallel processing, exploiting GPUs for better performance, etc., Interestingly, we got to know that this problem is called the “Two Language Problem” & there’s a language “JULIA”, designed to solve this very problem.I’ll give a detailed explanation of this “Two language Problem” in the later sections.

我是一家初创公司的分析师,在该公司中,我们使用各种统计,机器学习技术来增强客户的决策能力,从而发挥客户的绩效。 从我开始从事分析领域的旅程开始,我很好奇要学习统计和机器学习算法的概念并将其实现在R,Python等平台中。 我的团队广泛使用Python来构建Base ML框架。 在大量接触Python之后,我对Python的易编码性和众多可用库感到惊讶。 但是,当我们想进行大规模的工作时,我们不得不联系Spark。 作为探索替代方案的一部分,我们找到了一些解决方案,例如使用并行处理,利用GPU以获得更好的性能等。有趣的是,我们知道此问题称为“ 两种语言问题 ”,并且存在一种语言“ “ JULIA”,旨在解决这个问题。我将在后面的部分中详细介绍此“两种语言问题”。

I started exploring Julia out of my curiosity and found fascinating similarities between Julia & Python.When you complete this article, you’ll be knowing the virtues of Julia, it’s capabilities in multiple domains and the shortcomings of it. Most of the info in this article is available in the official website of Julia. They have released it’s new stable 1.5.1 version recently. From this blog, you can expect to get a bird’s eye view of Julia, it’s purpose, perks and shortcomings, apart from certain interesting facts that may trigger you to begin programming in Julia.

我出于好奇而开始探索Julia,并发现Julia和Python之间令人着迷的相似之处。当您完成本文时,您将了解Julia的优点,它在多个领域的功能以及它的缺点。 本文的大多数信息都可以在Julia的官方网站上找到。 他们最近发布了新的稳定的1.5.1版本。 从这个博客中,您可以期望获得Julia的鸟瞰图,目的,特权和缺点,以及某些有趣的事实,这些事实可能会触发您开始使用Julia编程。

WHAT ’s Julia?

Julia是什么?

Julia is an open source, high-level dynamic programming language. You can write and deploy codes easily using Julia. Julia started its development in 2009 and released its 1.0 version in 2012

Julia是一种开源的高级动态编程语言。 您可以使用Julia轻松编写和部署代码。 Julia于2009年开始开发,并于2012年发布了1.0版本

The Purpose:

目的:

Back in 2012, there was a conception that a programming language can be either fast or productive, but not both. This requires us to approach multiple languages due to lack of some important features in one language. For example, writing the original code in Python and later scaling it to Bigdata platforms like Spark, etc., This problem in programming world is called as the “TWO LANGUAGE PROBLEM”. Julia was designed to overcome this problem by providing a platform that can not only perform all the functions but can also scale it to Higher Dimensional data.

早在2012年,就有一种观念认为编程语言可以是快速的,也可以是生产力的,但不能兼而有之。 由于一种语言缺乏某些重要功能,这就要求我们使用多种语言。 例如,用Python编写原始代码,然后将其缩放到Spark等Bigdata平台。在编程世界中,此问题称为“两个语言问题” 。 Julia旨在通过提供一个不仅可以执行所有功能而且还可以将其缩放为高维数据的平台来克服此问题。

Julia’s Tagline summarizes the virtues of Julia in crisp way:

Julia的标语以清晰的方式总结了Julia的优点:

Looks like Python, feels like Lisp, runs like C (Fortran)

看起来像Python,感觉像Lisp,运行像C(Fortran)

It implies that an amalgamation of the best of all worlds has been achieved through Julia. Also, the creators of Julia, Jeff Bezanson, Stefan Karpinski, Viral B. Shah, Alan Edelman , being experts in MATLAB, Lisp, Python, Ruby and Perl have tried to create a solution that brings out the best features of these platforms and also addresses the shortcomings of them. They were working in areas such as Scientific Computing, Machine Learning, Data Mining, Large-Scale Linear Algebra, Distributed and Parallel Computing

这意味着通过Julia实现了世界上最好的融合。 此外,作为MATLAB,Lisp,Python,Ruby和Perl的专家的Julia, Jeff Bezanson , Stefan Karpinski , Viral B.Shah , Alan Edelman的创建者都试图创建一种解决方案,以充分发挥这些平台的最佳功能,并且解决了它们的缺点。 他们的工作领域包括科学计算,机器学习,数据挖掘,大规模线性代数,分布式和并行计算

Julia is well suited for High performance numerical analysis & Computational Science. We can discuss further about its capabilities in later sections.

Julia非常适合用于高性能数值分析和计算科学。 我们将在后面的部分中进一步讨论其功能。

Why Julia?

为什么是Julia?

When the founders were asked — Why did they create Julia, they gave an interesting reply. You can find the total reply in the blog, a sneak peek is provided below:

当创始人被问到-为什​​么创建Julia时,他们给出了一个有趣的答复。 您可以在博客中找到总答复,下面提供了一个偷看页面:

In short, because we are greedy.

简而言之,因为我们很贪婪。

We want a language that’s open source, with a liberal license. We want the speed of C with the dynamism of Ruby. We want a language that’s homoiconic, with true macros like Lisp, but with obvious, familiar mathematical notation like Matlab. We want something as usable for general programming as Python, as easy for statistics as R, as natural for string processing as Perl, as powerful for linear algebra as Matlab, as good at gluing programs together as the shell. Something that is dirt simple to learn, yet keeps the most serious hackers happy. We want it interactive and we want it compiled.

我们需要一种具有自由许可的开源语言。 我们想要C的速度和Ruby的活力。 我们需要一种同调的语言,具有像Lisp这样的真实宏,但又具有类似Matlab这样的显而易见的熟悉的数学符号。 我们想要的东西像Python一样适用于常规编程,像R一样易于统计,像Perl一样对字符串进行处理,像Matlab一样对线性代数具有强大的功能,以及像shell一样将程序粘合在一起的功能。 简单易学的东西,却让最严肃的黑客高兴。 我们希望它是交互式的,我们希望它是编译的。

This answer sums up many reasons that convey Julia is awesome.

这个答案总结了传达Julia出色的许多原因。

Julia in Multiple Domains:

Julia在多个领域

As we discussed before, Julia is well suited for High performance numerical analysis & Computational science. This section covers various domains where Julia is being used. The developers of Julia packages made it suitable to various Eco-systems. The list of domains is as follows:

如前所述,Julia非常适合用于高性能数值分析和计算科学。 本节涵盖使用Julia的各个领域。 Julia软件包的开发人员使其适用于各种生态系统。 域列表如下:

1. Data Science

1. 数据科学

Packages used in Julia: “DataFrames”

Julia中使用的软件包:“ DataFrames”

Data Analysts often rely on a handy tool that helps them perform some data munging operations like Cleaning junk values, Missing values Imputation, Outlier Treatment, Stacking, Unstacking, Aggregations, etc., These operations constitute ~70% of their work. To perform these Data wrangling operations with High dimensional Data, Julia’s “DataFrames” package is observed to be very helpful.

数据分析师通常依靠一种方便的工具来帮助他们执行一些数据整理操作,例如清除垃圾值,遗漏值插补,离群值处理,堆叠,拆栈,聚合等,这些操作约占其工作量的70%。 为了对高维数据执行这些数据整理操作,可以发现Julia的“ DataFrames”包非常有帮助。

2. Machine Learning

2. 机器学习

Packages used in Julia: “MLDataUtils”, “Flux”, “Lathe”

Julia中使用的软件包:“ MLDataUtils”,“ Flux”,“ Lathe”

There’s a very thin line between this part and the previous domain “Data Science”. While “Data Science” domain focusses on Data Wrangling & Intelligent data driven insights generation. This domain focusses on building models that predicts the outcomes which can be a potential part of Solution. If you’re familiar with Python, “sklearn” package is the tantamount of area of discussion. On the same note, Julia “MLDataUtils” package has many ML scientific models embodied as a package. Also, some non-trivial models that require operations such as Label encoding, Splitting the data into Train & test (splitobs function), Stratified Sampling, K-fold re-partition are implemented in an efficient way

在这部分和先前的领域“数据科学”之间有很细的界线。 而“数据科学”领域则侧重于数据整理和智能数据驱动的见解生成。 该领域专注于构建预测结果的模型,这些结果可能是解决方案的潜在组成部分。 如果您熟悉Python,那么“ sklearn”包就是讨论的重点。 同样,Julia“ MLDataUtils”包具有许多体现为包的ML科学模型。 而且,一些需要操作的非平凡模型,例如标签编码,将数据拆分为训练和测试(splitobs函数),分层采样,K折重分区等,都可以有效地实现

Packages like “Flux” & “Lathe” also have decent implementations of these functions.

诸如“ Flux”和“ Lathe”之类的软件包也具有这些功能的合理实现。

3. Parallel Computing

3. 并行计算

Julia has an in-built support for parallelism using the “Distributed” package. One can leverage the capacity of full resources of a given machine (considering the cores especially) using the parallelism concept. This shall help us to reach the pinnacle when we work on areas of Mathematical & Scientific computing.

Julia使用“分布式”包对并行性提供了内置支持。 使用并行性概念,可以利用给定计算机的全部资源的容量(特别是考虑内核)。 当我们在数学与科学计算领域工作时,这将帮助我们达到顶峰。

Other evolved languages like Python also can run operations in parallel. Python’s GIL(Global Interpretor Lock) allows only one thread to execute at a time even in a multi-threaded architecture.This makes multi-threading not a good choice. Due to this reason, people opt for multi-processing when multi-threading doesn’t solve their problem.You can understand this better through this article Multi-threading vs Multi-processing. However, multiprocessing module in python performs Serialization & Deserialization of Data between threads or nodes, (Intention is to minimize disk’s space or bandwidth requirements) which consumes more time. On the other hand, Julia does this in a more refined way. Further, Julia’s parallelization syntax is less top-heavy than Python’s, lowering the threshold to its use.

其他进化的语言(例如Python)也可以并行运行操作。 Python的GIL(全局解释器锁)即使在多线程体系结构中一次也只能执行一个线程,这使得多线程不是一个好的选择。 因此,当多线程无法解决他们的问题时,人们会选择多处理。您可以通过本文多线程与多处理更好地理解这一点。 但是,python中的多处理模块在线程或节点之间执行数据的序列化和反序列化(目的是使磁盘的空间或带宽需求最小化),这会占用更多时间。 另一方面,Julia以更精致的方式做到了这一点。 此外,Julia的并行化语法不如Python繁重,从而降低了使用它的门槛。

The Julia compiler can also generate native code for various hardware accelerators, such as GPUs and Xeon Phis. Packages such as “DistributedArrays.jl” and “Dagger.jl” provide higher levels of abstraction for parallelism.

Julia编译器还可以为各种硬件加速器(例如GPU和Xeon Phis)生成本地代码。 诸如“ DistributedArrays.jl”和“ Dagger.jl”之类的软件包为并行提供了更高级别的抽象。

Application:

应用:

The Celeste.jl project achieved 1.5 PetaFLOP/s on the Cori supercomputer at NERSC using 650,000 cores.

Celeste.jl项目在NERSC的Cori超级计算机上使用650,000个内核,达到1.5 PetaFLOP / s。

This was a project of Cataloguing the visible universe, which had to optimise parameters of188M stars and galaxies, loading and processing 178 TB across 8192 nodes. To achieve this, Celeste exploits parallelism at multiple levels (cluster, node, and thread) which in turn made the process complete in 14.6 minutes.

这是对可见宇宙进行分类的项目,该项目必须优化1.88亿颗恒星和星系的参数,在8192个节点上加载和处理178 TB。 为了实现这一目标,Celeste在多个级别(集群,节点和线程)利用并行性,从而使该过程在14.6分钟内完成。

4. Scientific Computing

4. 科学计算

Julia comprises of Simulation specific packages in domains such as Differential Equations (DifferentialEquations.jl), Optimization (JuMP.jl, Optim.jl), a general-purpose quantum simulation framework (Yao.jl), and many more.

Julia包括领域中特定于仿真的软件包,例如微分方程(DifferentialEquations.jl),优化(JuMP.jl,Optim.jl),通用量子仿真框架(Yao.jl)等。

On another note, Julia has domain-specific packages like

另一方面,Julia具有特定于域的软件包,例如

BioJulia — Biology

BioJulia —生物学

JuliaOpt — Operations Research

JuliaOpt-运营研究

JuliaImages — Image Processing

JuliaImages —图像处理

QuantumBFS, QuantumOptics — Quantum Physics

QuantumBFS,QuantumOptics —量子物理

JuliaDynamics — Non-linear Dynamics

JuliaDynamics —非线性动力学

QuantEcon — Quantitative Economics

QuantEcon —定量经济学

JuliaAstro — Astronomy

JuliaAstro —天文学

EcoJulia — Ecology

EcoJulia —生态

Where is Julia used Currently?

Julia目前在哪里使用?

Apart from the Application of “Celeste.jl”, which was mentioned in “Parallelism” section , many tech giants have realised the capability of Julia. This article covers various applications of Julia and the impact Julia can create in start-ups especially working on Machine Learning problems. I recommend you could have a look at it.

除了在“并行性”部分提到的“ Celeste.jl”应用程序之外,许多科技巨头还意识到了Julia的能力。 本文介绍了Julia的各种应用程序,以及Julia在初创公司(特别是致力于机器学习问题)中可以产生的影响。 我建议您可以看一下。

“Amazon, Apple, Disney, Facebook, Ford, Google, Grindr, IBM, Microsoft, NASA, Oracle and Uber are other Julia users, partners and organizations hiring Julia programmers” -Shah, CEO of Julia Computing.

“亚马逊,苹果,迪斯尼,Facebook,福特,谷歌,Grindr,IBM,微软,NASA,Oracle和优步是雇用Julia程序员的其他Julia用户,合作伙伴和组织。”-Julia Computing首席执行官Shah。

Advantages of Julia over other Programming Languages:

与其他编程语言相比,Julia的优势

As we have discussed that Julia founders have included the best features of many languages, Julia obviously has many advantages.

正如我们所讨论的,Julia的创建者包括了许多语言的最佳功能,Julia显然具有许多优势。

In this blog, you can see that most of my comparisons are with Python. Now some of the readers may feel that it’s unfair to compare Julia, which is in such early stage compared to Python, that has evolved over course fo last few decades. I fully support this view. Python which was there in the market from 90’s and has evolved a lot, especially in Data Science and ML Domain. But, it’s very important to acknowledge the areas that has scope for improvement.Only then, the developers and the users community can evolve to bring out a better version of the language.So, let’s see the areas that Julia can outperform Python and what could be the scope for Julia to develop.

在此博客中,您可以看到我的大多数比较都是与Python进行的。 现在,有些读者可能会觉得,将茱莉亚(Julia)与Python相提并论是不公平的。茱莉亚与Python相比还处于早期阶段,而Python已经发展了几十年。 我完全支持这种观点。 从90年代开始出现在市场上的Python,并且已经发展了很多,尤其是在数据科学和ML域中。 但是,承认有待改进的地方非常重要,只有这样,开发人员和用户社区才能不断发展,以开发出更好的语言版本,因此,让我们看看Julia可以超越Python的领域以及在哪些方面是Julia发展的范围。

  1. Speed!!!

    速度!!!

In its default state, Julia is faster than Python & is as fast as C. Native Julia beats the native python’s speed in various orders of magnitude. The reason is the type declarations & JIT (Just In Time) compilation with help of LLVM (Low level Virtual Machine) compiler used by Julia. It means that despite being a compiler level language, its code is compiled at run-time. Also, Julia involves pre-compiling the code at the beginning.

在默认状态下,Julia比Python快,与C一样快。Julia在各种数量级上都击败了python的速度。 原因是在Julia所使用的LLVM(低级虚拟机)编译器的帮助下进行了类型声明和JIT(Just In Time)编译。 这意味着,尽管它是编译器级别的语言,但其代码是在运行时编译的。 此外,Julia还涉及在开始时对代码进行预编译。

You can refer this website, to benchmark the speed of various languages by considering the execution time of different operations.You can also check the Benchmanrking done by Julia themselves.

您可以参考该网站 ,通过考虑不同操作的执行时间来测试各种语言的速度。您还可以查看Julia自己完成的基准测试。

2. Easy Package Installation

2.易于安装的软件包

Installing packages in Julia is very easy. They use a modern package management system that pulls the packages from the GitHub page from the REPL interface. On the other hand, Python packages installation can be quite complicated sometimes especially due to different versions (2.x, 3.x).

在Julia中安装软件包非常容易。 他们使用了现代的软件包管理系统,该系统从REPL界面从GitHub页面提取软件包。 另一方面,Python软件包的安装有时会非常复杂,特别是由于版本不同(2.x,3.x)。

3. Multiple Dispatch

3.多次派遣

This is also known as Multiple methods. It’s the ability of the programming language to dynamically dispatch a function or a method based on run time type / attributes of its arguments. This also is a feature in Python.

这也称为多种方法。 编程语言具有根据运行时类型/自变量属性动态调度函数或方法的能力。 这也是Python中的功能。

4. Easy Code Conversion

4.轻松的代码转换

It is very easy to convert code from Python and/or C to Julia. But the other way around is not an easy path. Converting code from Python to C or C to Python is very difficult. But Julia can interface with external libraries very easily written in C and Fortran. Data can be shared easily with Python using the “PyCall” library.

将代码从Python和/或C转换为Julia很容易。 但是相反的方法并非易事。 将代码从Python转换为C或从C转换为Python非常困难。 但是Julia可以很轻松地与用C和Fortran编写的外部库进行交互。 使用“ PyCall”库可以轻松地与Python共享数据。

5. Easy to Use

5. 易于使用

Coding in Julia is very easy. It’s easy to understand and use. Especially, if you’re from Python background like me, you won’t find it much difficult to use, because Julia almost gives you a feeling that you’re coding in Python.

使用Julia编码非常容易。 很容易理解和使用。 尤其是,如果您像我一样来自Python背景,您将不会觉得很难使用它,因为Julia几乎给您一种使用Python进行编码的感觉。

6. Metaprogramming

6.元编程

Julia supports metaprogramming. Julia programs can generate other Julia programs, and even modify their own code, in a way that is reminiscent of languages like Lisp.

Julia支持元编程。 Julia程序可以生成其他Julia程序,甚至以类似于Lisp之类的语言来修改自己的代码。

7. Automatic Memory Management

7. 自动内存管理

Like Python, Julia has automatic memory management. Julia doesn’t burden the user with the details of allocating and freeing memory. The idea is that if you switch to Julia, you don’t lose one of Python’s common conveniences.

像Python一样,Julia具有自动内存管理功能。 Julia不会给用户增加分配和释放内存的负担。 这个想法是,如果您切换到Julia,就不会失去Python常见的便利之一。

Disadvantages of Julia over other Programming Languages:

与其他编程语言相比,Julia的劣势

1. Smaller Community

1. 较小的社区

Julia being a new language has its reach limited to a smaller group of people. So, the Julia community is small, making it little difficult for doubts clarification.

Julia(Julia)是一种新语言,其影响范围仅限于一小部分人。 因此,Julia社区很小,很难澄清疑问。

2. Not many Libraries

2. 图书馆不多

There aren’t many libraries in Julia compared to much evolved languages like Python. But, it shall eventually improve with time & growing community.

与Python之类的进化语言相比,Julia中的图书馆并不多。 但是,随着时间的推移和社区的成长,它最终将得到改善。

3. Arrays are 1-Indexed

3. 数组是1-索引的

Julia in contrast to general programming languages is 1-indexed, which might be difficult for programmers with background of C, Python. There were many discussions on this “0 vs 1 indexing” thread. Julia founders felt that this wasn’t a major issue and it defeats the idea of presenting the Julia code as mathematical. Also, they mentioned that implementing arbitrary indexing can slow down things.

与一般的编程语言相比,Julia是1索引的,这对于具有C,Python背景的程序员来说可能很难。 关于“ 0比1索引” 线程有很多讨论。 Julia创始人感到这不是一个主要问题,并且使将Julia代码呈现为数学形式的想法成为现实。 此外,他们提到实现任意索引会减慢速度。

To summarize a comparison of various features among the programming languages is given below:

总结一下各种编程语言之间各种功能的比较:

Feature wise comparison of Julia with other languages
Julia与其他语言的功能明智比较

Now, these comparisons might go on. But, I believe that this blog has given enough reasons for those who haven’t started programming in Julia yet. And, it’s very important to know for an Analyst “When to use a language and when not to use it” . This can be answered after one starts working on the language and create their own perspective to it.

现在,这些比较可能会继续进行。 但是,我相信这个博客为那些还没有开始使用Julia编程的人提供了足够的理由。 而且,对于分析师来说,“何时使用某种语言以及何时不使用某种语言”非常重要。 在开始使用该语言并为其创建自己的观点之后,可以对此进行回答。

Future Work:

未来的工作:

Currently, I’m working on my next blog — “Comparison of an End-to -End basic Linear Regression Implementation in Python & Julia”. The intent is to provide a guide for other Julia newbies out there like me, by drawing comparison between Julia and Python. Please share your feedback and suggest some more topics that you want me to explore.

目前,我正在下一个博客上工作-“ 使用Python和Julia进行端到端基本线性回归实现的比较 ”。 目的是通过在Julia和Python之间进行比较,为其他像我这样的Julia新手提供指南。 请分享您的反馈,并提出一些您希望我探讨的主题。

翻译自: https://medium/@nagapavannookala/intro-to-julia-as-a-programming-language-an-analyst-pov-e33740af0de9

julia 编程语言

更多推荐

julia 编程语言_Julia(Julia)编程语言入门