![Page 1: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/1.jpg)
1
Gentle Introduction to Programming
Tirgul 1: Shell and Scala “hands on” in
the lab
![Page 2: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/2.jpg)
2
Today• Login to your account• Your Account, basic Linux commands• Using the interpreter• Eclipse – “Hello World!”• Understanding compiler messages• Eclipse:
• Command line arguments• Debugger
• Home work – practice Shell commands
![Page 3: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/3.jpg)
3
Today• Login to your account• Your Account, basic Linux commands• Using the interpreter• Eclipse – “Hello World!”• Understanding compiler messages• Eclipse:
• Command line arguments• Debugger
• Home work – practice Shell commands
![Page 4: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/4.jpg)
4
Your Account, Basic Linux Commands
• User’s account: to log in select session: GNOME• Web browser • Open the “system handouts” file from the course’s site (in the session’s section)• Shell / Console
![Page 5: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/5.jpg)
5
Basic Linux Commands
![Page 6: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/6.jpg)
6
Security (chmod)
![Page 7: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/7.jpg)
7
Today• Login to your account• Your Account, basic Linux commands• Using the interpreter• Eclipse – “Hello World!”• Understanding compiler messages• Eclipse:
• Command line arguments• Debugger
• Home work – practice Shell commands
![Page 8: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/8.jpg)
8
Using the Interpreter• Type “scala” from the console• Start trying some basic commands:
• println(“hello world!”)• val x = 5• var y = 1.4
• Define a function that receives two integers and return their sum. Use it on several inputs.
![Page 9: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/9.jpg)
9
Today• Login to your account• Your Account, basic Linux commands• Using the interpreter• Eclipse – “Hello World!”• Understanding compiler messages• Eclipse:
• Command line arguments• Debugger
• Home work – practice Shell commands
![Page 10: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/10.jpg)
10
Eclipse• Type “eclipse35 &” from the console• Use a workspace located on your account• How to solve common technical problems:
• “Clean” your eclipse by removing the .eclipse directory (rm –R .eclipse, from your root)• Start a new workspace / remove the old one
![Page 11: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/11.jpg)
11
Open Eclipse – Set Workspace
![Page 12: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/12.jpg)
12
Open Eclipse
![Page 13: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/13.jpg)
13
Define New Project
![Page 14: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/14.jpg)
14
If you don’t find the Scala new project…
File New Project
![Page 15: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/15.jpg)
15
New Object
![Page 16: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/16.jpg)
16
Write Some Code
![Page 17: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/17.jpg)
17
Run
output
![Page 18: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/18.jpg)
18
Today• Login to your account• Your Account, basic Linux commands• Using the interpreter• Eclipse – “Hello World!”• Understanding compiler messages• Eclipse:
• Command line arguments• Debugger
• Home work – practice Shell commands
![Page 19: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/19.jpg)
19
Understanding Compiler MessagesOpen the interpreter, try the following lines of code, and try to understand what the compiler means, and how to solve it
val x = 5
x = 6
Println(“123”)
val f = (x : Int => x + 1)
if x > f(x) x = 9
val f = (x : int) => x + 1
![Page 20: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/20.jpg)
20
And In Eclipse
• Select and copy a program of your choice to Eclipse• How are compilation errors marked in Eclipse?• Perform compilation errors purposely and see how the compiler’s errors look like:
• Change an upper-case letter to lower case• Remove a closing brackets
• Where are the compiled files?
![Page 21: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/21.jpg)
21
Today• Login to your account• Your Account, basic Linux commands• Using the interpreter• Eclipse – “Hello World!”• Understanding compiler messages• Eclipse:
• Command line arguments• Debugger
• Home work – practice Shell commands
![Page 22: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/22.jpg)
22
Command Line Arguments In Eclipse
![Page 23: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/23.jpg)
23
Command Line Arguments In Eclipse
![Page 24: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/24.jpg)
24
Usage Example
?
Fibonacci.scala
![Page 25: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/25.jpg)
25
Example: Prime
• Write a program that receives from the command line arguments a list of numbers, and prints out for each whether it is prime
• Use the prime code that is published, and wrap it as a function• Notice, that the number of arguments is not known in advance!
![Page 26: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/26.jpg)
26
The Debugger
• Some programs may compile correctly, yet not produce the desirable results
• These programs are valid and correct Scala programs, yet not the programs we meant to write!
• The debugger can be used to follow the program step by step and may help detecting bugs in an already compiled program
![Page 27: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/27.jpg)
27
Debugger – Add Breakpoint
• Right click on the desired line
• “Toggle Breakpoint”
![Page 28: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/28.jpg)
28
Debugger – Start Debugging
breakpoint
debug
![Page 29: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/29.jpg)
29
Debugger – Debug Perspective
![Page 30: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/30.jpg)
30
Debugger – Debugging
Current state
Current location
Back to Scala perspective
![Page 31: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/31.jpg)
31
Today• Login to your account• Your Account, basic Linux commands• Using the interpreter• Eclipse – “Hello World!”• Understanding compiler messages• Eclipse:
• Command line arguments• Debugger
• Home work – practice Shell commands
![Page 32: 1 Gentle Introduction to Programming Tirgul 1: Shell and Scala “hands on” in the lab](https://reader036.vdocuments.net/reader036/viewer/2022062421/56649d585503460f94a382f1/html5/thumbnails/32.jpg)
32
Home Work - Shell