Showing posts with label students. Show all posts
Showing posts with label students. Show all posts

Wednesday, 28 November 2018

Budding Programmers.... Subscription to Learn

Harping back to my prior post about learning to program, when I spoke at my old Uni, I spoke to a lovely trio of ladies, whom wanted to be programmer/computer folks... And one thing struck me, was how narrow their knowledge was.

When they asked me how I got into programming and I explained that when I learned to program in the 1990's there was no github, indeed there was no internet, you could not just go and download a program or join an open source project.  If you wanted tool, and had no BBS dial up to find someone with something like it, you wrote your own.

I wrote code to record kills in games on the Atari ST, I wrote text editors for the ST and DOS (EGA graphics FTW), I write 2D painting programs for DOS.... I distinctly remember my college tutor seeing my using DOS interrupt 11 to control the mouse and his saying "you're the first person I've seen work that out"... I didn't work it out by trial and error though, I worked it out by reading, about the DOS platform, about BIOS, about my machine.

Today folks seem to know more about the bits they're interested in, than the whole machine, because they're not driven out of the comfort zone to explore and push the boundaries.  If today you're only interested in writing a neural network, you don't have to get your hands dirty with nodes or sigmoids or anything really, you can just get google to do the thinking for you, indeed they can even provide the solution.

So, I say folks, if you are of a technical bent, whenever you do a task, even if you use a pre-formed library, take time to explore what it does for you, look at your machine could it do things better.

A notable interview technique I've seen in action (and indeed practiced) is to give someone a multiple looping piece of code and ask them to edit it... It works single threaded, but could be multiples of times faster, I want to know if they think about threads and lambdas, and then I also want to know whether they think about the machine itself... Do they think about the number of cores, to optimise the number of threads being sprung up?  Do they think about cache hits and cash orientation of data (row verses column order)?....

And I want to know if tech folks read this, and they don't know about cache hits, or finding the number of physical processors, that they take heed and go look at and think about how to accomplish those points!

To that end I have a set of sites for such folks to subscribe to, along with my pages here of course...




And then look for conferences in the language you want to study... Lets say C++....


C++ Now (formerly BoostCon) 

Many folks pay to attend virtual ticket tours of game conventions, why not also take the time to follow the computer languages?...

Saturday, 17 November 2018

Can you Learn to be a Programmer...

I was asked this very interesting question this week... "Can you learn to be a programmer?"... Lets be clear, the question is can you be a programmer, not can you learn to program.  I believe anyone can learn to use a programming language, to drive their computer to perform a task for them, after all computers are tools and everyone can learn to use any tool.

Be a person trying to write a batch script, create a spreadsheet to do their home accounts, throwing together some python to process a few text files or creating a whole compiled program of some kind, pretty much anyone can make themselves, with a book, a little internet searching and enough time, appear on that bell-curve of skill.

Does this therefore make everyone a programmer?  I think it most certainly does not.  I can pick up a saw and a hammer, I have in my time knocked out some dovetail joints and repaired the odd chest of draws, does that make me a carpenter?.. NOPE... And likewise, if that self same carpenter picked up their laptop and wrote a bit of C# to tally the number of planks they use they are not a programmer.  He has programmed, just as I have knocked some holes in wood, but one does not transgress nor deign to call oneself the other; it would be insulting to the skills in the craft inherent to each's own chose trade.

And there's the key phrase, chosen trade.  Anyone can program, but to be a programmer you've got to choose to apply yourself, either through some personal interest, a passion, experience and ability at the task.  You must strive to learn, to expand and to know your craft.

Very many folks come to try and be a programmer after learning simply to program, throwing a few lines of code together is not enough; certainly not in my mind it is not enough.

Why do I say this?  Well, I sat down this week with several lovely students at my old Alma Mater, and I was bereft to hear from Computer Studies and Systems and even Software Engineering Students that they hadn't really programmed anything before, they asked me "how do you get into programming", "what should I program to get better at it [programming]" and they indeed asked "can you learn to be a programmer".

I of course come from a different place in time, which they pointed out with their shock and awe, when I answered they should write programs to support what they are interested in, if they're interested in video film making, write a video encoder or player, if you like games, write some games, if you're not sure just write some programming tools you can use... Say you (like me) repeatedly have to created code to write our structured data (say XML) then write yourself a tool to generate that code in whatever language you need it (I have one written in Python, which generated XML loaders for C#, C++ and Python itself).  I did this because I needed a tool, specific to my needs.  But these students were a little shocked, they asked "why not just get it from github (or wherever)"... And they're right, you could most likely find exactly the solution you want from else where...But... Would you learn anything doing so?... No.

Folks, students if you are reading, you are there to learn, we are in the programming craft to learn, you will not learn without doing.  So, yes use whatever is at hand, get the jobs done, solve the problems of today, by using libraries or leveraging a package manager to get other resources into your projects.  But if you opt to use a library today (like I used tesseract recently to do some OCR for me) when you're done, take a moment, take stock, look what that library does, think how you might do it, try to implement your own even (variations on the same theme).

In this way you will learn more and experience more and feel more confident in your own skills.

Wednesday, 4 March 2015

C++ Cock Ups - Tips on Programming C++

Spot the problem in this code... I've just summarily rejected a piece of code from a developer, and they're being really really pissy about it, they're in fact being so pissy they've been moaning about me in the kitchenette at the side of the office, and the people they've been pissing and moaning at about me have been coming to me laughing that the guy can't work out that he's in the wrong and his code is shite.

Now, I'm not able to post the full code, it's a commercial product, however, I will give you a quick over view... Here's a sort of example:

#include <iostream>
#include <sstream>
#include "CString.h"

char* IntToString (int value)
{
std::ostringstream s;
s << value;
return s.str().c_str();
}

int main (int c, char** v)
{
CString str (IntToString(c));
std::cout << "There are: " << str << " parameters" << std::endl;
}

Now, this is pretty much how part of his program looks, that "IntToString" function is taken straight from his code, and it's horrible, but he really can't see why...

So, can you see why folks?...

Right, well, first things first, and this is the elephant in the room... Why the fuck has he reimplemented String?... He's written his own "CString" function to wrap character pointers as strings of characters, and he's done a bad job of that because he's done this:

char* buffer = new char[256];
delete buffer;

Yeah, see the mistake?... He doesn't, I've pointed out "delete[]" to him several times elsewhere.

But, yes, despite using the standard library for "string stream", he's not used "std::string"...

So, changing the code above:

#include <iostream>
#include <sstream>
#include <string>

const std::string IntToString (const int& value)
{
std::ostringstream s;
s << value;
return s.str();
}

int main (int c, char** v)
{
std::string str = IntToString(c);
std::cout << "There are: " << str << " parameters" << std::endl;
}

So, we've used "std::string", we've fixed the return type to be a constant, and also made the value input to the function a constant reference, so we don't copy the value into a new integer before passing to the function - I know a 4 byte integer is trivial - bit imagine copying a 2MB class, or a 35mb image before passing it!

However, I'm still not happy with this code... In this project, in all my C++ projects the boost libraries are always made available, they're built ont he platform for the project, and go along with it as a "contributing" library of helpers, to stop people reinventing the wheel.  On the office wall, printed on the notice board in the very kitchenette the moron has been moping around in there is a print out of several template functions we lilke to use.

These template functions are also included in a "Framework.hpp" file, which I tell all contributors to use, inside there is a function:

#include <string>
#include <boost/lexical_cast.hpp>

namespace Framework
{
class Helpers
{
private:
Helpers() {}
public:

template <typename T>
static const std::string ToString<T>(const T& p_Value)
{
std::string l_result("");
try
{
l_result = boost::lexical_cast<std::string>(p_Value);
}
catch(const boost::bad_lexical_cast&)
{
// Report
}
return l_result;
}

template <typename T>
static const T FromString<T>(const std::string& p_Text)
{
T l_temp;
try
{
l_temp = boost::lexical_cast<T>(p_Text);
}
catch (const boost::bad_lexical_cast&)
{
// Report
}
return l_temp;
}
};
}

These functions let you convert any type to and from text easily, and you don't reinvent the wheel...

Someone did point these out, "Why not just use helpers in the framework?"...

Which would tell me to do "Framework::Helpers::" and see what the code completion came up with, at the very least, or just to go look at the Framework.hpp file, this guys response was apparently:

"I can't, the constructor is private, and when I make it public I can't see the to and from string functions in the instance of the class I create"

Just, the... ah... This is a "graduate" programmer, who considers (at least according to his CV) himself an expert user of C++ for over 4 years, expert in C++11.

I swear to god, the guy is testing my patience to the max, not least because he just moans all the time, and most of the time, it's just his being shite.

I mean, I've moaned before, moaned whilst coding systems, whilst coding parts of things, sometimes warranted, sometimes not, but I don't think I've ever put my foot as far in my mouth as this guy has ever, ever!  And I once accidentally text'd a manager pondering why said manager was such a wanker!

Hey ho, I wish the office was not open plan, I'd like to take the guy aside and explain to him these problems, thede deficiencies in his knowledge, but there's no private space, I may send him a mail asking him to hang back to talk when others have floated out, most of the other developers disappear after 4, and all are usually gone by 6; it's only myself doing the later hours in general.