Gosh, I've passed a study course «The basis of the functional programming».
Though I don't know why. Well, since I started, I had to finish. But now I can boast the diploma numbered Nine Thousand Six Hundred And Sixty Six.
The general impressions are somewhat mixed. IMHO the course tries to include everything but as a result it comes out superficial enough. If only I have not an idea about Lisp before, I doubt whether I could understand some subjects given casually.
But after all it was interesting, the description of the basis of the realization LISP interpreter and compiler in Russian I have not met before in the Internet.
But the test questions of the course are definitely rotten. Still nobody manage to finish the course with the highest mark (5).
2006-03-15
2006-03-04
The programming: 99 bottles in Drools
I've posted to www.99-bottles-of-beer.net my solution in Drools. It was accepted.
You can see it here
You can see it here
tags:
java
The programming: 99 bottles
Oh, amazing site - www.99-bottles-of-beer.net It collects a great many programs in different languages printing plain and simple song:
What languages there are not here: ANT, J, K, CLIPS, Erang, Ocaml, 1C, naturally there are C/C++, Java, Perl.
Some exoteric languages made me smile - Ook! (This is for those who read Pratchett),
Shakespeare Programming Language (at least a brief acquaintance with works of the author with the same name is also recommended), Multithreaded Brainf * ck, procmail.
But as the most beautiful solution I unexpectedly chose a program in Refal.
With the printing the beginning of the song all languages cope pretty enough. The simple end spoils everything:
In some languages code is short, simple and clear but either incorrectly declines «1 bottles», or gladly reports in the end «0 bottles of beer on the wall». After fixing it becomes huge and confusing.
ANT by using the extensions package ant-contrib demonstrates the all ugliness of XML for recording consecutive actions.
But 1C code looks rather good due to the presence of operator ? in the language. If there is no petty operator + it would be not so bad illustration of imperative approach for solving this problem.
Excel VBA wonderfully demonstrates what terror can come out of it if do not separate logic from visual appearance.
Common Lisp code made me smile — the only program, which actually does what was requested — printing the song. In the language standard there is 'format' function (highly advanced analogue of C printf) its abilities are pretty enough for this song :).
Program in Scheme generates the required string in compile time. There there is a terrifying realization and quite good one.
C++ solution with using templates amazes by its laconism and demonstrates a simple rule-based approach in compile time.
Rule-based forward chaining language CLIPS fits successfully. It's a little bit verbose, but then easy extended.
For some reason neither JESS nor Drools solutions are present. Aren't they unpopular?
Java Exception oriented programming is the joke of the month! throw new BottleExeption(1), and redefine printStackTrace() method %)
Refal is great! Pattern matching is a wonderful tool for the decomposition.
I expected to see something similar in OCalm, but in the beginning they build recursive variant type isomorphic to the song verses and after that the substitution is going on. I have not understood yet either it is an awfully overhead, or a remarkable approach, using effectively the advantages of compile time and run time.
At the same site there is a lot of programs written in different Assembler dialects, Basic and SQL, but they are not so interesting for me.
99 bottles of beer on the wall, 99 bottle of beer!
Take one down, and pass it around. 98 bottles of beer on the wall.
98 bottles of beer on the wall, 99 bottle of beer!
Take one down, and pass it around. 97 bottles of beer on the wall.
...
What languages there are not here: ANT, J, K, CLIPS, Erang, Ocaml, 1C, naturally there are C/C++, Java, Perl.
Some exoteric languages made me smile - Ook! (This is for those who read Pratchett),
Shakespeare Programming Language (at least a brief acquaintance with works of the author with the same name is also recommended), Multithreaded Brainf * ck, procmail.
But as the most beautiful solution I unexpectedly chose a program in Refal.
With the printing the beginning of the song all languages cope pretty enough. The simple end spoils everything:
...
2 bottles of beer on the wall, 2 bottle of beer!
Take one down, and pass it around. 1 bottle of beer on the wall.
1 bottle of beer on the wall, 1 bottle of beer!
Take one down, and pass it around. No more bottles of beer on the wall.
No more bottles bottles of beer on the wall, No more bottles bottles of beer!
Go to store and buy some more. 99 of beer on the wall.
In some languages code is short, simple and clear but either incorrectly declines «1 bottles», or gladly reports in the end «0 bottles of beer on the wall». After fixing it becomes huge and confusing.
ANT by using the extensions package ant-contrib demonstrates the all ugliness of XML for recording consecutive actions.
But 1C code looks rather good due to the presence of operator ? in the language. If there is no petty operator + it would be not so bad illustration of imperative approach for solving this problem.
Excel VBA wonderfully demonstrates what terror can come out of it if do not separate logic from visual appearance.
Common Lisp code made me smile — the only program, which actually does what was requested — printing the song. In the language standard there is 'format' function (highly advanced analogue of C printf) its abilities are pretty enough for this song :).
Program in Scheme generates the required string in compile time. There there is a terrifying realization and quite good one.
C++ solution with using templates amazes by its laconism and demonstrates a simple rule-based approach in compile time.
Rule-based forward chaining language CLIPS fits successfully. It's a little bit verbose, but then easy extended.
For some reason neither JESS nor Drools solutions are present. Aren't they unpopular?
Java Exception oriented programming is the joke of the month! throw new BottleExeption(1), and redefine printStackTrace() method %)
Refal is great! Pattern matching is a wonderful tool for the decomposition.
I expected to see something similar in OCalm, but in the beginning they build recursive variant type isomorphic to the song verses and after that the substitution is going on. I have not understood yet either it is an awfully overhead, or a remarkable approach, using effectively the advantages of compile time and run time.
At the same site there is a lot of programs written in different Assembler dialects, Basic and SQL, but they are not so interesting for me.
2006-01-21
Drools: Experimenting with «Jackal» game.
There is an old child's table game. Here http://zhurnal.lib.ru/g/glebowa_u_w/statja1.shtml an inspiration introduction can be read. Unfortunately, I have not found detail description of the game rules in the internet, but this is not so important — now I'm interested in its small subset:
The game takes place on a field consisting from 11x11 small square cells with turned over images. A player can sail his ship to any field edge and put ashore a sailor. A cell is turned over (is the image was hidden) as the sailor stand at it. Further actions depend on the cell image. I will not describe all cell types, I'll tell about 3 types, one of which roused me to program this game.
1. Empty cell — nothing happens
2. Arrow — a sailor automatically moves to a cell which the arrow is pointing at.
3. Reflection — a sailor moves to a cell, which is symmetric to its initial state.
For example:
where numbers are empty cells, «@» is the reflection card, well, the arrow is the arrow.
Sailor comed from cell 1 moved by the arrow to the reflection cells, which moves him to the cell 1'. Similarly for 2-2' and 3-3'. This is all rules for this cell kind, which were familiar to me, the rest special cases should be invented ;) . Since everybody has different ideas, the rules shold be programed so that they can be easyly changed later.
Here is my variant:
1. Arrows are not reflected, i. e. even if a sailor passed several arrows during the moving to a reflection cell, his further moving is symmetrical to the last empty cell.
2. But after the reflection further reflections will be relative to the result of the first one. E. g. when coming from cell 4 to the reflection cell, the sailor will be moved to the arrow, which will be reflected this time, and the sailor will be back at 4.
3. And a little exception — a sailor reflected to the reflection second time, will be reflected related to the same cell as first time.
It seems to be enough rules for this time. You can already see that this game is not like many other children's table games with fixed map representable as plane graph.
In the beginning I wanted just to set all rules and associated actions by using some rule-based engine. But I've discovered that the game field is not plane oriented graph, though it can be represented as 3-D graph. Each path containing a reflection cell can be passed through vertices located at some level. Thereby, if desired, any existing engine of a plane table game can be adapted to «Jackal» without considerable problems.
But to solve the problem of conversion Jackal field to graph I decided to try Drools engine.
The game takes place on a field consisting from 11x11 small square cells with turned over images. A player can sail his ship to any field edge and put ashore a sailor. A cell is turned over (is the image was hidden) as the sailor stand at it. Further actions depend on the cell image. I will not describe all cell types, I'll tell about 3 types, one of which roused me to program this game.
1. Empty cell — nothing happens
2. Arrow — a sailor automatically moves to a cell which the arrow is pointing at.
3. Reflection — a sailor moves to a cell, which is symmetric to its initial state.
For example:
2 3'
1 -> @ 4 1'
3 2'
where numbers are empty cells, «@» is the reflection card, well, the arrow is the arrow.
Sailor comed from cell 1 moved by the arrow to the reflection cells, which moves him to the cell 1'. Similarly for 2-2' and 3-3'. This is all rules for this cell kind, which were familiar to me, the rest special cases should be invented ;) . Since everybody has different ideas, the rules shold be programed so that they can be easyly changed later.
Here is my variant:
1. Arrows are not reflected, i. e. even if a sailor passed several arrows during the moving to a reflection cell, his further moving is symmetrical to the last empty cell.
2. But after the reflection further reflections will be relative to the result of the first one. E. g. when coming from cell 4 to the reflection cell, the sailor will be moved to the arrow, which will be reflected this time, and the sailor will be back at 4.
3. And a little exception — a sailor reflected to the reflection second time, will be reflected related to the same cell as first time.
It seems to be enough rules for this time. You can already see that this game is not like many other children's table games with fixed map representable as plane graph.
In the beginning I wanted just to set all rules and associated actions by using some rule-based engine. But I've discovered that the game field is not plane oriented graph, though it can be represented as 3-D graph. Each path containing a reflection cell can be passed through vertices located at some level. Thereby, if desired, any existing engine of a plane table game can be adapted to «Jackal» without considerable problems.
But to solve the problem of conversion Jackal field to graph I decided to try Drools engine.
tags:
java
2006-01-19
Link after link...
My GUIbuilding googling turned into rule-based engines googling which gradually turned into studying one of them. Mostly it was provoked by beautiful design and the presence of «Tutorials and examples» section at http://www.drools.org.
Now my task is to write it all down in order to remember the new information and, besides, to be able to recollect this in case of need.
I suppose, it will be about four posts in one and a half screen :)
Subtotals can be sumed up just now:
1) Concentration on a task is amazing, the main thing is do not forget constatly repeat the mantra: «everithing is a fact, I can operate facts only». If to use such an approach, most inefficient solutions are fall away. And you can wink at memory overhead.
2) «Rete network + OOP» is equivalent to «a fish + a bicycle». Probably, I will not rush to assert that rete + OOP is useless, it's only advantage is easy integration with existing systems. But during development it's only prevent thinking. IMHO duck typing is a good compromise in this case.
Now my task is to write it all down in order to remember the new information and, besides, to be able to recollect this in case of need.
I suppose, it will be about four posts in one and a half screen :)
Subtotals can be sumed up just now:
1) Concentration on a task is amazing, the main thing is do not forget constatly repeat the mantra: «everithing is a fact, I can operate facts only». If to use such an approach, most inefficient solutions are fall away. And you can wink at memory overhead.
2) «Rete network + OOP» is equivalent to «a fish + a bicycle». Probably, I will not rush to assert that rete + OOP is useless, it's only advantage is easy integration with existing systems. But during development it's only prevent thinking. IMHO duck typing is a good compromise in this case.
tags:
java
2006-01-14
Links: a story of a small optimization
Here and here is told how a profiler sometimes may help. Who could have imagined that it is possible to reduce program run time from 78 minutes to... 5 seconds
tags:
java
2006-01-10
Programming: GUI - new concepts
Yep.. Eclipse guys are not behind new trends - JFace Data Binding. In Eclipse 3.2 will be analogue of Cocoa Controller Layer.
Subscribe to:
Posts (Atom)