E N D
1. “We shall review your impudence at a later date…” David Niven in “Around the World in 80 Days” (1956)
2. Computer Science 101Lecture 19 Spring Semester 2008
Friday, February 29
Week 7/18
Albert H. Carlson
3. Announcements Due March 7: Midterm Essay
Bring your FLASH drive to lab
Bring your Castro Book on HTML to lab. Also, study the assigned reading to this point so you are familiar with it.
4. 5th Generation/Research The newest experimental languages
Often OO
Used for special purpose computing problems
Not used by large numbers of programmers – mostly used by specialists
Customized to do one thing very well
5. Compilers Compilers are really translators
Translate very abstract languages into more specific directions to the machine
Because they try to be general purpose they can insert extra steps that aren’t really needed – “code bloat”
Use two passes when reading the code
Pass 1: Find all the names in the code (variables and labels)
6. Compilers II Then a table is made for each name
Second pass uses the table made in pass 1 and translates the code with the location of the name in the table in mind
Compilers are made for a language and a target computer
7. Languages Interpreted
BASIC
FORTH
HTML
Structured/Functional
C
Pascal
OO
C++
Java
8. Languages II 5th Generation
Prolog
Haskel
9. Coding Examples - Microcode 11000010
00000000
00101000
00101100
11000100
00000000
00101000
00110000
10000110
10001000
10. Coding Examples - Assembly ld %r4,%r5
ba loop
addcc %r3,%r5,%r3
jmpl %r15+4,%r0
11. Coding Examples - HTML <body>
<div id=welcome>
<h1>Welcome to the CS101, Spring 2006 Website!</h1>
</div>
<marquee scrolldelay="0">
<!-- Enter your marquee text here. To change the width of the marquee, edit it in the CSS -->
The Study Guide for Exam 1 is Linked in at the bottom of the page
</marquee>
<p>
<br>
</p>
<h1>Lecture</h1>
<div id=indent_5>
<p>
<!-- Enter the Lecture information here. To change indentation of paragraph, goto #indent_5 and edit the left property of the p section. -->
Sections 1 - 3 have lecture at 12:30 - 12:20 in 222 TLC <br>
Sections 4 - 6 have lecture at 2:30 - 3:30 in 222 TLC
</p>
12. Coding Examples - C++
int main()
{
int val = 1;
int count = 0;
int unicityu = 7; //Upper bound for a unicity measurement, used to make it easier to run a loop past a float value (ie, rounding up)
int k = 25;
int a = 26;
int max;
float s;
float rl = .75;
float confidence = 0;
double unicity;
int filecounter = 0;
double intern, top, bottom, denom;
//Calculate unictiy
// k=fact(26);
top = log10(k);
// cout << top << endl;
bottom = (rl*log10(a));
unicity = top/bottom;
cout << "Calculated unicity distance is as follows:\n";
cout << unicity << " = " << top << "/" << bottom << endl << endl << endl;
unicityu = unicity+10;
// cout << k << endl;
for(count=0;count<26;count++)
{
key[count]=0;
singkey[count]=0;
dikey1[count]=0;
dikey2[count]=0;
13. Coding Examples - Python z = ins.read(1)
# print loop
# print tempcount
# print lettercount
loop = 0
outs.write(inputfile)
outs.write("\n")
while(loop < 26):
# print lettercount[loop]
outs.write("%d," % (lettercount[loop]))
loop = loop + 1
print inputfile
print lettercount
ins.close
outs.close
print "File is written and this job is done."
14. Coding Examples - Prolog get_attrs(Word,'adj',Ok)
:- get_quant(Word,Quant),
stringlist_concat([Word,',',Quant],Attrs),
file_data(adj,Attrs),
write('Saving '),write(Word),write_ln(' as an adjective to permanent memory.'),
retract(words(_)),
make_word_list,
Ok is 1.
15. Coding Examples - Scripting echo Changing directories into %1
echo Using input file %2 as the input file
echo ....
cd %1
echo .....
echo Checking all m-gram combinations
c:\dissertation\shiftandsubcipherc++files\debug\main -i %1\output35.txt
c:\test\release\tester -i %2 >> %1\output35.txt
c:\dissertation\shiftandsubcipherc++files\debug\main -i %1\output35.txt
echo ....
cd c:\dissertation
echo Complete
16. Algorithms Algorithms are sometimes called methods
Done step by step and in order the steps will be accomplished
Specify things in detail
Lets try an example
Washing clothes
Typically designed in “pseudo code”
Can contain other algorithms
17. Programs Typically written by programmers
Contain one, or more algorithms
Written in, or can be translated into, a language that is understood by the computer
Usually stored for multiple uses
Perform one job
18. Program Attributes (Should be) Small as possible
Portable
Store as many as possible in memory
As fast as possible
Use as little memory as possible
Easy to understand when read
Well tested (get rid of the errors)
19. Programs Several fields study software programs:
Software Engineering studies ways to make better programs
Complexity studies how to make faster programs that use less memory
Note that sometimes the goal of fast, small, and memory efficient are exclusive of each other and decisions have to be made
20. Questions?