Software Development

Correcting The Future

Archive: April 2009

Breaking Vigenère Autokey Cipher

Charles Babbage broke the autokey cipher in secret, and several years later, Kasiski accomplished the same feat in 1863. Looking online, I could not find any substantial descriptions as to how this was done (and there seems to be some confusion as to exactly WHICH variant Kasiski broke). I originally thought that many cryptographic algorithms were complex and difficult to understand. Not so. They are actually very simple.

The Vigenère cipher comes in many different flavours. There are the autokey variants as well as the Quagmire variants. A simple explanation can be found here.

Read more...

Undo

Undo functionality is a known problem that is often very difficult to implement. For Project V, I need to implement this. And I'd rather implement it sooner instead of later.

I figured out there are three ways of doing this.

1. Save the state of the entire Project V network (including the GUI) before each command and store it in a stack.

Advantages: Easy to implement.
Disadvantages: Takes huge amounts of memory and is slow as hell. May not even work if too many undo's are stored.

Read more...

Project V Pre Alpha Release Version 0.0.0.0

I've had a request to see component interface creation, so here it is.

WARNING: This release does nothing. Really!

You may consider this my version of the black triangle.

It just shows Project V component interface creation and deletion. This will change in the near future since an interface is supposed to be global, but using that interface needs an instance (or at least a way to reference each use of that interface). Right now, there is no difference. Then again, I may simply leave instances without a name since only the user needs it (the compiler can already tell the difference). If the user wants to name it, they can. (Thinking out loud here.)

The type editor (left pane) is still disabled because there's a bug in it and I haven't gotten to fixing it yet.

Oh, and this is just the tip of the iceberg. The Project V type system is fully operational as is the compiler. The runtime engine will need some tweaking, but again, this is all code that has no visual counterpart.

Have fun!

Requires DirectX 9.0c (vs 1.1+, ps 1.4+, 32MB+ video RAM)

Project V Install (4MB)
Mirror #1

Project V: How to Visually Build Components

I'm at the point where I want to build networks and component. I have everything figured out how I want it work data-wise and how everything is stored internally. All that is done. Now, I just need to build the damn thing. Only thing is that I'm stuck. I have no idea how this would work visually.

Sure, connecting components and selecting EXISTING components to place in your network is easy. I'm talking about creating a new component interface. How do I add new inputs? How do I ask the user to select the type and enter the instance name? Isn't that a bit tedious?

I have half a mind to enable a command line where you can tell the GUI what to do. I also think having text based definitions for interfaces wouldn't be a bad idea.

type AddInt32 : component
{
inputs:
  Int32 a,b;
outputs:
  Int32 out;
}


The main objective here is to specify the inputs, outputs and interface name. That's it. That's all a component interface is.

Perhaps I can have a button that creates a new, blank, interface would work. It'll display it blank. And then you can click on an icon on the component itself to display the textual definition where you can update it. This would work well for other types as well.

I could also have each component in the component list treeview have a popup where you can insert that component as a new input or output, or to copy its type in the clipboard.

Any ideas? I've been staring at this for two days. I have no clue what would work best. I don't think this kind of thing really works that great in a visual mode. This is one area where everything is telling me stick with what has worked in the past, text.

If I don't come up with anything better, that's what I'm going to implement. Unfortunately, this means my implementing a text editor. Are there any open source editors that aren't GPL (and are similar to BSD license)? I'll take a look and see if I can find one and port it.

Luckily, connections are simple. Simply click and drag. I can't wait to get to that part. But by then, I'll be working on the runtime engine.

Yeah, I'm thinking I'm gonna implement a command line and a textual mode for different aspects. The text editor could also be used to implement scripts. For those that want traditional dataflow (w/ scripts), what scipting language should I use to start off? I need something rather simple where I can add bindings to existing types and variables. I'm thinking I'll build my own scripting language that looks similar to C. I already have my own parser generator. May as well use it. And I can add dataflow operators to the language. Other people can implement their own scripting language later on.

What is a Large Project?

I was reading on reddit, and other places, and saw a few comments on project size. One person said that 30K was approaching a large project. Is this still the metric?

<5,000 line = small project
~50,000 lines = medium project
>100,000 lines = large project

I could write 100,000 if I wanted to, but I always try to keep it small.

Project V is now topping 42,000 lines (this includes blanks and comments, reduce by 20% to get code only). And I have over 30,000 more lines of throwaway code. By the above scale, Project V is a "medium" project. Luckily, it still feels like a small project.

The breakdown is about 15,000 lines for the GUI (mostly visual components). The setup phase and resource handling take about 7,000 lines of code. And the type system for Project V takes roughly 10,000 lines of code. The other 10,000 lines are mostly support code like RNG's, font instance implementations for ICU, interface implementation for texture manipulation, stuff like that.

What I find strange is that the type system takes that much code. Most of it isn't even about the type system itself. It's just about handling sets and nodes. The core type system itself is a mere 574 lines. This file handles type and value comparisons. But I should mention that I have a lot more "glue" code that most other projects, especially in the type system. I don't just rely on what the language has provided.

Project V has 35 cpp files at this point.

I know I will reach 50,000 lines in a month's time since I'm going to be coding up Project V components and the runtime. So I will officially be heanding into "large" project land soon. Like I said, I try and keep the "small" project feel. And I believe I've more than succeeded with Project V.

What are your thoughts on project size? Does it affect anything? For me, nothing has changed because I've built projects this size before. Well, perhaps not 50,000 lines, but in the tens of thousands anyhow. So I started the framework with the intention and knowledge that it would get this big. Not only that, but I consider these to be proper software development practices. I've mentioned these in the past such as helper objects, separating different modules and including plugin mechanisms.

In the past, for me, a large project meant one that suffered under its own weight. Where you could feel its bulk getting in the way of contributing to the project. These were rather large projects. Close to a million lines. Sometimes well over that if you consider satellite projects. I'm not sure this is necessary anymore.

Flaw in Halting Problem Proofs

I wrote a paper that explains why there is a flaw in the Halting Problem Proofs. I've written it in plain language because I felt it conveyed the message in a clearer fashion.

Flaw in Halting Problem Proofs[pdf]

It's based on a single point. I believe this to be the simplest and best explanation I've come up with yet. I'm glad to see that more people are starting to realize that the Halting Problem Proof is nothing more than a parlor trick that has nothing to do with computing. More than that, it is a very specific problem that only applies to one particular type of computing machine. For example, dataflow doesn't really have a concept of halting. Dataflow can produce multiple results, at different times, and the network can continue to be active afterwards.

But my paper doesn't talk about those issues. It revolves around the way the proofs are framed and one critical assumption that is taken as absolute, and is ultimately incorrect.

I post my paper here for reference. It does not include citations of other work because I'm not building on someone's idea. And it's quite a simple issue.

Project V: Events are Done

Another update on Project V. I'm done events. This was a really ugly and intrusive change. It's one of those things that I rant against. I did it as cleanly as I could and implemented in the way I've mentioned in the past to keep two versions of the code accessible. One version triggers an event. The other does not. The reason for this is that member functions often want to do modifications without triggering events mid-way through. So the no event methods come in handy.

This is one of the things that really does not work anything like the real world. In real life, you can have someone watch the entity in question, and if it changes, the person can report back with that change. Or you can simply have a device do the work for you.

On the other hand, with memory you can't just monitor a memory location. In theory you could, but it'd be awfully inefficient. The processor can tell when a 4K (or 1MB) page has been written to. This is necessary for virtual memory. Certain memory profilers on Linux use this method as well to know if your memory has been corrupted or if you have any bad pointers. But allocating 4K (or 1MB) for each object is ridiculous.

What I have to do is actually insert some code before and after the changes take place. For the events that get called right away, I have imposed a restriction that you may not modify the entity in question within the event handler. However, delayed event handlers may do whatever they like.

IOW, immediate event handlers are for monitoring purposes only. Delayed event handlers are used if you need to update the component network itself.

I think this is a good compromise and ensures that there are no recursive event triggers.

Another problem I encountered was deletion of entities within the component network. I don't want to trigger events and then find out that entity in question isn't even around anymore. Actually, this is what made me consider delayed events in the first place. Not only delayed events, but delayed deletion. Deletion will do everything you would think. It separates itself from any other nodes and triggers all the events that these actions would generate. But it doesn't actually delete the node itself. So all events will at least get access to the entity itself which includes its name and ID. Once all delayed events have been handled, all items queued for deletion are deleted.

And yes, I'm well aware that this is one case where GC would have been helpful. But I don't want to be dependent on a GC when I build the native compiler. It's simply not necessary.

Next up on the agenda is completing the building of networks. I've had most of the code done for a while now. But with events, I can keep the GUI automatically updated of any changes. This is what was slowing me down. I did not want to have to tell the GUI of every change. How am I supposed to know what GUI components require updates? Instead, GUI components register an event handler within the Project V component network. That way, each GUI component will be in charge of keeping itself updated. Much cleaner and much easier to maintain. Also reduces coupling between GUI components and the Project V component network.

(Note that GUI components are visual like buttons and Project V components are computational nodes like addition).

After I can build networks, I'll built the single core runtime engine which is already done. I just have to update a few things on it to reflect the changes I've made since then.

Then multicore runtime engine... then distributed runtime engine... then the WORLD!

If ONLY ONE Item is Different, It's Likely To Be Skipped Over

Is this a principle? Anyone know if it exists or is known at all?

It's simply that if you're scanning a list of items visually and only ONE item is different from all the rest, I'll usually skip over that item because it's different and I assume it's in a different category. For example, Open Office has a different icon in the start menu. I was looking for it and couldn't find it. I kept skipping over it because different icons usually mean executables or files, and I'm looking for a folder.

Anyways, maybe it should be check in GUI design. Dunno.

Just thought it was interesting considering I'm doing some GUI development now.

Merging of Different Operations

I'm getting closer to finishing events in Project V and although I will simply have built-in components to start, I am starting to think about how to represent different operations when I get to executing them natively. When do different operations actually represent the exact same operation?

For example, in video cards, we render one texture at a certain location to essentially copy one texture into an (x,y) location in another (the backbuffer). Leaving out 3D operations for the moment, isn't this really just an array copy? How would a generic operation be described?

Read more...

Project V GUI Demo (Fixed)

Update: There was a wrong switch for compiling shaders. It is now fixed.

This is a little (and I stress little) demonstration of the GUI system that I've developed for the Project V IDE.

You need three things to play this.

1. DirectShow XviD codec (or DivX or other MPEG4 decoder)

Either ONE of these will do. I've tested them both though I recommend the first one.
XviD
FFDShow

2. DirectShow or ACM MP3 codec

You should already have this.

But you can find it here if you've NEVER played MP3's on your machine before.
MP3 Decoder

3. 64MB Video card that has PS1.4+ and VS1.1+ along with DirectX 9.

This means that if your video card isn't older than 10 years, you should be fine.

As far as I can tell, this should work on ATI 8500 and better (X and HD series are WAY better) along with Nvidia Geforce 5 FX (5200) and better.

For memory, you'll definitely need at least 32MB of video RAM. No clue if it'll run on only 32MB though. It's not that I have lots of graphics, but that I use a lot of textures for processing stuff behind the scenes and caching text.


I needed a video to display in the video player in the demo, so I used the Iron Sky teaser that was put under a Creative Commons license. If you haven't seen the teaser yet, please do so at the official site BEFORE viewing this demo, otherwise you will regret it. I only needed it to show that I can play videos, so it's reduced in quality. See the best quality first at the following link.

GO SEE IT NOW!
Iron Sky teaser


Ok, finally the demo. Again, it's about the GUI. NOT Project V. So you'll see some text, graphics, video, audio, stuff like that. Hmmm... Guess you can actually SEE audio. Wait a little while after the end. Tell me what you think. And the little game is what was possible in Java about 10 years ago (without antialiased fonts). I ported it to my GUI system just to compare. Took a day to port it in case anyone wants to know, mostly to take stuff out.

The point with this is to have a GUI system that makes the video hardware directly available to the user. I could have added 3D, and it IS available, but damn... I only want a 2D application for now.

Demo - 19MB Download

I had to use a hosting site as Opera blog doesn't allow hosting of executables.

Have fun.

Oh, one last thing. If your screen size is anything other than 1680x1050, I haven't tested it. I tried to make things resolution independent, but it's funner if there are possibilities for surprises.

For those interested, I used this technique once. Guess where.

GPU Gems Chapter 21
June 2013
S M T W T F S
May 2013July 2013
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29