A Binary Code Program Cannot Be Made Back into its Original Source Code

Mark Harrison says you cannot know which two numbers you used to make the final result. It could be any two or more numbers. When you translate the source code that defines a program into an actual program that can be ran on a computer, that actual program is not a mirror image of the source code used to make it. That means different source codes can produce the same resulting program.

If every code ended being .exe, why can’t we turn it back into code?

Advertisements

Review of Book, Optimized C++

Two conflicting views exist in considering how to write software code. Abstraction vs. optimization. Abstraction is about getting your model right and matching software to the business environment. Make the software mirror the concepts in the real-world. An example is when you design a financial software package and the code has concepts baked in like accounts, debits, credits, merchants, and customers. You have object classes written in software that looks just like the way the real-world talks about the process the software facilitates. This is thought to lead to easier to maintainable code that can be kept better in synch with the way the business operates.

The other approach is to put less an emphasis on models and make sure the software is highly competent in using computer resources. The program runs fast, uses computer memory appropriately, scales up to handle more data, and so on. Technical operational criteria that may not immediately map to the business drivers, but that nonetheless could lead to a quality solution in the right circumstances. An example are video games. Get the technical aspects right such as high-speed rendering on graphics cards; reduce page swaps and cache misses for smoother AI, solid use of asynchronous functions for solid multi-player and pre-rendering of terrains, then you get a great solution. In the business world, it may mean adapting a software design to accommodate disk storage capacity, processing windows versus available compute resources and giving up pretty code that looks like the business for code that enable more data and calculation per unit of time.

People argue about these two views all the time. Oft cited is Dr. Knuth’s statement about premature optimization. Despite the pros and cons, substantial gains are available through the power of abstractions. I found no more powerful statement about abstractions in the form of the book From Mathematics to Generic Programming in Alexander Stepanov’s material on the subject which I reviewed in Janurary 2015. The right abstractions provide a significant amount of productivity. You can build more and cover more conceptual and functional ground through abstractions. The abstraction oriented approach has been a major part of the progress of software for many years.

Continue reading

Gautier Rss Reader – Allegro 5 C++ 2016 on GitHub

The final 2016 version of the Rss Reader is on GitHub. The following screen is little changed from the last version. The main update is to apply multiple lines to the details section after you click on a headline. I added a call to al_draw_multiline_text into the process based on a flag set at the application level. When you go to GitHub, you can browse and/or download the full source code and build script. See previous articles on the subject for context.

The following is the current GUI output on a 4K screen. As you can see, the font rendering is excellent with no changes to system settings.

Gautier Rss Reader 2016 Edition

 

If you build the program on Linux using the command-line, your build output may appear as follows. I also show a file listing that notes the minimum files created/used by the program and their file sizes.

Gautier RSS Reader 2016 Edition Makefile Build for C++ 14

On GitHub, Gautier Rss Reader 2, defined in C++, compiled to the C++ 14 specification using Allegro 5 graphics, sqlite3 embedded db, and libxml2 to download feeds and parse them before assigning entries into C++ Standard Library containers such as map and vector.

C++14 GUI with Interactivity (A basic RSS Reader, 4K monitor capable) 12/15/2016

The basics of an interactive RSS reader built completely from scratch using a cross-platform C language graphics library, C language embedded database library, and a C language XML library all shrouded in C++14 based application that ties it all together. The interactivity is was the final piece to pull it all together. I would have finished this yesterday, but the code I had defined that worked out-of-the-box in GCC versions 5 and earlier did not compile so well in GCC 6.2. I took it as an opportunity to make the code better. After the screenshots is the latest code that provides a rudimentary example of a software application that can run across all desktop/laptop operating system upon a foundation that can also be adapted to mobile operating systems. The best thing about this code, it is works well on a 4K monitor and I am confident that the foundation can be expanded with little effort to support 8K monitors and beyond.

Rss Reader in 4K Resolution

My basic goal is achieved. I wanted to get to the point of an interactive Rss Reader application that works across platforms and, now, renders successfully on different screens. This approach works and provides near maximum control over the solution. The approach I have pursued using the Allegro 5 Graphics Library provides a solid balance of productive and highly capable GUI definition. It is awesome!

gautierrss20161215

Writing Code in gedit

A year or so ago, gedit was a good editor for this type of task. This year, it is not so hot, but I’ve adapted to it and it does the basic functions of handling text entries. The left side shows the folder hierarchy into which I’ve placed source code, makefile, and runtime assets like fonts.

gautierrss20161215codelayout

Building the Application on the Command-line

I use the standard make build system and Alt-Tab between gedit and the terminal. The following is the latest binary listing of the executable compiled in debug mode. The other files are the fonts (courtesy of Google) and the sqlite database that is created when the program starts up. The database contains the rss feeds data (headlines, articles, and feed names). It is essentially the same application I built in 2015 but better adapted to C++14 and, in this case, GCC 6.2.

gautierrss20161215build

The C++ Code

The majority of the code is C++ conforming to the C++14 spec. I also limited dynamic memory management at the application level with solid performance. The RSS Engine in which Rss feeds are pulled from the Web, sliced and diced using libxml2 and interred into an embedded sqlite database is still largely C language based with a C++14 covering I’ve put in place. The application accesses this wrapper to present the data to the reader which then arranges to render it and respond to mouse clicks and scrolls. The latest code is shown below. Compared to the previous article, I’ve added the RSS Engine represented by gautier_rss_model.cxx/hxx as well as updates to the interactivity sequences in InteractiveRegion.cxx/hxx. RssReader.cxx/hxx was updated with code to combine the implementation in both of those solutions into an overall application.

gautier_rss_model.hxx

Defines the interface the application uses to get rss feed data.

gautier_rss_model.cxx

Rss feed data engine implementation. This code is the actual Rss logic in terms of pulling data from the Web and containing it within the software application or the attached sqlite database. Unlike the 2015 version, this was changed from a series of namespace scoped functions to functions contained in a class. This was more practical that resolving internal vs. external linkage issues. After a few hours of “tuning”, it handles the loading of data quite well. The main bug was when this area of the program did not receive the right value for the name of the database file. Once that was resolved through aligning the storage classification of the variable involved to the overall definition of the rss_model type in the main namespace, all was good.

InteractiveRegion.hxx

Defines the interface the application uses to present lines of text that can be scrolled and clicked.

InteractiveRegion.cxx

The actual interactive solution for lines of text that can be scrolled and clicked.

RssReader.hxx

Defines the interface that the operating system’s representation of the program, in main(), uses to initiate the software application.

RssReader.cxx

The actual Rss Reader solution that links together various elements to provide an overall visual and logical representation of the Rss Reader concept.

Makefile

Updated makefile to build the application sourcing in all the relevant includes and libraries

Cross-Platform C++ GUI Structure 12/14/2016 Update

The following is a complete set of structures for a C++ GUI that can be compiled for Microsoft Windows, MacOS, Linux, and more. It took a lot to put this together roughly 4 hours a week during the last few weeks. Please refer to the previous article for relevant screen shots of how this solution appears. That article also discusses the GUI in general. The point is not the appearance of the GUI, which can and will be changed, but the structures that allow you to produce a GUI using C++ and the Allegro 5 Graphics library as the means to assemble a GUI. I spent the most time so far on scrollbars. I had never hand created done scrollbars from scratch.

Makefile

The makefile is the means I use to compile and link all the source code into a program.

Continue reading