POV-Ray : Newsgroups : povray.off-topic : Games programmers Server Time
10 Oct 2024 13:12:50 EDT (-0400)
  Games programmers (Message 120 to 129 of 179)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Nicolas Alvarez
Subject: Re: Games programmers
Date: 12 Sep 2008 16:34:58
Message: <48cad272@news.povray.org>
Mueen Nawaz wrote:
> I believe
> you can insert an element in the middle of a vector.

You can. It's O(n) where n is the number of elements between the insertion
point and the end; but you can.


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Games programmers
Date: 12 Sep 2008 16:47:02
Message: <48cad545@news.povray.org>
Invisible wrote:
> Alternatively,
> 
>    while(*v++ = *s++);
> 
> I mean, what THE HELL...?

I think it was Linus Torvalds who said:

"It's like that while(*p++ = *q++) strcpy code. It works, sure, but it's the
worst code in the world."


Post a reply to this message

From: Warp
Subject: Re: Games programmers
Date: 12 Sep 2008 16:48:13
Message: <48cad58c@news.povray.org>
scott <sco### [at] scottcom> wrote:
> I really don't understand why you find it so hard to learn C.

> There are only a tiny number of core statements (like if, while, return etc) 
> and the syntax of them all is very similar.  How to write functions you just 
> have to learn, but that's the same for any language.  Writing mathematical 
> formulae is also very easy and similar to almost every other language (using 
> + - / * etc).

  Yet there are things in C which even expert C programmers have hard time
understanding. One good example: What does this mean (and why):

(******************putchar) (4 ["Hello"]);

  (Yes, that's completely valid standard C.)

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: Games programmers
Date: 12 Sep 2008 16:55:17
Message: <48cad735@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> You know what? In Java, if you reference a null pointer, a little 
> message pops up that says "hey, you just dereferenced a null pointer". 
> And it even tells you where it happened. In C, your program just behaves 
> bizarely.

  Actually no. IIRC the C standard defines that accessing the null pointer
is illegal (and will usually cause a segmentation fault). If you are running
a proper debugger, it will tell you the exact line where the null pointer
was accessed.

> Ditto for EOF

  You mean reaching the end of the file is such a fatal error, that the
program must be terminated with an exception?

> array index out of bounds

  Unless you use a proper debugger.

> out of memory...

  Causes a null pointer access in C.

> (And you don't have to memorise whether 0 is true or false.

  I see how that's such a hard thing to memorize.

> Memory leaks? What memory leaks?

  Yeah. Java leaks memory constantly. In fact, *everything* is leaked.

> No dangling pointers here either.

  Except for the null references.

-- 
                                                          - Warp


Post a reply to this message

From: Vincent Le Chevalier
Subject: Re: Games programmers
Date: 12 Sep 2008 17:01:18
Message: <48cad89e$1@news.povray.org>
andrel a écrit :
> On 12-Sep-08 21:14, Vincent Le Chevalier wrote:
>> There is also a similarity between the behaviours of positive 
>> integers, multiplication and addition, and booleans, AND and OR. That is:
>>
>>  Integers            Booleans
>> a*(b+c) = a*b + a*c        a AND (b OR c) = (a AND b) OR (a AND c)
>> 0 + a = a            false OR a = a
>> 0 * a = 0            false AND a = false
>> if a>0, a+b>0 for all b        if a is true, a OR b is true for all b
>> And so on...
>>
>> It does not work out that well if you set true <-> 0.
>>
> If you take
>   true <-> 0
>   false <-> 1
>   OR <-> *
>   AND <-> +
> it works again.

No, it's not as perfect. For example the equality:
(a AND b) OR (a AND c) = a AND (b OR c)

would translate as:
(a+b) * (a+c) = a*a + a*b + a*c + b*c
	= a * (1+b+c) + b*c
	!= a + b*c

because 1+b+c is not equal to 1 in all cases.

I agree it works in the boolean sense, that is if one side is zero, the 
other is too. But you do not have the equality that you have in the 
other approach.

I'm nearly sure there is a deeper reason for that but I can't think of 
it right now.

-- 
Vincent


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: Games programmers
Date: 12 Sep 2008 17:01:58
Message: <48cad8c6@news.povray.org>
Invisible wrote:
> You know what? In Java, if you reference a null pointer, a little
> message pops up that says "hey, you just dereferenced a null pointer".
> And it even tells you where it happened. In C, your program just behaves
> bizarely.

In Java, if you deference a null pointer, it throws a NullPointerException
which basically kills your program if you don't catch it anywhere (and
usually you shouldn't).

In C, your program immediately segfaults, and if it was running under a
debugger you get the line of code where it did. Or at least the address of
the code it was executing.

> Java has a seperate Boolean type, so you can tell when a function
> returns a numer and when it returns a Boolean. (And you don't have to
> memorise whether 0 is true or false. And if you accidentally try to use
> a number where a Boolean is expected, the compiler *tells* you about
> this. And...)

C++ has a bool type. Although it's easy to accidentally convert it to a
number (true + true isn't a compiler error).

> Memory leaks? What memory leaks? No dangling pointers here either.

In Java, you're leaking memory all the time (quote from Warp), and the
runtime environment is trying to clean up the mess behind you. Forgetting
to set a reference to null when you don't plan to use it anymore would keep
it from being cleaned up, and would cause the same effect as not freeing
memory in C/C++.

C++ doesn't need garbage garbage collection because it generates so little
garbage (quote from Bjarne Stroustrup).


Post a reply to this message

From: Warp
Subject: Re: Games programmers
Date: 12 Sep 2008 17:04:32
Message: <48cad960@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> scott wrote:

> > I really don't understand why you find it so hard to learn C.

> (I really don't understand why everybody else finds it so hard to learn 
> Haskell, but there we are.)

  Because Haskell is not imperative and doesn't use modules. Haskell uses
a paradigm which does not correspond to how normal people think.

  (Of course it doesn't help that 90% of the keywords and standard library
function names are obfuscated. Sometimes the names are obscure because the
concept behind them is so obscure. Other times it's simply this weird
obsession Haskell people have with writing code which is as short as
possible, even at the cost of clarity.)

> Any operation involving strings seems to require you to use functions 
> with names like "strnmsx" or something. (What, you couldn't afford a few 
> more octets for some extra letters?)

  Have you looked at the standard library function names in haskell
recently?

  (Besides, if you want easy string manipulation, use C++, not C.)

> I spent about 3 days trying to figure out the syntax for making function 
> pointers work.

  I can't even begin to imagine what do you need function pointers for,
as a C beginner programmer.

  I have programmed C/C++ for over 10 years, over half of that
professionally, and I have used function pointers probably less than
a dozen times.

> Which one is FALSE? Is that 0 or 1? I know it's one or the other, but I 
> can never ever remember which - and it's kind of important!

  You have a ridiculously bad memory if you can't remember such a trivial
thing.

> What insane nutcase thought that making assignment an expression as a 
> good idea? Seriously, WTF? That's excellent. So if I say "if (x = 5)..." 
> then my program will silently fail to work correctly, and I'll probably 
> spend hours if not days trying to figure out why.

  Use a proper compiler.

> Boolean operators and bitwise operators. Which is which? Which ones are 
> the short-circuit ones, and which aren't? I can never remember.

  Says the person who has probably memorized over half of the most
obscure functions and tricks in haskell.

> What's the difference between #include "" and include <>?

  Does it matter?

-- 
                                                          - Warp


Post a reply to this message

From: Warp
Subject: Re: Games programmers
Date: 12 Sep 2008 17:10:55
Message: <48cadadf@news.povray.org>
Nicolas Alvarez <nic### [at] gmailcom> wrote:
> I think it was Linus Torvalds who said:

> "It's like that while(*p++ = *q++) strcpy code. It works, sure, but it's the
> worst code in the world."

  I wouldn't put too much weight on what Torvalds thinks is good code and
bad code. Sure, he developed the linux kernel, but his views of programming
and programming paradigms are just nuts.

  (I'm not saying he is wrong in this particular case, just that I don't
consider him any kind of authority or expert on programming and programming
practices.)

-- 
                                                          - Warp


Post a reply to this message

From: Orchid XP v8
Subject: Re: Games programmers
Date: 12 Sep 2008 17:20:10
Message: <48cadd0a@news.povray.org>
>> You know what? In Java, if you reference a null pointer, a little 
>> message pops up that says "hey, you just dereferenced a null pointer". 
>> And it even tells you where it happened. In C, your program just behaves 
>> bizarely.
> 
>   Actually no. IIRC the C standard defines that accessing the null pointer
> is illegal (and will usually cause a segmentation fault). If you are running
> a proper debugger, it will tell you the exact line where the null pointer
> was accessed.

I guess it works differently with a real OS. I've only ever compiled C 
code under MS-DOS, and there you don't get "segfaults", you get "my 
program does something really weird which may even require me to reboot 
the whole PC to fix". Pascal programs never, ever did that.

>> Ditto for EOF
> 
>   You mean reaching the end of the file is such a fatal error, that the
> program must be terminated with an exception?

Well, it beats producing random garbage, surely?

>> array index out of bounds
> 
>   Unless you use a proper debugger.

I've never seen a C debugger. Nor would I know where to find one. 
(Although presumably it's a standard tool that a real C programmer would 
know how to find and use.)

>> (And you don't have to memorise whether 0 is true or false.
> 
>   I see how that's such a hard thing to memorize.

There are two possibilities which are apparently equally valid. It's 
very difficult to remember which one of them was arbitrarily selected by 
the language designers.

>> Memory leaks? What memory leaks?
> 
>   Yeah. Java leaks memory constantly. In fact, *everything* is leaked.

I was waiting for that one... ;-)

>> No dangling pointers here either.
> 
>   Except for the null references.

You can still forget to make a pointer point to something, but you can't 
accidentally delete a chunk of memory that's still in use.

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Gail
Subject: Re: Games programmers
Date: 12 Sep 2008 17:28:58
Message: <48cadf1a@news.povray.org>
"andrel" <a_l### [at] hotmailcom> wrote in message 
news:48C### [at] hotmailcom...

>
> The ij is originally 'ii' with the second 'i' notifying that it is a long 
> vowel. Nowadays it is a single glyph (unless you are using American 
> software). The sound changed in the area where the official dutch 
> originates to be the same as the 'ei' 'vowel'.

Afrikaans has the 'ji' construct, usually as part of the diminutive suffix 
'tjie', but in other places too

>> Die taal is maklik vergelyk its soos Zoeloe.
>
> Het blijft leuk om een taal van de andere kant van de wereld te zien die 
> je gewoon kan lezen. Al moet ik zeggen dat als iemand het spreekt het meer 
> dan een paar seconden kost om het te vertalen en ik dus elke keer de draad 
> kwijtraak.

I'm gonna have to ask for a translation of that. Lost in the 2nd sentance.
My afrikaans isn't as good as I made it out to be.

>
> BTW Gail, somewhere in october I will hear if there is a change to visit 
> SA in 2015. There is also a change that we will be involved in 
> preparations for that and be there in februari or so...

Feb next year? Cool. It's a good time of the year to visit, if you like hot 
weather.
Joburg, Cape


Post a reply to this message

<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.