2006-12-18

Links: Lisp without parentheses in book

It is recommended to fans of rubber women, alcohol-free beer and lisp without parentheses - G J Chaitin THE UNKNOWABLE


CONTENTS
1. A Hundred Years of Controversy Regarding the Foundations of Mathematics
2. LISP: A Formalism for Expressing Mathematical Algorithms
3. Gödel's Proof of his Incompleteness Theorem
4. Turing's Proof of the Unsolvability of the Halting Problem
5. My Proof that You Can't Show that a LISP Expression is Elegant
6. Information & Randomness: A Survey of Algorithmic Information Theory
7. Mathematics in the Third Millennium?
8. Bibliography


An excellent example of how a good idea can be spoiled. After removing parentheses an author has to comment every(!) line of a source code... otherwise everything is completely confusing.

Running over it, I started to mess about just on the phrase
[is set empty?]
The first thought is... aha it's usual thing - besides parenthesis we add square brackets for easing of understanding. I.e. after translating to human language we get:
(define (is v p)
(p v))

(define empty? null?)

(is set empty?)


Oops... it turned out it was just a comment. Further it's getting worse huge sconses instead of one call of list, strange "'.

For educational purposes Lisp-1 can be used resolutely, and functions and usual variables may not be separated.

2006-12-13

SQL Programming Style

I've finished «SQL Programming Style» by Joe Celko. Chapter about scales and measures is great, I'll read it again.
I laughed a lot at the book pages telling what won't do. I'm fully agree with it. All negative examples I'm watching in the real life.

The author's devotion to natural keys seemed very strange to me.

Argument against it — very often the appearance of a natural key is the result of concrete stage of a workflow. When building database scheme based on natural key we implicitly specify the actions order. Business rules are changed a little - oops, on basic stages we lost the key.

But in general the book is consist as it is expected from the title of personal rules of code writing style. Too many moot points...

2006-12-12

Mess

I've just forgotten parentheses in a constructor declaration... and got


--------------------Configuration: credits - Win32 Debug--------------------
Compiling...
DocumentState.cpp
D:\MyProjects\Credits\Classes\DocumentState.cpp(24) : fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1794)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
Error executing cl.exe.

creditsD.exe - 1 error(s), 0 warning(s)

2006-12-06

Dependence on Google

I'm sick — once and for all, after transferring friend tape to google reader the only last step is left.


Yesterday I've realized that it is become to read everything in one program. I've got the following variant:
1) Mark pages you like with tag «read» in del.icio.us (there is a plugin for FireFox).
2)Subscribe to feed from del.icio.us like http://del.icio.us/rss/fyodor/read in a favorite aggregator
3)Read your interest pages in the aggregator when you have free time, together with news.

2006-11-27

Emacs: Free pascal interaction

Hum... I googled, but have not found. Evidently, nobody was concerned with the problem of interaction emacs and fpc.

Well, I've readjusted what I can - highlight uses, support of compile errors messaging and the default compile-command.

;;Pascal mode
(require 'compile)
(pushnew '("^\\([a-zA-Z0-9\\.]+\\)(\\([0-9]+\\),\\([0-9]+\\))\s\\(.*$\\)" 1 2 3)
compilation-error-regexp-alist)
(defun pascal-mode-additional-init ()
(local-set-key "\C-c\C-c" 'compile)
(unless (or (file-exists-p "makefile")
(file-exists-p "Makefile"))
(set (make-local-variable 'compile-command)
(concat "fpc -g " buffer-file-name)))
(font-lock-add-keywords 'pascal-mode
'(("^[ \t]*\\(uses\\)\\>[ \t]*\\([a-z]\\)" 1 font-lock-keyword-face prepend))))


What should else I do so good?

2006-11-20

Odd thoughts about testing

Approaches promoted in TDD and something that many people consider to be unit tests are like apples and oranges. In Test Driven Development tests are the way of thinking, one cannot create a program without writing tests to it. To write tests before the code is easy, to write unit tests after it is boring, useless and very often impossible.

All kind of tests are important.

In the traditional TDD there is no loss of time for tests writing by definition.

I'm not used to think by tests. I can assume that it is hard for many people too.

Possibility of automate testing <= Low coherence <= Good architecture.
There is also the reverse chain.

To estimate the coherence from the tests point of view is more easy.

It is not necessary to test everything for early finding problems out. A complex problem that was not found in the low level as the snowball will grow to snow slide and bring dawn the most banal tests of the high level. But before the fixing you'll have to write the test, all the same :)

Tests are documenting errors. Write a test, fix a bug, run the test — it's a guarantee that neither you, nor your mates will trigger this backflash again (that is especially important during the refactoring).

Refactoring without tests <=> you have only yourself to blame

If after the refactoring test is not compiled it's a reason to let your team mates know about changes and ways of moving the old code.

Pre- and post conditions it is not automatic tests (emphasis is placed on any word to your taste). They still need a set of automated scripts.

Unlike homemade solutions unit tests are an industry standard of automated scripts design. There is support from IDE for them.

Tests automate the developer labor, supplement IDE with its specific functionality. Tests highlight the place of errors. Tests simplify debugging. One click and you are in the place of a problem.

There is no good code, there is a code which is easy to rewrite. Tests are one of ways of achievement of ease.

There is a separate chapter in Lingvo - "Easy-to-test"

The main thing is brain, still tests do not guarantee success.

The four large letters IMHO before each peremptory statement about the software development can be dropped only in a personal LJ.

Bigloo Scheme - simple type conversion

For a long time I looked for a function real->integer, it turned out that everything is much more easy.

1:=> (integer? 6.0)
#t
1:=> (real? 6.0)
#t
1:=> (exact? 6.0)
#f
1:=> (inexact? 6.0)
#t
1:=> (vector-ref (make-vector 10 0) 6.0)
*** ERROR:_vector-ref:
Type `int' expected, `real' provided -- 6.0
0.interp
1.engine
2.main
1:=> (vector-ref (make-vector 10 0) 6)
0
1:=> (vector-ref (make-vector 10 0) (inexact->exact 6.0))
0