Starting to think that I should cough up the ~$200.00 for a copy of the c++ 2017 standard

I have a copy of C++ 1998 that I bought some time ago. The language has changed pretty dramatically since then.

The drafts have often been a decent informal ‘go-to’ option but the posted draft for C++ 2017 has a comment on the first page that suggests it is known to be no only poorly formatted but wrong in places.

While the standard isn’t the place to go for day to day reference it is very nice to have the authoritative document around to resolve some issues (and asking what the compiler you’re using at the moment does in not an acceptable answer…ever).

The ISO Standard C++ page has a pointer to the main ISO/IEC 14882:2017 Programming languages — C++ page but the buy button there is denominated in ‘CHF’ (swiss francs). The ANSI web store has it for $232.00 which is a bit steep (substantially more than I paid for the 14882:1998 back when) but may be worth the investment. Budget will tell I guess…

I hate answering a programming question badly…

So…yes, to delete a derived type through a base class pointer safely your hierarchy must define a virtual destructor in order to invoke the actual class destructor rather than the destructor associated with the static class of pointer

That being said, the behavior you get when destroying a derived type through a base class pointer is undefined so in practice anything could happen…

So:

class Foo 
{
Bar() 
{
// Some initialization
}
  ~Foo() 
{
// Do something here
}
}

class Bar : public Foo
{
Bar()
{
// Some initialization
}
~Bar() 
{
// Do something here
}
}

Foo *p = new Bar;
delete p;

The results of executing this code are undefined. It likely will execute the destructor for the static type of p (i.e. Foo) but it is perfectly acceptable for it to generate a crash dump or even delete the Bar instance properly.

The correct version of this would declare the base and derived destructors as virtual and ensure that on destruction the destructor associated with the actual (dynamic?) type rather than the static type is executed.

 

Loving what AcapellaScience does…

On a lighter than usual note:

Layering real physics into classic songs…priceless. This guy (these guys?) talk about string theory and the cosmic microwave background in layered acapella song. Try it and you’ll like it.

Acapella Science

Bohemian Gravity: This is the first one I ran into (while looking for talks on quaternions) and gives string theory a bohemian twist.

The Surface of Light: Brings Disney to the cosmic mocrowave background.

Entropic Time: Uses some cool effects to make the point that the arrow of time doesn’t have to be what we think it is.

Defining Gravity: Just saw this one last night and it is wicked cool…

There are more up there…these are just the ones I liked best. Enjoy!

Quaternions, Coordinate Transformation and a bit of Tensor Calculus

I started the weekend intending to write some java code as a ‘stretching exercise’ as I’ve been away from java for a couple of years.

This took me to the linear algebra based representation of transformation matrices and from there to quaternions. I’ve looked at them in the past just a bit. This time I decided to dive in and found a good presentation at mathoma on youtube.

They make sense as an extension of the complex numbers and seem to provide a superior way of managing rotations about an arbitrary axis in three-space.

I’ve started framing out some code to process quaternion values and I expect that to be helpful. I’ve also got the rudiments of point, vector, plane and transformation matrix classes. I’ll push what I’ve got up to github tonight and keep working on it later in the week.

I wound up watching another segment here that I switched away from after realizing that this was a mathematician who claimed not to believe in the real numbers.

I did run across another channel that has a pretty decent series of lectures on tensor calculus and vector calculus. I got pulled into the tensor calculus lectures and I’m currently here.  I expect to work through the remainder and likely watch the vector calculus side.

I has been a long time since I did any vector calculus and I’ve never until now looked into tensor calculus, but it looks intriguing.

I’ll probably start reading the accompanying text while I’m on vacation. I’ve also bought a more comprehensive book on quaternions that should arrive before vacation.

 

Floating point 3D primitives in Java…

I’ve been looking for some vector (3D) primitives in Java. I was hoping to find an existing library (something like blitz or tnt in c++). So far no luck so it looks as if I’ll wind up writing those I need myself.

Shouldn’t be too bad really. Mostly looking for things like dot product, cross product and some matrix multiplies in floating point. I did find pieces here and there, but none of the libraries I came across has the full set and since everyone implements their own point, matrix and vector classes, they don’t play well together.

The pieces I need shouldn’t take all that long to write and test so I’m going to go that way. Not looking for anything attached to 3D rendering, just need to work with some geometry in three-space and get some results. In the end, probably not a bad exercise.

More fun with RS232-C

I need to do some RS232-C communications from a java program. My initial investigations suggest that java support for serial port connections is at best rudimentary and that the dedicated solutions are mostly old and poorly maintained.

I odn’t need all that much sophistication from the solution so I may be able to get away with treating ‘\.\COM10’ as a file type device and simply streaming bytes to and from it. I’m currently putting together a setup here at home that will help to play with the alternatives.

I bought a null modem adapter on the way home at a local computer shop (I was mildly surprised they still stocked them, but they had a broad selection of RS232 adapters).

Turned out that the pin 2/3 swap wasn’t the issue after all though.

Continue reading More fun with RS232-C

Different languages, different strengths

I’m convinced that in the modern world of software engineering it is critically important to be comfortable building systems that use different programming languages and runtime environments for their various parts.

With the wide variety of options that are available and the capabilities of different languages and tools to make specific tasks simpler, being able to write PHP for some middle-ware pieces with Java or C# microservices on the back-end (perhaps in docker containers) and a javascript/typescript web UI is likely to allow your team to build faster and create a more capable system than keeping everything in a single language would have.

The wider the range of tools that are available to your team (and that your team is comfortable working with) the more flexibility you’ll have to move quickly and adapt to changing needs.

Apache Commons Daemon

Pulled the code and built a copy from source. Looks like it doesn’t handle the pre-shutdown flag in its out of the box form. It probably can have the capability added easily enough.

The harder question will be how we interface that functionality to the hosted java code. The hosted java would need access to the message and be able to generate the response that tells the system how long to wait before allowing shutdown to proceed. It also needs access to the win32 function that can request the shutdown be aborted.

Given this code is native C, I’d expect that to be relatively easy.

 

Looking at Java, Windows Services and hosted Javascript

This weekend I’m roaming a bit afield of my normal haunts.

I’m looking at service hosted JVMs in windows and in particular having such a service interact with the SERVICE_CONTROL_PRESHUTDOWN message. Handling this message allows a service to defer shutdown while handling activities that it needs to complete before the actual shutdown processing begins. I suspect it may also allow that service to call AbortSystemShutdown()  in order to cancel the shutdown.

I’m looking at the Apache Commons Daemon package first as it seem to be common, well regarded and reasonably licensed. At first look it doesn’t seem to support the extended messaging from the host OS but it seems like an interesting starting point. Continue reading Looking at Java, Windows Services and hosted Javascript

Engineering execution and creativity mixed for the best results…