Be a Supporter!

Programming Regs Lounge

  • 501,429 Views
  • 16,814 Replies
New Topic Respond to this Topic
Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-09 15:55:00 Reply

At 7/5/12 02:53 PM, WizMystery wrote:
This took me hours to figure out. Aint that great?

Yeah that's the trouble with writing C++; debugging is a pain in the ass.
I once spent like 20 minutes debugging code only to find I forgot to type a semi-colon. Sometimes the errors in C++ aren't very helpful (depending on your knowledge of C++ and its errors). Take the following for example:

template <class Ty>
class Foo {
private:
    typedef Ty prv_Ty;
public:
    Ty name;
    Foo(Ty name) : name(name) {}
    Ty getthing() const:
};

template <class Ty>
Foo<Ty>::getthing() const
{
    return name;
}

int main()
{
    Foo<int> f(42);
    return 0;
}

If you attempt to compile that you will get these errors:

Error	1	error C2590: 'getthing' : only a constructor can have a base/member initializer list (8)
Error	2	error C2533: 'Foo<Ty>' : constructors not allowed a return type	(8)
Error	3	error C2583: 'Foo<Ty>::Foo' : 'const' 'this' pointer is illegal for constructors/destructors (8)
Error	4	error C2760: syntax error : expected '{' not '}' (9)
Error	5	fatal error C1004: unexpected end-of-file found (9)

All that is caused because on line 8 const: is supposed to be const;, and that is only a 21 line script; the errors get a lot more hairy for larger projects.

kiwi-kiwi
kiwi-kiwi
  • Member since: Mar. 6, 2009
  • Offline.
Forum Stats
Member
Level 09
Programmer
Response to Programming Regs Lounge 2012-07-10 16:07:33 Reply

Longer update here.
It's been a while now since I quit my job as a game designer and while I enjoy the freedom and free time, there's still a part of me that misses the AAA atmosphere.
But life goes on and I got a better job at a smaller company where not only will I be working for a better salary, but also on some very challenging C++ stuff, so everything went better than expected.

Other than that I still have two weeks of vacation until I start and while finishing college will take most of the first one, I wanted to try my hand at making a game for my own pleasure again during the second week, so I'll be participating in this very interesting competition called the liberated pixel cup.
Everything will be publically viewable on my soon to be github account, so if you guys feel like making fun of (and/or praise XD) my coding practices I'll be posting a link sometime in the future.

And that's about it.

WizMystery
WizMystery
  • Member since: Feb. 3, 2009
  • Offline.
Forum Stats
Member
Level 11
Musician
Response to Programming Regs Lounge 2012-07-11 17:26:13 Reply

At 7/9/12 03:55 PM, Diki wrote: All that is caused because on line 8 const: is supposed to be const;, and that is only a 21 line script; the errors get a lot more hairy for larger projects.

Yeah, I've learned how much of a pain debuggers themselves are.

Thegluestickman
Thegluestickman
  • Member since: Mar. 16, 2007
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to Programming Regs Lounge 2012-07-11 17:56:59 Reply

So I had a question and I thought this would be the best place to ask it.

How exactly do hardware and software interact?

I understand as far as software goes, the compiler transforms written code into binary, assembly or bytecode (I think) that a machine can understand. The part I don't understand is, say for example I built a piece of hardware and wanted to run a program on it, how would this work? Does the program need to be written in assembly for the hardware to know what's happening? I don't think you could just compile C or C++ and run it on the hardware.


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

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-11 18:29:38 Reply

I am by no means a professional or an expert on the subject, but I'll offer my input; when I was in high-school I took a Computer Engineering course where I built a robot car that ran on Turing, and also built a hand-held device that acted as a security alarm in a similar class, so I know a little bit about this.

When hardware is built it is, obviously, built on a breadboard of some sort. That allows the device to create a number of different "signals"; these signals are just different frequencies of electricity. Some sort of a logical chip, such as a processor, is used to interpret what these different frequencies represent.
Follow this pattern to ridiculous complexity and you have common hardware devices.

Basically it all comes down to interpreting different frequencies of electricity.

As for how all this is done: I'm not really sure, because, like I said, I'm by no means an expert. I'd really only be able to speculate that part, so I won't.

At 7/11/12 05:56 PM, Thegluestickman wrote: I don't think you could just compile C or C++ and run it on the hardware.

Well, there isn't anything preventing that per se; it would just be incredibly impractical, so that's why it, generally speaking, doesn't happen.

Thegluestickman
Thegluestickman
  • Member since: Mar. 16, 2007
  • Offline.
Forum Stats
Member
Level 13
Game Developer
Response to Programming Regs Lounge 2012-07-11 18:54:34 Reply

At 7/11/12 06:29 PM, Diki wrote: When hardware is built it is, obviously, built on a breadboard of some sort. That allows the device to create a number of different "signals"; these signals are just different frequencies of electricity. Some sort of a logical chip, such as a processor, is used to interpret what these different frequencies represent.
Follow this pattern to ridiculous complexity and you have common hardware devices.

Basically it all comes down to interpreting different frequencies of electricity.

As for how all this is done: I'm not really sure, because, like I said, I'm by no means an expert. I'd really only be able to speculate that part, so I won't.

At 7/11/12 05:56 PM, Thegluestickman wrote: I don't think you could just compile C or C++ and run it on the hardware.
Well, there isn't anything preventing that per se; it would just be incredibly impractical, so that's why it, generally speaking, doesn't happen.

Thanks Diki for the great post.

To clarify, the program generates the frequencies? I remember something from my computer science class about Fetch, Execute and Decode preformed by the CPU; so does the CPU fetch commands from the kernel? Is the kernel written in assembly or a different language? I think understand basically, man computers are a huge achievement in Human history.


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

BBS Signature
NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 20
Programmer
Response to Programming Regs Lounge 2012-07-11 21:10:34 Reply

lol @ google

Basically, Chrome warned me about 3 errors in my code. look where the errors are located at

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-11 21:33:30 Reply

The first two messages are warnings, not errors; they look like you're using an incorrect MIME type to display some sort of media.
As for the "Unsafe Javascript" error that looks like you're using a Google API to access another URL in an unsafe manner.

Basically, to me, given the vague information you've given, it looks like you're just misusing Google's tools.

In fact, Occam's Razor says this is your fault:
Do you think you caused this?
Or do you think that Google's developers, some of the brightest, skilled, and experienced web developers in the world, caused this?

Not trying to insult you, but, you didn't post the code the caused the error. Do you seriously expect someone to believe that Google fucked up and you didn't?

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 20
Programmer
Response to Programming Regs Lounge 2012-07-12 10:34:37 Reply

At 7/11/12 09:33 PM, Diki wrote: Not trying to insult you, but, you didn't post the code the caused the error. Do you seriously expect someone to believe that Google fucked up and you didn't?

As a thank you for proving me being an idiot (I am one, obviously), I give this link, as I read you're into Ruby now.

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-12 10:41:42 Reply

Well that's pretty neat, but I'm like some old grandpa when it comes to social networking: I don't get it, need it, or want it (I don't have any social networking accounts).
So I definitely won't be looking into this/ever using it. :)

That project has some very well written code though, which isn't surprising given that it's Ruby.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 20
Programmer
Response to Programming Regs Lounge 2012-07-12 14:09:21 Reply

At 7/12/12 10:41 AM, Diki wrote

That project has some very well written code though, which isn't surprising given that it's Ruby.

That's why I wanted to forward it to you

Shakyjake
Shakyjake
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 22
Programmer
Response to Programming Regs Lounge 2012-07-13 02:43:38 Reply

Moving into Android App development because I'm a slave to trends.

Anyone used Eclipse before? Is it just me or is it buggy as hell?

kiwi-kiwi
kiwi-kiwi
  • Member since: Mar. 6, 2009
  • Offline.
Forum Stats
Member
Level 09
Programmer
Response to Programming Regs Lounge 2012-07-13 04:45:45 Reply

At 7/13/12 02:43 AM, Shakyjake wrote: Anyone used Eclipse before? Is it just me or is it buggy as hell?

yes eclipse starts to freak out when you have projects more complex than a calculator and starts to flip a coin every 10 minutes to see if it has to crash or not

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-13 08:59:54 Reply

At 7/13/12 02:43 AM, Shakyjake wrote: Anyone used Eclipse before? Is it just me or is it buggy as hell?

You could try using NetBeans.
I don't have very much experience with it, but when I did use it it seemed like a pretty solid IDE.

Shakyjake
Shakyjake
  • Member since: May. 7, 2005
  • Offline.
Forum Stats
Member
Level 22
Programmer
Response to Programming Regs Lounge 2012-07-13 15:57:30 Reply

At 7/13/12 04:45 AM, kiwi-kiwi wrote: yes eclipse starts to freak out when you have projects more complex than a calculator and starts to flip a coin every 10 minutes to see if it has to crash or not

Actually it was freaking out with my calculator app too :)

At 7/13/12 08:59 AM, Diki wrote: You could try using NetBeans.
I don't have very much experience with it, but when I did use it it seemed like a pretty solid IDE.

Aye that was one of the ones I'd considered before lumping for Eclipse (I thought, "If Google is recommending Eclipse then it must be good..."). Might have to check it out, I'm getting sick of having to keep removing all the packages Eclipse keeps importing for no discernible reason.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 20
Programmer
Response to Programming Regs Lounge 2012-07-14 12:15:40 Reply

I'd need some navgation/design related help, if possible. Go here. When you hover over a second category on the left menu "Dijagnostika", a submenu appears. Then, hover over a first submenu category "SpecijalistiƄki pregledi". You see I had to change the effect to come from right to left (it's from left to right when you hover on the main menu) and merge the second submenu with the first submenu. I had to do that because otherwise there's a gap between a 1st and 2nd submenu, and when you try to switch from aforementioned submenus (with mouse), the whole navigation (except the static, main menu, always visible part) closes. But not such thing happens when you switch from the main menu to a 1st sub menu. I don't even know how I accomplished that, it just happened that way.

In short - I also want a gap between the 1st and 2nd submenu, as when switching from main menu to 1st sub menu. But the problem is, I am unable to make a it, because I tried making that, and the submenus would vanish when I tried moving the mouse from the 1st to 2nd sub meun.

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-16 12:17:45 Reply

Some people here might remember a JavaScript project that I've been working on: SimpleJS.
For those who don't, or never knew about it in the first place: it's a framework designed to simplify JavaScript when massive frameworks such as jQuery or Mootools are not required. I also took inspiration from them to allow SimpleJS to be familiar to jQuery/Mootools users.

For the most part I have finished it.
You can download it here.
My GitHub page for it has examples for everything it can do here.

If anyone is interested in checking out I'd appreciate some feedback, so far I am the only person who has been using it.
Currently it is a little bit buggy in IE6, still working on that; otherwise it should be glitch free.

Cheers.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 20
Programmer
Response to Programming Regs Lounge 2012-07-16 14:38:38 Reply

At 7/16/12 12:17 PM, Diki wrote: Cheers.

cool

Mordarke
Mordarke
  • Member since: Aug. 22, 2003
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to Programming Regs Lounge 2012-07-17 00:30:29 Reply

At 7/16/12 12:17 PM, Diki wrote: Some people here might remember a JavaScript project that I've been working on: SimpleJS.
For those who don't, or never knew about it in the first place: it's a framework designed to simplify JavaScript when massive frameworks such as jQuery or Mootools are not required. I also took inspiration from them to allow SimpleJS to be familiar to jQuery/Mootools users.

For the most part I have finished it.
You can download it here.
My GitHub page for it has examples for everything it can do here.

If anyone is interested in checking out I'd appreciate some feedback, so far I am the only person who has been using it.
Currently it is a little bit buggy in IE6, still working on that; otherwise it should be glitch free.

Cheers.

This looks almost ideal for what my missus needs. I'll point it her way and see if it's much use, cheers!

P.S: JavaScript is a fucking horrible language and I hope it dies a horrible death.

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-17 09:30:56 Reply

At 7/17/12 12:30 AM, Mordarke wrote: P.S: JavaScript is a fucking horrible language and I hope it dies a horrible death.

JavaScript isn't going anywhere, nor would I want it to; client-side scripting is very useful.
Admittedly, Microsoft's implementations of JavaScript on their older browsers, such as IE6 and 7, wasn't exactly well done, but nowadays with SpiderMonkey, Rhino, and V8 JavaScript is actually pretty powerful; especially with V8.
Take a look at these WebGL examples to see the power of modern JavaScript; they work best if viewed in Chrome, or anything else that uses V8 (I only know of Chrome).

I'm curious though, why do you dislike JavaScript so much?

WizMystery
WizMystery
  • Member since: Feb. 3, 2009
  • Offline.
Forum Stats
Member
Level 11
Musician
Response to Programming Regs Lounge 2012-07-17 12:28:47 Reply

Everything's been going great with this game so far. I'm having very few problems lately, but I've just noticed something.

The CPU usage is always around 40-42 on my desktop and 27ish on my (new) laptop even when it's doing very minimal work. Is this a byproduct of using multiple threads that are always running? I don't have any resting periods written in (al_rest() or SLEEP), but even a single thread that doesn't stop stays around 02-03.

Mordarke
Mordarke
  • Member since: Aug. 22, 2003
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to Programming Regs Lounge 2012-07-18 00:48:12 Reply

At 7/17/12 09:30 AM, Diki wrote:
At 7/17/12 12:30 AM, Mordarke wrote: P.S: JavaScript is a fucking horrible language and I hope it dies a horrible death.
JavaScript isn't going anywhere, nor would I want it to; client-side scripting is very useful.
Admittedly, Microsoft's implementations of JavaScript on their older browsers, such as IE6 and 7, wasn't exactly well done, but nowadays with SpiderMonkey, Rhino, and V8 JavaScript is actually pretty powerful; especially with V8.
Take a look at these WebGL examples to see the power of modern JavaScript; they work best if viewed in Chrome, or anything else that uses V8 (I only know of Chrome).

I'm curious though, why do you dislike JavaScript so much?

I am not saying Javascript is bad but I find it to be too much of a "clunky" language, especially after working with Ruby for a fair time (that and I still have recurring nightmares regarding the sodding language). Coding for Ruby is an absolute breeze, though, I am unsure how well it'd work on a large-scale operation.

P.S: If interested in Ruby, check out Ruby Koans. Absolutely fucking BRILLIANT learning tool.

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-18 08:43:54 Reply

At 7/18/12 12:48 AM, Mordarke wrote: I am not saying Javascript is bad

But you did say that though:
"JavaScript is a fucking horrible language".

Horrible how?

At 7/18/12 12:48 AM, Mordarke wrote: I find it to be too much of a "clunky" language, especially after working with Ruby for a fair time

That's comparing apples to oranges though; JavaScript and Ruby are very different languages intended to solve very different problems.
Sure, JavaScript has some design flaws, but so does Ruby, and any other language ever made; no programming language is perfect.

What sort of client-side scripting language would you prefer?

P.S.
For the record: Ruby is an excellent language and what little I've written in it I enjoyed.
I still prefer Python though; I love Python.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 20
Programmer
Response to Programming Regs Lounge 2012-07-21 20:42:16 Reply

fucked up my finger pretty badly. i kinnda forgot to remove it when i was closing my car's door. the door is quite robust, and I slammed it more than usual.

typing (and wiping my ass) is a pain in the arse

Programming Regs Lounge

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-23 13:03:45 Reply

Was going through some old code snippets and came across a JavaScript gem.
I didn't write this, but I found it funny all the same:

alert(
(![]+[])[+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]
);

Try to guess what it outputs and then click here to find out.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 20
Programmer
Response to Programming Regs Lounge 2012-07-23 13:29:09 Reply

At 7/23/12 01:03 PM, Diki wrote: alert(
(![]+[])[+[]]+(![]+[])[+!+[]]+([![]]+[][[]])[+!+[]+[+[]]]+(!

[]+[])[!+[]+!+[]]

);

dafuq

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-23 14:32:04 Reply

That happens because of how JavaScript treats empty arrays (which is, a lot of the, treated as a string).
So that first piece of code:

(![]+[])

Creates the string "false".
This is because when you do this:

![]

You get a boolean false, because an array is not considered false, so therefore when used with the ! (not) operator returns false. Inversely if you were to do this:

!![]

You would get a boolean true, but that's not really important.
In order to convert the boolean to a string the boolean is incremented by an array; that is the same as incrementing by an empty string. The following two lines do the same thing:

![]+[]; // "false"
![]+""; // "false"

So now you have the string "false" and need to get the "f" out of it, which is at index position 0.
Before explaining that, take the following for example:

+5; // 5
-5; // -5
-+5; // -5
+-+5; // -5
-+-5; // 5

The positive/negative symbols do pretty much what you'd expect:
- Positive plus Positive equals Positive
- Positive plus Negative equals Negative
- Negative plus Negative equals Positive

Or, in other words:
- No negative sign, or equal number of negative signs, equals Positive
- Otherwise equals Negative

What happens when you use these with an empty array?

+[]; // 0
-[]; // -0

Yes, negative zero really is a thing.

So using that, you can easily get the "f" from a string of "false":

var falseStr = ![]+[]; // "false"
var fStr = falseStr[+[]]; // "f"

// One line:
(![]+[])[+[]];

Now knowing how to do goofy shit like that, you can break that code into smaller chunks:

// Generates "f":
(![]+[])[+[]];

// Generates "a":
(![]+[])[+!+[]];

// Generates "i":
([![]]+[][[]])[+!+[]+[+[]]];

// Generates "l":
(![]+[])[!+[]+!+[]];

And it stops becoming an incomprehensible mess.
Make sense now? :)

P.S.
I don't consider this a "fail" at all; just a neat trick produced by abusing the hell out of JavaScript.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 20
Programmer
Response to Programming Regs Lounge 2012-07-23 16:55:28 Reply

At 7/23/12 02:32 PM, Diki wrote: Make sense now? :)

P.S.
I don't consider this a "fail" at all; just a neat trick produced by abusing the hell out of JavaScript.

bWF5IGJlIHBpY3R1cmUgdGFsayBpbnN0ZWFkIG9mIG1lLg==

Programming Regs Lounge

Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Programming Regs Lounge 2012-07-24 11:23:57 Reply

Ignoring the stupid memes this video is a pretty interesting talk on some goofy things JavaScript does (as well as Ruby).
And this post explains why JavaScript does the things that are outlined in the video.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 20
Programmer
Response to Programming Regs Lounge 2012-07-25 12:50:41 Reply

At 7/25/12 05:08 AM, citricsquid wrote: http://phpjs.hertzen.com/

good for some fun I gues, as the docs say it's not recommended for production env