Category Archives: Uncategorized

Definitely need to cycle back to C++

A few recent conversations have reminded me that while I’ve been focused on bringing my Java, C# and JavaScript up to a high polish, I’ve been doing very little C++.

C++ has been my go-to language for most of my career. I haven’t written any significant amount of C++ code in a couple of years though so now is likely a good time to circle back in the sandbox at home. Not sure what I’ll write, but I’m sure I’ll find something.

Still trying to deal with a bunch of house stuff at the same time so this is likely to be slow going in the near term…

That being said, I’m still inclined to view C#, Java and JavaScript as important parts of the whole picture. Developer productivity in C# and Java is much higher than in C++, even for someone skilled in both languages. JavaScript offers an easy and dynamic environment for tasks that benefit from ease of change and don’t involve huge amounts of code. JavaScript driving a web UI very much seems to be the way things are heading…at least for serious commercial user interfaces…combine ease of development with local/remote transparency and a wealth of tools and things like MFC, WPF and JavaFX have a hard time competing.

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.

WiX bits…

I’ve been reading more on WiX while wrapping up the loose ends of C# coding on my current program. I’m a team of one at this point but it is rather nice to get some straight-up coding done without needing to take care of the other issues that leading a team brings to the table.

The ‘heat’ tool in WiX generates files containing WiX descriptions of files on the file system that need to be installed. I have built small WiX installers in the past for projects but those have contained only a handful of files. Things I hadn’t known before this piece of work:

  • WiX has a ‘compiler/linker’ structure to it. Individual WiX files can be built and then linked together into a final installer. This makes the heat generated files more useful as they’re not going to be hand modified, just included in a final MSI file that was hand generated.
  • With larger installs the component group makes things dramatically less cluttered. Nice feature to have…I now need to re-generate my heat output with proper group naming.
  • Fragments are the ‘div’ elements of WiX. They allow grouping of components for link time binding. If you pull in one item in a fragment then all other items in that fragment get pulled as well. This appears to be not only a convenience but a way to pull in items that can’t otherwise be referenced from another linkage input.
  • You can run heat every build pass but I don’t think you want to. I can see where this would be convenient, allowing you to add items to the build and have them get inserted automatically. The down side here is that the GUIDs for existing items would change every time through and that makes a mess of the windows installer’s view of things.

There’s clearly much more to learn on this front but for the moment I’ve got what I needed. Installer UIs and more complex system interactions would be nice to know about but I know where to go to find that information when I need it…