I've just released on github a script for which adds some important features (like repository support) on top of the GNU stow package manager:
This is a working prototype of an application level based package manager
based on GNU stow (www.gnu.org/software/stow/).
stow installs a specific version of a program from the so called stow dir
to a destination directory.
The intent of this prototype was to find out if adding missing functionality to
the core stow application (like repository support) would be a simple
replacement for non-root installations of software on a Linux system.
If stow is a very simplified dpkg, then stow-manager is a very simplified
(and dumb) version of apt-get.
See the github repository for the code (rather large bash script) and documentation.
Donnerstag, 27. März 2014
Samstag, 22. März 2014
Becoming a Wizard - Studying "Structure And Interpretation Of Computer Programs"
A while ago I was listening to some interview on software engineering radio. The person interviewed said that he is shocked about so many programmers nowadays haven't heard about what he believes is one of the most influential programing books ever written: "Structure And Interpretation Of Computer Programs" (SICP) - also called the wizard book:
Well - he would have been shocked by me as well. SICP is apparently one of those books which one should have read in programmers life - or better worked through. SICP is teaching not a particular programing language but how to program. It is more about the bigger picture.
The book seams to be popular in the US since many universities are using it as the basis for their own lectures. Here in Germany SICP is rather unknown.
After I got my own copy of the book I started reading. After a while I felt that I should not read but properly study this book. An Internet search brought me then to UC Berkley and their variant of the course. It is based on SICP but is using Python as teaching language (instead of Scheme in the original version).
For each term, UC Berkley is providing all study material online, including a complete set of screencasts of the lectures. For me, sitting in Germany and working full time, this is a fantastic way of participating at the lectures to a convenient time, learning at my own pace.
My personal project for the next couple of months is to finish this course, doing most of the homework and also trying to do some project work - being a proper nerd.
Since I'm not enrolled I won't earn a certificate or something similar - but my intend is to gain a broader understanding of programing - not an other piece of paper.
This will be fun :-)
Well - he would have been shocked by me as well. SICP is apparently one of those books which one should have read in programmers life - or better worked through. SICP is teaching not a particular programing language but how to program. It is more about the bigger picture.
The book seams to be popular in the US since many universities are using it as the basis for their own lectures. Here in Germany SICP is rather unknown.
After I got my own copy of the book I started reading. After a while I felt that I should not read but properly study this book. An Internet search brought me then to UC Berkley and their variant of the course. It is based on SICP but is using Python as teaching language (instead of Scheme in the original version).
For each term, UC Berkley is providing all study material online, including a complete set of screencasts of the lectures. For me, sitting in Germany and working full time, this is a fantastic way of participating at the lectures to a convenient time, learning at my own pace.
My personal project for the next couple of months is to finish this course, doing most of the homework and also trying to do some project work - being a proper nerd.
Since I'm not enrolled I won't earn a certificate or something similar - but my intend is to gain a broader understanding of programing - not an other piece of paper.
This will be fun :-)
Samstag, 15. März 2014
gcc's cleanup attribute instead of goto
While reading Dr. Dobbs article about Apples goto fail bug I stumbled across the gcc attribute cleanup as a potential replacement for the mighty goto.
Here is a quote from the gcc manual:
The
So instead of using goto to free resources locally, at declaration of a variable you also attach a cleanup function to it. As soon as the variable goes out of scope your cleanup code is being run.
If you search the internet for "gcc cleanup" you'll find many hits. My favorite one including a nice demonstration is here.
Nevertheless, for my current projects I won't make use of this feature. Mainly because I'm happy with the simple goto mechanism (as thousands of other C developers apperently are). Also, I want to keep the C code portable.
Here is a quote from the gcc manual:
The
cleanup
attribute runs a function when the variable goes out of scope. This attribute can only be applied to auto function scope variables; it may not be applied to parameters or variables with static storage duration.
So instead of using goto to free resources locally, at declaration of a variable you also attach a cleanup function to it. As soon as the variable goes out of scope your cleanup code is being run.
If you search the internet for "gcc cleanup" you'll find many hits. My favorite one including a nice demonstration is here.
Nevertheless, for my current projects I won't make use of this feature. Mainly because I'm happy with the simple goto mechanism (as thousands of other C developers apperently are). Also, I want to keep the C code portable.
Montag, 3. März 2014
Bash - Returning function status and error message at the same time
Fortunately the bash is Turing complete so one can do advanced programing task with it - if there is no other choice to pick a proper dynamically typed scripting language like Python, Ruby or Perl.
Quick detour: Much to my regret, in German Linux magazine long term author of the Perl snapshot series, Michael Schilli, admitted that over the past years Perl got less important. He's part the Perl comunity since a very long time, so this statement might be even more an indicator for looking at the newer kids on the block.
Anyway, I recently found my self again doing rather complex tasks with the bash. I was prototyping some logic which will eventually be implemented in some other (proper ;-) ) language. At some point I started combining two very basic things:
Combining the two gave my some nice syntax which kind of resembles a common C programing pattern:
This nice construct comes with the usual limitations of a subshell operation - the code inside the subshell can read the outer variables but can't alter them.
Quick detour: Much to my regret, in German Linux magazine long term author of the Perl snapshot series, Michael Schilli, admitted that over the past years Perl got less important. He's part the Perl comunity since a very long time, so this statement might be even more an indicator for looking at the newer kids on the block.
Anyway, I recently found my self again doing rather complex tasks with the bash. I was prototyping some logic which will eventually be implemented in some other (proper ;-) ) language. At some point I started combining two very basic things:
- returning true or false from a function ( return zero or non-zero)
- returning a string from a function ( via echo to the standard output of the subshell the function is running in)
Combining the two gave my some nice syntax which kind of resembles a common C programing pattern:
#!/bin/bash function isGreaterThan() { local firstNo=$1 local secondNo=$2 if [ ! ${firstNo} -gt ${secondNo} ]; then echo "${firstNo} is not greater than ${secondNo}" return 1 fi return 0 } # main errorMsg= if errorMsg=`isGreaterThan 3 1`; then echo "here comes more logic" else echo "got error: ${errorMsg}" fiThe function isGreaterThan returns the result of the evaluation as normal return codes. Additionally, in case of a false an error message is given back. One level above the error message is received by calling the function in a subshell (I prefer the old backticks syntax over the new brackets notation).
This nice construct comes with the usual limitations of a subshell operation - the code inside the subshell can read the outer variables but can't alter them.
Abonnieren
Posts (Atom)