Tue Sep 6
Questions about anything ?
installing software : getting up and running on windows ...
We discussed this last week, but I'd like to check in to see where you all are.
The fix seems to be to type "winpty python" rather than "python"
at the command prompt. (The problem is a bug in the GitBash terminal;
this runs a different terminal within that one.) This fix can be
made invisible with the "alias" command, i.e. 'alias python="winpty python "'.
That will run each time the GitBash shell is started if it's put
into ~/.bashrc (Note that files beginning with period are 'invisible'
files which are commonly used for settings.) This may then cause
another small issue - that gitbash will complain that it isn't
finding the other bash invisible files like .profile . If so,
you can create a zero size version of each with "touch" , like this :
$ cd ~ # change directory to home
$ touch .profile #
I did a Windows 10 installation which I will show in class, with
AnonymousPro (a coding font that I like)
GitBash (the mingw64 bash shell from GitHub)
Anaconda python 2.7 (take the defaults during the install)
Notepad++ (a good windows code editor)
GnuEmacs25 (another code editor; what I'm used to)
Firefox (what I'm used to)
I pinned to the task bar GitBash, an editor, and Firefox,
set everything to display (Anonymous Pro 14), set my ~/.bashrc file to
# startup customizations
#
# workaround for a gitbash (mingw64) terminal bug
alias python = "winpty python "
#
# always start in my home folder
cd ~
#
# customize the bash prompt
export PS1="laptop:\W \u\$ "
and did the "touch" stuff described above. And we're off ...
chap 1 : overview of computers and terminology
The point here is to just make sure that we're
all on the same page when it comes to what
computers are and how they work.
computer & software overview
To understand what programming is and how it works,
it's helpful to have good mental
model of how the parts of computer systems function.
We have a book in the library that does
a nice job with the ideas behind all this :
Code: The Hidden Language of
Computer Hardware and Software
Let's walk through the basic concepts :
- data : everything (text, numbers, code, audio, video, ...) is binary "bits", interpreted different ways.
- hardware : from inner (fast, small) to outer (slow, big) : cpu, cache, memory, disk, network ; monitors/keyboard/speakers/printers for in/out ; various "pipes" and "buses" for moving data about
- software : layers of services built on one another : kernel, operating system, libary, process, application, GUI
Other buzzwords :
- shell, bash, command prompt, command line : all roughly the same
- compiler, programming language, (python, java, basic, perl, ruby, C, ...), source code : what we're learning about this term, eh?
Walk through what specifically happens when we "run" a "program" in python, and how that differs from other languages like C.
What do these buzzwords mean?
- memory / disk / cache
- source code
- compiler
- process
- shell
- operating system
- library
- network
chap 1 : chaos
Just for fun, I've uploaded a jupyter (i.e. ipython) notebook
showing the chaos example from chapter 1, adapted so
that I can plot the numbers.
Near \( \alpha = 3.9 \) there is a "period doubling" route to chaos ...
See the attached files.
chap 2
software development cycle
- understand problem (can be harder than you think)
- create specs : inputs? outputs? (be very specific)
- choose algorithm: what does it do?
- implement (write the code)
- test and debug (again, can be harder than you expect)
- maintain (if used over time, needs will usually change)
variables
- a named place to put data
- legal names : x, yy23 the_data, this_is_a_long_name
- NOT legal : 3x (starts with number), x-y (no dashes), x.y (no periods)
- good names : principal, count, first_name
- not so good names: h (usually short), hpltz (too cryptic)
assignment
name = "Jim Mahoney"
age = 57
data = [2.3, 3.2, 16.23]
The part on the RIGHT is evaluated first.
Then that is put INTO the thing on the left.
Consider
x = x + 1
What is going on?
an example
- aside: python code in wiki pages
- does this have any bugs? Hmmm.
debugging
Discuss ...
what's next
We're looking at chapters 2 & 3 this week.
The next assignment from those two chapters is
posted - jump in and let me know
how it's going.