On Sun, 6 Aug 2023 08:09:58 +0100, The Natural Philosopher wrote:
> I want to control my central heating remotely via a browser interface,
> in great detail and in a highly configurable way , yet with an elegant
> and simple user interface.
>
I'd use Java for that. Its standard library classes for handling control
panels, menus etc are much nicer to write the GUI in (Provided you use the
generic Window/Controller/Model program structure) than anything available
in C or C++.
One of the most satisfying small personal projects I've done in Java was
to write an editor for CSV data files. Yes, I know that you can use a
spreadsheet, but they have stupid limits such as 16K rows per file and
apparently (I don't use M$ software) no warning to a user exceeding that
limit that data is being lost. Also, spreadsheets and have almost no
decent tools for search and display within a large file, let alone any
ability to search for rows containing specified value(s) and convert them
to or from comment lines. When I was roster manager at my gliding club I
needed to edit CSV files with 5000+ lines and up to 30 columns, I wrote my
own CSV editor in Java. This provides several editing features I needed
that are not available in spreadsheets and for giggles included a
scripting facility as well. It all went together much faster than I
expected, does exactly what I need and does it quickly.
The only other way to handle these edits rapidly would be to use bash:
this would be equally fast to use but would it take longer to write the
various scripts than it does to run a CSV file through my editor.
Some of the 4GL systems come close, but (a) who uses then now and (b)
there's no way they can be a front end for your sort of controller. Anyway
they get tiresome if you try to do anything with them except what they're
designed for: maintaining data in related sets of indexed files, though I
did write a Sculptor 4GL system to handle scoring for the British National
Free Flight Champs and the Stonehenge Cup. This ran on a bog standard
80286 PC in the back of a covered van and was powered by a portable
generator.
> To make it simple to use, it gets to be fiendishly complex to program.
>
> I *could* use the hooks that are in basic HTML - the input statements
> and the GET and POST methods plus refreshing the pages via submit
> buttons, but that is even worse than the existing box on the wall with
> its fading 20 year old LCD display and its complex and time consuming
> button presses.
>
That sounds nasty. For HTML pages that will be displayed by a web server I
generally stick to vanilla HTML pages with bits of PHP thrown in if I want
to accept data from an HTML page. The O'Reilly "Programming PHP" book is
pretty straight forward and is well organised, and some of the things yo
might want to do may require an HTML server (I run an Apache server at
home on my LAN).
If you'd rather stick to C, have you considered using Curses to display a
control panel and manage both status display and input of control
settings? Its a while since I've used it, but I seem to recall that it
will also accept input from on screen windows. O'Reilly have a decent
guide to it.
> It's so much easier to use GUI type tools - mouse movements and scroll
> wheel and button presses or drag and drop type techniques to configure
> things, and these techniques simply didn't exist when HTML was first
> invented. Now they are accessible, but only as JavaScript events, so I
> have to use the bloody language.
>
I tried Javascript: I tried it once and found both it and the book on it
to be poorly organised, badly written, and lacking in any overall
description of how the bloody language works and how its various parts
interact.
> And let me tell you, it's AWFUL.
>
Couldn't agree more.
But seriously, as a C man it would be worth your while at least looking at
either Curses for laying out and painting the display if its directly
attached to the MPU (i.e. is running on an RPi, and combining PHP and HTML
(they work well together) if you need anything that Curses can't handle.
> I learnt SQL because I wanted to do some stuff with databases. SQL is
> remarkably sane. At least for simple stuff. When it got complex I
> dragged out a compiler or PHP to do the clever stuff. Because even when
> I could figure out the exact SQL command to get the result I wanted with
> nested joins and what have you, it took me longer to figure it out than
> write C code to do it with multiple simple queries, and the C code ran
> 50 times faster than, at least MySQL. I cant answer for e.g. Oracle etc.
>
That's generally true. I like SQL and have used it on several different
databases and data warehouses. Its particularly well integrated into both
C and Java.
Mind you, I also liked IDMS, the CODASYL database. Its so well integrated
into COBOL that its effective a language extension.
> My coding career was always driven by *result* targets. I wanted to
> achieve an end, what do I have to learn to do it? And I learnt enough to
> do it, and *not a penny more*.
>
I thought that was a fairly general approach, at least in the better
software houses. Certainly I was used to be asked what I knew about 'x'
and,if my answer was 'heard of but not used' and it was within my
skillset, getting a heal of manuals dumped on my desk and told 'You're on
the project starting week after next' and also knowing that, if I was
struggling, somebody I could talk to about 'x' would be in the pub on
Friday.
> What I want to do here, requires javaScript. And some sort of server
> side scripting. That could be C, C++, or PHP or almost any language
> that runs on a linux server. I am sure that you could write it all in
> perl or assembler, too.
>
See above except that, assuming that your application drives the display
directly, I'd look at Java or C plus Curses, and PHP if absolutely
necessary - I've used PHP and quite like it, combined with HTML, for pages
managed by an Apache server..
> But the shortest route that appeared to me some years back was PHP,
> which is a hacked together POS, but its fairly simple if you don't ask
> it to do huge tricks, just like MySQL. In the past I have interfaced it
> with C code when it proved incapable of handling large data objects
> without crashing, but it's fine for simple jobs, like taking a
> javaScript Ajax requests and updating a file on the server for example.
>
I suspect its not meant to work that way, which is why I suggested using
Curses for output to the screen and PHP only to read user input to the
screen.
Of course, Java does both pretty much seamlessly, but seeing that you
prefer C,...