Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 309 310 [311] 312 313 ... 796

Author Topic: if self.isCoder(): post() #Programming Thread  (Read 902623 times)

Nadaka

  • Bay Watcher
    • View Profile
    • http://www.nadaka.us
Re: if self.isCoder(): post() #Programming Thread
« Reply #4650 on: July 11, 2013, 12:26:59 pm »

I hate ruby on rails. For the same reason I hate extJS. pointless boilerplate code with tiny bits of bullshittingly arcane and obtuse configuration.
Logged
Take me out to the black, tell them I ain't comin' back...
I don't care cause I'm still free, you can't take the sky from me...

I turned myself into a monster, to fight against the monsters of the world.

Levi

  • Bay Watcher
  • Is a fish.
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4651 on: July 11, 2013, 12:28:20 pm »

I hate ruby on rails. For the same reason I hate extJS. pointless boilerplate code with tiny bits of bullshittingly arcane and obtuse configuration.

Ditto.  Rails is the one big thing I don't like about ruby. 
Logged
Avid Gamer | Goldfish Enthusiast | Canadian | Professional Layabout

GlyphGryph

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4652 on: July 11, 2013, 12:30:00 pm »

I actually love Rails. So blah to all of you.
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4653 on: July 11, 2013, 12:48:32 pm »

Django is where it's at! (I'm only slightly mocking - there are enough WTFs in the Django codebase to make life interestinginfuriating)

Speaking as someone who's used both, I enjoyed Rails when I used it but I didn't care for how it managed databases. There are certain things Rails does much better, though.

Guard was pretty nifty and standard among a number of Rails projects even though it's third party. Django has nothing as immediately obvious and popular as that, though I haven't went out of my way to find anything.

If I recall correctly, Rails also has pretty nice browser testing support.

I may have to get back into it if Rails 4 is as big of an improvement as I've been led to believe.
« Last Edit: July 11, 2013, 01:02:32 pm by Mephisto »
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4654 on: July 11, 2013, 01:07:28 pm »

Lesson 3: Operators, Functions, and Basic Scope

C++ has a lot of operators. A lot. 55, to be exact. But, don't worry, because we will only be covering a handful of the most common ones here. Operators are organized into groups by their precedence level - which ones resolve before others.

Code: [Select]
// For convenience, operators will be grouped in order by precedence

std::cout; // The operator here is the ::, which is the scope resolution operator. It tells the compiler that you are referencing the cout object in the std namespace. More about namespaces in a later tutorial.

a++; a--; // The ++ and -- are postfix increment and decrement operators. They return the value of a, and then respectively increase and decrease the value of a by 1. If a was 5, a++ would return 5, and then change the value of a to 6.
f(); // The () is the function call operator, which follows the function name.
array[0]; // The [] is the array subscript operator, which returns the given element in the array. In this case, it would return the first element.

++a, --a; // Like the postfix increment and decrement, the prefix operators do the same thing, except they increment/decrement the value of a before returning it. If a was 5, ++a would increase the value of a to 6, and then return 6.
+a; -1; // These operators are called unary plus and minus (unary meaning taking one argument). They are used to change the sign of a number, to positive or negative, respectively.
!true; // The ! operator is called the logical NOT operator - it returns the opposite of the given boolean argument.
~a; // The ~ operator is called the bitwise NOT operator - it returns the given value with all of its bits flipped.
(int) a; // The operator here is actually the type name in parentheses. It causes the given argument to be interpreted as the given data type.
sizeof int; // The sizeof operator returns the size of a given type, class, or data object, in bytes. On most systems, sizeof int would return 4.

5 * 4; 2 / 1; 5 % 2; // The multiplication, division, and modulus operators. They would exactly how you would expect, with a few small caveats. If two different integral/floating-point types are given as arguments, the result is given in the larger of the two types. For this purpose, floating-point types are always considered larger than any integral type. Also, / does integer division if it is given 2 integral arguments: 5 / 2 == 2. If either (or both) of the arguments is a floating-point type, the operator does floating-point division: 5.0 / 2 == 2.5.

2 + 2; 2 - 5; // The addition and subtraction operators work exactly how you would expect.

5 < 2; 2 <= 2; 3 > 1; 3 >= 42; // The comparison operators, which work exactly how you would expect.

5 == 5; 2 != 3; // Equivalence and non-equivalence operators, self-explanatory.

true && true; // Logical AND, returns true if both arguments resolve to true, and false otherwise.

false || true; // Logical OR, returns true if either or both of the arguments resolve to true, and false otherwise.

a = 5; // Direct assignment, exactly what it says on the tin.
a += 2; a -= 3; a *= 3; a /= 2; // These work just like the regular arithmetic operators, and they also assign the return value to the left operand.

a + 5, b + 2; // The comma operator is the lowest-priority operator. The first operation is performed, its return value is discarded, and then the second operation is performed, with its return value returned. This has nothing to do with comma-separated lists, like function arguments.

The next part of the lesson will be about functions. As per usual, I will provide example code first, and then explain how it works.

Code: [Select]
#include <iostream>

using namespace std;

int addition(int a, int b) {
    return a + b;
}

void foo() {
    cout << "Foo!" << endl;
}

int main() {
    foo();
    cout << addition(2, 2) << endl;
    return 0;
}

Code: (Output) [Select]
Foo!
4

Let's get down to business, and figure out what the hell I just did.

Functions are pieces of code that can be called by name to execute their code. This is a huge benefit, because functions allow programmers to refer to code with a name, rather than typing the same code over and over.

Code: [Select]
int addition(int a, int b)

This is a function header. It tells the return type for the function (int), the name (addition), and the types and names of the required arguments (two int's, which are called a and b inside of the function).

Code: [Select]
{
    return a + b;
}

This is the function body, which contains the code for the function. As you can see, the function simply returns the sum of a and b.

Code: [Select]
void foo()

This is another function header, with a twist - it has a void return type, which means it returns nothing. Ok, I lied, it has two twists - it also has an empty argument list, which means it will not accept any arguments. None. Nada. Zero. Zilch.

...okay, you get the point.

Code: [Select]
{
    cout << "Foo!" << endl;
}

The function body tells us that, when foo is called, "Foo!" will be written to the standard output, followed by a newline.

Code: [Select]
    foo();

This is the syntax for calling a function with no arguments. At this point in the program, "Foo!" and a newline have been written to the standard output.

Code: [Select]
    cout << addition(2, 2) << endl;

Here, we call addition with 2 for both arguments. Our expertise in mathematics tells us that we will get 4 as the return value. That 4 is printed (with a newline) to standard output.

Spoiler: Extra Credit (click to show/hide)

Now for a basic discussion of scope rules.

Code: [Select]
int foo(int a) {
    int b = 2;
    return a + b;
}

int main() {
    int c = foo(2);
    b = 4; // compile error - b does not exist!
    return 0;
}

If you tried to compile this, you'd get an error saying that b does not exist. But, clearly, we defined b in the foo function! Well, that only means that b is defined within the scope of that function. As soon as that function returns, b stops existing. A rule of thumb is, any time you see a set of curly braces, a new scope is being introduced.

It's funny how, after typing a word a lot, it stops seeming like a real word. Scope scope scope scope scope.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4655 on: July 11, 2013, 10:39:59 pm »

Does this mean I should probably write the next couple Java lessons so you don't have to explain mechanics in excessive detail like I did?  I suppose I could make time in the next day or two if I really felt motivated.  Somebody motivate me! :P
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4656 on: July 11, 2013, 10:44:48 pm »

Go for it. My next few lessons are going to be basic OOP and delving deeper into the computer to understand what's really going on.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4657 on: July 11, 2013, 10:58:43 pm »

Go for it. My next few lessons are going to be basic OOP and delving deeper into the computer to understand what's really going on.

Damnit Mego, you've got me looking up my old posts in this thread trying to figure out where I left off and what my future plans were.  On the bright side, I specifically remember posting my plans, so there in here somewhere.  Searchfu don't fail me now!
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4658 on: July 11, 2013, 11:01:25 pm »

If only there was a table of contents in the OP...

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4659 on: July 11, 2013, 11:07:14 pm »

If only there was a table of contents in the OP...

I actually went there right away.  It points to the lessons and my String rant/investigation.  Not the half dozen random posts where I outlined my general road map for further lessons.  I'm trying to find that since I assume if I made a road map at one time, it probably wasn't that bad of a plan.  Granted I have a tendency to improvise.
Logged

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4660 on: July 11, 2013, 11:29:06 pm »

Fun fact: none of my lessons have been planned in advance. Just before writing them, I decide what subject(s) to cover.

Fun fact: for this reason I will never be a teacher/professor.

Stargrasper

  • Bay Watcher
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4661 on: July 11, 2013, 11:49:29 pm »

Which is one of my aspirations.  I'm a bit tired on studying right now, but eventually I want to go to grad school and eventually become a professor.  We'll see how motivated I get.

Also, I apparently haven't been posting in here enough.  Search is showing six pages of total posts by me.  It's a bit nostalgic.  It's also reminding me of how much of an idiot I can be.
Logged

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4662 on: July 12, 2013, 01:07:07 am »

Sometimes I worry I don't have anything (respectable) to show off to colleges. >__> How to remedy this? Pretty sure games don't count :v
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward

Mego

  • Bay Watcher
  • [PREFSTRING:MADNESS]
    • View Profile
Re: if self.isCoder(): post() #Programming Thread
« Reply #4663 on: July 12, 2013, 01:23:47 am »

Sometimes I worry I don't have anything (respectable) to show off to colleges. >__> How to remedy this? Pretty sure games don't count :v

Games totally do count. A game is one of the most ambitious projects you can embark upon. Not only will showing future professors a game that you made impress them, it will also give them a new way to waste time. And everyone wants new ways to waste time; if not, games would not be nearly as popular.

Skyrunner

  • Bay Watcher
  • ?!?!
    • View Profile
    • Portfolio
Re: if self.isCoder(): post() #Programming Thread
« Reply #4664 on: July 12, 2013, 02:08:03 am »

But professors don't look at apps, only the admission officers. And they only look at the titles and don't investigate S:
Logged

bay12 lower boards IRC:irc.darkmyst.org @ #bay12lb
"Oh, they never lie. They dissemble, evade, prevaricate, confoud, confuse, distract, obscure, subtly misrepresent and willfully misunderstand with what often appears to be a positively gleeful relish ... but they never lie" -- Look To Windward
Pages: 1 ... 309 310 [311] 312 313 ... 796