Category: Uncategorized

Defector

XEmacs is a nice GUI. Problem is, most of the handy little utilities you need are written for GNU-Emacs and they don’t work too well.

I wanted to get a function like the vi `dot.’ function, that simply repeats the last command. It’s not there in XEmacs. This has been in GNU-Emacs for ages, and there is a patch for XEmacs, but I don’t have the energy to mess about building one or contacting the guy that implemented it to see if there’s a windows build with it in.

I wanted a function like the gvim get-keyword (normally bound to ^X^P) that takes the characters you’ve just typed, scans backwards (or forwards if you use ^N) for a word like the one you’ve just typed a bit of. I found this for GNU Emacs and it would’t compile with XEmacs. Have’t tried it yet but I know it’ll work. Gvim has a way of getting a whole line but I don’t need it that much.

I wanted a function like gvim find word under cursor (bound to * for forward and # for backward)  and found a very simple example that I hacked to work in both directions; to be fair this worked on both. I’ve bound it to control- keypad * and -. I suppose if you’ve got tags it is’t that important, but I’ve yet to see proper tags for PL/SQL (not so sure about Python).

I don’t like the poor mouse menu stuff in XEmacs either. The mouse works like with X-Windows on GNU and if you hold down control you can get to the buffer menu, the edit menu and the mode menu from the 3 mouse buttons. XEmacs only gives you the mode menu on the third mouse button so you can’t do silly stuff like select. copy, move to another location, paste. The X-Window behaviour gives you that anyway in a much neater form. This functionality does’t work quite correctly in gvim so one up for GNU Emacs I think.

[[ Update Dec-06 most of this stuff is there but called something different, the copy existing word in buffer is

(global-set-key [C-return] ’dabbrev-expand)

– here bound to control-return. Find element under cursor, press incremental search and use ^K to select more and more of the word. Also works with reverse search as well. ^Y after incremental selects the whole of the rest of the line ]] 

Tabs and indentation

This is a total pain. Tabs are mode dependent and indentation depends upon the whims of whoever set up the mode you are using. In essence, to make it work correctly for the Enter key, do this in your run file (works with both):

(global-set-key “C-m” ‘newline-and-indent)

PL/SQL mode is’t quite right. When I have the time I’ll fix it and send it back to the guy who wrote it originally. I love being able to pick the procedures and functions from a list.

I’ve also got

(setq indent-line-function ‘indent-relative-maybe)

(setq-default tab-width 2)

But can’t remember why at the moment!

Rectangles

Not as good as gvim, I can mark a block and indent from it. I think that once I can remember the rectangle mnemonics I’ll be OK. Bought the O’Reilly GNU Emacs book with my Xmas book token – god I’m sad.

The XEmacs mouse rectangle stuff is difficult to use. I think the GNU will win out when I get used to it.

It’s been an interesting few days but I think my productivity will start to rise, particularly with the more powerful PL/SQL mode.

Just need to add all of my abbreviations in next …

 [[ Update Dec-06 dabbrev-expand makes running SQL*Plus a dream, press your bound key and up pops the column name or value from any other open buffer – brilliant ]]

XEmacs & Lisp – TOAD replacement

Over the Xmas break I followed a link from the Joel on software blog (see linked entry) and got to an on-line version of The Structure and Interpretation of Computer Programswhich got me looking at Lisp again. I’ve been translating the examples from Scheme to Common Lisp. At this level it’s mainly changing define for defun and moving the function name out of the list. I believe that the two languages veer more later, but you can still do useful things in them. Scheme is allegedly more restricted because it’s a teaching language. (have a look at the flame wars on the net – I’m keeping out of it)

For the first time in ages, when I was working through the questions, I was faced with a genuine mystery about why something didn’t work. Gahd it was refreshing. I had to learn how to use the GNU CLisp debugger using (step …). Then work out what the problem was.

This got me thinking about dev environments and I decided to have another go at Emacs. Downloaded XEmacs for windows and have spent some jolly time getting it to understand PL/SQL properly and do auto indentation the way I want it done. Still not quite right, but it’ll do.

Spent a pleasant time today at work with SQL*Plus in one buffer and copying stuff from one place to another and executing it.

I will post how I did things another day – I want to get some sleep now. Back at work after a nice long break and I’m feeling a bit washed out.

Joel replied to my mail and pointed out that Java isn’t really the new C; it’s the new VB. All of the irritating non-projects that used to get written in VB are now (at least some of them) being done in Java – hence all of the frameworks rather than a way to Just Get It Done. I think he’s right, and this means I’ve been learning some kind of weird proxy VB, which probably explains why I don’t like it.

TOAD replacement

Have a look at Oracle’s project SQL Developer. It looks like the SQL part of JDeveloper unbundled with some extra reports. Maybe Quest will start charging something slightly less silly for TOAD. Definitely worth a look, and it’s free.

Java Schools

Mail sent to Joel in response to this:

Ha!

I’ve been through this myself. Back in the mid-80’s I got a degree in Applied Statistics and Computing. There was an awful lot of numerical maths and heavy statistics as well as a firm grounding in structured programming. We were taught using Pascal, which did have pointers but nowhere near as bare bones as C. The year I left they took out a lot of the maths because people were whining – what did they think the course was going to be about with a title like that? Knitting?  I wish I had done a proper compsci course, all of my knowledge has come from reading books on compiler design and how to write better C, I bet none of these books are in print any more. Same with database design – no-one in the current crop can design a database properly or write SQL that gets data from more than one table without major brain surgery, the Java crew just use raw tables without proper relationships and then look on in surprise when their databases are full of junk orphaned data because of an application crash in the middle of a transaction (no, they don’t understand transactions either).

This stuff has been driving me mad for ages. One of the things you didn’t mention (maybe indirectly because of the sanitising of J2EE) is that Java generates an awful lot of frameworks. It drives me nuts trying to get anything done – each has another acronym and XML file, each is independent of the others, and each is useless, and each is embedded in every IDE you can use with no proper explanation of what the hell it adds to the mix.

I recently switched to PHP to get a personal project done from Java Struts. I got it done in about 2 weeks in the evenings and this included learning PHP and translating an XML config reader from Java.

Java is, in fact, too low level in many ways. Everything generic is type Object and then you have to screw around with it to work out what it really is. I’m currently studying for my EJB certification and it’s totally perverse. Badly-named packages with interfaces in different places, a query language for using entity objects together to construct queries (nasty and pointless), the list goes on.

I do think that in corporate terms Java is the new C, mainly because it’s become the language of assembling apps from other people’s components, and it’s also “safe”. I don’t like it any more, I did when it was new, but now it’s too clever (in the wrong sense) for its own good.

I agree totally about the int/Integer thing, as well as why they hell is there a char and a String? Why are there base types and then wrapper objects – why aren’t there just objects? Those objects can be implemented very efficiently with some syntactic sugar to make it easy but instead we have this deaf-mute child of C++ forced on us. The worst bits of C++ combined with the worst bits of Smalltalk. Why doesn’t the syntactic sugar around strings work for StringBuffer – which is the mutable version of String – lots of tiny objects in a large web app will start to fill the heap with loads of tiny thrown-away bits of strings. Using a mutable object could ameliorate this, but you’d have to have the insight to realise it and then rewrite all of the string manipulation using heavy-looking method calls, so no-one does.

My blog is on http://francis.blog-city.com – don’t worry, I attack C as well but for different reasons.

An interesting take on object orientation etc.

Have a look at this:

I sort of agree with him. See the comments on Java and whatnot I’ve been making here recently.

But I don’t see why we need to care about inefficencies in structures in ‘C’. If you care about this then use the alignment technique I gave earlier. I like structured data, probably because I’m a database programmer by training and inclination. I can’t stand writing code like this:

select a, b, c, d
into var_a, var_b, var_c, var_d
from bingo where …

gimme

select a, b, c, d
into bingo_rec
from bingo
where ….

This looks trivial. But you try it when there are 20 or 30 columns you are selecting and you (in a fit of editing) inadvertently transpose a couple of lines. Like I say, you have to be disciplined, but why be too disciplined?

Aother thing is I like syntatic sugar around things, I like using structures to pass structured data around. I know (I was trained to program in the 1980’s) that all of the data structures you’ve ever wanted can be modelled using arrays, but I don’t want to. I don’t want to have to think about silly bugs I may have put there when I reinvented my linked-list or stack as a home-grown array for the fiftieth time. A well-crafted utility library (with thousands of users) will be more reliable (eventually) than anything I write myself.

This approach to coding also doesn’t work well with teams and different levels of ability. To write code in the ‘C’ and no datatypes style requires a good memory and lots of discipline. This isn’t a bad thing, just very challenging to find enough people with that mind set (and talent, to be honest). Java is very much a big-corp, lots of specifications, language. It lends itself to that approach because of the built-in support for interfaces and polymorphism that object-orientation gives you.

It’s just that I’d like the whole purple spotted o-o bus to be optional (or gradual) when I need it.

Quick ‘C’ programming tip for aligning those pesky bytes in structures

Just a quick note. One of my friends, Roger, was on the ANSI ‘C’ committee.

One of the problems, if you have ever written an interface that either listens on a pipe for structured data or tries to read a packed binary file written by COBOL or somesuch, is that something like

1
2
3
4
5
struct record
{ char indicator[3]; 
int bill_amount 
/* etc. not sure of syntax these days */
} ;

If you try to read directly into this you will find that, even though the indicator variable is 3 bytes, the compiler will have allocated an even number or more, so that things fall easily on word boundaries. This doesn’t matter if you are writing a program that doesn’t need to talk to anything else. If you have a packed record where the fourth byte is indeed the beginning of the integer variable you are in trouble when you try and read it in.T

The traditional solution is to harass your compiler vendor until they tell you what the undocumented swiches are that make it not do word boundaries and a byte in memory is exactly a byte from your pipe or file or whatever.

In the ANSI standard, however, tucked away, you can do this:

1
2
3
4
5
6
7
8
/* assuming 4 byte int */
struct record
{ char indicator[3];
 int bill_amount;
/* etc. not sure of syntax these days */
 }
union
struct filler { char dummy[7] };

The compiler/linker is forced to byte align because the filler structure would be invalid. As I say, I’m not sure of the syntax these days but there is the idea in a nutshell. Beware that not aligning things can give you horrible errors on certain processors though.

Hope this save some pain out there.

Cohesive Libraries

http://www.regdeveloper.co.uk/2005/12/11/cohesive_code_packages/

Kevin’s responses are posted here in black

I know what you mean about the java.util package.

On a slightly related note I’m studying for the Business Components Developer exam and you need to learn serveral interface specs.

Not a problem.

Then you need to know which comes from java.rmi., and which from javax.rmi..

Ah, an unnecessary subtlety.

Why have the same thing twice – why is one object extended and the other not? Why?

The Java libraries are riddled with this and it makes passing the certifications unecessarily hard. I want to slap whoever did this but have to control myself.

Yes, it appears to be a fact you have to know for the fact’s sake. In other words, a poor decision on cohesion has been elevated to “clever” status.

Intensely depressed

Not sure why this is to be honest.

Driving home today I was suddenly overcome with an intense feeling of despair, not even despair, just an almost overwhelming desire to do something else.

I can’t afford to:

  • Buy the books I want (was just coming back from a wander around Borders)
  • Take my wife out for a meal now and again, or the kids for that matter
  • See a film I want to see
  • Buy the toys and stuff the kids want
  • Keep my debts from growing faster than I can pay them off

Then the depression, the heavy limbs and tearfulness started. It’s really boring, I’ve been fighting with this crap for years and years.

Totally fed up. I have a business that should sort this out, but it’s a long-term thing and involves me being a person I’m not. I need to be more approachable and friendly. I can do it, but I’d rather be curled up somewhere with a book, or writing some software that’s interesting. (Don’t get me started – my current very boring assignment at work is at least 50% of my problem).

As Churchill said never, never, never, never give up. Ok, Winston, I hear you. But sometimes just breathing is hard.

I’ve run out of energy getting some things ready at work and haven’t been able to work on the Java Certification. This phase is almost over (I’m into documentation now) and I will return to it. Another person said pay yourself first. Remember that one and stick to it. I’m going to book the exam for mid-January and the JSP one for end-Feb, then I’ll do the web-services one and then I’ll start on the Systems Architect (thinking of doing the IBM UML basic first, actually).

Removing some of the pain from Oracle Forms

More than 1 code editing window

(Thanks to Nadia for this one)

Yes, it is possible, when you want another window select the pl/sql object you are interested in editing and press ctrl-shift before you double-click. The new window appears on top of the old one but you can move it. No more navigating to find something out, writing it down (or pasting it into the buffer) and then navigating all the way back. Ah, the joy of getting into the 1980’s, it’s too much.

Adding elements in the middle of a pick list

(Thanks to Ade for this one)

To add an element press ctrl-shift->, remove press ctrl-shift-<

If anyone out there knows how to move elements into a different place, don’t hold back, I’ll add it here.

I’ve never seen either of these tips in the documentation, and yes, I did once go on an Oracle course when I were a lad.

FInally, a use for old loyalty cards! My laptop is a laptop again.

I don’t know if this bugs you.

I use all of my fingers for typing and rest my hands on the wrist rests on the bottom of keyboard when I do so. If you have a laptop that has one of those touch pads and want to type using the laptop’s keyboard you have to put up with your cursor jumping about to some arbitrary place on the screen that depends upon where the mouse pointer is sitting, even if you don’t think you’ve touched the thing. Very annoying. If you have a cheapy laptop like me you can’t switch it off when you’re using a mouse, either. I can’t adjust the sensitivity and there doesn’t seem to be anything in the BIOS.

Finally I had a brain wave. I took an old dry-cleaning loyalty card and cut it to the same shape as the touchpad. I can now sit here typing with the laptop’s keyboard and not have the cursor jump around if I catch the touchpad with my thumb. Weirdly the touchpad still works through the loyalty card. Anybody want the keyboard I bought? (keeping it because it’s much better than the laptop one).

Joy.

Wireless PCMCIA Network Cards

Got a D-Link G650 from ebay because the US Robotics one was acting up since I installed XP service pack 2. Suspect you need to turn off the “let windows manage this connectio” thing. It was working OK until about 2 patches ago. I will EBay the USR one, of course being honest about the SP2 thing. Also move to 802.11g and getting 54 MBPS, probably cooking my poor brain. Works a treat.

Work

Job hunt continues. Lots of interesting work around, but the main reason for looking is financial. I’m quite a way down (20%) from what I had when I was when I lost my job a while back and struggling. I still hate Oracle forms, they’ve done NOTHING with making it easier to get stuff done. If you’ve ever used a modern IDE with method name completion and documentation a right-click or function key away. I won’t cry never to have to use the damn thing again and it is definitely part of my wanting to move on, but not enough on its own. (I won’t mention having to restart Forms every couple of hours because it screws up, either, or the crap library management system that corrupts things or the bug where you can’t navigate between fields with a mouse at certain patch levels). That said, if the market demanded it and offered big bucks it would be churlish to refuse.

Anybody looking for an experienced software designer in the North of England?