The Joys Of Programming

Then release Spambook, a social networking site for spambots.

duckilama wrote:

You know what would be funny?
Start another site, SpamOrNot.com where user vote on whether a given piece of text is ... spam or not. Use that as the approval process for your site. Provide an API and when it gets really popular, sell it to Microsoft for a jillion dollars.

Couldn't spammers just set their bots up to skew your spamornot results so that they're useless?

juv3nal wrote:
duckilama wrote:

You know what would be funny?
Start another site, SpamOrNot.com where user vote on whether a given piece of text is ... spam or not. Use that as the approval process for your site. Provide an API and when it gets really popular, sell it to Microsoft for a jillion dollars.

Couldn't spammers just set their bots up to skew your spamornot results so that they're useless?

IMAGE(http://imgs.xkcd.com/comics/constructive.png)

Hahahahaha! I'd forgotten about that xkcd.
That's awesome!

Curious what the people running RoR have decided to use for their server software. I see Apache2 with the correct plugins being recommended but then read about nginx + unicorn.

I'm sure neither way is wrong, but would like to get a feel for why you chose what you did.

I am running Passenger, both with Apache and nginx.

It is very easy to get going and offers good performance. Passenger dynamically manages your worker processes for you, so that you don't have to worry about details like that until you are ready to.

I have been interested in experimenting with Unicorn, but I haven't gotten around to it. I would definitely recommend Passenger until you actually find a reason to want to use something different.

Rob: this is just one of the reasons I hate kakadu:

return Add_ilayer(_layer_src, _full_source_dims, _full_target_dims, (boolean) false, (boolean) false,
(boolean) false, (int) 0, (int) 2);

me: What a piece of kakadouchecode.
Rob: for serious
me: The guy who wrote it must be such a kakadouchecanoe.
Rob: haha
probably
Rob: I really like how he capitalizes all the method names
but ONLY in java
me: c coders are barbaric, uncivilized, unwashed heathens.
Rob: some of them sure
this one is just a jerk
me: I should post this to the "Joys of Programming" thread on GWJ
Rob: there is a joys of programming thread?
me: Yeah, with "Joys" in air quotes mostly.
Rob: hehe
awesome

WTF is a kakadu? Also, that code is just bad--not bad C coder code. T_T;

Some sort of image graphics library that's half Java and half C and all garbage.

I've started learning Python 2.7 before I start school for my BS in Computer Science. So, tracking thread.
When I finished the first chapter of How to Think Like a Computer Scientist: Learning with Python there was a vocabulary section. I spent the next hour or so completely deviating from the lesson and making a vocabulary test program (pops up with the definition, when you input the term it goes to the next one or loops back if you get it wrong). The first time I made it and ran it through with 0 errors was such a joy, as simple as it was. Then I figured out I could remake it using considerably less code (using an else statement instead of a second if) and did so
Programming is fun.

Woo go Fedora go!

FedoraMcQuaid wrote:

I've started learning Python 2.7 before I start school for my BS in Computer Science. So, tracking thread.
When I finished the first chapter of How to Think Like a Computer Scientist: Learning with Python there was a vocabulary section. I spent the next hour or so completely deviating from the lesson and making a vocabulary test program (pops up with the definition, when you input the term it goes to the next one or loops back if you get it wrong). The first time I made it and ran it through with 0 errors was such a joy, as simple as it was. Then I figured out I could remake it using considerably less code (using an else statement instead of a second if) and did so
Programming is fun.

You've just taken your first step into a larger world.

Grats!

Next step: lookup tables of questions and answers. Next next step: lookup tables of functions in which the questions and answers are encoded. Next next next step: strong drink.

Hypatian wrote:

Next Step: Strong drink. Next Next step: lookup tables of questions and answers. Next Next Next Step: Strong drink. Next Next Next next step: lookup tables of functions in which the questions and answers are encoded. Next Next Next next next step: strong drink.

Fixed for proper programming practices.

I created a presentation once for my alma mater's CS orientation day.

Some of my "advice to new CS students" bullet points:

* Don't expect to be taught everything in the classroom. You will be expected to study and learn on your own, above and beyond the coursework you're provided. In my school's department, most of our coursework was done in C++, and we did not have a single class on learning C++ the language. That was left as an exercise for the student. CS is not for the student who expects everything they need to know to be handed to them in assignments.

* Don't sell back your textbooks. At least, not very many of them. Provided your department is doing things right, many of the books you buy should end up on your bookshelf for life. Structure and Interpretation of Computer Programs? Introduction to Algorithms? K&R? Yeah, those should be with you until you die.

* Learn UNIX. Even if you love Windows, as a CS student you absolutely should learn to use the power of UNIX when you need it. Linux and other free UNIXes make it trivial to get started. Not to mention the whole experience of using and tinkering with an OS that's an open book instead of a closed-up black box. You can still love Windows afterwards, it's OK.

* Save all your code. I don't think I have a single line of code that I wrote in college, and that sucks. Nowadays, you can get a free Bitbucket account and create private Git repos and store everything up in Bitbucket. Or GitHub if you don't mind having the repos public. You no longer have to set up your own version control server or try and manually manage all your code.

* CS done right is one of the more strenuous college majors, with one of the highest dropout rates. Many departments have tacitly designated "weed-out" courses early in the curriculum, to prevent people who just can't wrap their brain around programming logic from delaying their shift into another field of study. If it's known what and when these courses are at your institution (they usually are known, passed down as lore from outgoing classes to the new incoming ones), be certain you don't overload yourself with too many other classes and responsibilities. Make that semester one of your slightly lighter loads.

* Today, there's a million free online resources from very prestigious universities. If you're not wrapping your head around a concept, look for other resources to see it taught in a different way.

* There are places like StackOverflow where you can ask other programmers questions. When asking questions, especially about code, (a) make an attempt at it first, and (b) show your attempt. People will help you where you're stuck, but nobody wants to do your homework for you.

* Compared to many majors, CS is slightly hardcore, yeah, but it's not a macho exclusive club either. Ignore the people that think they're special because they're in CS. Plenty of other disciplines can be just as strenuous. As long as you have the proper expectations for the amount of work you're going to be doing, and have at least a bit of aptitude for that kind of thinking, it won't be some soul-crushing initiation rite.

Dr.Ghastly wrote:
Hypatian wrote:

Next Step: Strong drink.
Next Next step: lookup tables of questions and answers. Comment the crap out of that.
Next Next Next Step: Strong drink. Comment that, too.
Next Next Next next step: lookup tables of functions in which the questions and answers are encoded. Comment. I'm talking the "War and Peace" of comments, here.
Next Next Next next next step: strong drink. Comment some more. (but not "tou drink to cod" )

Fixed for proper programming practices.

Fixed again for even more proper programming practices. I'm in the middle of garbage washing someone else's code today. No comments at all, no white space, topped off with single letter variable names, function names, and some of the CSS styles are named with NUMBERS. It's a damned good thing the dribbling little junk-monkey is in another state.

I would add this to your list, Legion.

- Study something other than Computer Science when you have free credits.

In my experience my favorite co-workers are people who are self-taught with degrees in liberal arts. Mostly because they tend to communicate well and are easy to work with. I think coming out of college well-rounded is equally important.

Also, special emphasis on "learn Unix". I'm still stunned by the number of software developers I come across who don't know Unix. It definitely puts you a step ahead. Learning Windows, going the other direction, is easy.

Is Unix something I should start working on now or something I should work on in school?
Does Unix have it's own language within it or is it just the open OS coded in another language? If so, what is that language?

FedoraMcQuaid wrote:

Is Unix something I should start working on now or something I should work on in school?
Does Unix have it's own language within it or is it just the open OS coded in another language? If so, what is that language?

I think he's just saying that you should be comfortable with doing stuff in the Unix operating system. For example, things like using the terminal, editing text files via VI or basic stuff like that. If you can move around and accomplish things in Linux via a terminal, that is similar. If you wanted to start learning stuff, you could probably just run a copy of Linux in a VM or something. That wouldn't require you to actually install an extra OS on your computer, and it's all open source a.k.a. free.

DSGamer will have to elaborate on the more important things of using Unix.

Comment the why, not the what. School seems to teach people to do it the other way around, which isn't as useful in the field when debugging something someone else wrote a decade earlier.

Yeah I've been adding comments into everything I've been writing for pretty much any line that contains different code from another. Mainly as a way to help myself understand what I'm doing, as I'm doing it. Hopefully it will be a habit that will stick.

FedoraMcQuaid wrote:

Is Unix something I should start working on now or something I should work on in school?
Does Unix have it's own language within it or is it just the open OS coded in another language? If so, what is that language?

Unix is a family of operating systems, of which Linux is a member. Traditionally the various parts of a Unix system are written in C, but you don't need to know C in order to use it.

Knowing how to use a Unix system means a few things. One is knowing how the system is organized. Another is knowing the various commands and tools available on the system. A third might be knowing how to operate a shell (such as bash).

Unix is a system designed by and for people who work on computer systems. It is therefore pretty good for developers.

Aside from Unix in general, you will want to become familiar with a number of different kinds of tools. (A key part of the Unix philosophy is dividing software into a large number of tools, which each have a relatively small, well-defined purpose.) The compiler or interpreter for whichever language you are using is an obvious one. A good editor is another one. Version control is a third. As you work more with the language, you will also want to learn how to operate a debugger for it.

You want to write code that is self explanatory and doesn't need comments. Comments are for when you need to explain why something is done a certain way.

for a simple example, instead of:

//if the answer is correct then do something
if(x==true)
doSomething();

you want something like:

if(currentAnswer==true)
doSomething();

I consider your example a bare minimum proper coding; not as a replacement for commenting. If you're dealing with anything more complicated than Hello, World! that won't cut it. Particularly if you're dealing with complex code across multiple development tiers.

Where is it getting currentAnswer from? The database? A variable assignment above? A code-behind? An object or component? At least tell me type is it -- string, Boolean, numeric? Maybe a note about whether the variable local or global? What comes out of the doSomething function? A string? A return value? What's using it, and what for?

[[removed long stupid code sample]]

You can't put all that in just the variable name. And you make it 10 times worse when you combine a lack of commenting with single letter variable and function names.

FedoraMcQuaid wrote:

Is Unix something I should start working on now or something I should work on in school?

It's something you can start using immediately.

Used to be, this would require dealing with a full install onto your computer, but now with multi-core CPUs and plentiful RAM, you can very easily play around with Linux and other OSs in a virtual machine on your desktop. That makes it very easy and very convenient.

tuffalobuffalo wrote:

I think he's just saying that you should be comfortable with doing stuff in the Unix operating system.

At least for a start.

Ultimately, I would want him to learn all the tools in a typical UNIX base system that make using UNIX so powerful, as opposed to just learning to do in UNIX what one can do in Windows. The ability to pipe together a bunch of powerful commands in a quick one-liner or shell script is what makes UNIX powerful and is simply not matched in Windows. There's a reason that there's a blog named BASH Cures Cancer. A good shell and base system is some of the most powerful software on Earth.

I saw fellow CS students in my class that were Windows-only users struggle with things that were trivial to solve at a BASH prompt. There's a reason that areas like servers and scientific computing (and pretty much anything outside of shiny GUI desktop usage) are dominated by UNIXes. A CS student should most certainly be discovering why that is.

If you're on Windows and want to learn about the Unix command line and programming environment, install Cygwin. It gives you an environment pretty much identical to the Linux command line (and X11, the Unix GUI framework, too if you want it) without having to run a virtual machine, with full access to your Windows file system. Pretty much all the widely used Unix and GNU software is either included in the Cygwin installer or can easily be built from the command line.

momgamer wrote:

I consider your example a bare minimum proper coding; not as a replacement for commenting. If you're dealing with anything more complicated than Hello, World! that won't cut it. Particularly if you're dealing with complex code across multiple development tiers.

Where is it getting currentAnswer from? The database? A variable assignment above? A code-behind? An object or component? At least tell me type is it -- string, Boolean, numeric? Maybe a note about whether the variable local or global? What comes out of the doSomething function? A string? A return value? What's using it, and what for?

[[removed long stupid code sample]]

You can't put all that in just the variable name. And you make it 10 times worse when you combine a lack of commenting with single letter variable and function names.

Woah slow down!

I don't need to write production ready code to illustrate to Fed that you don't need to comment every line of code you write. I think a bad example and an alternative way of conveying the same information with sane variable names is appropriate. He has been programming for a whole 20 hours now. Anything more and he's going to wonder wtf I'm talking about.

EDIT: I'd consider my examples completely unacceptable coding, not bare minimum proper.

DSGamer wrote:

I would add this to your list, Legion.

- Study something other than Computer Science when you have free credits.

In my experience my favorite co-workers are people who are self-taught with degrees in liberal arts. Mostly because they tend to communicate well and are easy to work with. I think coming out of college well-rounded is equally important.

Well put. I would build on that idea into a more general, "have a life and interests outside computing" guideline.

CS is something you can easily wrap yourself into 24/7, especially when you're in your early 20s. But it's important to maintain a life and interests outside of that.

This is the point where I would normally talk about college being the best single & available women buffet you'll ever attend, but Fedora has recently revealed to us (like a boss) that he's a proud member of the other team. I couldn't speak at all to the experience of being gay in college, but I think that's the point where they say, "it gets better". I would imagine college is a much more positive environment for that, and having a dating life becomes more of a reality. But like I said, I have no personal experience to base that from, just looking at it from the outside.

My ultimate point, though, is to pursue romantic relationships, as part of living a well-rounded life. I pulled away from computers enough during my time in school to meet my wife. I don't know about gay men, but women are generally in rare supply in the computer science department, necessitating one actually go outside of their normal school routine to find people to date. Mine was waaaaay across campus in the big fancy Education building.

CaptainCrowbar wrote:

If you're on Windows and want to learn about the Unix command line and programming environment, install Cygwin. It gives you an environment pretty much identical to the Linux command line (and X11, the Unix GUI framework, too if you want it) without having to run a virtual machine, with full access to your Windows file system. Pretty much all the widely used Unix and GNU software is either included in the Cygwin installer or can easily be built from the command line.

I forgot about Cygwin! Yeah, that would be a great way to start learning commands and whatnot. It would be way easier to get started than setting up a virtual machine with Linux. You'd just want to make sure you learned how the file system in Unix/Linux is structured differently than in Windows.

Also, I haven't been paying attention to what Fedora is doing in school, but if he's in any sort of engineering/CS program at school, they should have a Unix environment setup somewhere. You could either access it remotely or truck on over to the computer lab to play on a Unix machine directly. I remember doing both of those things at school back in the day.