Posts mit dem Label english werden angezeigt. Alle Posts anzeigen
Posts mit dem Label english werden angezeigt. Alle Posts anzeigen

2008-02-15

Esoteric Programming Language: CopyNPaste

Well, there is just a good bunch of Esoteric Programming Languages on the market, some really serious (means: causing serious damage to your brain), some meant as a joke .

Sigh, would I have more time, I could contribute with an idea for a new one.

What makes modern PLs so successful? It is that they express common programming patterns and paradigms directly on the code level.
A good example is Scala, which incorporates e.g. the singleton pattern with the keyword 'object', or implicit getter/setter generation for a property (you find that in Groovy too).

And here is the new idea, here is one pattern which was never implemented on language level:
Copy and Paste.

Really, a such often used pattern, and no language designed for it ....

And it would be so easy!

Simply take a base language, say: Java.

There you could have a class with a method, say:


1 public class MyTest {
2 ...
3 public Collection doSomething(Collection input) {
4 Collection newcoll = new SomeCollectionType();
5 Iterator iter = input.iterator();
6 while (iter.hasNext()) {
7 Element elem = (Element) iter.next();
8 Object someNewElem = somethingReallyImpressingDoneWith( elem );
9 newcoll.add( someNewElem );
10 }
11 }
12 }


In Java, adding a new method which also iterates over its input, but does some other impressing stuff with the elements and does not return a collection would be very annoying. You would copy and paste the above method and change the parts which shall differ from the original version per hand.

But why doing it yourself if your computer can do it for you? So it would be much better to simply tell your computer what to do, and the best way is to make this an integral part of the language itsself.

So the job could be done very easy with CopyNPaste, a language based on Java, but with additional features:


1 public class MyTest {
2 ...
3 public Collection doSomething(Collection input) {
4 Collection newcoll = new SomeCollectionType();
5 Iterator iter = input.iterator();
6 while (iter.hasNext()) {
7 Element elem = (Element) iter.next();
8 Object someNewElem = somethingReallyImpressingDoneWith( elem );
9 newcoll.add( someNewElem );
10 }
11 }
12
13 paste:: copy(L:{3-11}) -> {
14 onLine(1): s/Collection/void/ s/doSomething/doSomeOtherThing/ ;
15 delLine(2);
16 delLine(6);
17 onLine(5): delChar({1-21}) ; s/thingReallyImpressing/OtherThing/ ;
18 }
19 }


It will indeed become more interesting if the second method will be used as template for a third one ...

The advantages are obvious: You have to think only once about the way the first method doSomething() shall work. Then you are free to concentrate on how the method doSomeOtherThing() differs from that method.
You are free to think in your copy and paste paradigm without leaving this context when doing the new coding.

Thinks can be so easy ...

2007-12-18

How not to use static class members

Recently I came across a new experience which I consider a good example of "How not to use static class members".

Static class members are members (attributes and methods) which are shared between all instances of a class.

I.e.: If one instance changes the value of a static attribute, all other instances know this new value immediately.

Static members -particularly attributes- are shurely useful for configuration purposes, where all instances share a really really common knowledge with each other.

Static members are also indeed necessary for patterns like Singleton or Factory.

They are absolutely necessary to declare constants.

BUT: Static members are fatal if their usage include a runtime aspect.

I experienced that, when I inherited some code which extended the JUnit Framework to do validation on a loaded Model. Each validation was declared as test method of a so called "ValidationCase". As JUnit implicitly creates new instances for each test method to be called as test case.
So when running a specific test class, there are a bunch of instances of this class. For the validation now they had to share the model element to be tested.

The quick answer to this problem was: put it into a static member, all instances will know it then. Advantage: The location where these instances were created was inside the JUnit framework and didn't need to be touched.

BUT:
The error in this notion was: Not all instances of a test class share this model element. (As there are more model elements which are tested later and before by the same test class).

So the rule is: Only all instances of the test class which exist at a given time share this knowledge. At other times the share contains other information, shared by all instances actually existing then.

It worked well as long as only one model element was validated at a time.
The problem of this approach occured when once the validation system was extended to call a validation of one model element out of a validation of the other.

Now there were two groups of instances, one for element A, one for element B. But when B was under test, all instances shared the reference to B. And the reference to A was lost. Overwritten at a point in time.

Even this worked, as long as the validation of B happened to be the last action in the test of A, and the A reference was never needed afterwards.

But it was obvious that this card house once would collapse....

So: Everytime you introduce a static variable into a class, check carefully if its value is really valid for all instances of this class, even over time.
Avoid using static members out of well known pattern (like constants, Singleton, Factory ...).

2007-11-08

Hacker's Emblem

So since today you find a new simple little logo on this site:

hacker emblem

What is it? What is it about?
Why do I display it here?

I will answer the last question first:
Because I am a software developer, grew up with Unix (and now Linux), saw the upcoming of the Internet and the Hacker culture (see also: History) and strongly sympathise with the paradigm of 'free' like used in 'free software'. This logo symbolises how I now understand life and society, perhaps also the universe and all the rest ;-) .

The other questions are well explained here:
The Hacker Emblem and The Emblem's FAQ

and in german:
Das Hacker Emblem und Häufig gestellte Fragen zum Glider
Daneben: Was ist ein Hacker? - leider sind andere vormals vorhandene deutsche Übersetzungen von ESR's Texten inzwischen nicht mehr verfügbar.

2007-03-20

DreamTimeException

Für Java-Kenner ...


[FATAL] Fatal system error: End of virtuality reached,
falling back to real world
StackTrace:
au.inhabit.DreamtimeExeption: Broken dreamtime
at Office
at 08:15
at Monday
aborigined by:
org.det.absent.VirtualityException
at org.det.Brain.dream() (Brain.human: 42)
at org.det.Me.awareness()(Me.human: 0)
caused by:
org.det.body.OutOfBrainException


2006-08-15

Cites all around computer stuff

Programmers don't die, they GOSUB without RETURN.


(Found in a signature in www.rubyforen.de)


Programmer: A biological machine designed to convert caffeine into code.

(Found in a signature in www.rubyforen.de)


There are two ways of constructing a software design; one way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.

C. A. R. Hoare


If the code was hard to write, I'm going to damn well make it hard to read!

Dimator, on Slashdot


Walking on water and developing software from a specification are easy if both are frozen.

Edward V. Berard


Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning.

Rick Cook (NASA)


C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg.

Bjarne Stroustrup


Managing programmers is like trying to herd cats.

Greg Settle


$cd /pub
$more beer

Found on T-Shirt


Alcohol and calculus don't mix... Don't drink and derive.


The great thing about standards is that there are so many of them...


Personalization: the automatic tailoring of sites and messages to the individuals viewing them so that we can feel that somewhere there's a piece of software that loves us for who we are.

David Weinberger, JOHO


Weeks of coding can save you hours of planning.

An ironic "Microsoft Solution Framework" course attender


Lubarsky's Law of Cybernetic Entomology: There's always one more bug.


If at first you don't succeed, add 1 to any integer variable.


111,111,111 x 111,111,111 = 12,345,678,987,654,321

Useless facts


Tips to make your life and reality more computer-adapted:

  • Doubleclick all buttons
  • Put bookmarks on your favourite locations
  • Check your mailbox every 10 minutes
  • Start a newsgroup at the noteboard of your local supermarket
  • Recover things from the trashbin that you regret you threw away
  • When you show emotions, turn your head vertically and make faces
  • When something goes wrong during the day, reboot: go home, go to sleep and start over :-)

Java technology is not fault tolerant and is not designed, manufactured, or intended for use or resale as online control equipment in hazardous environments [...] in which the failure of Java technology could lead directly to death, personal injury, or severe physical or environmental damage.

Microsoft IIS license


A friend of mine in a compiler writing class produced a compiler with one error message "you lied to me when you told me this was a program"


Consistently separating words by spaces became a general custom about the tenth century A.D., and lasted until about 1957, when FORTRAN abandoned the practice.

Sun FORTRAN Reference Manual


0x2B | ~0x2B

Hamlet


There are only 10 types of people in the world - those who understand binary and those who don´t

(unknown)


As soon as we started programming, we found to our surprise that it wasn't as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs.

Maurice Wilkes discovers debugging in 1949


Telling computer guys that they need to have permission to quote things is like having to tell little children about Death.

Ted Nelson


One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs.

Robert Firth

2005-07-08

Bomb attacs in London.

Yesterday four bombs, three of them in underground trains,one in a doubledecker bus killed more than 37 people and left over 300 wounded.
Hard to believe, what happens in the modern, civilised countries since 9/11. I was shocked too and feel with the people in London.
It seems like the peaceful life inside the european borders is over and we have to be prepared to terror attacs, more serious and dangerous like the menaces we faced before. A form of war, new to most people of us.
Indeed we should not fall into a fearful and life-blocking paranoia but keep a cool mind. But on the other hand it seems to be the time to be aware of that menace and to be prepared, by training a conscious and watchful mind, discipline and also by obtaining necessary competences to be an aid to one another in such critical situations.
It is not only bomb attacs but all forms of likely harmful situations in which hundreds of people are involved. Panic could be inhibited and impact of such critical moments could be reduced. The officials and emergency organisations in London demonstrated discipline and good preparation, but much more the affected people impressed by their behaviour.
As a former soldier, instructed in SE (self protection), having a son in the auxiliary fire brigade's youth group, I'm now thinking about what can be done to increase civil protection skills of our population.
Trying to prevent such catastrophes is one thing, education in dealing with it another. Perhaps there should be lessons in civil protection and crisis behaviour in our schools, to increase the citizens skills.