Saturday, 27 December 2008

How far the web has gone

Two signs of how far the web has gone. The second is pretty cool, though.

1. Google Native Client, runs native binary code inside the browser, deploying the necessary binaries just in time of browsing the page.

2. VisualWebGUI, implements Windows.Forms in web context using AJAX, so after replacing System.Windows.Forms references to Gizmox.WebGUI.Forms and moving the source to a new project, your forms work on the web.

Earlier than this, we were trying to run web applications on offline machines, mostly using installation packs containing middleware like apache/php/mysql. I guess the basic drive behind this was to make offline machines run the same application. They weren't rare at that moment, but now offline machines are barely considered as proper computers.

We're trying to run web applications locally, and local applications on the web. We're desperate.

Java was right to the spot, and 7 years before .net was there. I don't know, maybe it was too early for the concept, or Sun couldn't make a good job on keeping Java up to date. But I'm sad to see Java is dying. How do I know? Because Java programmers are paid well these days.

Thursday, 27 November 2008

What is scrum

A simple blog entry, just point at a video that explains 'what is scrum'.

Well, "it's a great method... to develop software..."

Credits to Kestutis from work.

Wednesday, 26 November 2008

Teach them assembly first!


I've come across a project, a software that aims to teach object oriented programming through 3D objects in a virtual world.

For example, you drag a skater onto the snowy mountains, right click to her and invoke her methods like move, turn, roll or whatever. Then you go to the little code window, and drag her methods into a list to execute them in order. You have some containers like 'loop', 'if', or 'do together' for parallel execution. You drag and move methods around, move them inside containers and put together a program that controls the movement of the skater.

It brings no new teaching approach to programming model. It only removes the hassle of type-written languages and compiler-oriented problems. I wouldn't let any student to spend time on such a tool, but the ones in primary school. Programming world is big enough not to waste time on such toys; and teaching programming is not hard anyway, if you have people who really understands it and knows how to express the knowledge correctly.

Object Oriented Lobotomy

Another terrible failure is teaching an object oriented language like java or c# to a newbie for his first programming experience. Later in their careers, they'll eventually need to learn low-level stuff anyway, and they'll be scared to death. They can't live in that abstract world of managed runtimes forever. On the other hand, these languages are designed to be coded, reused and maintained easily, through the years of experience. They're not designed to be learned easily. Yes, there's a difference between "easy to code" and "easy to learn how to code".

First of all, it's harder to appreciate something, if you don't know the lack of it. The inventors of the assembly language were possibly bored enough of combining numeric instructions together, so they have used mnemonics to represent instructions. That's why we call the Assembly language a 'second generation language'. And in time, because writing assembly code is mostly dull work, and maybe because it's also hard to read and follow, they have decided to write a program which writes assembly through easier expressions, hence came the compilers and 'third generation languages'.

This is exactly why some fresh programmers hate writing getters/setters. They don't know how messy things can get if you don't do this. They don't know why it would take times and times longer to maintain a code that uses some variables which are accessed and manipulated by large numbers of lines.

Teach them assembly first!

Start simple, and teach them how to program assembly. They don't need to go in details. Indeed, basic concept of assembly programming is a lot simpler compared to higher level languages. Just a set of basic instructions will be enough to teach what it is like to program a computer to do what you want. MOV, ADD, INT, CMP, JNZ... None of them asks for more than one line of explanation. Registers are the only variables they have, and they'll naturally learn pointers which are considered as one of the hardest concepts to grasp for beginners.

As they write loops in assembly, the pattern will be obvious, and they'll appreciate why that 'for' statement has three sub statements as initialization, termination and incrementation. Then they'll know what is happening during the compilation of that for statement, and they're free to analyse the machine code.

When they're fluent with a procedural language like C, they'll again notice patterns and drawbacks of it. Some of them will appreciate object oriented, and some of them will develop their own solutions and stick to procedural model until they are pushed to switch to object oriented by a teacher in school or team leader at work.

Tuesday, 18 November 2008

Roasted broccoli

Roasted broccoli
Originally uploaded by Görkem PAÇACI
A new and absolutely delicious way to cook broccoli.

Roast it with some salt, pepper and olive oil. The only important thing is that they need to be completely dry. Roast them until they get brown spots on them.

Take them out, add some more olive oil, lemon juice and parmesan cheese. Stir well so the juice is all over them.

Do you hear them screaming?

Eat us! Eat us!

"Hunkar Begendi" for David

He said he would take "requests" for our occasional Wednesday night post-yoga din-dins. So here I go!

Hunkar Begendi is a very typical Turkish dish. It takes time to prepare, so when it's cooked it's almost a special occasion. (at least in my family where every women works)

The name means "The sultan loved it", by chicken translation. Indeed the name comes from "Begendi", which is a mixture of béchamel sauce and aubergine purée. (also served as a "Meze" along strong drinks)


The base

- 4 aubergines
- 3 tbsp flour
- 4 tbsp butter (half a tablet, I guess)
- 2 glasses of milk
- 2 tsp salt

- Roast the aubergines in the oven. You can wrap them with foil. Try not to pierce them, since we don't want to lose the juice. Don't cook very much so they are dry or burnt. And don't cook so little so they still have the sponge touch. They should be very soft and juicy. After cooked, peel the black skin off and smash the aubergines to have aubergine purée.
- In a pan, melt the butter and add the flour. Slowly pour the milk, and the salt after that. After the béchamel is ready, stir the purée in.

The meat sauté

- 1 kg of lamb meat
- 4 garlic cloves, smashed
- 1 tbsp flour
- 1 tbsp tomato purée
- 5 tbsp olive oil
- salt and pepper (amount up to you)

- Cook the meat in olive oil, in low heat
- Add the flour and keep stirring
- Add the smashed garlic cloves and tomato purée
- Add salt and pepper
- Keep stirring until garlic and tomato purée are cooked.

How to serve
First, put the aubergine base onto the plate, and add meat sauté in the middle. You can also serve with rice, but it's mostly eaten with normal-bread in Turkey. Ciabatta or 'cross-cut bread' from tesco will do.

For drink
"Ayran" will go perfect with it. It's basicly shaked yoghurt, cold water and salt. 1 unit yoghurt to 1 units water. Tesco's light yoghurt has the same sour flavour like the yoghurt in turkey.


Sunday, 2 November 2008

Logitech V150

Cable length is too short. Today I've bought this mouse but the cable length is around 50/60cm. It's obviously not the appropriate mouse for a desktop. Now I'll need to buy a usb extension as well.

I'm writing this because I couldn't find the cable length of the mouse anywhere on internet, before opening the packaging.

Edit: I've bought this usb hub and it's very pleasing:

Friday, 10 October 2008

back to dundee

Holiday version Izmir Q4 has ended. A family gathering tonight, and flight to istanbul in the morning.

if you worry if I was in that plane crashed:

at 10:30 from izmir to istanbul
at 15:25 from istanbul to paris
at 20:25 from paris to edinburgh

and hopefully train from inverkeithing to dundee.

sunday will be possibly spent in Selcuk&Gokcen's. and in monday I'll be at work. I did miss the work as well :)

Sunday, 5 October 2008

whoops! holiday is already out!


Last week of my holiday, and there's still a lot to do!

This photo is from today's meeting of Flickr Izmir group. Lovely people, lovely day.

Saturday, 6 September 2008

Sunday, 3 August 2008

Some more good movies

The Dark Knight
This movie had deserved to be watched at cinema, at the moment it hit the 1st in IMDB. I wouldn't rate it 1st, but it's absolutely in my first ten. Classic batman theme, plus some brain activity on the meaning of the 'crime' and continuous action. Best spent 5£ of last weeks. (mm, maybe except pub lunches)

Kingdom of Heaven
Worth to watch even only to see Eva Green. She's smashing. Movie has a middle-age western theme, with a bit of eastern Islam salt towards the end. I would say who will get the Jerusalem at the end, but I don't want to spoil it.

A Clockwork Orange
Took two days to watch, since I fell asleep around the middle of the movie the first day. But second day was great enough to make me feel satisfied. Makes you review your thoughts about violence, how much of it is done individually, how much of it comes from the society.

Wednesday, 30 July 2008

Some good movies

The man from earth.
This is a great movie reccommended by Hazan. It doesn't let your brain out for two hours. Pretty fun, and a good ending. Very similar to the theme of '12 Angry Man'.

North by Northwest (Hitchcock)
Not impressive as much as Psycho, but still very fun to watch especially considering unique structure of its scenario. spoiler [ many plot-twists ].

Death proof
A must-watch for Tarantino lovers. After watching this movie with friends, Umut went: "Ok now somebody tell me what was the genre of this movie?". It's only Tarantino-genre.

To singleton or not to singleton

A colleague (Jacques or David L.?) pointed out an article explaining why singletons are evil, and they should be avoided:

Although there are some valuable points coming from experience, I can't say that I totally agree with it. This article makes a better representing of my thoughts:

I'll try to come up with my own explanations as objections :)

1. "Singletons are almost like globals, and since globals are bad, singletons are bad."

In my opinion, the first reason why global variables are bad is that you have almost no control over initialization or modification operations over them. There's a global variable in the global scope who knows where it's coming from, who and when initialized it, does it contain valid information... Second, probably the strongest objection to globals is, when you keep writing code depending on globals, those globals sit in the centre of your design with an extremely tightly coupled fashion, Turning your whole code domain into a single 'deadly complex finite state machine'. [Not mentioning about debugging problems of such a code]

But they don't apply for singletons. You know when a singleton is initialized (lazy to death, if you like), and that the class initializes itself. It still only publishes an appropriate interface with read-only members, etc.

2. "Code that depends on a singleton is hard to unit-test."

Well, it's completely right. But it's not the fault of singleton objects, It's weakness of your testing framework. If you really want your objects to be stateless at the beginning, then I'm sorry but you have to well-write those Setup() and TearDown() methods, even it comes with a cost of dynamically loading and unloading many dlls.

3. "Don't use singletons, write a 'factory method'".

Well, this is possibly the most ridiculous one. A factory method, if it doesn't incorporate 'static' concept, can't do what a singleton does. And if it incorporates the static concept, it actually IS a singleton.

4. "Singletons screw polymorphism."

I don't have any objection to this. It's completely true. They do screw polymorphism. But you may have deeper problems with your design if you think an object 'will have only one instance' and there are going to be more than one objects subclassing the previous one. I better seal the singleton with a 'sealed' or 'final' keyword and take a French leave.

My objections don't eliminate the fact that singletons are abused. But I think the answer to this singleton deal is old and classic enough not to make me seem smart: "It depends.". It's always better to pass a reference to your single-instanced-object when you can, for many reasons like clear representation of coupling. But there will always be some cases you'll end up with ridiculously complex solutions just to avoid an innocent sweet singleton. It's a trade-off decision.

Tuesday, 29 July 2008

C# and beforefieldinit

C# and beforefieldinit

I didn't know that explicitly defining the static constructor could have an effect on initialization time of implicitly initialized members!

Friday, 25 July 2008

Yet another wishlist for programming languages, part 2: Inverse enumeration

How do you enumerate an IEnumerable inversely, from the last to first? Sometimes I need it. Maybe there can be a MovePrevious() method in the IEnumerator interface...

Please drop a comment if anyone thinks it's not 'doable' or why it's a bad practice :)

Thursday, 24 July 2008

Yet another wishlist for programming languages, part 1: 'local functions' or 'parameterized labels'

Well, the only languages that I can say I'm confident to talk about are c#, c++, php and vb. It means that I may be surprised to hear some languages do already have the features I wish. But I need to start from somewhere. Here we go!

I want 'local functions'. Or 'embedded functions' if you like. Javascript already has them, thanks to its functional programming basis. The problem is, I want to implement a piece of my algorithm as a function, but I don't want to publish it to other methods in that class. The think I'm looking for is written some like this in javascript:

function mainfunc()
var subfunc = function(args) { .... }

I dream about something like this in c#:

public void mainfunc()
bool subfunc(int args) { ... }

Or we can extend something we already have, labels, to 'parameterized labels'. It doesn't satisfy the requirement in my mind, because label-goto pairs cause a different impact on the program flow, which may lead to extra complexity of your overall algorithm. Parameterized labels may seem like this, in c#:

public string mainfunc(
if (...some condition...)
goto returnOne("foo");
goto returnTwo("zoo", "(two)");
// do some unrelated stuff
returnOne(string s):
return s+"(one)";
returnTwo(string s, string s2):
MessageBox.Show(s, s2);
return s+s2;

As you can see, it becomes something else, but it's still useful. It was also possible to do the same with the help of some variables and a couple of if statements, but I think this adds to readability and overall maintainability of the code. Of course it may also lead to that exaggerated old saying about 'spagetti code', but it depends on how careful you use labels and how much you care about overall simplicity of the code.

Thursday, 3 July 2008

Generic and efficient paging query for SqlServer and Oracle

A friend just pointed at an old post of mine in my blog
in Turkish. Basically, it's a parameterized wrapper query
which returns rows in an interval among the results
of a given query.

It's possible to implement this the same way in
both Sql Server 2005 and Oracle 10i. I had tested it quite
well to assure that it's better than alternative methods.
I had implemented this solution for our XSLT-enabled
data and view framework for 2.0, while I was
working in Netsis.

Assumed that your raw query is:

SELECT * FROM friends;

And you need just last 10 records from a 4million-records
table. (you're very popular)

You need to wrap it this way:

RawTable as ( SELECT * FROM friends ),
NumberedTable as
FROM RawTable)
SELECT * FROM NumberedTable
WHERE rownum <> 3499990

As far as I can remember, It was quite better than these

- Server-side cursors of ADO.NET on SQL2005
- Embedded subqueries with two seperate SELECT TOP N

And using ROW_NUMBER() over @@IDENTITY keyword
had helped a lot, instead of giving it a name of a column
to order. It was both fast and generic.

Use responsibly :)

Sunday, 27 April 2008

How to switch between .H and .CPP files in visual studio.

I've written a macro for this, since I don't know any existing commands in VS.

Sub SwitchBetweenHeaderAndSource()
Dim oldFile As String
Dim newFile As String
oldFile = DTE.ActiveDocument.FullName
If (oldFile.EndsWith(".cpp")) Then
newFile = oldFile.Replace(".cpp", ".h")
If (oldFile.EndsWith(".h")) Then
newFile = oldFile.Replace(".h", ".cpp")
newFile = oldFile
End If
End If
Dim pi As EnvDTE.ProjectItem
pi = DTE.Solution.FindProjectItem(newFile)
If (Not pi Is Nothing) Then
End If
End Sub

You can write this macro in macro explorer, which you can find in Tools->Macros menu.
To assign a keyboard shortcut, you can go to Tools->Customize and click the Keyboard button. On that window you can find the macro and assign it a keyboard shortcut. I'm using Ctrl+"

Tuesday, 1 April 2008

This summer

I had applied to Realtime Worlds for a summer placement job. I got a quiz, and an interview today. I've got an email that says I'm accepted for a summer placement, I'm quite glad to hear that :)

I'll finish my coursework earlier and go to turkey for a three-week holiday with family&friends, and from the beginning of the June, I'll be working at RTW for three and a half months. Yee-haw cowboy!

A saying that Raymond Chen has used in this article:
- Yee-haw cowboy:
A great latin-jazz album from Ayhan Sicimoglu:
- Friends&Family:

Wednesday, 5 March 2008

c++ benchmark: list or vector?

In games programming, it's likely to have a collection of objects you want to draw to the screen. In some cases, the number of items in such a collection can be quite high.

I wondered if there's an efficient option between using std::list or std::vector, and I did a benchmark to see it myself.

Scenario 1: Insert n items, traverse n times.

when n=100, there isn't a huge difference but list is better. For vector it's between 15ms and 78ms, and for list it's between 15ms and 62ms.
When I calculate the average of rates, I can see that list is ~%11 faster.

when n=300, I can't see a clear winner. For vector it's between 200ms and 310ms, and for list it's between 203ms and 343ms.
According to the average of rates, vector is ~%3 faster.

Here's the source for this benchmark:

Scenario 2: Insert n items, traverse n times and replace %20 of items on every iteration whilst traversing.

when n=100, mostly list wins. For vector it's between 170msms and 250ms, and for list it's between 172ms and 190ms.
List is ~%5 faster on average.

when n=200, list is always the winner. For vector it's between 1360ms and 1531ms, and for list it's between 1297ms and 1422ms.
List is ~%7 faster.

Here's the source for this benchmark:


If the number of items in your world are around 300 or more, and you don't perform so many insert&remove operations, pick vector. Otherwise, pick list.

I think the reason behind the truth that vector can't deal with continuous insert&remove operations is that it has to relocate remaining elements in the array when you delete one of them. For list, it's far more easy because it's implemented as a linked-list which means it's just about modifying two pointers to remove an element.

On the other hand, I think the reason why the list beats vector for 100 items is about the allocation strategy that vector uses. I don't know exactly how MS implemented this in standard library, but it's generally something like doubling the allocated memory everytime it's completely consumed. If it starts with a number like 5, to reach 100 it must be doubled 5 times, and everytime it looks for a bigger chunk of memory. The memory management has to find a continuous part in the memory for it. And after 100, to reach 300 it hast to be doubled just twice.

Saturday, 23 February 2008

Visual studio 2005 culture problem

Ok, I admit that it isn't a "problem". While working on our project "geekers", every time we update our project folder from subversion, we get this change to visual studio project file of the visual studio:

Ok, it's a desirable feature to have culture-specific data types in the xml streams. But do we really deserve this situation in this screenshot? I think we don't. :)
It remembers me a great article of Joel Spolsky, on "leaky abstractions."

Wednesday, 20 February 2008

Microsoft's another investment

As you can see on this page, microsoft is giving some of its products (visual studio, xna, windows server) to the students in UK for free. I've learned from Euan from our games project. I've already got those products thanks to MSDN membership of my university in Izmir, and many universities do.

An article I've read on 'Joel on software' claims that microsoft indeed would love to give its development products for free. Because the value of an operating system is dependent on the various software it has on it, and windows (with office) is the flagship product of microsoft. -- not visual studio --

I've never thought about it this way, and it really sounds smart.

Monday, 4 February 2008

Visual Studio SP1: Installation source for this product is not available

While trying to install Visual Studio 2005 SP1, I've encountered this error message: "Installation source for this product is not available".

After spending my whole day on this problem, I've found this blog entry:

And this MSDN knowledge base entry & patch:

And it managed to solve my problem. What a sunday!

Monday, 28 January 2008

Sun buys MySQL

It is not unreasonable, but it was unexpected; just like Serkan agreed. And in the digg post, the submitter's comment is: "Didn't see that one coming" :)

I can understand it, because the current commercial-opensource hybrid status of java is just like how MySQL is running for years. Probably, sun has foreseen more profit in this kind of work model.

Through a software guy's eye, I can tell that MySQL will strenghten its connections with Java, and it will implement/stabilize features which java used to supply from Oracle. Because of their strong relationship in the industry, this is something important for Oracle, as well.