Visar inlägg med etikett programming. Visa alla inlägg
Visar inlägg med etikett programming. Visa alla inlägg

tisdag 2 maj 2017

Some thoughts on concessions

People are claiming that the material can not account for concessions. I do not believe this. Instead I think there are some key functions that, together with emergence, create concessions.
Those key functions are (partly)
* contents addressing
* association feedback
Contents addressing means that the data is the address. Or rather that there is no difference between  data and memory addresses. That means that by purely thinking about something, that that something is addressed in memory. Once that memory is accessed, if there is data there, there is also a new address that will be looked up. This kind of structure could perhaps be emulated in a computer by having a list of addresses included in each object stored in memory. 
Next, association feedback means that once a memory has been addressed, the memory contents is automatically used as a new address - accessing anything that can be addressed using that memory.
In this way, human (long term) memory is really made up of many interleaved tree data structures. Kind of like a block chain.

torsdag 19 maj 2016

In Python, -k/2 != -(k/2)

I just found an interesting fact about Python. The following C program:
#include

int main(int argc, char * argv[]){
int k = 11;
printf("k = %d\n", k);
printf("k/2 = %d\n", k/2);
printf("-k/2 = %d\n", -k/2);
printf("-(k/2) = %d\n", -(k/2));
}
will output:
k = 11
k/2 = 5
-k/2 = -5
-(k/2) = -5

However, the following Python program:
k = 11
print k
print k/2
print -k/2
print -(k/2)
will output:
11
5
-6
-5

I guess this is related to Pythons floor division, and has apparently been changed in Python 3.

torsdag 28 januari 2016

The software revolution

The industrial revolution occurred because someone came up with the idea that instead of making items, we should make machines that makes items. Now, could the same be applied to software? A software revolution when we stop making software and start making machines that makes software.

For this to come true, entirely new programming models will probably be required. We also need to start thinking of when the multitude of software will be required.

One interesting thought in connection to this is my previous post discussing communication as transmission of software. Thus; the communication revolution we see now, really corresponds to the industrial revolution in the sense that we produce software that is used only for a very short time (the "message" in classical terms). Maybe only once.

söndag 3 januari 2016

I just learned about the dining philosophers problem...

The dining philosophers problem is an interesting one, invented by Dijkstra, and important in multi-threaded programming. I read the Wikipedia article and some others on the subject, and noted that the problem is very similar to what is faced in a wireless communication scenario where several clients needs a way to share the channel.
In communication the problem seem to have been solved in some other ways that in programming. E.g. Cellular systems usually employ a scheduler. 802.11 instead uses CSMA/CA. It is interesting to note that the communication system problem description actually is closes to the original problem formulation by Dijkstra where he considered shared access to a tape recorder system.
It would be very interesting to investigate how the computer science solutions perform in a wireless scenario, and vice versa, how would the wireless (and wired, e.g. Ethernet) solutions perform in concurrent programming scenarios.
I will have to get back on that.

onsdag 30 december 2015

Why I hate everything Windows

These are just some issues that I simply can not understand how they can be allowed to stick around?!
  • When I mount a USB stick, I get a note about that my monitor does not have the optimal resolution set.
  • Then I compile a program using VS2010, or VS2015, domain name look-up does not work.
  • Adding a network drive with other authentication forgets the authentication if it failed to connect one time (which of course it will since I have connected network drives from many local networks).
  • The default (which I do not know how to sensibly change) timeout when trying to connect to a network drive is something like 30s. Now, the OS is stupid enough to verify these connections every time a file access is attempted by any software. And if the connection fails (after having being active, a not very unlikely scenario if I move my laptop) it will still try to connect EVERY time a file access is attempted. And this continues until the system is rebooted?!
  • If I want to save a word-file using save as, I have to activate editing of the document - ridiculous!
The list will be extended as I find more craziness.

Update 2016-01

I should probably actually generalize this to Microsoft products in general. How about this one:
I have to use two Office 365 mail accounts on the web belonging to two different companies. But the system can not handle that, so I have to log in and out every time I need to do something on the "other" account...

onsdag 2 december 2015

A suggestion for a C++1z feature

This is probably quite a controversial proposal. And I am by no standards a very skilled programmer. But anyway, I think this feature could be rather nice to have.

The idea is to have some kind of Post-constructor automatically generated and executed member function. A suggested name for this function would be initializer. It is not entirely clear to me how it should be run, but maybe in reverse compared to constructors, so that derived classes initializers are run before base classes.

The rationale for this proposal is; How many times have you seen code like:

class A{...};
class B : private A{...};
B m(param p);
m.Init();

Or something like that. The reason for this construction (that is, why the code that goes into init does not go into the constructor) is that Init calls some interface function from a member of the base class A to the derived class B. Now this interface function for sure will need stuff created when B was constructed, and hence it can not go into A's constructor. It can also not go into B's constructor since, B does not know about all stuff in A.

For this, a really nice solution would be if all classes run Init-functions in reverse automatically. Then if this function is not user created, it does not have to be run. However, if the user created it, it should be run automatically at the end of the constructor. Maybe it could be done in a fashion similar to the init list in the constructor, but appearing at the end of the function declaration instead? Something like:
B::B(param p) : ...{
...
} : !A()
Where I named the function !A.