Language and Editor Notes
Let me know if a link is broken or if you found something interesting that should be added to this list!
ANTLR
Smalltalk / Pharo #
- Learn Smalltalk in Y Minutes
- Smalltalk Cheatsheet
- Pharo by Example:
- PharoJS: Run Pharo applications as client side web applications!
- Pharo Books
Prolog #
Graphviz / DOT #
Haskell #
- Online
- Learn You a Haskell for Great Good!
- Lists and Tuples | Wikibooks
- Pattern Matching | Wikibooks
- Tuples and List Patterns | Wikibooks
- Haskell Operators and Other Lexical Notation (orig)
- Different Mult Function Definitions
- In this
.hs
file are four version of a function that multiplies anInt
factor by everyInt
in a list. The first three versios work with finite and infinite lists without a problem. The last version works only with finite lists, where infinite lists will recurse forever.
- In this
Various Articles and Links
Esoteric Languages
Befunge: Hello, World!
< v v"Hello, World"+64< >,v >:| > @
Software Packages to Install #
The instructions below walk you through installing on Ubuntu all the software that we will be using throughout the course. In the next section, the instructions walk you through setting up IntelliJ to use ANTLR v4.
Available via Ubuntu/Debian Package Manager
# Programming Languages sudo apt install gnat # Ada sudo apt install mono-mcs # C# (Mono) sudo apt install golang-go # Go sudo apt install ghc # Haskell sudo apt install nodejs # Javascript sudo apt install perl # Perl sudo apt install swi-prolog # Prolog (swipl) sudo apt install python3 # Python 3 (not 2!) sudo apt install ocaml # OCaml sudo apt install ruby # Ruby sudo apt install rustc # Rust sudo apt install racket # Scheme
IntelliJ
Get the latest version of the Community Edition of IntelliJ from the download page.
ANTLR
Follow the directions under IntelliJ+ANTLR Set Up section.
Pharo
Pharo comes as a standalone VM and the VM image. I found the Command Line section worked well (download).
mkdir pharo && cd pharo # create folder for Pharo wget -O- "https://get.pharo.org/64" | bash # download 64bit version ./pharo-ui # test
Language Resources
We will be using the following language implementations.
- Ada: compile your code with
gnatmake [filename]
(a wrapper for the GNU Ada translator). It produces native executables. - C#: Compile your code with
mcs
(the Mono project C# compiler) and run with themono
JIT/run-time system. - Go: Run your code from the command line with
go run [filename]
. - Haskell: Run your code under the
ghci
interpreter or compile withghc
(the Glasgow Haskell Compiler) to produce native binaries. - JavaScript: Use the
nodejs
interpreter. - Perl: Use the
perl
interpreter. - Prolog: Use the
swipl
interpreter. - Python: Use the
python3
interpreter (notpython
orpython2
). - OCaml: Run your code under the
ocaml
interpreter or compile withocamlc
to produce native binaries. - Ruby: Run your code under the
ruby
interpreter. - Rust: Compile your code with
rustc
. - Scheme: Run your code at the command line with
racket
.
You are welcome to work with other language implementations and/or platforms, but you must ensure that your final versions compile and run correctly using the implementations listed above. We will be testing using only these.
I won't be devoting lecture time to show how to use these languages. You'll need to find on-line tutorials or other resources and teach yourself. Here are some decent starting points:
- Rosetta Code is a programming chrestomathy site. The idea is to present solutions to the same task in as many different languages as possible, to demonstrate how languages are similar and different, and to aid a person with a grounding in one approach to a problem in learning another. Rosetta Code currently has 1272 tasks, 403 draft tasks, and is aware of 944 languages, though we do not (and cannot) have solutions to every task in every language.
- Ada
- http://www.adacore.com: Principal web repository for everything Ada, including documentation, compilers, and tools.
- http://www.adahome.com: An older repository, now going somewhat stale, but still with some excellent content.
- http://www.adaic.org/ada-resources/standards/ada12/: The Ada 2012 Reference Manual. (Note: this is a tough slog. You'll want to find a gentler tutorial—do a Google search.)
- C#
- http://www.ecma-international.org/publications/standards/Ecma-334.htm: The international language standard. Covers C# 2.0.
- http://www.mono-project.com/: The C# implementation we are using. Open source; supported largely by Xamarin, with a particular emphasis on high quality compilation of C# for the x86.
- https://docs.microsoft.com/en-us/dotnet/csharp/: Microsoft's main page for C# resources.
- Go
- https://golang.org/: Principal web site for Go. Includes a nifty in-the-web-page interpreter with which to experiment.
- Haskell
- http://haskell.org/: Principal web site for Haskell, with documentation, tutorials, implementations, tools, etc.
- http://www.haskell.org/hoogle: Type or name based function search through all the library documentation.
- http://learnyouahaskell.com/chapters/: An easy-to-follow online book.
- JavaScript
- https://www.w3schools.com/jsref/: JavaScript Reference.
- Perl
- https://www.perl.org/books/beginning-perl/: Beginning Perl (free)
- Prolog
- http://www.swi-prolog.org/: The Prolog implementation we're using. Includes documentation and downloads (if you want to install it on your personal machine).
- http://www.fmi.uni-sofia.bg/fmi/logic/skordev/ln/lp/logic-prog.htm: The Internet Virtual Library page for logic programming. Lots of resources on logic programming in general and Prolog in particular.
- Python
- http://www.python.org/: Principle web site for Python, with documentation, tutorials, implementations, tools, and news from the user community.
- OCaml
- http://ocaml.org/: Principle web site for OCaml, with documentation, tutorials, implementations, tools, etc.
- Ruby
- https://www.ruby-lang.org/en/: Principal web site for Ruby, with documentation, tutorials, implementations, tools, etc.
- Rust
- http://rust-lang.org/: Principal web site for Rust, with documentation, tutorials, implementations, tools, etc.
- Scheme
- http://schemers.org/: Good general site for Scheme resources.
- http://racket-lang.org/: The Scheme implementation we're using. Actually supports a significantly larger extended language. Includes documentation and downloads (if you want to install it on your personal machine).
- http://schemers.org/Documents/Standards/R5RS/: The Scheme R5 standard (the version you should use). R7 is the latest standard, but you won't be needing any of the newer features.
IntelliJ+ANTLR Set Up #
There are two options for installing the ANTLR 4 plugin into IntelliJ. The easiest option is to search the Marketplace in IntelliJ's Plugin editor. Alternatively, you can install the plugin directly.
After you have installed the plugin, you will need to add the ANTLR runtime to your project.
Finally, ANTLR will convert your grammar into a set of Java files containing the lexer and parser for your grammar (along with some additional files for listening or visiting while parsing).
These files are generated under a gen
folder, which IntelliJ will not see as source code.
You will need to mark the folder as Sources Root or move the Java files to the src
folder.
Installing ANTLR 4 Plugin Through Marketplace (Option 1)
If you are at the "Welcome to IntelliJ IDEA" screen, choose "Plugins" on the left. If you are already in a project, open the main menu (under the hamburger menu in top-left), click "Settings" under "File", then choose the "Plugins" option on the left. When in the Marketplace under Plugins, search for and install "ANTLR v4". You will need to restart IntelliJ after the plugin is installed.
Installing ANTLR 4 Plugin Directly (Option 2)
-
Download latest version of ANTLR4 plugin
- Go to ANTLR v4 grammar plugin site
- Click Get button in top-right corner
- Download the latest version
-
Install plugin into IntelliJ
- Open IntelliJ project
File
→Settings
- Choose
Plugins
on left - Click
Install plugin from disk...
- Browse to your
Downloads
folder, selectantlr-intellij-plugin-v4-*.zip
, pressOK
- Press
OK
- Press
Restart
to restart IntelliJ
Including ANTLR 4 Libraries in Project
The ANTLR runtime can be downloaded from this page, just under the ANTLR tool and Java Target. You can use any of the jar files.
Note: you need to download the version that matches the ANTLR version of the plugin. For example, around 2024.06.03, the ANTLR IntelliJ plugin version is 4.13.1, but the latest ANTLR runtime version is 4.13.1.
There are two ways to add the ANTLR4 Java Runtime to your project. One way is...
- Copy the ANTLR runtime to your project's folder
- Open IntelliJ
- Right-click on the ANTLR runtime
- Choose Add as Library
- Press
OK
The second way is...
- Open IntelliJ project
File
→Project Settings
- Choose
Libraries
on left - Click
+
, chooseJava
- Browse to and select the
antlr-runtime-4*.jar
file (not v3, if exists) either- under the path
~/.IdeaIC*/config/plugins/antlr-intellij-plugin-v4/lib/
(need to click the eye icon at top to show hidden files and folder), or - under the downloads folder where do downloaded the ANTLR runtime
- under the path
- Press
OK
+
Including ANTLR-Generated Source in Project
After generating ANTLR Recognizer source code by right-clicking on .g4
file and choosing Generate ANTLR Recognizer
, ...
- ANTLR Plugin will create
.java
files, placing them undergen
folder - Right click on the
gen
folder, - Select
Mark directory as
- Select
Sources Root