User Tools

Site Tools


blog:fall2015:dm016807:journal

This is an old revision of the document!


Week 1

C prog

Captain's log, we are en route to beginning our journey through C and C++. We press forward through a language of functions, where one must declare, define, and call the aforementioned in order for them to work in our programs. We have encountered strange data types of extraordinary power: char, short int, int, long int, long long int, float, double, and long double. The latter three being used where decimal's are needed. Though we may not yet have machines, we will still attempt to go where probably almost anyone who has signed up for this class, even those who dropped in week 2, or even individuals who have lightly googled the subject, have gone before. We do not know yet where this course will take us, but we move forward into the dark regardless, with our newly learned s/p/fprintf and stdin/out/err statements.

UNIX

This first week I was not of this course, mostly in part because I did not realize I would need it… again. Figuring out how to use the journal, navigate lab46, and checking new projects are becoming second nature. I am working on setting up the class IRC channel, subscribing to the mailing list, and getting used to the repository. I still find it a bit odd that these journal entries are due two days before the project, when often times they are meant to at least partially include things about the project you had worked on. I suppose it could encourage us not to procrastinate, or to revisit old entries to update or simply include updates in future entries. Just need to put the time in and it should all come together.

Week 2

C Prog

Houston we have machines. Standard I/O and Header files soon become a part of muscle memory soon after typing the words nano and a file name. Hands on learning with Lab46, with a variety of hg commands (status, add, commit, push, pull, log, etc.). We've begun learning a new way to do arithmetic, leading into our first project beyond Hello, World. Beyond that an introduction to base 2, 8, 16, and the traditional numeric system we know as base 10. 10 is no longer ten, but one zero, numbers can now also be symbols and no longer hold the same numeric meaning we once knew. Though since this code existed before I did, in some context I'm just now learning the truth. % is an escape character, which denotes a special character when preceding something. Simplifying a number like 110111100001 has never been easier now, being able to segment it off into four three digit segments to express it as 6748 in base 8, or three four digit segments into DEI in base 16. We've learned tricks like a base 2 number starting with a 0 is positive, and a 1 is negative in signed base 10. This coincides with how they line up with base 2 numbers on the table. With ASCII characters in the mix, attention to fine detail on quotes has never been more important. It's all confusing like most things language related the first time around, but it seems to get easier each day I see it.

UNIX

I attended my first class the day before our first assignment was due. Luckily it seemed like a good one to be at, with a lot of pertinent information for the task at hand. Figuring out how to navigate creating, compressing, etc was difficult at first. Once I learned the manual command it got quite a bit better. I was confused at first by the random symbols after having opened each file, until realizing if I sat back I could make out the portions of a horse. Unscrambling them wasn't an issue, nor putting them together into a text file, however when I went to make it into an archive and zip it, apparently I did it twice and caused lines through my stallion. I fear he may never race again. Tar seems to be a more efficient way, using less read/write than many other methods. Also with it being so close to the hardware, it's compatible on almost every device. Tar.xz seems to be a more modern format, which compresses better than gzip or bzip2. It does make me wonder the type of person who first programmed some of the functionality of UNIX, with commands such as touch and finger. We learned about using cat, /etc/motd, as well as wc, rev, etc. Quotes make sense, though back-quotes could be an oddball. Next week we get to mess with the hgrc and customize our setups a bit more to our liking. For now I keep looking at notes to do things, but it should come almost naturally.

Week 3

C Prog

Things are ramping up quicker as we move on through our 4th week of classes. We've gotten into a lot more code in the ways of if, else if, and else. Getting used to not using a semicolon now is new, but you learn quick since your code won't work properly if you don't. Imagine if my computer wouldn't turn on or my car wouldn't start if I hadn't done my homework (assuming the homework wasn't on the computer), it's a much bigger motivator. We got into the rules of how else cannot exist without if, if works when you have exactly 1 thing, else if works with 0 or more, and else is simply zero or one things. So if I want a cannoli, but there is only a salad drenched in ranch, else I don't eat, print hunger grows. We got into relational operators: instruction, fetch, decode, execute, store, and their relation in the instruction pipeline. Aside from almost always using fprintf to get used to it, we're now getting used to using == to mean equals instead of the traditional math expression =. It's just a different and technically more correct way to think of equals, as apposed to just “is.” Diving deeper we got into ways to write more efficient code using our new found friend if, using multiple parenthesis to group logical expressions or formulas with && and || or that may some day save memory in our future programs. It could make the difference in the long run if little Jimmy gets to play a game or program you helped write, if his computer specs are good enough. But thanks to your knowledge of for, while, and do while loops you've saved enough memory usage over the course of the code to make it all work for him. You're welcome Jimmy. All these tools, along with the incrementation notation which looks similar to what my grade should be (a++) allow us to do this weeks project. The initial logic and math involved was very straightforward from the prior squares project, however once you get to subtracting the largest fitting number multiple of 7, I actually had to stop and think. We figured out one way and learned a few more in class, however it is apparent there is a much easier method that only my inner child could deduce. I've attempted watching the Sonic the hedgehog Saturday morning cartoon and some episodes of Jim Henson's Dinosaurs to invoke him, but despite my glee the equation evades me. If only I had some icee's to melt down and pretend they were gummy berry juice to bounce around with, perhaps that could be the key to unlocking this memory.

UNIX

This week we got into memes, quotes, and wildcards. Somehow a full(literal) quote is only one quote, while a half quote is two quotes. How a half quote has twice as many quotes as the full quote and isn't called a double is initially confusing. It seems like there are a lot of terms that I've grown accustomed to based on how people use them in my surroundings, that in the UNIX world can mean fairly different things. Backtick makes sense at least. We echo'd memes, and denoted their variable access using the dollar sign. We also learned some of the key words/environment variables in UNIX like $USER, $HOME, $PATH. Much like Mario we bashed some stuff in our shells, and messed with alias'. Our good ole friend the PS1 and PS2 also made a showing, only this time not in it's console Dark Cloud playing self. Also figured out a fix to getting stuck while trying to do something to a series of > > >'s. My retention of the things I just did last week seem to fail me. I just need to continue practicing with different commands until I know what to type, what it is, and how to use it by heart. I've reached the project and messed with it a little, but haven't figured out the commands for all the different modification options. Manual is my friend, but sometimes I struggle to input the right command to look up and end up turning to Google. Google is not always my friend. I plan to look at and work on this more in depth tomorrow. I intend to tackle this hgrc file, and reclaim the use of my mouse. Not that arrow keys aren't fun, but the longer our code gets, the less fun it will become. Depending on the option, the effect it will have on the program can vary greatly. Currently I am still a little flustered with the system, but I'm sure we'll become old chums once I put more time into customizing it and making it my own. This project is good because it will force recognition with many of the commands involved, but until you grasp that it can be a real pain.

Week 4

C Prog

For this week we are essentially learning how to dig a mote with a shovel, and then next week we're learning how much more convenient and simple it is to dig it with a backhoe, assuming you're pretty spot on with a backhoe. Only instead of the difference being the cost, it's more about our individual knowledge/skill based on effort and education. In class we've moved onto the wonderful world of containers (or composite varibles). Such wonders referred to as the array, struct, and the vowel used less than y, union. Array's being homogenous composite variables, they only deal with the same data type, in our case mostly int's. Whereas structs being heterogenous can be filled with all different data types, and contain array's within them. Unions however are like the red headed in-law cousin of structs. Syntactically they're very similar, but no one interacts with them. It'd be like if you had to room with the aforementioned cousin anytime he came over, but there's only one pillow, and it's allocated to whoever was interacting/using the bed the most recently. Much like in the auto industry, the union is rarely useful in present day application, though it was created with good intent in a time when it was necessary. Back to the topic of shoveling, this weeks project is furthering from last weeks mental math exercise to now be multiplying by 11. The trick here seems to be how to have the program detect and respond appropriately for if the input is a 1, 2, or 3 digit number, with the input only being allowed to be a single integer value. The math is pretty straight forward, as long as you remember to increment the next number by 1 if needed. I find that conceptualizing the idea behind the project and the steps isn't so bad, but putting that into coding terms can be a bit of a trouble. Hopefully that's just something that will come with time (and more practice/playing..). As for the input, it seems like we could just set it up for 3 digits always, and if there's not they'll just automatically fill in as 0s which won't matter or show up anyway. This program could be extended to 4, 5, and so on fairly easily. There's a repeating pattern when you take two numbers, add a possible carry, and check if they're greater than 9 to see if you need to make the carry 1 or not, otherwise setting it to 0. As long as we add another variable to the last and first function, to make them the same so we can loop it (setting them to 0 so they don't impact the outcome), we can relatively easily convert this program to do bigger and bigger numbers. It seems like this program will need a minimum of 4 variables, and if we don't reuse them we could probably get halfway through the alphabet. Since we're doing most of the heavy lifting this week, next weeks project should be much easier, assuming there's no additional screwball thrown in, which there very easily could be.

UNIX

This week in class we reviewed different ways to list the word count of a variety of file names. The main focus was on the editor VI, and all of it's commands and insert modes. The most important thing we learned about VI, was how to actually get out of it, being :wq to save and quit or :q! to abandon ship with no hopes of saving anything. It seems like a pretty powerful tool in terms of efficiency / time saving, however at this point in time most things I have to type require to be in a .doc file, so it's not entirely for the lazy of heart. With the amount of time you can save, I'm sure it's worthwhile to open it and possibly have to modify a little to save it accordingly for whatever course or purpose, however change is scary. I like that you can use commands like 7dw to delete 7 words, p to paste below or P to paste above, and that anything you delete is basically cut and can be pasted wherever with ease. It's still a bit of a hassle now, but once familiar it seems much better than any word processing editor I've used. Despite being a dinosaur of a program, it still holds fare more available options for quicker and easier editing to any who have grown accustomed to it. As for this weeks project, I question if I have learned anything. If I have to type one more command and get back This is a simple text file. It contains ASCII text. I might have to aggressively lose half of the keys on my keyboard. The magic number doesn't seem to give me anything, and half the other file options don't seem to help too much. I'm sure this is probably a simple thing and I'm merely overlooking or just unaware of a command needed, but I've still got two days to figure it out. I know there's some way to get it to analyze an ASCII file to see if it conforms to some language, but I haven't figured out how to make it do what I want. Also since when I nano into it, the file says the same thing about it being ASCII, it could just be lying since there were a ton of hints/bluntly stated as to things not being as they seem. I'll have to cat around and compress and uncompress some stuff, as well as reading would probably be helpful. Next up will be the riddle.html file, which I will attempt to open up in VI or just cat. I still need to get file(1) under my belt, this could be the key to my success. Overall this is a pretty interesting project, if given the time necessary I imagine it's very doable. It's probably even easy if you don't overthink/overlook things. Only two weeks to go, and then we get a full week to play around to our hearts desire. It'll be interesting to see what all I can do by the end of this course, hopefully having made it there in one piece.

Week 5

C Prog

One more week until break week, and then I can sleep in for once. So far sleeping 3-6 hours a night and taking naps has worked, though I suck at this nap thing. Set two alarms for 20 minutes, fall asleep, wake up 2 hours later, feel terrible. Must be an acquired thing… As for class we've dove into functions, basically the process after the input and before the output. We've gone over returnvalues, function names with parameter(s) that are datatype variables, as well as the three steps to function success. Declaring the function prototype, defining it WITHOUT A SEMICOLION, and using the function in the form of a call. Diving straight into funcfun we practiced some of these new found functions. FuncFun2.c took us into familiar territory of pointers, but in a very unfamiliar way. We now saw how they could point to functions, which have to be of the same data type. We also got to play with cases for the first time, and also used break for the first time. The function pointer allowed us to use one print statement for several possibilties, saving both time for more efficient laziness and memory usage. Eventually we graduated up to FuncFun17.c where we learned that when Matt doesn't get his 2pm nap he becomes exceptionally troll-y. Creating such npc characters as mudkip, with structs mario2isthebestmario, and starfishlovesyou. The premise of functions makes sense, but it'll take more practice and familiarity with getting used to how to write it out. We're definitely starting to see how this language can be used to it's full extent, and it sort of feels like a glimpse of what c++ will begin to grow out of. Functions are just more useful for larger programs or more complex situations, where variables can be altered over the course of the program. As for this weeks project, we're expanding on our old friend multiply by 11. Now that we've finished our mote via shovels, we're learning how we can dig the same mote, only better, and much more efficiently with our new found backhoe, also known as the array and loop. There's some added difficulty with numbers up to 8 digits, but with loops and arrays it's not really any more work. Adding code to display more things can be a bit of a pain, but it helps to understand each step as we go. It's especially nice for troubleshooting errors in the code that compile, but mathematically don't add up.

UNIX

Just incase you didn't feel stupid enough for trying to break down the 644 code into a series of 2s making it 322, or twisting the random gibberish of some files in a variety of ways to realize it didn't make a code, there's now a whole new puzzle box! I've learned from the first one Matt isn't as diabolical as he could be, yet, and that it's mostly just using what you can see infront of you, consulting the manual on said possibilities, and trying things out. Wemux has become a close friend to the class now, making it so I no longer have to look up from my computer screen to feign attentiveness. Our vi command library continues to grow, with such cool tricks as .,3co$ which allows us to copy 3 lines to the bottom. Generally almost all the commands seem to be able to work together, which makes mastering this text editor seem quite worth the challenge. We've now discovered the mystery of dinosaurs with hats, which is basically just velociraptors with hair pieces, though I guess that's not as catchy of a title. Customizing our VI has never been easier, with such commands as set number, syntax on, set cursorline, and set tabstop=4. By making a .vimrc file in our home directory, we were able to make VI look quite a bit more welcoming. Having color coded keywords in a nice desert fashion makes it much more enjoyable to look at, as well as readable. Smartindent allows us to be more productively lazy, as well as setting the shiftwidth and tabstop. This time I'll attempt to be a little less “what's the most ridiculous thing this could mean,” and try to just go by what i see, and what i can understand from that. There's more abstract thought this time around, which potentially means more headaches, but also more possibilities some of my ridiculous notions might turn out to be correct. This project as the last one, has taken a step back on spoon feeding, which should be good in the long run, but can be a real pain in the ass for now. The process page has now diminished to a mere two paragraphs of about one two sentences each. Now for the remaining word count to surpass 640 for this week, lets look at some Linux history by Paul Cobbaut: All modern operating systems have their roots in 1969 when Dennis Ritchie and Ken Thompson developed the C language and the Unix operating system at AT&T Bell Labs. They shared their source code (yes, there was open source back in the Seventies) with the rest of the world, including the hippies in Berkeley California. By 1975, when AT&T started selling Unix commercially, about half of the source code was written by others. The hippies were not happy that a commercial company sold software that they had written; the resulting (legal) battle ended in there being two versions of Unix: the official AT&T Unix, and the free BSD Unix. Development of BSD descendants like FreeBSD, OpenBSD, NetBSD, DragonFly BSD and PC-BSD is still active today. In the Eighties many companies started developing their own Unix: IBM created AIX, SunSunOS (later Solaris), HP HP-UX and about a dozen other companies did the same. The result was a mess of Unix dialects and a dozen different ways to do the same thing. And here is the first real root of Linux, when Richard Stallman aimed to end this era of Unix separation and everybody re-inventing the wheel by starting the GNU project (GNU is Not Unix). His goal was to make an operating system that was freely available to everyone, and where everyone could work together (like in the Seventies). Many of the command line tools that you use today on Linux are GNU tools. The Nineties started with Linus Torvalds, a Swedish speaking Finnish student, buying a 386 computer and writing a brand new POSIX compliant kernel. He put the source code online, thinking it would never support anything but 386 hardware. Many people embraced the combination of this kernel with the GNU tools, and the rest, as they say, is history.

blog/fall2015/dm016807/journal.1444103294.txt.gz · Last modified: 2015/10/06 03:48 by dm016807