2021-09-25 - Terrible with Dates
I like to think my memory is pretty good. I can remember song lyrics and movie quotes. I can remember classes, function names and programming concepts. I can imagine locations in my head. I can remember math and physics concepts even if I haven’t used them in a while, but I am terrible at remembering dates.
It seems like my brain strips away date information from whatever I’ve learned. It could be a historical fact or personal information. It could be something that happened to me. I can remember the event but for some reason I have difficulty recalling when it happened. Not only that but I have a hard time keeping track of the order of events. Did I go visit my parents before or after I got a hair cut?
It seems like my brain prefers to arrange information based on a physical rather than a chronological similarities. I can picture most of the houses I’ve lived in and where everything would have been but I struggle to recall when we would have moved into them. If you ask me where something is I might be able to figure it out but if you ask me when something happened or if one thing happened before another I probably won’t be able to tell you.
I think some of this is because of my eyes. Not being able to see well, I have learned to focus on and memorize where things are and what they look like. That way I can easily find those things even if I can’t really see them. I can navigate through a place or recognize something from far away. Concentrating on the physical aspects of things has probably made me less aware of the timing of things as that’s less critical to me.
I also notice that I’m better at remember what something looks like then what happened at an event. I can tell stories fairly well, I think, but I can’t recall them. If you ask me what happened I’d probably say “I don’t know”.
Another of those brain oddities.
2021-08-27 - Goals
I’ve been contemplating goals a lot lately. It seems like goals can be both good and bad depending how you set them. They can help you get stuff done while at the same time discouraging you from doing things.
On the positive side, goals are good for making sure you know what to do. Having a plan for your career, hobbies, life etc. If your goals are short term they can provide with options when you are contemplating what to do with your spare time and then make you feel more accomplished when you complete them. If your goals are long term they can give you direction and tell you what to work for.
On the negative side, they can be discouraging if it’s not clear how to accomplish them. If a goal is difficult or requires a lot of luck it can be easy to not even try. They can also make your other accomplishments feel less impressive because they aren’t what you’re supposed to be doing.
It seems like the further out your goals are the more vague they need to be. Don’t set yourself an absolute target far away instead try to set a general direction you want to go in. Figure out a few things that you can do along that path but don’t set up too many things upfront. Complete those tasks, see where you are, figure out where you want to go and make some more tasks.
You may not end up where you originally planned to go but you should at least end up going somewhere.
2021-06-06 - In IL: Class Definitions
IL is a object oriented language like C# and Visual Basic .Net. This means that classes are a built in concept. Classes are defined with a class header describing the class followed by a class body enclosed in curly braces.
.class <attributes..> <Id> extends <baseClas> implements <interfaces…>{ }
A class is declared using the .class directive. This is followed by a set of attributes which describe how the class behaves. The Id is the name of the class. The extends keyword is used to specific the base class. If no base class is provided system.Object is assumed. The implements keyword is used to specify which interfaces the class supports.
There are a variety of attributes that can be set.
Visibility
The visibility attributes are used for non-nested classes to indicate if they are exported, available, outside the assembly or not.
Attribute | Description |
---|---|
private | Class is not exported outside assembly |
public | Class is exported outside assembly |
Accessibility
The accessibility attributes are used for nested classes to indicate if they are available to other classes.
Attribute | Description |
---|---|
nested private | Visible only within the containing class |
nested famandassem | Visible to containing class and derived classes within the same assembly |
nested assembly | Visible to the containing assembly |
nested family | Visibility to containing class and derived classes |
nested famorassem | Visibility to containing class and derived classes or to the containing assembly |
nested public | Visible everywhere |
Layout
The layout attributes control how the fields of the class will be laid out in memory
Attribute | Description |
---|---|
auto | Layout of fields in the class is determined by the runtime |
sequential | Layout of fields will be sequential based on order of the fields in the class |
explicit | Layout of fields in the class will be set explicitly |
Type
The type attribute is used to specify what type of class is being defined
Attribute | Description |
---|---|
interface | Class is an interface |
Inheritance
Inheritance attributes control how a class can be used
Attribute | Description |
---|---|
abstract | Class cannot be instantiated |
sealed | Class cannot be derived from |
Interpolation
Interpolation attributes control how the class is handled when interacting with unmanaged code. Specifically it controls how strings contained in the class will be marshalled, packaged, before being sent to the unmanaged code.
Attribute | Description |
---|---|
autochar | string marshalling is determined by platform |
ansi | Marshalled using ansi strings |
unicode | Marshalled using UTF-16 strings |
Special
Special attributes are used by the runtime or tool to control how the class will be treated
Attribute | Description |
---|---|
beforefieldinit | Don’t initialize fields before a static call |
serializable | fields can be serialized (reserved) |
rtspecialname | Name has special meaning to the runtime |
specialname | Name has special meaning to tools |
2021-05-16 - Abstraction is Magic
In computing terms an abstraction is treating something like a magical box. You put certain things into the box and get certain things out of it but how the box actually works is irrelevant to you. Typically this magic box is a system, program or library provided to you by someone else that solves some general problem of computing or provides certain functionality that makes developing an application easier. Abstractions are the basis for a lot of the advancements in computing because they allow us to spend more time focusing on the problems that are specific to the thing we are trying to make. To see how this works I’m going to go through several levels of abstraction and show how they allow us to create more complicated programs.
The zeroth level of abstraction is hardware. The first computers were all hand assembled using components specifically built for those computers. This meant that every computer was unique and a lot of time was spent designing and building each one. Eventually companies started to mass-produce components, CPUs, memory managers, disk interfaces, video controllers etc, and when you can build a computer using off-the-shelf chips instead of specifically designed components it makes it a lot easier and faster to get a working computer. The trade-off is you have less control over the specification and characteristics of each individual component.
The first level of abstraction is machine language. Machine language programs are made up of a series of binary values that tell the computer what to do. A 120 might tell the computer to move a value from one register to another and a 195 might tell it to jump to an instruction at a specific address. Now that were are using mass-produced chips we no longer have to worry about how these codes control the computer and instead we can focus on what we want the computer to do. The trade off is that we are limited to the operations that were implemented in the chip we are using.
The second level of abstraction is assembly language. These are the textual mnemonics used to represent the machine language instructions available. Instead of a 120 we now have a MOV A,B instruction and instead of 195 we now have a JMP instruction. An assembler program provided to use takes this text and converts it into the binary machine language that the computer understands. Assembly languages usually also have directives and labels which allow the programmer to tell the assembler what they want it to do without having to specifically set things up. Some can even perform optimizations that improve performance or memory usage. Now we don’t have to memorize the binary value of each instruction or figure out which addresses we want to use. Instead we can focus more on what we want the program to do which is easier to describe using mnemonics. The trade off is we have less control over the set of operations that the computer actually executes.
The third level of abstraction are compiled or interpreted languages. These are more advanced programming languages which don’t try to represent the actual machine language operations available. Instead of MOV instructions we have variable assignment and instead of JMP instructions we have conditional statements. The compiler or interpreter takes the text you wrote and does the hard work of turning it into the machine instructions that the computer can actually execute. Now we don’t have to know anything about the instruction set of the computer we are running on or sometimes even which computer we are running on. Instead we can focus more on what we want the program to do which is a lot easier to describe using the keywords of the higher level languages. The trade off is we have even less control over what operations the computer is executing.
The fourth level of abstraction are frameworks and libraries. These are collections of code which have been written to handler UI or database operations for us. Instead of drawing a dialog box using box characters we just tell the framework that we want a dialog and where we want it and it draws it for us. Someone wrote the framework to have a dialog function in it and we simply have to call that function. Now we don’t have to worry how to draw dialogs or connect to databases. Instead we can focus more on what we want to do with the dialogs and the database. The trade off here is we don’t have any control over how these dialogs are implemented or what functionality they provide.
The further up we go the more we get to focus on our specific problem. A program is about getting information from a source and then doing something useful with that information. The less we need to focus on the operations of getting information, displaying information or storing information the more we can focus on what we specifically want to do with that information. The trade-off with abstraction is efficiency. If you do everything from scratch you can develop a solution that is extremely efficient at doing what you want it to do but will likely require a lot of work to complete. On the other hand using abstractions you can be more efficient at designing and implementing your solution because you are simply putting together magical boxes created by other people with a little bit of customization on top for your particular needs. The solution won’t be quite as optimized as all the magical boxes need to support a variety of situations which don’t all apply to you but it will be a lot quicker to design and implement.
As computers have gotten more powerful the need for efficiency has gone down. We no longer need to fit our programs in 1 MiB of memory or less so using a large library that we only need a small part of is less of a problem. The more abstractions we can use the less we need to worry about and the more we can focus on what we are trying to do.
Of course the downside of abstractions are when things don’t work the way you want them to. Then the magical box concept becomes a pain because you need to know how it works and hopefully change it to better suit your situation.