Sunday, August 30, 2015

Return from overseas

Finally I have my stuff from Canada :] There is a lot of them but one of the important ones are my computers. Thanks to that I return to normal programming but well before that I needed to sync my projects.

There was a lot of changes in projects in last three months so I expected problems and well there were :)

  • First is my lack of normal internet connection :/ yep I still waiting for it. So right now I try to use hotspot option in android to be able exchange code between Linux laptop <-> PC.
  • Second was broken Windows build :/ I tried really hard to have working version of windows but without continuous compilation it's hard to switch systems all the time just to check if I didn't broke something. But well hour later the build worked.
  • Third were missing manifest generations (TBD) which allow me to hold plugins to editor in separate folder. Because of that I needed to do some changes manually.
  • My continuous compilation is still dead I need to recover it (I missing it).

There were also things that went well:
  • New project generator works great :D I needed to do some improvement which took like one minute. Right now I'm adding support to vs2013 and I'm really happy how easy it is.
  • Compilation time - better computer and I don't have time almost on anything between pressing compiling and starting tools.
  • After fixing compilation errors everything works again.
  • I started using sharing of keyboard and mouse (I using Synergy) and this allow me on quicker switching between systems :) 
So as you see I'm not laying around and doing nothing. Return of my hardware should be boost for me in development and allow me on quicker iteration time and there is a lot to do :/ But well, such a life.


Sunday, August 16, 2015

Am I good programmer?

After some break in posting I returning with another weird topic :D

Am I good programmer ? 

This is one of this topics that is simple: I'm the best programmer :D so we all came to this nice conclusion and we can end all discussion ...

If only real life was so simple :) Some time ago I spend whole evening with friend discussing if I am good in what I do. Funny thing is that in this discussion I was the person who claimed that I'm still not skilled enough. Because what in the end mean that I'm good programmer?

I think that this is tricky question because of multiple reason:

  1. It depend who you compare to.
  2. It depend what kind of work you do/done.
  3. It depend what you expect being good in.
  4. It depend what you mean by being good.
So lets start in order:
Follow and be followed

After all this year I spend on programming I still seeing that there are people who are better than me and in the same time I see people that are not so good as me. It don't mean that they are good or bad. 

It just happen that in current time we are in this configuration. Few years later situation may change I can be better than all of them. Nothing may change and there exist possibility that I will be the worst of them. This is the reason why we programmers can never stop learning. In this world everything changing and if won't change with it we will be left behind.

Look what I done

This one is tricky because what mean that I done something? This most of the time mean that:
  • This task was assigned to me,
  • There was need for it,
  • There is no similar system in code base,
  • I sacrifice my own time to do something after work.
All of this mean that not everybody can do great, big stuff in work. There is army of people which do small changes, bug fixes and support. This not mean that they are worse than the people who done big systems.

I'm good in what I do

In this world there are specialist, generalists and stupid people like me. 
  • Specialists - are people who are awesome in what they do but they knowledge behind their specialization is often really limited. 
  • Generalists - are people who know a little bit of everything but they don't have tight specialization.
  • There are also this stupid people who want to be specialists in everything. Always trying to have big knowledge in everything they touch.
No mater which kind of people you want to be it won't be easy.

I'm who I'm 

If you see me as good programmer I'm appreciate this. If not then tell me why you think so. I will try my best to fix this. In the end I'm just another programmer who do the best it can to be the best in what he do. Thanks to that I know that I still have infinite possibilities for growth and this is what I love in this work: 

I can learn new stuff all the time so it's never really boring.

This is also reason why in my eyes you need to deserve for being good programmer you don't gain it just because you done something or you have a lot years of experience. You need to prove it to me and do this all the time.


Monday, July 27, 2015

Bug in rendering of editor

Week ago I wrote post about porting editor to linux. I was mentioning there this weird bug :
Editor works (Yes I know that drawing area is shifted to right. This is one of bugs that I still don't know why happening and I already spend on it like two days :/)
Which is really nicely visible on this screen shoot:

I spend on it like three days and still wasn't able to figure out why it happening or find any trace of it. I tried to ignore it but after noticing similar issues with blender and chrome I decided on desperate step. 

From my experience I know that upgrades of system never ending good. This is the reason why I try avoid them as much as it possible. But well sometimes you need to do stupid things so I decided to update my Linux (Ubuntu 14.04) and graphics card drivers (fglrx-14.301) to newest versions.

What went good: I was nicely surprised that system upgrade went without bigger problems. There were two steps 14.04 -> 14.10 -> 15.04 which took some time but except that I cannot complain.

What went wrong: Update of graphics card drivers. This is sad that after all this years you are not able to install driver without any problems. It took me half day of work, checking a lot of pages and in the end modifying source code of driver to make it work. This was just one line of code but still :/

Final result: Well decide yourselves:

It work how it should work but well I hate bugs like this. If I knew update of system would fix that I would spend 1 day on update not 3 days searching blindly what I doing wrong.

But well this is our developers reality: dealing with our bugs and bugs of others.


Saturday, July 18, 2015

Scripting language in game ....

I know I know I stepping on thick Ice. Some people love scripting languages other hate and other don't care. Personally I still don't know to which group I belong.

I somehow understand all sides:

  • Scripting language:
    • [+] Have quick iteration time
    • [+] Non programmer can do some simple stuff
    • [+] It's easier than native code
    • [+] Separate game from engine
    • [-] Can be slow (most of the time is)
    • [-] Use garbage collector so it was more user friendly 
    • [-] Can be tricky to debug.
  • Native code:
    • [+] Can be really efficient
    • [+] Give you access to everything
    • [+] You have full control
    • [+/-] No garbage collector
    • [-] Can get easily messy
    • [-] Easy thing can take really a lot of time
    • [-] Slow iteration time
    • [-] You need really good programmers to utilize it
Because I'm not 100% sure about using scripting language in game I will try to create some add-on to engine so you could use scripts but you weren't forced to do this if you want. 

And here start my dilemma and request for advice: 

Which script language you would like to use create game and why ? 

There is big choice of them C#, Lua, Python, Java Script (This one I would like to avoid) or maybe something completely different? I will be happy to hear your opinions.


Friday, June 19, 2015

Understanding of problem

This topic came to my mind in meantime of resolving linking problem on Linux. When I build dynamic library my app missed some of the symbols. 

And no I didn't forget to compile *.cpp file which contain it. If it was so easy I wouldn't spend hours on resolving it. But this won't be topic of this post. The topic is about understanding of problem that we try resolve. I talking especially about this weird situations when something happening and we don't know why.

I know different schools how to deal with this hard problems :] 

Conclusion 1: It's for sure not in my code. 

And this issue wasn't in my code :]  I didn't believed that this code was wrong from start. It was my fault for sure. Question only where. 

Of course I'm not always was this way. In my younger days very often after hour of searching I were deciding it's for sure not my fault. Of course in 99% of time I was finding out later that I was wrong. Well privilege of being young.

Conclusion 2: Let's shuffle code and it will work.

Not literally but point of this is to do some change which we think will fix issue but we don't understand why. After this we run application if it work we are happy. To give example we have crash in application because of NULL value so we add check if it is null.

Sadly this way of resolving problems is one of the worse I can imagine. There is nothing worse than changing randomly code because we try to resolve some issue. This is just bad idea because very often this "fix" hide real problem. With time passing finding steps to reproduce it became harder and harder.

Conclusion 3: Let's understand what happening.

I think is the best solution but have one bottleneck: it consume time. But I will add from my experience: that very often it save time later. Issue is resolved properly, we understand what we done to make it work and finally if it will reported again most of the time it's some other problem.

Conclusion 4: I understand what happening but don't know why.

This is my current situation where I know that my issue is because of linking of static libraries (*.a) inside dynamic (*.so). Static library missing virtual table symbols because one of virtual function is not in the same *.cpp. So I know why this issue happen I expect that there are some missing flags of linking to resolve it. I just need to find which one :]


Of course all this sound easy :] but its not. There are situation where you need to do null check because there is no time. You need to ship something in hour and there is no choice. Of course good approach is to look into the problem deeper after sending build to find real issue.

Other thing is that life showing that sometimes problem is really in some external library or not your code. This happening but still safer is to assume that you done something wrong. And if you really don't know what you could do wrong prepare some solid test case and contact person responsible for this piece of code.

Finally, approach to understand problem is not something we are born with (in most cases). This is for sure not the easiest way of dealing with problem and we need to put a lot of effort into it. But with time it start to being natural approach which bring only benefits.


Saturday, June 6, 2015

Lets play : Good code / Bad code

If you try to find answer what good/bad code is, you won't find it in this post. I don't try to sell my beliefs and I'm sure you wouldn't like them anyway. To show you that, check this simple pieces of code:

void CAnimationResource::releasevoid )

I use void when function don't use any arguments. I know this useless and do nothing but I just like look of it (Personal preference). Other example:

CAnimationResource::CAnimationResourceconst wrResourceIDa_idIResourceManagera_manager )
    : CResource(a_id)
    , m_manager(a_manager)

I using prefix a_ for arguments of functions and use this style of organizing initialization in constructors. This is my way of coding. You probably have your own style this is perfectly fine. We shouldn't fight over some conventions details. Everybody is different and everybody code differently. This is sometimes not easy to accept (even for me) but we just need to live with it. 

So let's not focus on programming style and move to the main topic:

Good code

So what good code really mean ? Some time ago I would probably give answer right away. It would be long and boring talk how to write code, what to do and what not to do. But right now I'm doubt I could easily answer this question.

Lets assume that we have piece of code which resolve some issue. Code is really messy with hacks all over it. Because of all this we cannot call it good code, great candidate to refactoring. Sadly without rewriting half of other big system it's hard to create better solution. People with commercial experience know that in production environment you not always can rewrite everything.

Following all this thoughts we can have bad code in which we have bad code which in given situation is the best possible code. So probably we could call it good code which don't make sense at all :| I'm lost in my thoughts.

So is this mean that bad code is good ?

I think it's just like problem mentioned in this presentation. The same gray tiles looks brighter  in shadow but in light area they look darker. I think this is accurate description of code. Our way of code perception is affected by code we know. Bad code may look pretty good if you deal with even worse code all the time.

So what bad code mean ?

Everybody recognize bad code when they see it. But defining it is not easy. For me there are few points which make code bad for me (this is my subjective opinion):
  1. If you spend more than hour to understand small piece of code and still fail to do it.
  2. Code show no understanding of problem it should resolve.
  3. Code with weird dependencies which are hard to follow.
  4. Duplicating of functionality that can be simple achieve by modification other piece of code.
  5. Overusing allocations.
  6. Not strict access rights to class members.
There is probably hundred more points which I missed. But this are the one that came to my mind right now.


So Good and Bad code is hard to define. Some "good" code that I wrote few years ago look for me crappy right not. Sometimes it's really bad piece of code and it's perfectly fine. If I'm saying this then it mean I'm better now and I can see flows in what I done. At some point when I will find time or need I will try to improve this bad code.

If in work somebody telling me that my code is bad. It mean that it's bad no matter how I see it right now. I will ask why he think so, we will discuss this mater and I will try to fix it. There is point in arguing who is right and who is wrong. It's about understanding why other person see my code as bad and dealing of source of problem.

Of course it's easier to talk about it then do it. We are often stuck in our boxes which are comfortable and don't try look outside. But there is outside world and we cannot forget about this. That's why I learned that I need to experience as much as I can. Different code, different technologies, different languages, different opinions, different approaches. I'm not always succeeding in that but I try and this is what allow me to grow.

What you think about this problem? And how to deal with it?


Sunday, May 24, 2015

Project generator

I like to experiments and have fun doing that. Right now I work on another crazy idea. You know because developing of game and technology behind is not enough. Don't worry this is just another side project connected with this one. 

Project generator.

I know that I could use some existing solutions (i.e CMake) but this wouldn't be so fun as doing it myself in python :] Well I started doing ... some time ago and returning to it whenever I had some time. Right now I'm at the level where Linux make support is better than previous generator I use. Sadly Microsoft Visual Studio support not exist there right now :D

Well I fix this in future. But lets move to some details about new project generator which is wrote in python.

Sunday, May 17, 2015

Singleton pattern

Singleton pattern... People love it or hate it. There are also group of people who don't mind them.

I'm still try figure out which I'm :] I'm for sure not the one who love them. I'm also cannot say that I rally hate them because I still use them in code (It is like with my Facebook account. After I created one I try not complain about fb. ). So probably I'm best fit to don't mind group.

But my past experience showing me that I have bigger tendency to removing them from code than adding new one. And probably some colleagues from work will be happy about this because we spend a lot of time discussing about problem.

I remove them because I put even more effort in good design of systems. In a lot of cases thanks to changes I just don't need global objects. Which is good. It allow me to better utilize multithreading thanks to encapsulation.

Today sadly I had problem where I still don't know cleaner solution than global state:

template<> bool write<CResHandle>( ISerializerWritera_writerconst CResHandlea_value )
    return a_writer.serialize(a_value.isValid() ? a_value->getId() : wrResourceID());

template<> bool read<CResHandle>( ISerializerReadera_readerCResHandlea_value )
    wrResourceID id;

    if (!a_reader.deserialize(id)) return false;

    if (CResource::isValid(id))
        a_value = getResMgr()->createResource(id);
        a_value = nullptr;

    return true;

Function getResMgr() return global resource manager. I don't want to pass it around inside arguments because this is ugly and I would need to do the same with each manager I want to use. This would increase my arguments list and each new manager would recommend changes in all write/read functions.
I thought maybe about storing inside ISerializerReader/ISerializerWriter function like setData()/data() in some Qt classes. This way it will be really easily to extend list of available data even by game (which may add some new write/read functions). 

I'm still not sure about this solution and how nice it is. I will spend some time thinking about it but for now I will leave getResMgr() use with nice macro call right before it : 

WR_TODO("gwojciechowski""Think about way to not use global getResMgr().");

If you have any idea, thoughts or you just want to comment this. I'm open on opinion how to make this nice and clean :]


Sunday, May 10, 2015

Sculptures gallery moved

To make my life simpler I moved my sculptures gallery to my deviant art account. You can find link in Arts page or here :


It's funny that only with time and experience you start to understanding how hard UI code is. I remember a lot of situations when UI freeze in meantime of doing something. Whole window is locked and you just prying that its still alive.

First version of my tools were similar: everything happening in one thread which was block when I was doing some longer operation. Because there was not too much to process it was not so painful. With time this changed, amount of data grow. To fix the issue I started adding progress bars to some operations and was happy.

Sadly I was still wrong. This solution is still messy. I block whole UI and just update progress bar when some operations may be processed in background. Recent change of threading taught me beaut of asynchronous operations.

Right now all my communication Engine <-> UI is happening by events which cleaning my design of whole tools. All code where I mix UI with mechanics changing in creation of event and processing of it later. Bellow you can see code creating event:

if (autoevent = m_appCtx->createEventT<CEditorEventGetLevelProperties>())
                                 .connect(this, &QWrPropertiesEngine::onRequestTreeEvent));

Later I just need to process returned callback:

void QWrPropertiesEngine::onRequestTreeEventCEditorEventa_event )
    if (EErrors::isFailed(a_event->getErrorCode()))

    QPropertiesWidgetproperties = (QPropertiesWidget*)a_event->getUserData();


    autoevent = WR_RTTI_CAST_PTR(IEditorEventPropertiesa_event);



I like this approach so much that I will probably switch in game UI on the same basics. How it will go we will see but for now I fell that this is good decision.