I'm way too distractable!

I swear I have adhd or something!

So I am trying to learn python by making a text adventure game, and I got a few things going, I have a prologue and a main routine that runs the prologue and a way to hold all the variables and transfer them between modules (but not yet to save them although I am sort of working on that but I got distracted…).

Then I got fed up of how ugly the prologue was when I was trying to make flowcharts to guide making chapter1. So I went off exploring to find out how to use ncurses. Which is what I am doing now lol.

I’m never actually gonna get anything done am I, I’m just going to be all “arrgggh that needs changing” and maybe by the end of it I will have the best prologue ever, but that’s it lol. (Looks much prettier with curses…).


You will find (!) as you learn bits, if you encapsulate them in classes you’ll be able to forget the details … this makes like “much” easier.

But just to rock the boat again, I have to say I only use python for services / batch scripts, not for anything interactive. (too slow) If you want a nice GUI programming language with a nice built-in IDE, IMHO the best thing available on Linux is Gambas. (VB for Linux)

Having said that (!) I do all my UI coding in Javascript now using ExtJs.
(Take a look at; Docs | Sencha Documentation )


Now you are suggesting more things right after I said how distractible I was :o

I wonder if this is the kind of thing where it is better to focus on one thing at a time or where its ok to go off a wandering in all directions to look at stuff that seems interesting? With natural languages I was always told that you have to only learn one at a time, to be honest I am a little sceptical of that advice, I think its perfectly feasible to learn two, and if you have time, even three at a time (but most people will not have time for three languages they don’t know unless they are like a professional linguist or something), you don’t really get confused between them so much (OK I admit sometimes my Russian sentences have German/Welsh and even rarely French words in them, but I am not trying to learn German, Welsh or French so the confusion is not down to that - and you pick up on it immediately).

One thing that is certainly true with natural languages is that the most important thing to do is actually use them, even if like me you don’t actually know any native speakers and just torment your poor family by talking to them in weird foreign tongues (they can’t correct you of course like a native could…). I would presume it is the same also with programming languages - but that is a very hard part for me I think, thinking up things to actually do… I’m way too complacent in that respect (why do you think I used nothing but windows till I was 24!)

Oooh, but I emailed the guy who runs the compsci department at my uni and he said it’s totally ok for me to sit in on the first year’s programming lessons if I want.

Goes to investigate how this classes thing works

Difference is , computer languages are all very similar;

BASIC: for x = 1 to 10 .. next C: for(x=1;x<=10;x++) {} Javascript: for(x=1;x<=10;x++) {} PHP: for($i=1;$i<=10;$i++) {} Python: for i in xrange(1,11):

You can get caught out on subtle syntax differences, but they really are all similar … it’s just speed and method of execution, robustness, access to system resources, built-in constructs etc that differ. It’s not like we still work in COBOL (or DIBOL, or FORTRAN …) :wink:

Note specifically how similar C, Javascript and PHP are … learning one of those pretty much gives you instant access to the other two in terms of syntax, at a superficial level at least. The only real difference is that C runs faster and at a lower level and is missing lots of the nice data types like strings and lists.

So you’re advice is try and learn them all at once? (because they are all similar so it what you get from one helps with others) or definitely don’t try and learn them all at once (because they are all similar and you will mix them up)?

My advice is “learn to code” and don’t worry too much about the “what in”.
95% of coding is problem solving, 5% is syntax and language.

Personally I’d always start with ‘C’.
Just for kick-off, this is what most other languages are written in, indeed it’s what ‘C’ is written in.
Once you’ve “got” ‘C’ , you’ve pretty much got most of everything else. (/everything else is easier … :slight_smile: )

(It’s a self-compiling compiler … bit like GNU being a recursive acronym … :wink: )

Ok - I earned the most time of professional life my money as programmer. So my 2p:

  1. It is important to learn a strict and clear style. I do not see C or Java here as the best languages, but Pascal or ADA, even both are not very common, but both are forcing a clear and consistent style.

  2. Read some the basic texts regarding software engineering - especially, “Algorithms + Data Structures = Programs” by Niclas Wirth, Prof. emeritus, ETH Zuerich

  3. Burn your fingers on your own: Be not afraid of making mistakes: We all do and it is normal that a beginner does so.

  4. Test your program extensively! You will see the nonsense you made (see 3 above)

  5. Write documentation: Documenting is important for the quality of your software. If you need to explain in writing the stuff you made, you will come across a lot of the errors you made.

  6. Adopt a good coding style: May have a look in Steve McConnell, Code Complete (even it comes from M$)

Not really; lets take a bit of C:

char szString [10];
char *pChar;
int    *pInt;

/* something code */

pChar = pInt;

szString [12] = 'A';

In C this code will compile in C without any difficulties, leading to disaster. In C++ you would need to cast the pointer:

pChar = (char *) pInt

… again leading to disaster.

Doing the same in Pascal (my old love):

szString : string [10];
pChar : ^char;
pInt : ^int;

{ some code }

pChar := pInt;
szString [12] := 'A';

Would just not compile! There is no way to force a Pascal (or ADA) compiler to do such nonsense.

My dad still uses FORTRAN he was complaining to me his compiler has no concept of random number generation. I was very confused by that. Surely that cannot be? That’s my favourite thing!

Not really; lets take a bit of C:

char szString [10];
char *pChar;
int *pInt;

pChar = pInt;
szString [12] = ‘A’;

pChar = (char *) pInt

… again leading to disaster.

Ok, you can break anything if you try hard enough, the fact you ‘can’ drive a car into a brick wall doesn’t make it inherently unsafe …


pChar = pInt;

This will compile (as you would want it to) but it will tell you that what you’ve done might cause you a problem. Specifically you’ll get an “assignment from incompatible pointer type” warning … it might be that this is actually what you want to do, it’s certainly something I’ve used in the past, naturally if you wanted to do this you would type the conversion with pChar = (char*)pInt - off the top of my head, quite handy for converting an integer into bytes, here’s a runnable segment, compile with “gcc -std=c99 mp.c -o mp”;

/* mp.c */
#include "stdio.h"
#include "stdlib.h"
        char *pChar;
        int *pInt;

        pChar = pInt;

        for(char *p=pChar;p<(pChar+sizeof(pInt));p++)
                printf("%02x ",*p);

As I’m guessing you know, no ‘C’ programmer would do this;

szString [12] = 'A';

Assuming this is the function required, you’d always wrap it with something like;

int setChar(char *memory,int size,int index,char byte)
    if(index>=size) return 0;
    return 1;


Which would be safe … as for C++, nobody in their right mind (fx: don’s fireproof suit) uses C++ through choice. See this link; The Invention of C++ - Nice bit of net lore. Now I know this is touted as a “joke”, but I think there’s more than a sliver of truth in it, which is why it’s been reproduced so many times … (!)

Firstly I like Pascal, it was the first language I was taught at Uni, however it’s doesn’t typically have library support for writing high level applications and it’s not flexible enough when it comes to system applications. The only half-way decent implementations were Borland Pascal and Borland Delphi, (or Kylix on Linux) but eventually Borland sort of collapsed and they do all-sorts now - Delphi never really worked for them and Kylix was a spectacular failure.

Code: [Select] szString : string [10]; pChar : ^char; pInt : ^int;

pChar := pInt;
szString [12] := ‘A’;

Would just not compile! There is no way to force a Pascal (or ADA) compiler to do such nonsense.

Erm, Pascal has typecasting just the same as ‘C’ has typecasting, it’s really easy to produce the same sort of problem in Pascal and as for Delphi, it’s potential for mis-casting is epic! See how badly this breaks for you …

program demo;

        pChar = ^Char;

        S1 : String = '123';
        ch : pChar;

        Writeln('Hello World');
        ch := @S1;

At the end of the day, all languages (generally, I think Pascal is an exception) are written in ‘C’, as is Linux, and until you learn ‘C’ you’ll never ‘really’ understand how all the other languages work … personally I got a lot from writing an interpreter in Pascal, but didn’t quite get everything until I ported it into ‘C’.

Incidentally, were you aware that Linus did actually port the Linux kernel to C++ and released a version at one point … from memory it was back in the early / mid 90’s … but it was very short lived. More recently Linus has been quoted as saying;

C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it. Quite frankly, even if the choice of C were to do *nothing* but keep the C++ programmers out, that in itself would be a huge reason to use C.


I've come to the conclusion that any programmer that would prefer the project to be in C++ over C is likely a programmer that I really *would* prefer to piss off, so that he doesn't come and screw up any project I'm involved with.

My personal preferences are ‘C’ for anything needing performance, ‘Python’ for system services / scripting, PHP for web / JSON applications, and Javascript (obviously) for client side browser UI work. (and Gambas for native/UI work) I don’t tend to use anything else apart from the occasional Bash script. I’d use Pascal, if I had to (never have) , C++ if I was desperate, and Perl the day Hell freezes over.

When I get some time I will be taking a Peek at “go”;

I wrote in Std./ISO-/DIN-Pascal in the early 1990s software for statical modeling of support masts for the railway and power supply - it was perfect for the mathematical stuff and I enjoyed it, but a text-file-in-text-file-out is not what is asked today. There were some implementations of the conio for Pascal, to create at least some menus in text mode, but far below of today’s standards of usability.

I still would promote Pascal as a first learning language, for which it was originally designed.

Not really C has some, from a structural programming concept point of view, “ugliness”, as the void-pointer and the union, often misused for quick-and-dirty type conversations (I think it was N. Wirth how doubt that C is really a high language). But those “ugliness” are of great benefit for low level programming, as for the Kernel, or for high performance.

C++ is an ugly language and gets from version to version even more ugly by implementing different and antagonistic concepts into the same language - unfortunately it is also the most used language (“People eat more shit - millions of flies can’t be wrong” :wink: )

I started a while ago to teach myself ADA and I found the object-orientated concepts much clearer and easier to implement than with C++. But ADA is only a niche language, but does deserve IMHO a much more prominent place.

PHP is good in experienced hands, but can be a nightmare in bad programmer’s hands.

One of the programs that gives us the most headaches here is… wordpress. Badly optimized, and is a right pig to scale to high-load websites.

I do consultancy … :wink:

linux.co.uk is configured for 1/8th of cloud capacity and can do ~ 70 pages / sec (using “ab”) , and of course it’s Wordpress … and it’s on a shared platform … :slight_smile:
(I see no reason why within the context of current hardware scalability shouldn’t be linear, so that would be over 500 pages / sec … which isn’t bad!)

The problem is, our hardware is expensive. For a fully managed server, list price for our most basic is around £380 per month, though it’s rare to charge list.

So, most people can’t afford hardware. So, they instead tell us to get the most performance out of their single (admittedly, quad-core) machines. One server we’ve got dies horrible the second you take off either wp-supercache, or eaccelerator, with their standard constant traffic load.

Another set of servers spends most of the time mostly idle, and every now and then goes bat-shit insanely busy. Though that system, eaccelerator is too much of a pain. (It randomly causes seg-faults in apache, from time to time.) That was solved by throwing hardware at the problem. 3 web servers x 2 quad-core CPUs in each.

Ok, I’ve found Apache to be a great solution for something, PHP applications not being one of them. Issues;

Most people tend to use mod_php, which means PHP is running as part of apache, so restarting apache and php are tied which can lead to problems, esp if mod_php screws up as it can take apache down in different ways. (previously I was using Apache+HA-proxy to do proper load balancing because the apache load balancer just wouldn’t do it …)

I’m now using lighttpd, and all I can say is that I wish I’d found it years ago.
One front-end with lighttpd and multiple back-ends, each running fastcgi. On occasion I do get a PHP/fastCGI crash, but lighttpd just removes it from the round-robin queue and carries on. Means you can restart PHP/fast-cgi independently of the webserver, also means each user / fastcgi instance can run with it’s own UID which means proper security on a shared platform.

Don’t tend to get any problems with SuperCache, and I use APC and memcached rather than eaccelerator.

We tried memcached, and APC. Memcached produced absolutely no performance boost on test, even with code added to the WP core to make it use it properly, and APC seg faulted more than eaccelerator…

Lighthttpd is on my list of ‘to try when I get a chance’, along with Varnish :slight_smile:

Memcached produced absolutely no performance boost on test

Depends on the site / the speed of your IO subsystem … I use £50 7400rpm 1Tb disks which are relatively slow … if you use SAS then there’s probably little benefit. I don’t get any problems with APC … although I tend to use the up-to-date version rather than the antique version available in the repo’s.

Guess how many years out of date Ubuntu are on “Bluefish” , my Editor of choice …

We were using the up-to-date version

Guess how many years out of date Ubuntu are on "Bluefish" , my Editor of choice ...

Mmm, quite possibly, but I don’t know exactly as the news announcements only cover the last couple of years!