官术网_书友最值得收藏!

What makes Julia special

Julia, as a programming language, has made rapid progress since its launch in 2012, which is a testimony to the soundness and quality of its design and coding. It is true that Julia is fast, but speed alone is not sufficient to guarantee a progression to a main stream language rather than a cult language.

Indeed, the last few years have witnessed the decline of Perl (largely self-inflicted) and a rapid rise in the popularity of R and Python. This we have attributed to a new breed of analysts and researchers who are moving into the fields of data science and big data and who are looking for tool kits that fulfill their requirements.

To occupy this space, Julia needs to offer some features that others find hard to achieve. Some such features are listed as follows:

Parallel processing

As a language aimed at the scientific community, it is natural that Julia should provide facilities for executing code in parallel. In running tasks on multiple processors, Julia takes a different approach to the popular message passing interface (MPI). In Julia, communication is one-sided and appears to the programmer more as a function call than the traditional message send and receive paradigm typified by pyMPI on Python and Rmpi on R.

Julia provides two in-built primitives: remote references and remote calls. A remote reference is an object that can be used from any processor to refer to an object stored on a particular processor. A remote call is a request by one processor to call a certain function or certain arguments on another, or possibly the same, processor.

Sending messages and moving data constitute most of the overhead in a parallel program, and reducing the number of messages and the amount of data sent is critical to achieving performance and scalability. We will be investigating how Julia tackles this in a subsequent chapter.

Multiple dispatch

The choice of which method to execute when a function is applied is called dispatch.

Single dispatch polymorphism is a familiar feature in object-orientated languages where a method call is dynamically executed on the basis of the actual derived type of the object on which the method has been called.

Multiple dispatch is an extension of this paradigm where dispatch occurs by using all of a function's arguments rather than just the first.

Homoiconic macros

Julia, like Lisp, represents its own code in memory by using a user-accessible data structure, thereby allowing programmers to both manipulate and generate code that the system can evaluate. This makes complex code generation and transformation far simpler than in systems without this feature.

We met an example of a macro earlier in @printf, which mimics the C-like printf statements. Its definition is in given in the base/printf.jl file.

Interlanguage cooperation

We noted that Julia is often seen as a competitor to languages such as C, Python, and R, but this is not the view of the language designers and developers.

Julia makes it simple to call C and Fortran functions, which are compiled and saved as shared libraries. This is by the use of the in-built call. This means that there is no need for the traditional "wrapper code" approach, which acts on the function inputs, transforms them into an appropriate form, loads the shared library, makes the call, and then repeats the process in reverse on the return value. Julia's JIT compilation generates the same low-level machine instructions as a native C call, so there is no additional overhead in making the function call from Julia.

Additionally, we have seen that the PyCall package makes it easy to import Python libraries, and this has been seen to be an effective method of displaying the graphics from Python's matplotlib. Further, inter-cooperation with Python is evident in the provision of the IJulia IDE and an adjunction to IPython notebooks.

There is also work on calling R libraries from Julia by using the Rif package and calling Java programs from within Julia by using the JavaCall package. These packages present the exciting prospect of opening up Julia to a wealth of existing functionalities in a straightforward and elegant fashion.

主站蜘蛛池模板: 靖江市| 通许县| 湛江市| 昆明市| 平度市| 讷河市| 南澳县| 德清县| 瓮安县| 张家港市| 彰化市| 郸城县| 融水| 长岛县| 集安市| 青铜峡市| 普宁市| 基隆市| 上虞市| 白山市| 绥化市| 海丰县| 张掖市| 东丽区| 邻水| 米脂县| 基隆市| 大英县| 津市市| 望奎县| 海晏县| 古蔺县| 龙川县| 准格尔旗| 芒康县| 那坡县| 肥城市| 冀州市| 麦盖提县| 涿鹿县| 南华县|