Showing posts with label Language. Show all posts
Showing posts with label Language. Show all posts

Wednesday, 23 October 2024

Read the Screen

We are at the change of am epoch, moving from a time where we would mockingly tell someone to read the manual when they became stuck to now having to literally instruct people to read the screen.

 "READ THE SCREEN!"

If it is not an in your face, center of screen obscure everything until you dismiss it; or worse still a ping followed by a side of screen chat bubble; then users simply do not engage with it.

Time and time again issues arise where some user declares they are stick, some player derisively mocks a game as hard, or bad, because their little monkey brain did not tell them to read the screen.

Away from computer screens, apps and games, in the classroom their are standards to be met in fluency, fluent readers just see the text and can not but help to read the text.  One can forgive none fluent readers, or non-native speakers, when they struggle in this regard.

However the seeming trend one can observe is for native speakers of the language software is delivered in are unable, or unwilling, to engage and read the screen.

This trend seems doubly emphasized in gaming, where modern games design bread crumbs and way markers and all sorts of mechanisms to point the player to a conclusion or action.

Gone are the games of leaving the content and the player to mull over the opportunities, the sandboxing, in a game world.  There can be no more sandboxes, you can not leave a player washed up on a beach and expect them to work out all the mechanics and order to survive:

Tom Hanks makes fire for the first time | Cast Away | CLIP - YouTube

They are simply unwilling or unable to do so and instead opt for any game play sequence which achieves their aims and that internal self-satisfactory dopamine hit on achievement the quickest.

I believe the major driver to this change in play style is an absolute lack of willingness to engage with the screen and especially players avoiding reading.  The reading comprehension levels have dropped, I can make assumptions that some of this allowed drop in prerequisite levels can be draw between who is playing games along with the kind of games being played.

I do not believe anyone can deny video game players have taken this turn.  And in the market space it is understandable, if frustrating for those of us wishing for a more engaging and interesting game play loop.

Game makers have had to follow the trend to maintain the mass number of players and major titles, they can not and do not take the risk of making a game which is too hard, or has too high a cost of entry.  They want as many customers as possible directed to the short cut the masses to the feeding trough.

The recent vogue of playing World of Warcraft Classic in Hardcore mode is perhaps a phenomenon we can point to where players sought their own meta, to make the game harder and more engaging and I believe more fulfilling because it broke this trend.  If you played badly you died, you were not rewarded, if you did not engage with other players you died and you got them killed, you were ostracized not rewarded.

A literal case where if you were not up to spec you were actively nulled out of the pool, as perhaps Darwin Theory states nature should be.  It was refreshing, if nerve wracking, to see.

Beyond large new titles or established franchises indie makers are a little more able, and some of the most amazing experiences come out of that style of play, a style of play today considered niche, we must remember many of the game play tropes considered niche today were once mainstream.

MadseasonShow: Lifelong WoW Player Plays Old School Runescape
 

I remember fondly feeding coins into a machine to keep playing and death reset you to naught; without wishing to raise a tangential thought too eagerly, I would highlight that feeding coins into an arcade cabinet was the original micro-transaction driven game play loop and I'm surprised it isn't leveraged more widely today (it may very well be and I'm simply ignorant).

All this concern in the drop in seeming fabric of the game play experience all seems to me to stem from the audience attention spans having dropped, memory skills have dropped, social skills having dropped and crucially language skills have dropped.

We no longer interact like group oriented beings, even in team forming experiences, too many games proffer group finding, raid finding and instant way to find two, four or thirty players you hope to maybe mold an effective fighting force out of and it does not work.  I personally believe this is yet another tangential thought, but it is closely related to this degradation in attention and communication skills, as group finding actively assists such lone wolf selfish players to remain competitive, if not dominate, a play experience.

Wednesday, 18 January 2023

ChatGPT Poetry

I've had a play with ChatGPT, completely away from asking it to write or improve code snippets I asked it to generate some poetry...

Could you tell me a poem in the style of Wilfred Owen but about Strawberries and Skunks?

And here's the reply....

The strawberry fields, so red and sweet,
Are guarded by the skunk, so discreet.
He sprays his scent with such disdain,
To keep the birds and beasts at bay.

But man, with greed in heart and mind,
Does not let the skunk's defense bind.
He steals the fruit, so plump and ripe,
And leaves the skunk with nought but spite.

But in the end, the skunk prevails,
For though the berries may be hailed,
The smell of skunk, it lingers still,
And serves to remind us of our ill.

So let us honor the skunk's defense,
And give the strawberries their due recompense.
For in this balance, all is fair,
And all may share the bountiful air.

Tuesday, 10 January 2023

Prodj, Praw or Pro?

I've just had one of those moments, I speak with an accent from the British Midlands.  I've been told my accent is fairly neutral, but I know I have a Nottingham twang to certain words, and when I'm being lazy I can sound right common (that is lower-class).

The vowel constructs I know I'm worst at are "Op" such as "Open" and "Operation" and "Ov" as in "Over", and I often made even my wife's eyes twitch when I say "it's upen uver there" pointing at a shop or parking space.

Today however I'm picking on "Pro".... Now, as a British English speaker I've never had this issue locally, we all say "project" with a "prodject" sound, we don't stress the "pro"... It's a prodject, not a PROject to my ear.  It's like saying "podge" as in stuffed full of food, but with an 'r'.

Right or wrong this distinguishes that word with "Projector" and "projection", you know the habit of shining light through something to put an image on a screen or wall... that is "PROjection" when I say it.  And this has been automatic to me all my life and I've known what my peers at school, home and work meant we were all very local, so we all knew the distinction and never really thought about it.

However, working in game development with a very wide range of folks I've just been called out.

Talking about a project with graphics the projection matrix came up.... And yes, you guessed it, in the meeting I said (something like) "the prodject is coming along well, I'm using the inverse PROjection matrix to check a ray intersection".

I literally got called out at that point, never noticed it before, I've heard folks saying "PROject" but ignored them... The problem?

One of the folks happened to be from the North West of England (Manchester I believe) and he said... "PRAWject".... and "PRAWcessing".... Yeah, even I was twitching then.

Either way, it was an interesting moment.

Monday, 26 July 2021

Your Best Work?

The best piece of work you've ever done?

This is one of those subjective questions you can pose people, and you always hope that there's better to come, so really what we're asking a software engineer is "What is the best piece of software or project you've done so far?"

As technology is always marching on and new ideas are always emerging you can often say you're going to make something better, which is great, but it makes it harder and harder to pick out the best pieces of work from your portfolio.... Do you judge it by the number of users or downloads or how much money it made the company or even how much you were paid to do the work?

Monetarily the most money I've ever made on a piece of software was for a website I wrote in about two weeks in ASP & javascript in about 2002, which netted me the grand sum of £4000 for 80 hours work, literally £50 an hour.  But it wasn't the best work I ever did; I mean (snear) it was javascript.

The most interesting work I've ever done is the work I'm doing right now, but I can't talk about that.

So this leads me back a step to my long tenure at my prior employer, the best work I think I did, was a project to port the existing system to a new hardware platform; this involved reverse engineering the hardware interface and writing a new interface for the hardware abstraction layer for that particular hardware, which worked seamlessly and the whole system was agnostic as to which hardware type it was booted up upon.

This was not how that particular system was engineered, so in about four weeks I not only made the hardware interface an abstract interface, but also developed a test bed for the new hardware and then sewed the two together; four weeks in that environment was an incredibly fast turn around.

And it was extremely enjoyable.

That section of work was one of the best pieces of work I ever did.

Years later the creator of that hardware came to work for the company, he saw his hardware but our software and asked a few pertinent questions, for he thought his hardware was secure and could not be made to work on another platform without his secret sauce.  Let us just say it was fun to NOT tell him quite how I'd done the reverse engineering; unfortunately this reverse engineering nous set me up for the next big reverse engineering jail break required by the company, and it was a totally different kettle of fish and worthy of it's own post later.

Monday, 15 October 2018

C++: To Reference or Not

Constant Something Reference or Something constant reference... I ask myself this in a similar manner as Prince Hamlet at the start of the nunnery scene... For as a C++ programmer and English speaker I've always found myself most comfortable using the phraseology thus:

const int X (0);

And to pass this to a function:

void foo (const int& p_X);

I find this most useful, we're passing a constant integer reference to the function... However, I was recently challenged that this meant something else to a reader, her input was that it meant "constant integer" reference, that is we would ONLY be able to pass "const int" instances, not "int" instances.   The thinking being:

const int X(0);
void foo(const int& p_X);

foo(X);

Would compile, whilst:

int Y(42)
void bar (const int& p_Y);

bar (Y);

Would fail to compile or at least spit out a warning because "int" was not able to be passed into the function as "constant integer" and "integer" to this reader were different types.

They're not really of course, constant is a decorator (and one which we can remove with const_cast) the aim of using "const int reference" as the type is not all of our purpose in declaring the function like so, the purpose is to communicate what we do with the value going into the function.

It is 100% not about stopping Y being passable into the function as above.

No, we want to tell any user of our code that within the functions "foo" and "bar" we do not change the value, if they pass Y to us with 42, when the function is complete Y will stil contain 42.  If the value could potentially change we would not be able to use "const" that's the purpose of passing const in this case.

Passing by reference is just to save us the time, effort and delay in allocating memory and taking a copy of the parameter before moving into the body of the function, so:

void bar (const int p_Y)

Would be the same operation as above, we tell the user we don't change the value of the parameter, but we do because we take a copy of the value being passed in and operate upon it.

The communication we get with this is very useful.

But of course, if we're using threaded programming and we pass a reference to a value at time point A, then sometime later elsewhere edit the referenced value, we may run into unexpected behaviour, so there is an argument sometimes to take a copy at the point of instantiating the child function, in the most part however, passing by reference is considered the norm.

Tuesday, 27 February 2018

"Zeiger" The Missing C Type Link

I'm just looking at an old C Compiler, the first C compiler I ever used, actually... And, I'll be honest, I didn't live with C long, I moved into C++ pretty quickly.  So much so, I never actually read the this C Compiler's Documentation, here for posterity, is an exert...

Pre-defined Data Types
----------------------

      Type        sizeof      Bits            Range
      ----        ------      ----            -----
  unsigned char      1          8             0 to 255
  char               1          8          -128 to 127
  enum               2         16        -32768 to 32767
  unsigned short     2         16             0 to 65535
  short              2         16        -32768 to 32767
  unsigned int       2         16             0 to 65535
  int                2         16        -32768 to 32767
  unsigned long      4         32             0 to 4294967295
  long               4         32   -2147483648 to 2147483647
  <pointer>          4         32
  float              4         32   (+-)3.4E-38 to (+-)3.4E+38
  double            10         80 (+-)3.3E-4932 to (+-)1.2E+4932
  long double       10         80 (+-)3.3E-4932 to (+-)1.2E+4932
  Zeiger             4         32             0 to 4294967295


I have never heard of the "Zeiger" type, it's simply an unsigned 32 bit integer, but where does that name come from?

It's a German word, meaning pointer or hand, so I can only assume it's a pointer to some memory location and the machine this compiler is for, if I recall correctly had a 4 megabyte maximum address space, plus 64K of addressable ROM.  So a Zeiger would be useful to parse over any location in both, however it's not clearly stated in the information.

Zeiger is a reserved word in this compiler, and yet it purports to be ANSI compliant... Hmmm.... Thoughts as ever in the comments below.

Wednesday, 31 January 2018

C++ boost::replace_all Slowed Me

I've just had myself into a complete frazzle, code yesterday was fast, rendering 120fps, the same code today was struggling to pass 11fps.  And it had me pulling my hair out, of which I have little left to spare.

The problem?

I had been processing strings for specific patterns and only replacing them, so a variable in my engine might have the value "SCORE" and it'd replace the players score value directly into the std::string instance for display.

I however decided I wanted to compound all these reserved words to allow any value to contain any replaced value and also contain formatting, so I could so something like "You have scored %SCORE% today" and it'd just place the number in place.

I turned to boost for this, boost::replace_all, to be specific, and I had about 45 pattern matches which would try to replace any instance of the string in place.

However, this function does not look a head if the predicate is present in the source string, it's in fact very slow.

So code:

const std::string l_Pattern("%SCORE%");
std::string l_Source("You have scored %SCORE% today");
.
.
.
boost::replace_all(
    l_Source,
    l_Pattern,
    Player::Instance()::ScoreAsString());

Would result in very slow performance, my solution is not perform the replace... search for the pattern predicate first:

if ( l_Scource.find(l_Pattern) != std::string::npos )
{
    boost::replace_all(
        l_Source,
        l_Pattern,
        Player::Instance()::ScoreAsString());
}

This latter code runs so much more quickly, I'm far in a way back a head of the speed curve, but I have this lovely dynamic placing of the variables into my rendering controls, and any control can receive any value just by my tweaking the loaded display script, so neat....

Anyway, I hope that helps.  If you want to help me, pop over to my YouTube channel and hit that subscribe button.

Wednesday, 27 December 2017

C/C++ Stop Miss using inline.... PLEASE!

This is a plea, from the bottom of my rotten black heart, please... Please... PLEASE stop miss using the inline directive in your C and C++.

Now, I can't blame you for this, I remember back in the 90's being actually taught (at degree level) "use inline to make a function faster", and this old lie still bites today.

inline does not make your function faster, it simply forces the compiler to insert "inline" another copy of the same code whenever you call it, so this code:

#include <iostream>

inline void Hello()

{
    std::cout << "Hello";

}

int main ()
{
    Hello();
    Hello();
    Hello();
}

Turns into the effective output code of:

int main ()

{
    std::cout << "Hello";

    std::cout << "Hello";
    std::cout << "Hello";
}

What does this mean in practice?  Well, you saves yourself a JMP into the function, and the position on the stack holding the return address, and the RET from the function which pops off the stack and returns from the function.

This is WHY people were told to use inline to make things faster in the 90's, I was taught this when I a system with around 254K of working RAM for the programs I was writing, saving that space on an 8K stack was important in complex systems, especially if you were nesting loops of calls.

However, today, on a modern processor, even modern embedded processors, DO NOT DO THIS!

You're no longer saving anything, you're in fact making your code bigger and slower as suddenly your program expands in size and you are having to fetch more and more from the slower RAM layers rather than the program instructions page fitting into the lower CACHE layers.

As you get page misses you fetch more, you literally stop the program and switch context to another item and then switch back, literally halting your program in its tracks as it suddenly had to go load the N'th of possibly thousands of repeated stanza's of code.

Don't do, this, don't lumbar yourself, let the compiler handle it's own optimizations, they're pretty good at it!

Now some of you will be saying "yeah, no shit Xel, what's your point?"... My point is I recently had around 4000 lines of code handed to me, a huge long listing, and around 40% of it was a series of functions.  This whole thing could compile down to around 62K.... But when compiled it was just over 113K... This was too big to fit into the memory of the micro-controller it was for.

The developer had been working merrily over the yule tide, happy and satisfied their code would work, they went to work this morning and instead of running the code on the IDE within an emulator, they actually ran it on the metal.

It crashed, and they couldn't figure out why, the size was why.

And then they couldn't work out why the code was so big... It is tiny code.

They came, cap in hand, to myself - and I took no small satisfaction in rolling my eyes and telling them to remove the "inline" from EVERY function... "But it'll run so slowly" they decried... "REMOVE THE INLINE".

Of course it works, they have the system fitting into the micro-controller RAM, the stack is working a lot harder, their code is a lot smaller, and they are now in possession of a more balanced opine on "inline".

* EDIT *

One person, yes hello Hank, asked me "why", why was this a not a problem on the emulator, but was a problem on the bare metal, well the bare metal was using a different compiler than the pseudo compiler for the windows based IDE, the Windows based IDE was actually running the code through a compiler which ignored "inline", and so produced code a little like this:

(Image Courtesy "CompilerExplorer")

You can see that even though "int square(int)" is marked "inline" it contains the push to the stack and the "pop ret" pairing, and making it a call from main results in two function calls to the same assembler.

The bare metal compiler did not, an undocumented difference I might add.

Tuesday, 18 July 2017

Speak More Slowly Please

I'm English, this means I speak English, or at least a dialect of it... This mere fact has furnished me with the ability to communicate to a myriad of other people, of different nationalities and inclinations.

However, it completely alienates me from the French.

Well, a certain sub-set of French speakers, whom simply are rude... Now, I'm sorry, but these people exist, and good on them, they want to protect their beloved French language from the likes of me, coming along speaking it with a terrible rich British Midlands accent.

I accept that.

I'm not trying to compose poetry in French, I'm just trying to communicate with someone, so when I say:

"parlez plus lentement sil vous plais, je ne pas parlez Francais bon"

I think I'm asking them to speak more slowly please, as I don't speak French very well.  I don't expect them to stop the conversation completely, roll their eyes and then turn their back on me.  That's rude.

And this wasn't an isolated case, since the mid-90's it's happened a few times.  And every single time it annoys me more.

When a French person speaks to me with strongly accented and semantically incorrect English, I of course listen to them, I'll even take a stab at working out what they were intimating, I'll smile and maintain eye contact, reassure them they are okay to just try... Very much a "we'll get there together" feel to the conversation.

Some French speakers however... Just Rude.

There, I've said it, I'll leave this here....

This post also may give away why there's been a small break in posts for the last half month... No I've not been anywhere, but I have been extremely busy.

Monday, 8 May 2017

Software Development : Get Constant in C++

What does "const" mean to you?  Does it just mean a value can not be changed?  If so, you may want to read on!

Const is one of those things, which though not unique to C++ is given more meaning when you leverage C++ fully, const allows you to not only define a value as invariant, but also to instruct other programmers coming to your code how a value should be used, how when it is passed as a parameter it should be treated and ultimately how to protect data from needless alteration, de-synchronisation or simple corruption.

Const is therefore your friend, and if you've come to C++ from C, Java, C#, Python or one of the other myriad of languages which don't treat const with as much relevance as C++ you may want to read more than I can say on the topic. 

Bjarne Stroustrop (the inventor of C++) and other authors on the topic (notably Scott Meyers & Herb Sutter) explain in much more detail than I ever could, but for brevity here are two examples of const from my own coding standard which I implore you to digest.

1. Initialise Const Values in the constructor ONLY....

Any instance of the "Ex" class can now access it's "Pi" value, and we communicate to all viewers that the value is a constant and only edited in one place.

2. Where-ever possible pass values as constant references....

We know for certain that the "p_Radius" parameter being passed is NOT to be changed by the function, this is important when you are thinking about letting code document itself, and easily accomplished with "const", and especially annoying when using a language lacking const!

Whatever you do, use const consistently, this needs no specific explanation here, however if you begin following my second rule, you must stick to it!  Don't change half way through a program, if you import a third party API which is not using const in the same way, abstract that third party interface away with a series of your own shims, to make it correct for your usage (the compiler will optimise all these layers away) to leave you with consistent and more easily maintainable code.

You can find must much more about const-correctness elsewhere, I'd start here.

Friday, 1 April 2016

Coding Standards: Functional Programming (Code Maintainability)

Functional Programming

When I were a lad, and was being taught to program, I read a bunch of Basic code and wrote great long lists of instructions; that's pretty much how many people in the 90's described programmers, coders or hackers "someone who spends lots of times typing great long lists of instructions into their computer" - Robert X Cringley.

However, long lists only get you so far, so my next step into the world of programming was to learn Pascal, and I first read a simple book as part of my A-Level, by P. M. Heathcote, which introduced very basic programs in Pascal, something like...

program HelloWorld (input, output)
begin
    println ('hello world');
end;

So, I suddenly had this idea of putting the long lists of instructions into sort of functions:

program HelloWorld2 (input, output)

   procedure foo()
   begin
       println ('foo');
   end;
   
   procedure bar()
   begin
       println ('bar');
   end;
   
begin
   print ('hello ');
   foo();
   print (' and hello ');
   bar();
end;

(Note: before you call me out and say you can "GOSUB" or "CALL" other functions in BASIC, not in the dialect I first learned, all you could do was SUB to a line number, following the instructions until you used RET to go back to where you were... So they were technical functions, or procedures, but they were really just more lines of code within the huge list of lines of code, no indentified in anyway, except by comments, as being functions).

Interestingly at this time, I was taught there were two kinds of functions you could call, ones which returned a value, known as "functions" in Pascal, and ones which didn't return anything known as "Procedures".  These latter you'll be very aware of from other langugages like C, where the return type is part of the function declaration, so "void foo();" obviously doesn't return anthing, whilst "int bar();" returns an integer.

That "Procedure/Function" definition stuck with me a long while, I was a kid, I was taught something and got a certificate to say to the world "He knows what he's talking about", so it was with some trepidation, years later, that I had to admit it was rubbish and everything was a function.

And this revelation came with my being taught about "Functional Programming", this was important for large projects written in languages like C, because you really wanted to start to learn how to keep functions doing one task.  So when you designed, named, write and test a piece of code, you can break it down, and know each piece, or each function, is doing just one job.

"void Max(const int& p_Left, const int& p_Right, int& p_Result)"

Here I've just defined a function prototype, even without my explaining, I'm pretty sure you could guess what it does... Yes, it takes the left and right integers given and decides which is the bigger, placing that value in the result.

We can design code, define the prototype, and hand the nitty gritty of the actual code body of to someone else, to write the body of it, or just to test our implementation works.  And though this is a trivial example, think about a single function to say format a disk, it might contain calls to dozens, or hundreds, of other functions, but it itself does one task, and each sub task is itself kept in a single function so you break the whole job down.  Within your large projects therefore you maintain a level of ease in how to debug, maintain and update the code, if your "foo" function doesn't work, just fix that one function and re-test, there shouldn't be multiple-foo's and there shouldn't be more than one task performed within the code inside "foo".

This was the first major meeting, and teaching, I had on "Functional Programming", and it was something I took to heart.  My code took on very much a "one function" style, where each function had a single purpose.

Twenty years on, and even in an Object Orientated world (of C++, C# and Java) I utilise the functional idea.

The main thing applying the single function ideal to my code has lead to is a vast improvement in maintainability, this has been important for my job and on going sanity with large projects.

However, there are other caviates, for there are other parts to functional thinking which have to be taken into account.  For example, are you going to allow functions in your code to have just one, or multiple exit points from a function?  For example:

const int bar (const int& p_i)
{
   return p_i * 2;
}

const int foo ()
{
    if ( x > 0)
    {
        return bar(x);
    }
    else
    {
    return bar(-x);
    }
}

This is perfectly reasonable code, foo does one job, deciding upon the value of x which value to pass, however, this is a trivial example, what if there are tens, hundreds or even thousands of different paths you could take as the result of foo?... A case statement with every character possible already throws hundreds of options our way, so it's not out of the ordinary.

You could be tracing through this code and ANY of those many exit points could fail, causing a crash, which you then have to dig through after the stack has all unwound.

Using many exit points is fine, if you can justify it, please don't get the impression I'm hating on the concept, if you have a low memory situation for example, I can see you won't have space spare for my suggested solution; and this is part of the many trade-offs you will learn about in a career of programming, when to, and when not to employ a technique.

But in the above example, I would change foo as follows:

const int foo ()
{
    int l_result = 0;
    if ( x > 0)
    {
l_result = bar(x);
    }
    else
    {
    l_result = bar(-x);
    }
    return l_result;
}

So, you see I have a local value copy, this is using more memory, and wants to allocate that memory... and there are other options than allocating that as a local variable, but for maximum maintainability keeping that value within the actual function is a key feature of this example.

And so how does this assist in maintainability?  Well, we can now debug the function a lot more easily, we can see the value of "l_result" at any moment in a watch within the debugger, we can wrap individual - failing - calls to "bar" into try-catch statements and debug the returned value for the whole function at the return at the bottom.

I've seen some horrors in the poor use of both returning from within a function, where return points are hidden three, four or more nestings deep, and it's made for nothing but frustration, try to avoid multiple function exit points.

What else does functional programming offer us?... Well, it also offers us an easy way to make code self-documenting, if we have a function like the "max" function earlier, it explained itself in just it's definition, take advantage of that fact.

But what about functions inside objects?  I hear you cry, well lets take a pure C++ example, in C++ (or at least most C++ compilers) we're allowed to just define a function prototype and go to town, but that's really; technically; C not C++.  To make things C++ we really should have the functions all inside a class definition... I stick to this idea, even if we just need a pseudo class of static functions:

class Helpers
{
    public:
    
          static void Max(const int& p_Left, const int& p_Right, int& p_Result);
          
          static const int Sum(const int& p_Left, const int& p_Right);
          
 };

 One can see what the functions mean, and the function have meaningful names, the class itself can have, a useful name, and indeed the class can then be in a namespace which itself has an even more useful name.  So we build up not complexity, as some assume, but ease of division of functionality, breaking numbers from user interfaces from strings from file management, break it down, divide and conquer, that was the original purpose of functions in computing, and so that original function is now emphasised in the languages and methods we employ today.

 C++, C#, java, Python, all can benefit from using the function idiom... Your projects certainly can.

Wednesday, 23 September 2015

Genius Lash Back

Yesterday's post about the "Genius Programmer" effect has had a ricochet, had a colleague, come over and bemoan me for not appreciating ability, and he had me fire up his new website... lots of PHP, lots of HTML and a smidgen of JavaScript... "There" he declared "proof I'm a decent programmer".

*cough* I interjected

"What?" he asked, puzzled.

"No you really don't want to hear my thoughts" I said, concentrating on the screen "it's a very nice site, very swish, is this javscript drive?"

But he already wouldn't let it go, "tell me what you're thinking?"

"All right, I think this isn't programming, this is scripting, coding at best, it's making a virtual environment do something, lots of the site here is from other libraries you've just brought them in by copying and pasting, that menu is just copied and pasted from one on another site, the art work is generic, and you've more stuck existing blocks and ideas together than created anything new"

For you see, I do see the Software Engineer category to be sub-dividable, you have classic programmers, working on the bare metal, or at least working on an emulation of the bare metal.  Then you have coders, who are essentially working in an interpreted language, so for the most part they're coaxing a virtual environment to do their bidding, and working around it's quirks whilst that environment obfuscates the metal below them, many programmers find themselves stuck being coders when they walk into java or C# roles.  But Python, java, perl, C# even some variants of Basic are all making coders out of people and fair do's to them.  Then there are scriptwriters, these are people writing scripts for other uses, so you have bash shell, DOS batch, JavaScript all manner of scripts, I find scripts to be a little like programming the VCR used to be, they have their nuances, but they're all basically the same and like programming the VCR they are very direct and set to a purpose, you can't make the VCR bake bread, but it will record Emmerdale without a fuss.

You could take this as a disparaging belief, but please don't, I think anyone creating actionable code, be that in a language, a script or via physical direction, all have their place and each technology has it's niche, many of us know and work in multiple languages for this very effect, I for example have been heavily using Python for two months, but I still consider my main role as a programmer to be C++, and then coding as C#.  I know Java enough to get by, but I don't consider myself a java expert.  I like C for certain things, but I compile it with a C++ compiler, so I'm not doing pure C unless it's on my old Atari's, so that's just a hobby language, and the same goes for Pascal.

But knowing I have this depth of experience to draw on, lets me move an algorithm, or a solution to a problem from one realm to the other... Take this all back to my colleague...

He copied blocks, used pre-written libraries, and generated the vast majority of his site through not knowing anything, but my copying.  "Great Artists Steal", and yes he stole this site and it looks great... But does that make him a programmer?  Far from it.

Thursday, 6 November 2014

Story Time - French Souvenirs

Souvenirs... When I was a kid I used to go places, I can't afford to go places any more, but when I was a kid I went to places... And everywhere I went I bought the family little gifts back, to remind them how much they like me, kind of like emotional bribes, so I could gauge how much they did or didn't miss me and suck up to them and retake my place in the pecking order of bullshit... No, no in reality it was just something we did... we got little gifts, little souvenirs.

Now, I understand you buy yourself a little souvenir, so you remember your trip... like from Egypt I have really nice bed covers, and they're over 14 years old now and I still remember being asleep in Egypt everytime I go to sleep in England...

But when I was a kid I brought gifts back to others... France, Twycross Zoo, the Royal Concert Hall Nottingham, Wollaton Hall Nottingham... Nottingham Castle!... All these little places made a little bit of cash off of me and I remember to this day that no-one really kept these little things.

Except one person, my Nan... She still has a painted rock I bought her from France, it was just a washed rock from the beach, someone had painted a scene of a harbour on it... Only now odes it strike me as strange, because we neither visited, nor saw, a harbour.  The shop I got it from was around the corner from the hotel we stayed in, and the hotel was just on a road in the middle of a Pas-De-Calais town, very dusty, a little smelly and I remember getting told off for throwing Marmite sandwiches from a window... when a) I didn't have any Marmite sandwiches and b) don't like Marmite!

The Hotel had dubious plumbing, the escape ladders were made of copper pipes and looked so unsafe as to make you wish you could just throw yourself out the window.  One of the toilets would not flush.  And the food was so bad that I think of the whole 5 days of meals they served we only ate one and that was the one with chips (fries)... They served raw fish, horrid paté and just guck.

When we ran into a local we either made friends or hated them, very much like the aforementioned Marmite in that respect.

But this was the 1990's, still before everyone spoke English, so it was a struggle to actually communicate, not least because most of us were pre GCSE, we were year 3 as was, not year 4/5 and only got on the trip to make up numbers.

However, I do remember my first application of French, we were dumped on the outside of a town by the bus.  Totally alone... this would never happen today, and I think only happened because the three French teachers wanted to go to a bar and get more drunk, however, dumped on the outskirts of this town we were told in the middle was a market and we had to make our way there and ask at least three people directions....

This turned into me walking a head of a group of kids my age, because I was confident - with a then brown belt in Karate I was pretty happy I could fight off an attacker, be they French or otherwise.  So we marched through this town like the Germans in 1940 had.

Two French kids kept staring and shouting something at us, so I gave them a Nazi salute... Literally the finger under the nose and arm out... they ran off in shock... Only later did I find out this was illegal...

We turned this corner and were basically in a dusty looking, very hot summers day, street lost... There was a man in his garden so I went to him...

"Excusey moi missuurrrr"  I still speak French like this, so must sound like a retard to them, but that's a whole other story...

"oooooo eweeeeey lay marrrrrr-shhheyyy ssssiiiii vvvvooooo play"

Meaning, I thought "Excuse me sir, where is the market please?"... He looked at me, and snored, turned his back and went into his house... I fucking tried al-right France, I tried, and you were so rude to me... If you come here and falteringly ask in English "Where's the market please", I'll tell you, and even help you along so I understand you... I won't just snort and walk inside my house.

I dunno, all these years later I remember him doing that, maybe I turned him on, maybe he went straight in and started furiously masturbating.  Whatever he actually did all I remember is "he's a French wanker"... So, well done him for casting all the stereo types about French people listening to others attempt to speak French.

Around the next corner however our saviour appeared, a man in the street, walking a long, he was smoking, wearing a leather jacket and a black polo neck - on this hot day - he looked the typical French guy... I hit him with my now famous line... and he looked at me puzzled, then in a broad Leeds accent said... "Just round that corner mate".

Tuesday, 18 March 2014

C++ (Passing by Reference) Programmer Insecurity

Sometimes even the smartest, and I mean proper mind blowing good, programmers can have an off day... And I just ran into one.  Now, let me just say I consider myself a good C++ programmer, and an excellent Pascal programmer, I prefer C++ however and am taking every chance I get to use it, and use it cross platform.

Now, the chap I'm talking about, is a bit of a mega brain, he is really good, but he's just had a massive problem on his hands, and I don't think he liked my input...

First of all, he was working with "int", on a 32bit machine... But he was using this "int" as an unsigned value... So why not use "unsigned int"... apparently, he is having the kind of day where he doesn't want to type "unsigned " everywhere, so I suggested, replace "int" with "uint" and do "typedef unsigned int uint;" the silence was palpable...

He did it, and his code started to work, but it seemed he really wanted to just continue having an off day, rather then have me intereject with a solution...

Secondly, when he was done, he was getting a lot of memory used, he reckoned his code was fast and not creating copies... "int ValueReturn (int _lhs, int _rhs)".... A second suggestion, which I gave him via another member of staff "void ValueReturn (const uint& _lhs, const uint& _rhs, uint& _retVal)" to cut down the number of parameter copies and return copies he makes also went down like a tonne of bricks, he's stormed off, moaning that "that lot are a bunch of know it alls"

I can relate to his frustration, he's had a major problem, and we've effectively solved it for him in a few seconds, with what could be assumed to be obscure pieces of C++ code, but these practices of passing by reference, and even constant reference, and if you want to avoid creating more memory returning a reference to an [in/out] parameter is all normal fair.  Scott Meyer points this out a lot in his books.

I think I grew out of this tantrum "my code is right, the system is wrong" attitude about three years ago, it feels longer, but I know it takes a long time for a programmer to be comfortable enough with their ability to sit back and say "yeah, I got that wrong" and fix it, rather than think admitting fault lowers their value to everyone.  I certainly know from experience that those programmers who sit on their pedestal and are never challenged about shoddy code they do (even code which gets the job at hand done) will never progress and improve.

Anyway, something funny...


Saturday, 5 October 2013

General Programming Tip: Control Alignment on Different Resolutions

I'm going to throw a piece of advice out there, to professional developers, and it might be a piece of advice many don't stumble upon.

Aligning things on your screen... If you have a piece of software, which fills the screen, or has a known size today, don't align the labels or controls on it to just fit that screen, use tricks like dock, and flow layouts, and alignments to layout the screen for any resolution.  It'll take more time now, but if you are planning to support the software on multiple platforms, or for many years, then it'll all be worth while.

Today your screen might be 800x600, and your label plonked on it might sit nicely...


But tomorrow...



Its a higher resolution, and its off to one side... So how might we quickly get around this?  Well, with a single label, its easy enough, make it fit the width of the screen, set the alignment to center... and voila.


Your text will always sit right... and this is a two second job... other patterns to achieve this take longer, but think about it now, save yourself some time in the future!

Saturday, 27 July 2013

LOTRO - Disappointing English

I played LOTRO when it first came out, I played a Dwarf and soon hated it.  At the time I was not willing to pay for the game - and since it went Free to play that barrier has been removed, I still don't play it, and I had to ask myself why?

Well, the look and feel of the game, I don't like, its awkward looking and I remember it looking pretty dated.  Things might have changed, but I'm simply not willing to download the mammoth sized download just to find out.  And I don't trust other peoples rigs capturing video, because their rig is not my rig.

But I don't think things have turned up very much in the quality, not least because this game representing one of the biggest names in English Literature, a book which sold so much in the twentieth century as to overshadow everything around it... this ENGLISH book through and through gets advertising mail like this:


"Through August 6"... its so yankie doodle fucking dandie.  Its not even correct English, and I hate that...

"Join the festivities from now until the 6th of August" would have been the more correct, Hobbiton, fashion of writing this, and its more meaningful.  The moment I see US tailored brain dead English like this I disengage with the topic, I don't want to have to wade through it, if you work in PR, then for god sake work in Language, not colloquialisms.

I think this is a personal peeve with the slap dapse approach to PR from across the Pond in the US of A, a better example of this might have been the birth of Britains new top baby boy, Prince George.


Lots of US news outlets were reporting him to be a new "to be" KING OF ENGLAND.  We don't have kings or queens of England, its the United Kingdom of Great Britain and Northern Ireland (not to forget all the commonwealth realms - Canada & Anzac loving vibes to all - across the globe)... But oh no "England" they came up with... Hey ho...

Maybe when Scotland vote on their independence the US news-tards can get that all to cock and someone will give a shit, they don't seem to give a shit when they piss off the English, but you pick on a "minority" and you get focus.