Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Scientific Computing with Scala
  • Table Of Contents Toc
  • Feedback & Rating feedback
Scientific Computing with Scala

Scientific Computing with Scala

By : Vytautas Jancauskas
4 (1)
close
close
Scientific Computing with Scala

Scientific Computing with Scala

4 (1)
By: Vytautas Jancauskas

Overview of this book

Scala is a statically typed, Java Virtual Machine (JVM)-based language with strong support for functional programming. There exist libraries for Scala that cover a range of common scientific computing tasks – from linear algebra and numerical algorithms to convenient and safe parallelization to powerful plotting facilities. Learning to use these to perform common scientific tasks will allow you to write programs that are both fast and easy to write and maintain. We will start by discussing the advantages of using Scala over other scientific computing platforms. You will discover Scala packages that provide the functionality you have come to expect when writing scientific software. We will explore using Scala's Breeze library for linear algebra, optimization, and signal processing. We will then proceed to the Saddle library for data analysis. If you have experience in R or with Python's popular pandas library you will learn how to translate those skills to Saddle. If you are new to data analysis, you will learn basic concepts of Saddle as well. Well will explore the numerical computing environment called ScalaLab. It comes bundled with a lot of scientific software readily available. We will use it for interactive computing, data analysis, and visualization. In the following chapters, we will explore using Scala's powerful parallel collections for safe and convenient parallel programming. Topics such as the Akka concurrency framework will be covered. Finally, you will learn about multivariate data visualization and how to produce professional-looking plots in Scala easily. After reading the book, you should have more than enough information on how to start using Scala as your scientific computing platform
Table of Contents (11 chapters)
close
close
10
Index

Using Emacs as the Scala IDE

If you haven't yet picked a Scala IDE to use, I would like to recommend the ENSIME mode for Emacs and other editors. You can find it at the following website:

https://github.com/ensime

Obviously installation instruction will be dependent on the kind of editor you are using. If using it with Emacs (a popular cross-platform editor), the installation process is described here. You can get Emacs from the Emacs website:

https://www.gnu.org/software/emacs/

There are a lot of books available on using it. It is completely open source and with ENSIME it makes probably the best open source IDE for Scala, in the author's opinion. After installing Emacs on your system, you can install ENSIME. To do this, first add the following lines to your .emacs file, which (on Linux) usually resides in your home directory. If you are not using Linux, consult the Emacs documentation for where the .emacs file is. The following code assumes a fairly recent version of Emacs. This was tested with Emacs 24:

(require 'package)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/"))
(when (< emacs-major-version 24)
  (add-to-list 'package-archives '("gnu" . "http://elpa.gnu.org/packages/")))
(package-initialize)
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)

After adding this and restarting Emacs, you need to actually install ENSIME, which is fortunately really simple. Just use the M-x package-install key combination, press Return, then enter ensime, and press Return again. Note that M in Emacs stands for the Alt key. So the combination is Alt-x. However, it is customary to write it the way we did.

Scala integrates well with the SBT tool, which we will discuss in the next section. Instructions on how to integrate the two are given in it. Here we will just list some of the things that ENSIME can do for you to enable you to write code more efficiently and mistake-free. These include code completion, type inspection, automated refactoring, and code navigation. ENSIME will also highlight parts of your code that contain compilation errors. It is usually easy to tell from the markings where you went wrong.

The code completion feature will show you possible completions for the code you are currently typing. If it is a variable name, it will try to guess how to complete it so that you can enter it quickly. Also, you can press the Tab key after entering the object name and a dot (.). This will show you a list of all methods you can use for that object.

Type inspection allows you to see what will be the result of Scala's type inference mechanism. To see what type has been inferenced, simply use the C-c C-v i key combination. This means Ctrl-c Ctrl-v i in Emacs notation.

Automated refactoring features let you conveniently rename variables, without worrying that you may have forgotten some, and do other similar stuff. This is more useful for larger projects.

Code navigation features in ENSIME let you move around in the code by finding the definitions of symbols under the cursor. You can use M-. to jump to the definition of the object under the cursor.

The complete command reference for ENSIME can be found at:

https://github.com/ensime/ensime-emacs/wiki/Emacs-Command-Reference

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Scientific Computing with Scala
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon