I’ve been using the PGI Compilers along with CUDA to do GPGPU development for some time. The compilers themselves are fantastic – OpenACC support, OpenMP support and loads of other cool things.
Recently I upgraded to CUDA 5.0 and noticed that a number of programs now failed to compile, as the compiler wasn’t seeing CUDA 5 correctly. After a while searching the docs, searching the errors and doing big dirty greps, I eventually stumbled upon the answer.
To override what the PGI compiler thinks the correct CUDA version is, simple create a file called .mypgirc in your home directory with the line set DEFCUDAVERSION=5.0;
Every aspect of your life is a choice. There are default choices: you can choose to sleepwalk through your life and accept the path that’s laid out for you. You can choose to accept the world as it is… but you don’t have to. If there is something in the world you feel is wrong, and you have a vision of what a better world would be, you can find your guiding principle, and you can fight for a cause. […] Think about what matters to you, what you believe in, and what you might fight for.
James Maguire’s article raises some interesting questions as to why teaching Java to first year CS / IT students is a bad idea. The article mentions both Ada and Pascal – neither of which really “took off” outside of the States, with the former being used mainly by contractors of the US Dept. of Defense.
This is my own, personal, extension to the article – which I agree with – and why first year students should be taught C in first year. I’m biased though, I learned C as my first language and extensively use C or C++ in projects.
Java is a very high level language that has interesting features that make it easier for programmers. The two main points, that I like about Java, are libraries (although libraries exist for C / C++ ) and memory management.
Libraries
Libraries are fantastic. They offer an API and abstract a metric fuck tonne of work that a programmer doesn’t care about. I don’t care how the library works inside, just that I have a way of putting in input and getting expected output (see my post on abstraction). I’ve extensively used libraries, even this week, for audio codec decoding. Libraries mean not reinventing the wheel and reusing code (something students are discouraged from doing, as it’s plagiarism, yet in the real world you are rewarded). Again, starting with C means that you appreciate the libraries more.
Memory Management
Managing your programs memory manually is a pain in the hole. We all know this after spending countless hours finding memory leaks in our programs. Java’s inbuilt memory management tool is great – it saves me from having to do it. However, if I had have learned Java first, I would assume (for a short amount of time) that all languages managed memory for you or that all languages were shite compared to Java because they don’t manage memory for you. Going from a “lesser” language like C to Java makes you appreciate the memory manager
What’s so great about C?
In the context of a first language to teach students, C is perfect. C is
Relatively simple
Procedural
Lacks OOP features, which confuse freshers
Low level
Fast
Imperative
Weakly typed
Easy to get bugs
Java is a complex language that will spoil a first year student. However, as noted, CS / IT courses need to keep student retention rates high. As an example, my first year class was about 60 people, final year was 8. There are ways to keep students, possibly with other, easier, languages in the second semester of first year – so that students don’t hate the subject when choosing the next years subject post exams.
Conversely, I could say that you should teach Java in first year and expand on more difficult languages like C or assembler (which should be taught side by side, in my mind) later down the line – keeping retention high in the initial years, and drilling down with each successive semester to more systems level programming.
There’s a time and place for Java, which I believe is third year or final year. This will keep Java fresh in the students mind while they are going job hunting after leaving the bosom of academia. This will give them a good head start, as most companies are Java houses in Ireland.
In computer science, abstraction is the process by which data and programs are defined with a representation similar to its meaning (semantics), while hiding away the implementation details. Abstraction tries to reduce and factor out details so that the programmer can focus on a few concepts at a time. A system can have several abstraction layers whereby different meanings and amounts of detail are exposed to the programmer. For example, low-level abstraction layers expose details of the hardware where the program is run, while high-level layers deal with the business logic of the program.
That might be a bit too wordy for some people, and not at all clear. Here’s my analogy of abstraction.
Abstraction is like a car
A car has a few features that makes it unique.
A steering wheel
Accelerator
Brake
Clutch
Transmission (Automatic or Manual)
If someone can drive a Manual transmission car, they can drive any Manual transmission car. Automatic drivers, sadly, cannot drive a Manual transmission drivers without “relearing” the car. That is an aside, we’ll assume that all cars are Manual transmission cars – as is the case in Ireland for most cars.
Since I can drive my car, which is a Mitsubishi Pajero, that means that I can drive your car – a Honda Civic, Toyota Yaris, Volkswagen Passat.
All I need to know, in order to drive a car – any car – is how to use the breaks, accelerator, steering wheel, clutch and transmission. Since I already know this in my car, I can abstract away your car and it’s controls.
I do not need to know the inner workings of your car in order to drive it, just the controls. I don’t need to know how exactly the breaks work in your car, only that they work. I don’t need to know, that your car has a turbo charger, only that when I push the accelerator, the car moves. I also don’t need to know the exact revs that I should gear up or gear down (although that would be better on the engine!)
Virtually all controls are the same. Standardization means that the clutch, break and accelerator are all in the same place, regardless of the car. This means that I do not need to relearn how a car works. To me, a car is just a car, and is interchangeable with any other car.
Abstraction means not caring
As a programmer, or someone using a third party API (for example), abstraction means not caring how the inner workings of some function works – Linked list data structure, variable names inside the function, the sorting algorithm used, etc – just that I have a standard (preferable unchanging) interface to do whatever I need to do.
Abstraction can be taught of as a black box. For input, you get output. That shouldn’t be the case, but often is. We need abstraction so that, as a programmer, we can concentrate on other aspects of the program – this is the corner-stone for large scale, multi developer, software projects.
Abstraction is not like Peter Sarstedt’s Where Do You Go To My Lovely.
You talk like Marlene Dietrich
And you dance like Zizi Jean-Maire
Your clothes are all made by Balmain
And there’s diamonds and pearls in your hair
You live in a fancy apartment
Off the Boulevard St. Michel
Where you keep your Rolling Stones records
And a friend of Sasha Distel.
You go to the embassy parties
Where you talk in Russian and Greek
And the young men who move in your circles,
They hang on every word you speak.
But where do you go to my lovely…
When you’re alone in your bed.
Tell me the thoughts that surround you.
I want to look inside your head.
I’ve seen all your qualifications
That you got from the Sorbonne
And the painting you stole from Picasso.
Your loveliness goes on and on.
When you go on your summer vacation,
You go to Juan-les-Pins
With your carefully designed topless swimsuit
You get an even suntan
On your back and on your legs
And when the snow falls you’re found in St. Moritz
With the others of the jet set
And you sip your Napoleon brandy,
But you never get your lips wet
But where do you go to my lovely…
When you’re alone in your bed.
Tell me the thoughts that surround you.
I want to look inside your head.
You’re in between twenty and thirty,
A very desirable age.
You’re body is firm and inviting,
But you live on a glittering stage.
Your name it is heard in high places.
You know the Agha Khan.
He sent you a race horse for Christmas
And you keep it just for fun, for a laugh, aha aha.
They say that when you get married,
It will be to a millionaire.
But they don’t realize where you came from
And I wonder if they really care, or give a damn.
But where do you go to my lovely…
When you’re alone in your bed.
Tell me the thoughts that surround you.
I want to look inside your head.
Ah, remember the back streets of Naples,
Two children begging in rags
Both touched with a burning ambition
To shake off their lowly-born tags, so they try.
So look into my face Marie-Claire
And remember just who you are.
Then go and forget me forever
But I know you still bear the scar deep inside, yes, you do.
Ah, I know where you go to my lovely…
When you’re alone in your bed.
I know the thoughts that surround you,
Cause I can look inside your head.
Back when I taught C programming labs, a student asked what was the difference between a Mutex and a Semaphore. My simple explination is below. Little did I know, Niclas Winquist came up with the same explanation in 2005. To me, this really is the best explanation for a non-technical audience.
Mutex
Mutex is also called “Mutual Exclusion”. The explanation is in the name, really. A Mutex is a bit like a bathroom on an airplane; cramped and piss on the floor.
You enter the bathroom
You lock the door
You do your business
You unlock the door
You leave the bathroom
Unless you are incredibly lucky or incredibly stupid, two people CANNOT be in the bathroom at the same time.
Semaphore
A Semaphore (flag) is a lot like bathrooms in a fancy hotel; nice heated seats and proper toilet paper. Let’s assume that there are 4 cubicles.
Andrew enters and locks his cubicle door
3 Cubicle’s are free
Bob enters and locks his cubicle door
2 Cubicle’s are free
Chris enters and locks his door
1 Cubicle is free
David enters cubicle and locks his door
No Cubicles are free
Edward waits
Bob is finished and leaves the cubicle – unlocking it
Edward enters and locks his door
What this means is, if there are N toilets and M people where M > N, someone will have to wait until there is a free toilet before they can proceed.
Programmers have a very precise understanding of truth. You can’t lie to a compiler. Try it sometime. Garbage in, garbage out. Booleans, the ones and zeros, trues and falses, make up the world programmers live in. That’s all there is! I think programming is deep, it teaches us about the non-cyber universe we live in. There’s something spiritual about computers, and I want to understand it.
Programming is good training in the scientific method. For example, last week I spent five hours learning that “50″ + 1 = 501 in my scripting system. That truth was available to me the instant I discovered the malfunctioning software, but it took five hours of investigating, digging in, and challenging assumptions before the truth was clear, and I could move on to the next problem.
Programmers build castles out of theorems. Every program is proof that certain input will produce certain output. We build more complex castles, and look for synergies that allow the generality we like and still be approachable in non-mathematical ways. In movies they call this suspension of disbelief. In programming we call it the user interface. Same idea.
In the last few years we’ve learned how to connect programs together producing meta-software built out of programs that come from many different places, from people who don’t even know each other. An amazing evolution has been happening!
When a programmer catches fire it’s because he or she groks the system, its underlying truth has been revealed. I’ve seen this happen many times, a programmer languishes for months, chipping at the edges of a problem. Then all of a sudden, a breakthrough happens, the pieces start fitting together. A few months later the software works, and you go forward.
This process can be very confusing viewed from the outside. If you’re not developing the software yourself, you can still understand the process if you listen to and trust the programmer. It’s a fascinating world inside the machine. When programmers connect with the truth, they want to tell you about it! I promise you. This can make many people uncomfortable, and that’s so unfortunate.
I think, in some ways programmers, who live the scientific method, are better prepared for life than non-programmers, but the opposite is often assumed. We all have a visual image of the programmer, but this is just the outer package. A great programmer is a seeker of truth and beauty. Successful programmers know how to ask questions, and they know how to ask the *right* question. You can’t go forward until that happens. A programmer is a rigorous scientist determined to coax the truth out of the ones and zeros. There’s the beauty.
My pitch to programmers, which is far more revolutionary than any programming language or operating system can be, is to look for understanding where you find it, work with people you want to work with, and don’t waste time with people who won’t listen and aren’t grounded in the truth.