Fun Stuff > CLIKC

A programming thread!

<< < (2/37) > >>

pwhodges:
It's years since I did any real programming, though I did loads back in the day.  And my best anecdotes are already somewhere in the forum.

Starting at uni in 1967, I was writing Algol-60 and K-autocode; out of uni I had a temporary job doing image processing in assembler for the English Electric Leo Marconi KDF-9.  I also played with Algol-68.  My first proper programming job at a software house had me writing in Coral-66; then doing embedded programming with no assembler - just writing the instructions in hex (non-standard hex using B-G instead of A-F).  And even some Cobol.

In the late 1970s and early 1980s I was selling an entire OS and medical image processing suite that I had written - to the Japanese, even - that was written in a mix of Assembler (for a Varian mini), BCPL and Fortran (both compilers ported and heavily modified by me), with some microcode for efficiency (subroutine entry and exit instructions for the BCPL and Fortran; backprojection code for tomographic image reconstruction).

Then I did a lot of system programming for Norsk Data machines, both in their machine code and in their own language, Planc (this work included a comms package for use with ICL mainframes which became one of Norsk Data's products).  I also ported my BCPL and used it for some utilities that the service department used (image storage and writing for our software library, which came from head office on floppies; a binary editor, which I used to rebuild messed up file systems on corrupted floppies).

The last part of my full-time programming career was in embedded systems (though I'd done some similar work right back in the early 1970s).  These systems were all for use in pharmaceutical manufacturing.  The main control programs were written in Modula-2.  At this time I started to make heavy use of OS/2 (starting with v1.3, and going on right through to the non-IBM successor product eComStation).

For the last fifteen or so years I have been a systems administrator, so comparatively little programming, but quite a lot of hacking of existing scripts (Rexx on OS/2, Perl especially, largely for spam detection in email servers).  Also web stuff (HTML & CSS of course, with JSP, Python and PHP scripting).  Mostly Windows systems these days; but I also run an OpenBSD firewall, and have an outdated RedHat Linux support qualification.

The main thing I've not had any practical involvement with is object-oriented stuff - C++, Euclid, etc.  I know the principles, of course (in fact the seeds of it are visible in Algol-68), but my mind just doesn't go that way.

ankhtahr:
I'm not sure whether it was Fortran or Cobol, but my grandfather told me of a problem he encountered at university. One program of his caused an error. The operators told him that the error was trying to calculate the square root of a negative number. He was very sure that there couldn't be any negative numbers at that point of the program. He had to manually calculate what the program did in every step to finally find out that the problem was that there was a difference between a positive and a negative zero. The error occured because of a negative zero. Once he transformed negative zeroes to positive zeroes at that moment it worked flawlessly.

pwhodges:
Zero being signed was a characteristic of certain hardware, not the languages.  Specifically, machines that didn't use twos-complement but used a signed magnitude format - typically these would be machines that worked directly in decimal, to avoid issues with binary-decimal conversion.  A decent compiler would have dealt with this problem, but many compilers were (are, I guess) not decent.

snalin:
So I've got a compulsory exercise set in my "Modelling of Computing" course. It's about turing machines and state machines and logic circuits and computability and that sort of stuff. The book used is this one

Now, one of the problems is this:
"Design in detail a TM that (bubble-)sorts any input word "

So, sort any string consisting of a's, b's and c's alphabetically; "cba" to "abc". Pretty simple stuff.

Now, the thing is, writing Turing machines in the form of state transitions gets kinda... messy. I hit 30 transition functions and lost completely track of where I was at. So, I figured I'd do this the good old fashioned way: test driven development! Yeah!

Now, to actually test a Turing machine, I need to have an actual Turing machine implementation. So I did that. Because to solve a simple problem, first solve a harder problem. This is the mantra! So now I can write Turing machines through TDD by testing against the expected output tape state. Aw yeah. The machines I can build don't actually have explicit accepting halting states - ALL halting states are accepting. So if they're used for language recognition, they can give positive answers ("the input string is in the language") by halting, but not negative ones.

If you want to see the Java project for whatever reason, I put it up on github: https://github.com/BBuanes/TM. Not sure why, but hey!

If you'd rather just see the setup of the machine:
(click to show/hide)/*
 * bubbleSort is a turing machine with starting state R. TM.RIGHT is the "go right" command, TM.LEFT is the "go left" command, and TM.EMPTY is an empty tape bit.
 * .setTransition("X", "a", "Y", b) means that in state X, when reading a, go to state Y and write b. If b is LEFT, go left instead. If b is RIGHT, go right instead.
 */

// R: "Run" (normal)
bubbleSort.setTransition("R", "a", "R", TM.RIGHT);
bubbleSort.setTransition("R", "b", "B", TM.RIGHT);
bubbleSort.setTransition("R", "c", "C", TM.RIGHT);

// B: "the last character read was b"
bubbleSort.setTransition("B", "c", "C", TM.RIGHT);
bubbleSort.setTransition("B", "b", "B", TM.RIGHT);

bubbleSort.setTransition("B", "a", "Ba", "b");
bubbleSort.setTransition("Ba", "b", "Wa", TM.LEFT);

// C: "the last character read was c"
bubbleSort.setTransition("C", "c", "C", TM.RIGHT);

bubbleSort.setTransition("C", "b", "Cb", "c");
bubbleSort.setTransition("Cb", "c", "Wb", TM.LEFT);

bubbleSort.setTransition("C", "a", "Ca", "c");
bubbleSort.setTransition("Ca", "c", "Wa", TM.LEFT);

// Wx: "Write x"
bubbleSort.setTransition("Wa", "b", "R", "a");
bubbleSort.setTransition("Wa", "c", "R", "a");
bubbleSort.setTransition("Wb", "c", "R", "b");

// ML: "Mark last"
bubbleSort.setTransition("R", TM.EMPTY, "ML", TM.LEFT);
bubbleSort.setTransition("R", "a'", "ML", TM.LEFT);
bubbleSort.setTransition("R", "b'", "ML", TM.LEFT);
bubbleSort.setTransition("R", "c'", "ML", TM.LEFT);
bubbleSort.setTransition("B", TM.EMPTY, "ML", TM.LEFT);
bubbleSort.setTransition("B", "b'", "ML", TM.LEFT);
bubbleSort.setTransition("B", "c'", "ML", TM.LEFT);
bubbleSort.setTransition("C", TM.EMPTY, "ML", TM.LEFT);
bubbleSort.setTransition("C", "c'", "ML", TM.LEFT);

// RTS: "Return to start"
bubbleSort.setTransition("ML", "a", "RTS", "a'");
bubbleSort.setTransition("ML", "b", "RTS", "b'");
bubbleSort.setTransition("ML", "c", "RTS", "c'");

bubbleSort.setTransition("RTS", "a", "RTS", TM.LEFT);
bubbleSort.setTransition("RTS", "a'", "RTS", TM.LEFT);
bubbleSort.setTransition("RTS", "b", "RTS", TM.LEFT);
bubbleSort.setTransition("RTS", "b'", "RTS", TM.LEFT);
bubbleSort.setTransition("RTS", "c", "RTS", TM.LEFT);
bubbleSort.setTransition("RTS", "c'", "RTS", TM.LEFT);

bubbleSort.setTransition("RTS", TM.EMPTY, "R", TM.RIGHT);

// F: "Finished" (clean up now
bubbleSort.setTransition("R", "a'", "F", "a");
bubbleSort.setTransition("R", "b'", "F", "b");
bubbleSort.setTransition("R", "c'", "F", "c");

bubbleSort.setTransition("F", "a'", "F", "a");
bubbleSort.setTransition("F", "a", "F", TM.RIGHT);
bubbleSort.setTransition("F", "b'", "F", "b");
bubbleSort.setTransition("F", "b", "F", TM.RIGHT);
bubbleSort.setTransition("F", "c'", "F", "c");
bubbleSort.setTransition("F", "c", "F", TM.RIGHT);

TL;DR: Programming at a university miiiight just have driven me insane.

ankhtahr:
Ok, so during this semester I'll have to do exercise sheets both in programming and in "software technology", which is basically software engineering classes. I'll have to pass the programming one, otherwise I won't be allowed to study computer science in Germany anymore. I should pass the SWT one too, because it would slow me down a lot if I wouldn't. So yeah, I'll have to do basic and advanced sheets at the same time, with my knowledge being stuck at about the half of the basic ones…

I'm still not too comfortable with object oriented programming. I enjoyed the small bit of C and the bigger bit of AVR assembler, so I probably have a slightly different viewpoint than most of my classmates. While they look down at the programming language from an abstract algorithm, I look up at the programming language from a system architecture point of view. Object oriented programming feels counterintuitive to me.

Anyway, I probably need to pick up an IDE now. I'd prefer just using vim, but that isn't much of an option with the SWT class. I'm going to need Maven, Checkstyle and Code Coverage using JaCoCo. The recommended IDE is Eclipse, with EclEMMA and a Maven and a Checkstyle plugin, but that crashed on me a few times. I've managed to reduce the crashes to a tolerable level, but it's still annoying. I've looked at Netbeans and promptly discarded it, and I looked at IntelliJ IDEA Community Edition and liked what I saw. It lacks the code coverage tools though, those are only available in the paid version. I could probably try to usi it anyway, trying to use JaCoCo manually through Maven or something, but would that really be a good idea? Any comments?

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version