Be a Supporter!

Programming Regs Lounge

  • 394,565 Views
  • 17,897 Replies
New Topic Respond to this Topic
Dean
Dean
  • Member since: Feb. 16, 2008
  • Offline.
Forum Stats
Moderator
Level 44
Programmer
Response to Programming Regs Lounge Nov. 6th, 2012 @ 05:32 AM Reply

At 11/5/12 08:45 PM, Diki wrote: To illustrate that you can check out this port of the C++ Standard Vector class that I'm working on as part of my portfolio.

That's one scary looking class. C++ is a language that I haven't looked at yet aside from a very brief encounter I had with it when I was being introduced to OpenGL. After Christmas I'll be using it in the Computer Games Programming course, which actually has "C++ programming skills" listed as pre-requisite knowledge, which I find strange considering they've never taught us C++ on any of the courses. Perhaps the very, very minimal amount we covered in Computer Graphics is what they're referring to.

We have had to use C in the past, so will that have any benefit when jumping into C++?


BBS + Chat Moderator - Feel free to send me a PM if you have a problem!
Want to instant message me? [ Skype - DeanNewgrounds ]

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge Nov. 6th, 2012 @ 02:04 PM Reply

At 11/6/12 05:32 AM, Dean wrote: We have had to use C in the past, so will that have any benefit when jumping into C++?

Very much so.

C++ is pretty much just C with additional features. The only thing it really "changed" was how you use structs. In C++ they're identical to classes except the members are public by default, where classes are private by default. You don't have to type out struct every time you create a variable in C++.
You can also exclude the return 0 from your main function if you want, but that's not really significant enough to consider it a "change" in my opinion.

Some of the new things in C++ are references, namespaces, and templates. If you come from C you should be able to grasp these no problem (except for maybe templates; they're tricky), and incidentally moving from C to C++ is a lot easier than moving from C++ to C.

SomeTurtle
SomeTurtle
  • Member since: Dec. 12, 2011
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Programming Regs Lounge Nov. 7th, 2012 @ 08:31 PM Reply

So just finished the little console RPG game I set out to do. Everything works and I managed to do things that a while ago I didn't think were possible(while minor accomplishments...they are still as fulfilling for someone just starting out). I think it really helped nail some concepts for me down, as well I learned some new things. Unfortunately some of those things I have to further research because I didn't understand exactly why I had to do something one way or do something another.

For instance:

float floatExample = 0;
floatExample = 5/100;
Console.Writeline(floatExample);
//Returns 0 as the value
floatExample = (float)5/100;
//Returns .05 as the answer

Although I to an extent understand why, I just want to make sure that I have no questions in the future of why I have to do that to get the desired results.

Anyways I'll probably end up finishing the tutorial series then go to work on creating(or recreating) console apps while still reading things here and there. But I do have a question, one of the hardest parts right now is I have an idea of something I'd like to do but I don't know how to convey in into words or into programming terms to search for the answers.

For instance right now I was wondering how would I take a string and take it apart and pull different values from it. So let's say I wanted a person to type in one line <first name> <last name> <a ge>, I'd want to be able to pull those three things from that one entry by the user. Any one know what this is referred to as in programming? I don't mind researching but also wouldn't mind getting a link to a few resources explaining how to do it/how it works.

Cheers.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to Programming Regs Lounge Nov. 7th, 2012 @ 11:57 PM Reply

Full TIlt poker was acquired and reopned its doors, so I'm back to my old addiction - online poker :)

Dean
Dean
  • Member since: Feb. 16, 2008
  • Offline.
Forum Stats
Moderator
Level 44
Programmer
Response to Programming Regs Lounge Nov. 8th, 2012 @ 09:20 AM Reply

I was watching a copy of The C Programming Language on eBay hoping I was going to get a bargain. It was listed as an unwanted gift and it never had any interest until the last few hours when it shot up to the usual selling price :(

As much as I want to get hold of a copy, I'm struggling to force myself to pay £20 for it.


BBS + Chat Moderator - Feel free to send me a PM if you have a problem!
Want to instant message me? [ Skype - DeanNewgrounds ]

BBS Signature
Thegluestickman
Thegluestickman
  • Member since: Mar. 16, 2007
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to Programming Regs Lounge Nov. 8th, 2012 @ 03:40 PM Reply

At 11/8/12 09:20 AM, Dean wrote: As much as I want to get hold of a copy, I'm struggling to force myself to pay Ã'£20 for it.

There are "other" means of getting it.


To protect the world from devastation.
kidd25 is the best Newgrounder ever.

BBS Signature
deckheadtottie
deckheadtottie
  • Member since: Oct. 21, 2003
  • Offline.
Forum Stats
Moderator
Level 58
Programmer
Response to Programming Regs Lounge Nov. 8th, 2012 @ 04:06 PM Reply

At 11/8/12 09:20 AM, Dean wrote: As much as I want to get hold of a copy, I'm struggling to force myself to pay £20 for it.

It's not like you're frittering it away, you'll have an awesome book at the end of it.

You can have mine for £50 if you like.

#coys

BBS Signature
egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Member
Level 05
Game Developer
Response to Programming Regs Lounge Nov. 8th, 2012 @ 05:59 PM Reply

At 11/8/12 03:40 PM, Thegluestickman wrote: There are "other" means of getting it.

dancing around fire, there.


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
Dean
Dean
  • Member since: Feb. 16, 2008
  • Offline.
Forum Stats
Moderator
Level 44
Programmer
Response to Programming Regs Lounge Nov. 8th, 2012 @ 07:06 PM Reply

At 11/8/12 03:40 PM, Thegluestickman wrote: There are "other" means of getting it.

I'd rather have a physical copy. I'm one of these old fashioned people who prefers to have actual books, if I can.

At 11/8/12 04:06 PM, deckheadtottie wrote: It's not like you're frittering it away, you'll have an awesome book at the end of it.

Something super awesome happened today. A PhD student gave me a £10 Amazon voucher in exchange for me participating in an experiment for him. It took about 40 minutes but I had nothing better to do and it got me money that I can put towards that book. Now I just have to decide whether that means I'll go for a new copy or maintain my reputation as a cheap bastard and go for a used copy. I do like to keep my books in nice condition so I'm leaning more towards a new copy.

Oh and if it's of any interest, the experiment involved me looking at images for 40 minutes on an iPad and describing what textures or emotion I associated with the images. Easy money.


BBS + Chat Moderator - Feel free to send me a PM if you have a problem!
Want to instant message me? [ Skype - DeanNewgrounds ]

BBS Signature
egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Member
Level 05
Game Developer
Response to Programming Regs Lounge Nov. 8th, 2012 @ 11:39 PM Reply

At 11/8/12 07:06 PM, Dean wrote: Oh and if it's of any interest, the experiment involved me looking at images for 40 minutes on an iPad and describing what textures or emotion I associated with the images. Easy money.

believe it or not, I was actually curious.


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge Nov. 9th, 2012 @ 07:25 PM Reply

A few months ago I made a post about a framework I'm working on a C++ framework for managing input from Xbox 360 controllers, which was basically just a wrapper for XInput. It was callback-based, and after talking to some other C++ developers I concluded that that was not a good design (you can read my original post and implementation code here).

So fast-forward about 5-7 hours of me thinking up a new design and then implementing and I now have a working prototype. This is the new implementation:

#include <iostream>

#include "inputmanager.hpp"
#include "utility.hpp"

int main()
{
    x360::Event event;

    while (true)
    {
        x360::InputUpdate();
        while (x360::GetEvent(&event))
        {
            switch (event.type)
            {
            case X360_PRESS:
                printf("Pressed the '%s' button\n", x360::ButtonIdToString(event.button));
            break;
            }
        }
    }

    return 0;
}

I'm heavily basing it on X11 and the Windows API as pretty much anyone who would be using this will be using one of those (probably the Windows API given that it's Xbox 360 controllers).
I don't have the source on GitHub yet, as it's too early for that, but the source for the InputUpdate and GetEvent functions (which are basically the brains of the whole thing) is here (it's unfinished, remember).

I can confidently say I am much happier with this design.

More updates to follow as I continue to development.

Dean
Dean
  • Member since: Feb. 16, 2008
  • Offline.
Forum Stats
Moderator
Level 44
Programmer
Response to Programming Regs Lounge Nov. 11th, 2012 @ 07:39 AM Reply

Well, there seems to have been a few used copies of The C Programming Language added to Amazon UK recently and they've been getting cheaper and cheaper. Looked to see what was on offer just now and there was a "like new" copy listed for £10 + shipping. So thanks to that Amazon voucher I was given earlier in the week, I only had to pay the cost of shipping for that book.

I'm not much of a reader so the the only other thing I'd have spent that voucher on was a copy of whatever Walking Dead volume I got up to. Volume 5 I think.


BBS + Chat Moderator - Feel free to send me a PM if you have a problem!
Want to instant message me? [ Skype - DeanNewgrounds ]

BBS Signature
pirateplatypus
pirateplatypus
  • Member since: Sep. 27, 2011
  • Offline.
Forum Stats
Member
Level 15
Programmer
Response to Programming Regs Lounge Nov. 15th, 2012 @ 12:57 AM Reply

At 11/5/12 08:45 PM, Diki wrote: You could always come visit and experience first hand our world-famous politeness. We're almost polite to a fault here. :)

That's an understatement. In my experience in call centers and face-to-face, polite Americans are still not as polite as a pissed off Canadian.


"If loving Python is crazy then I don't want to be sane." -Diki

Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge Nov. 15th, 2012 @ 05:18 AM Reply

At 11/15/12 12:57 AM, pirateplatypus wrote: That's an understatement. In my experience in call centers and face-to-face, polite Americans are still not as polite as a pissed off Canadian.

Yeah we're pretty good for that. :)
Even when I'm mad I still call people "buddy".

Also, made some updates on my Xbox 360 controller framework. It has support for release events now:

x360::Event event;
while (true)
{
    x360::UpdateInput();
    while (x360::GetEvent(&event))
    {
        switch (event.type)
        {
        case X360_RELEASE:
            printf("Controller #%d released '%s'\n",
                event.controllerId+1, /* Increment because Controller IDs are 0-indexed */
                x360::ButtonIdToName(event.which)
            );
        break;
        }
    }
}

Next up is adding events for when the analog sticks cease moving, since that's pretty important.

Dean
Dean
  • Member since: Feb. 16, 2008
  • Offline.
Forum Stats
Moderator
Level 44
Programmer
Response to Programming Regs Lounge Nov. 15th, 2012 @ 11:00 AM Reply

Just got a fairly big piece of coursework out the way (it was a report, nothing exciting) and my copy of The C Programming Language arrived yesterday so I reckon my night will be spent reading that and attempting the tasks in it. I've not been so keen to read a book (never mind a technical book) for a long time but I'm actually excited to get stuck into this one.

I've got two weeks left until I'm done for Christmas (excluding exams) and I can't wait. I'll finally have some free time to do what I want without worrying about getting coursework done. I'll probably try to finish off that simple forum I was building.

OpenGL is another thing that I want to look into. Used it before but that was a year ago so I'll start over if I can find myself a nice learning resource. This website seems like it will be a decent introduction to OpenGL. Any of you chaps used it or know of any other good places to learn graphics programming?


BBS + Chat Moderator - Feel free to send me a PM if you have a problem!
Want to instant message me? [ Skype - DeanNewgrounds ]

BBS Signature
pirateplatypus
pirateplatypus
  • Member since: Sep. 27, 2011
  • Offline.
Forum Stats
Member
Level 15
Programmer
Response to Programming Regs Lounge Nov. 15th, 2012 @ 11:34 AM Reply

I've got a question. I didn't feel like making a new topic for it because I'm lazy and it's not a massively important question.

I just read on Global Nerdy about a coder interview process where only 40% of interviewees could pass the "FizzBuzz" test. How they hell did they even get to the interview portion of the job app?

The interviewer made them write their code with pen/paper. They were free to write it in any language they like. Upon reading this, I jotted down a quick FizzBuzz function on paper and it took just under a minute. How is it that a high school dropout who's only recently started to take coding seriously can do this in under a minute and people with experience and degrees can't do it at all?

For the record, I don't consider myself to be a great programmer by any means. I'd say I'm competent in a handful of respects but I'm certainly not one of those gurus that can compile 15 different languages in their head.


"If loving Python is crazy then I don't want to be sane." -Diki

kiwi-kiwi
kiwi-kiwi
  • Member since: Mar. 6, 2009
  • Offline.
Forum Stats
Member
Level 09
Programmer
Response to Programming Regs Lounge Nov. 15th, 2012 @ 01:59 PM Reply

At 11/15/12 11:34 AM, pirateplatypus wrote: The interviewer made them write their code with pen/paper. They were free to write it in any language they like. Upon reading this, I jotted down a quick FizzBuzz function on paper and it took just under a minute. How is it that a high school dropout who's only recently started to take coding seriously can do this in under a minute and people with experience and degrees can't do it at all?

Well first of all do keep in mind that some people will lie in their CVs and within reason most employers won't check references, but apart from that I can tell you from my own experience that there will always be people that don't know how to program yet claim they do because they can get their inspiration from somewhere.

It's not necessarily that they can't program, their problem is that they can't think, they can't build something on demand, they will usually have a task and will search on the internet how to do it and they will slap together 10 snippets found on stackoverflow with the coding equivalent of spit and then they will present that as their solution.
I think 40% is a bit exaggerated though.

Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge Nov. 15th, 2012 @ 02:32 PM Reply

At 11/15/12 11:34 AM, pirateplatypus wrote: How they hell did they even get to the interview portion of the job app?

By lying about their abilities.
They're the kind of people that will read a few tutorials on a language, or take an introductory course on one, and then throw it on their resume as one of their known languages.

At 11/15/12 11:34 AM, pirateplatypus wrote: How is it that a high school dropout who's only recently started to take coding seriously can do this in under a minute and people with experience and degrees can't do it at all?

Usually they don't have degrees in programming. It happens a lot with computer science majors whom never bothered to learn anything outside of computer science, which will make for a pretty piss-poor programmer.
But, in short, like above, they just plain lie. It's pretty insulting to real programmers.

At 11/15/12 01:59 PM, kiwi-kiwi wrote: Well first of all do keep in mind that some people will lie in their CVs and within reason most employers won't check references
...
I think 40% is a bit exaggerated though.

Generally employers don't bother with references at all (in the software development field, at least).
And personally I'd say the 40% is a bit low. :)

pirateplatypus
pirateplatypus
  • Member since: Sep. 27, 2011
  • Offline.
Forum Stats
Member
Level 15
Programmer
Response to Programming Regs Lounge Nov. 15th, 2012 @ 03:01 PM Reply

Ugh, I should start lying on my resume. I don't even list programming languages. While I feel competent with a few, I kind of feel I should be a guru before I try telling someone I can do it for money.

I will never understand people who "code" by copy-pasta. I have far too much fun thinking about how to solve a problem and then implementing it. If I wanted to spend my time ripping off other peoples' work I'd be an eHow writer.


"If loving Python is crazy then I don't want to be sane." -Diki

Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge Nov. 15th, 2012 @ 03:27 PM Reply

At 11/15/12 03:01 PM, pirateplatypus wrote: Ugh, I should start lying on my resume. I don't even list programming languages. While I feel competent with a few, I kind of feel I should be a guru before I try telling someone I can do it for money.

Lying isn't a good idea. If you get called out on it you are guaranteed to lose the opportunity.
You don't need to be an expert in a language to list it on your resume. Just be competent enough to be able to write it without a reference. Being able to describe some of the pros and cons of the language will also help.

At 11/15/12 03:01 PM, pirateplatypus wrote: I will never understand people who "code" by copy-pasta. I have far too much fun thinking about how to solve a problem and then implementing it. If I wanted to spend my time ripping off other peoples' work I'd be an eHow writer.

That's really the thing: those people aren't doing it for fun. They're the kind of people who enjoy having the appearance of competence with a skill rather than actually learning how to be competent, and copying/pasting other people's code is an easy way to do that.

Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge Nov. 16th, 2012 @ 05:16 AM Reply

Finally updated my GitHub repo with my framework's new design, and also renamed it from X360 to EasyXInput since that's a better name.
Anyone who's interested can check it out the source code here.

The README kinda sucks right now, but I'm working on it.

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Member
Level 05
Game Developer
Response to Programming Regs Lounge Nov. 16th, 2012 @ 12:25 PM Reply

At 11/15/12 03:27 PM, Diki wrote: That's really the thing: those people aren't doing it for fun. They're the kind of people who enjoy having the appearance of competence with a skill rather than actually learning how to be competent, and copying/pasting other people's code is an easy way to do that.

the things newbies don't understand about programming is that after you get past all the hard stuff, coding becomes really fun.
I mean, i'm creating a 3D world. How friggin cool is that?

Then you get to build whole libraries just because you think it'd be fun. Or do whatever you want because you think it'd look awesome when it's finished.

Then you get to sit back when it's done and think: "I built that." - the self-reward system really is awesome :D

you just gotta wade through the crap that is learning first. Like anything ;)


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
kiwi-kiwi
kiwi-kiwi
  • Member since: Mar. 6, 2009
  • Offline.
Forum Stats
Member
Level 09
Programmer
Response to Programming Regs Lounge Nov. 28th, 2012 @ 05:15 PM Reply

A comprehensive list of implementations for an age old algorithm: link
I personally enjoy the one in lisp and the one in Developers.

pirateplatypus
pirateplatypus
  • Member since: Sep. 27, 2011
  • Offline.
Forum Stats
Member
Level 15
Programmer
Response to Programming Regs Lounge Nov. 28th, 2012 @ 06:21 PM Reply

At 11/8/12 09:20 AM, Dean wrote: I was watching a copy of The C Programming Language on eBay hoping I was going to get a bargain. [...] I'm struggling to force myself to pay Ã'£20 for it.

Holy crap! I just bought a copy (1st edition, 14th printing) at a thrift store for $2USD.


"If loving Python is crazy then I don't want to be sane." -Diki

Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge Dec. 5th, 2012 @ 05:45 PM Reply

I decided that it was time to fix up my lightweight HTTP server, as it is kind of messy, and missing certain features. I changed the name to "Parvus", added better routing support, removed the us of decorators, and just all-around improved the code.

The old implementation was this:

from spiderweb import Spiderweb

http = Spiderweb("192.168.0.123", 80)

@http.error(404)
def notFound():
    return open("404.html","r").read()

@http.route("/", methods=["GET","POST"])
@http.route("/index", methods=["GET","POST"])
def index():
    return open("index.html","r").read()

http.start()

And the new implementation looks like this:

from parvus import Parvus

def index(request):
	return "hello world"

def gif_image(request):
	return open(request.path[1:],"rb").read()

server = Parvus("192.168.0.113")
server.add_route("/(index)?", index)
server.add_route("/(.*?)[.]gif", gif_image, content_type="image/gif")

server.run()

Definitely an improvement in my opinion.
Still need to figure out a good way to handle 404 errors and the like, as well as include other necessary features (such as error logging, handling for cookies and query strings, and sending more complete HTTP headers in the response).

There isn't much to the source code but you can check it out here:
main.py: http://pastebin.com/JvwrcG2e
routing.py: http://pastebin.com/G4fGxRqs

It's a work in progress, remember. :)

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to Programming Regs Lounge Dec. 9th, 2012 @ 04:06 AM Reply

My mother's birthday is today, but snow was falling so heavily this weekend I couldn't make it to the city to buy her something. So I made her this. She was thrilled.

btw Sretan-Rodendan-Majko means (literally) happy birthday mother. She is 49, but I wrote in the page title happy 39th birthday.

lololol

egg82
egg82
  • Member since: Jun. 24, 2006
  • Offline.
Forum Stats
Member
Level 05
Game Developer
Response to Programming Regs Lounge Dec. 9th, 2012 @ 05:22 AM Reply

At 12/9/12 04:06 AM, NinoGrounds wrote: My mother's birthday is today, but snow was falling so heavily this weekend I couldn't make it to the city to buy her something. So I made her this. She was thrilled.

that reminds me, my mother's birthday is today.
Uh... Shit...


Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P

BBS Signature
NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to Programming Regs Lounge Dec. 9th, 2012 @ 05:24 PM Reply

At 12/9/12 05:22 AM, egg82 wrote: that reminds me, my mother's birthday is today.
Uh... Shit...

I guess I should've made API as well

Diki
Diki
  • Member since: Jan. 31, 2004
  • Online!
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge Jan. 3rd, 2013 @ 12:52 PM Reply

This thread has sorta died, so I figured I'd breath some fresh air into it.

Lately I've been trying to become more competent in C, so I've just been taking on random little C challenges. The most recent of these is making a dynamically allocating array (similar to the std::vector class in C++).
After a few hours of coding and debugging I managed to get some pretty basic functionality working:

int main() {
    darray_t array = darray_new(sizeof(int));

    darray_push(&array, (int[]){1});
    darray_push(&array, (int[]){2});
    darray_push(&array, (int[]){3});
    darray_push(&array, (int[]){4});
    darray_push(&array, (int[]){5});

    for (int* itr; itr = darray_each(&array);) {
        printf("%d\n", *itr);
    }

    darray_dealloc(&array);
}

That implementation was written for GCC with C99, so it won't work with MSVC.
It was a fun little project. These types of dealies really help get you into the mindset of C (especially if you're used to C++).

Source code here.

pirateplatypus
pirateplatypus
  • Member since: Sep. 27, 2011
  • Offline.
Forum Stats
Member
Level 15
Programmer
Response to Programming Regs Lounge Jan. 4th, 2013 @ 01:03 AM Reply

At 1/3/13 12:52 PM, Diki wrote: I've just been taking on random little C challenges.

If you're looking for little challenges, Project Euler is pretty cool.

I (today) decided that I wanted to switch to the Dvorak Programmer layout. I haven't typed so slow since I was four. That being said, it's much more comfortable than qwerty.


"If loving Python is crazy then I don't want to be sane." -Diki