You are on page 1of 5

Al-Baath University, Faculty of Informatics Engineering

Department of Software Engineering, 4th Year Students


Academic Year 2017-2018, 2nd Semester

Programming Languages

Introduction

Prepared by: Eng. Abdo Darbooli


Acknowledgment
 This document, and the whole course, are based on the course “Programming
Languages” crated by University of Washington. 2013

About the course


This course is an introduction to the basic concepts of programming languages, with a
strong emphasis on functional programming. The course uses the ML as vehicle for
teaching the concepts, but the real intent is to teach enough about how any language “fits
together” to make you more effective programming in any language -- and in learning new
ones.
This course is neither particularly theoretical nor just about programming specifics -- it will
give you a framework for understanding how to use language constructs effectively and
how to design correct and elegant programs. By using different languages, you will learn
to think more deeply than in terms of the particular syntax of one language. The emphasis
on functional programming is essential for learning how to write robust, reusable,
composable, and elegant programs. Indeed, many of the most important ideas in modern
languages have their roots in functional programming. Get ready to learn a fresh and
beautiful way to look at software and how to have fun building it.
1. Many essential concepts relevant in any programming language
o And how these pieces fit together
2. Use ML(Meta Languages) languages:
o They let many of the concepts “shine”
o In many ways simpler than Java, C#, Python, …
3. Big focus on functional programming
o Not using mutation (assignment statements) (!)
o Using first-class functions (can’t explain that yet)
o But many other topics too

Objective
Learning to think about software in this “PL” way will make you a better programmer even
if/when you go back to old ways. It will also give you the mental tools and experience you
need for a lifetime of confidently picking up new languages and ideas.

Tools
 SML (Standard Meta Language) by using SML compiler: SML/NJ 110.80
 Emacs text editor: emacs 24.5
 SML mode for Emacs: sml-mode-6.8.el
Installation Instruction- Windows
 Emasc Editor
Download a zip archive of the most recent full version, currently Version 24.5,
available at http://ftp.gnu.org/gnu/emacs/windows/emacs-24.5-bin-i686-
mingw32.zip . (More information and other versions of Emacs are available at the
GNU Emacs website, http://www.gnu.org/software/emacs/.)
Unpack the downloaded zip archive file emacs-24.5-bin-i686-mingw32.zip by
right-clicking it and choosing Extract All. This should produce a folder called
emacs-24.5-bin-i686-mingw32. Move this folder wherever you want, but pick a
permanent place (i.e., do not move it again after the next step).
Once you have moved the folder to where you want, look inside to find
bin\addpm.exe (the .exe extension might not be visible in the folder window
depending on how you have Windows configured). Double click on this file to run
it one time and it should add a Gnu Emacs folder to your Start menu and do some
other setup operations. Open the Start menu and select Gnu Emacs then Emacs (or
just type emacs in the search box) to launch Emacs.
Note:

 SML/NJ
Download and run the smlnj.msi installer available at
http://www.smlnj.org/dist/working/110.80/ . This will add an item for SML of New
Jersey to your Start menu and add a command sml that you can use at the command
line.
 SML Mode for Emacs Installation
1. Visit http://elpa.gnu.org/packages/sml-mode.html .
2. Locate, and download the latest version (currently sml-mode-6.8.el) from
that page.
3. In Emacs type Alt-x then package-install-file ENTER.
4. At the prompt Package file name: give the path to the just downloaded sml-
mode-6.8.el, and type ENTER.
This will split the window, and show the *Compile-log* with some lines
about Compiling file, and perhaps a warning.
If there are no errors, sml-mode should now be installed.
5. Exit and restart Emacs.
Emacs Basic
Using Emacs feels a little different than using other editors; it can take some getting used
to, especially the keyboard shortcuts. Fortunately, Emacs has buttons and menus to help
you adjust if that is your style. The following is a short primer on Emacs terminology and
keyboard commands.Beyond the basics described here, which should be all you need, there
are countless free resources available. An introductory "tour" is at
http://www.gnu.org/software/emacs/tour/ . For more information, see the Emacs Reference
Manual at http://www.gnu.org/software/emacs/manual/html_node/emacs/index.html (also
available within Emacs from the Help Menu), the Emacs Wiki at
http://www.emacswiki.org/, or the Emacs Tutorial (within Emacs from the Help Menu).

 The cursor is a rectangular block and is referred to as the point.


 The mode line displays information about the buffer displayed in the current
window. A buffer is a logical "thing" that you are working on. When you open a
file, it will be loaded into a buffer, typically with the same name as the file.
 Every buffer is edited in a mode. The most basic mode is Fundamental, which
provides only the most basic Emacs editing features. There are modes for many
different programming languages.
 There are many "special" buffers that do not correspond to loaded files. The one
above is called *scratch*. This buffer runs in Lisp Interaction mode, which means
that you can interactively type and evaluate expressions in the Lisp programming
language. But we won't do that.
Emacs uses many key combinations involving the Control and Meta keys. Such key
combinations are denoted C-x (Control-x (lowercase)) or M-x (Meta-x). On keyboards that
don't have Meta (just about all keyboards today), Alt should work on all systems, but on
some Mac systems you might use the funny-symbol-with-four-circles or Option keys
instead. (Emacs might complain about "Super" if you get the wrong one. If you or Emacs
gets confused about what you are trying to type, use C-g to cancel your current command
and start fresh.) If none of these work, use Esc, but when trying to type M-x, for example,
you might need to type Esc then type x. (This is only if using Esc as Meta. The other Meta
"substitutes" work as usual: hold while pressing the second key.)

The most important commands in Emacs:


 C-x C-c: Quit Emacs
 C-g: Cancel the current action
 C-x C-f: Open a file (whether or not it already exists)
 C-x C-s: Save a file
 C-x C-w: Write a file (probably more familiar to you as Save as...)
Cut, copy, paste:
 Highlight text with the mouse or by hitting C-Space to set a mark and then
moving the cursor to highlight a region.
 C-w: Cut a highlighted region
 M-w: Copy a highlighted region
 C-k: Cut (kill) from the cursor to the end of the line
 C-y: Paste (yank)

You might also like