A little update

So, if you haven’t noticed, I made my Github repos private. Specifically, I made the repos containing code for class projects private because my code was being, ahem, reused in ways that could have made me party to honor code violations. As a result, I won’t be making code written for class projects public except the executable files (maybe). In hiding my repos, I upgraded my Github account but I instantly hit the 5-private-repo limit. So, I’ve been making extensive use of bitbucket.org which is actually not bad at all. Bitbucket.org uses Git so I don’t have too much relearning to do. and it’s great for keeping track of my projects. I’ve tried to get my pair programming partners interested in using Git as a way of collaborating but so far, no luck.

Bitbucket

I’m taking two programming classes this semester (Java and C++/C). In both classes, I’m now learning about creating GUIs. For Java, we’re starting with the Swing toolkit; For C++, we’re using the FLTK (pronounced “fulltick”) toolkit. Being new to GUIs, I don’t have anything to say just yet. I’m still trying to wrap my head about the hierarchies, etc. I just wanted to post an update about the repo situation and talk about one|some of my projects!

My most recent project for the Java class involves creating a menu of functions that need to be implemented recursively e.g. factorial, fibonacci, sum up to n and 2 to the n. When using integers for the recursive factorial, I could only compute the factorials of numbers up to 12. When I switched to long, I could only go up to n = 20. So, I decided to use BigInteger which is not a primitive data type so I couldn’t do things like n * n as I would to a regular integer. Here, my favorite sites came in handy: the Java API (for learning how to create a BigInteger and methods available for use) and leepoint.net for an example of how to use BigInteger. Overall, it was pretty painless to use BigInteger for my factorial function. To make use of the BigInteger class, make sure you import java.math.BigInteger. Also, if you’re using an IDE like Eclipse, type a dot after your BigInteger variable name to bring up all methods available to your object.

Lastly, I leave you with an Emacs tip that I’ve warmed up to: Meta-D deletes the word to the right of the cursor and Meta-delete deletes the word to the left of the cursor.

 

Advertisements

Using Eclipse for C++

For over 2 weeks, I’ve been writing code using Emacs. To see what writing C++ in an IDE was like, I tried writing a simple “Hello World” in Eclipse and when I hit run, I was getting an odd “Launch failed. Binary not found” message. I googled that exact error message and hit pay dirt.

With hindsight, the error message told me all I needed to know. The .cpp file gets compiled to a binary file i.e. object code which is executed. If you were compiling via the commandline, your commands would look like: g++ -o executableName filename.cpp and to execute, you would type ./executableName. Accordingly, your .h/.cpp file needs to be built and in Eclipse, that command is Ctrl-B or the “hammer” symbol. 

Application_launcher_110Selection_113Selection_112

Getting comfortable with the CLI

For two of my classes (C++/C and more Java) this semester, I’ll be diving into the CLI. If you’ve read my other site (Jane Talks Tech!), you’ll know that I’ve been exposed to the Linux but for the most part, my stomping grounds have been the Microsoft Windows OS. Typing commands is something I haven’t done a lot of but now, I have an added incentive to learn how to use the terminal and the Unix environment!

The first thing I did was image my notebook using Acronis True Image. Then, I installed Ubuntu Oneiric on the entire disk. I have learned that the best way for me to learn is total immersion so that’s why I went for Ubuntu as my main OS and using VirtualBox to add any other OSes as needed. I had it the other way around i.e. Windows 7 as the main OS and Ubuntu as a VM but it wasn’t quite the same.

After importing my files, I’ve decided that I create way too many folders for my own good but it helps with organization. So as a shortcut, I installed nautilus-open-terminal which will let me open a terminal in whatever folder/directory I am browsing. This has saved a lot of unnecessary cd-ing commands and my fingers love me for it. 🙂 I would like to give a serious shout-out to the people who write the documentation at help.ubuntu.com. Besides the man page, the Ubuntu help site has been invaluable for simply finding the right commands to figuring out how to make my external monitor work with Ubuntu

Beyond getting comfortable with the CLI, we are actively making use of text editors and have been encouraged to use either vi or emacs. I selected emacs (for now) and so far, I have learned the key commands to be able to work well. All that needs to happen now is for the shortcut keys to become second nature. 🙂 Emacs integrates quite nicely into nautilus so that all I need to do is rightclick a file to edit it in Emacs. Of course, I could cd to the file and type “emacs filename” but I’ve quickly found out that unless I quit the file, I can’t use that particular terminal for anything else! Hence, my preference for navigating to the file in nautilus and rightclicking to edit in emacs. Please feel free to correct me if I’ve been “doing it wrong”. 🙂

Update (1/26): A way to start emacs from the terminal and get a Unix prompt back is to type: emacs & .Awesome. 🙂 

I’ve also been learning about make (really Makefiles which are a nifty way to compile & build executables). At first, I pooh-poohed the idea and wondered how hard typing “javac filename.java” was. However, as software applications increase in complexity and require more dependencies, having a Makefile totally makes sense. It’s quite powerful and I am sure I’ll become very intimate with its quirks.

Menu_070Synaptic_package_manager_062