POV-Ray : Newsgroups : povray.off-topic : Games programmers Server Time
10 Oct 2024 17:18:51 EDT (-0400)
  Games programmers (Message 81 to 90 of 179)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Warp
Subject: Re: Games programmers
Date: 12 Sep 2008 09:12:15
Message: <48ca6aaf@news.povray.org>
andrel <a_l### [at] hotmailcom> wrote:
> >>   while(*v++ = *s++);
> >>
> >> I mean, what THE HELL...?

> A nice example of language design inspired by hardware (and vice versa). 
> May result in very fast code.

  Actually a memcpy() call would probably be faster (at least if you know
the amount of data to copy).

-- 
                                                          - Warp


Post a reply to this message

From: Invisible
Subject: Re: Games programmers
Date: 12 Sep 2008 09:22:24
Message: <48ca6d10@news.povray.org>
>> I wouldn't exactly call that straightfoward either. It's not *actually* 
>> complicated, but it sure *looks* pretty baffling.
> 
>   But the haskell code is normal, regular haskell. Your C example is
> not code any sane person would write.

Mmm, and you think any sane Haskell programmer would implement the 
Fibonaci numbers that way in a real program? It's an interesting 
teaching example, but seriously, if you *want* Fibonacci numbers for 
some reason, there is a simple, well-known O(1) algorithm for that.

>> Alternatively,
> 
>>    while(*v++ = *s++);
> 
>> I mean, what THE HELL...?
> 
>   At least it's easy to understand what it does (and why it works) when
> it's explained. The haskell example isn't.

Really? I mean, it's a little perplexing that the computer is actually 
able to unravel it without getting stuck, but once you understand what 
the machine is doing internally, it's not so hard.

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


Post a reply to this message

From: andrel
Subject: Re: Games programmers
Date: 12 Sep 2008 09:32:04
Message: <48CA6F9B.2000506@hotmail.com>
On 12-Sep-08 15:22, Invisible wrote:
>>> I wouldn't exactly call that straightfoward either. It's not 
>>> *actually* complicated, but it sure *looks* pretty baffling.
>>
>>   But the haskell code is normal, regular haskell. Your C example is
>> not code any sane person would write.
> 
> Mmm, and you think any sane Haskell programmer would implement the 
> Fibonaci numbers that way in a real program? It's an interesting 
> teaching example, but seriously, if you *want* Fibonacci numbers for 
> some reason, there is a simple, well-known O(1) algorithm for that.
> 
>>> Alternatively,
>>
>>>    while(*v++ = *s++);
>>
>>> I mean, what THE HELL...?
>>
>>   At least it's easy to understand what it does (and why it works) when
>> it's explained. The haskell example isn't.
> 
> Really? I mean, it's a little perplexing that the computer is actually 
> able to unravel it without getting stuck, but once you understand what 
> the machine is doing internally, it's not so hard.
> 
You mean that you not only understands how it works, but it even helped 
you understand how compilers work?


Post a reply to this message

From: Phil Cook
Subject: Re: Games programmers
Date: 12 Sep 2008 09:35:35
Message: <op.uhdeq50gc3xi7v@news.povray.org>
And lo on Fri, 12 Sep 2008 09:16:07 +0100, Invisible <voi### [at] devnull> did  
spake, saying:

>>> Haskell is a small, simple, logical language. C++ is a huge, messy,  
>>> complex language. I don't see how learning an easy language should  
>>> enable me to learn a hard language.
>>  Heh, Haskell looks complicated and hard to learn to me.
>
> Well, I guess there are probably people who look at something like
>
>    x = (-b +- Sqrt(b^2 - 4ac)/2a
>
> and go "OH MY GOD! That looks SO complicated!" But actually, if you know  
> a little algebra, you discover that this contraption is actually quite  
> straight forward.

But look at the knowledge you need for that. We'll assume that the basics  
are covered = + - x ÷ and that you recognise the x, a, b, and c parts of  
the equation. First up we get - how can you start with a - symbol, what am  
I subtracting b from? Next is a ±; okay you hopefully recognise that it's  
a + and a - combined, but how do I add and subtract at the same time? Then  
we get a √ um okay the shape of that gives no clue unless you just know  
it. Then ² which we might know as shorthand for b x b as many times as the  
number. Then we get an 4ac, is that a new character; you know a-z, aa-az,  
etc? You have to know that it's shorthand for 4 x a x c. Then finally you  
get a / or just one big line which you need to recognise as a ÷.

Spell out all the assumed shorthand plus symbols there and you can see why  
it could legitimately be considered complicated.

-- 
Phil Cook

--
I once tried to be apathetic, but I just couldn't be bothered
http://flipc.blogspot.com


Post a reply to this message

From: Invisible
Subject: Re: Games programmers
Date: 12 Sep 2008 09:37:05
Message: <48ca7081$1@news.povray.org>
>> Really? I mean, it's a little perplexing that the computer is actually 
>> able to unravel it without getting stuck, but once you understand what 
>> the machine is doing internally, it's not so hard.
>>
> You mean that you not only understands how it works, but it even helped 
> you understand how compilers work?

Well I mean *notionally*, the way Haskell executes is fairly simple. In 
the case of the magic tail-chasing fibs definition, fibs starts out as a 
list where some list cells are defined, and some haven't been computed 
yet. And the ones that haven't been computed yet refer to the ones that 
have. (If it were the other way round, you WOULD have a problem.) As you 
ask for list cells, they get computed, one by one, until you get the one 
you want.

It's a nice example of how lazy evaluation allows you to program in 
unusual ways, but it's probably not terrifically practical unless you 
only need a handful of Fibonacci numbers.

-- 
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 09:37:50
Message: <48ca70ae@news.povray.org>
"Invisible" <voi### [at] devnull> wrote in message 
news:48ca500c@news.povray.org...
>>>   while(*v++ = *s++);
>>>
>>> I mean, what THE HELL...?
>>>
>>
>> I doubt that's the recommended way of copying an array any longer
>
> I doubt that was *ever* the "recommended" way. And yet I, a person who 
> doesn't know C very well, am aware of this example. What does that tell 
> you? ;-)

That you're looking for examples of why the language is incomprehensible.
That you had a bad lecturer/textbook at university
That you're reading up on why C++ is bad and what constructs are known to 
cause problems.

Taking the example to my prefered language, I'd say that 80% of people who 
have worked much with SQL can and will use cursors, yet every expert in SQL 
will tell people to never use them
Does that mean that SQL is incomprehensible to the average person and a 
language that's easy to break things in?


Post a reply to this message

From: Invisible
Subject: Re: Games programmers
Date: 12 Sep 2008 09:57:10
Message: <48ca7536$1@news.povray.org>
>> I doubt that was *ever* the "recommended" way. And yet I, a person who 
>> doesn't know C very well, am aware of this example. What does that 
>> tell you? ;-)
> 
> That you're looking for examples of why the language is incomprehensible.

Doesn't take much looking, does it?

> That you had a bad lecturer/textbook at university.

The long and short is, I spent several months at college using C, and I 
always round it excrusiatingly difficult to get any of the programs to 
work properly. Unfortunately that's just the way C is designed; nothing 
is checked, the programmer is assumed to know exactly what they're 
doing, and if the programmer does something wrong... well that's just 
too bad.

I'm sure this makes the compiler much easier to implement, and no doubt 
it contributes to the efficiency and flexibility of the language, but... 
I prefer having some kind of safety features in a programming langauge.

> That you're reading up on why C++ is bad and what constructs are known 
> to cause problems.

Actually... no.

> Taking the example to my prefered language, I'd say that 80% of people 
> who have worked much with SQL can and will use cursors, yet every expert 
> in SQL will tell people to never use them.
> Does that mean that SQL is incomprehensible to the average person and a 
> language that's easy to break things in?

I guess it depends what you're trying to do. SQL certainly has a few 
known flaws (default column orderings, anyone?), but in general it makes 
it quite simple and easy to do most things.

In C, just concatinating two strings is an ugly, complex operation. In 
fact, it seems to be easier to just write one string to stdout and then 
write the other, rather than trying to actually concatinate them. The 
language seems to make every tiny little operation really awkward and 
difficult. No thanks...

Still, since I am the *only* person on the entire news server who thinks 
this, I guess I should just let it go.

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


Post a reply to this message

From: andrel
Subject: Re: Games programmers
Date: 12 Sep 2008 09:58:36
Message: <48CA75D2.8010308@hotmail.com>
On 12-Sep-08 15:36, Phil Cook wrote:
> And lo on Fri, 12 Sep 2008 09:16:07 +0100, Invisible <voi### [at] devnull> did 
> spake, saying:
> 
>>>> Haskell is a small, simple, logical language. C++ is a huge, messy, 
>>>> complex language. I don't see how learning an easy language should 
>>>> enable me to learn a hard language.
>>>  Heh, Haskell looks complicated and hard to learn to me.
>>
>> Well, I guess there are probably people who look at something like
>>
>>    x = (-b +- Sqrt(b^2 - 4ac)/2a
>>
>> and go "OH MY GOD! That looks SO complicated!" But actually, if you 
>> know a little algebra, you discover that this contraption is actually 
>> quite straight forward.
> 
> But look at the knowledge you need for that. We'll assume that the 
> basics are covered = + - x ÷ and that you recognise the x, a, b, and c 
> parts of the equation. First up we get - how can you start with a - 
> symbol, what am I subtracting b from? Next is a ±; okay you hopefully 
> recognise that it's a + and a - combined, but how do I add and subtract 
> at the same time? Then we get a √ um okay the shape of that gives no 
> clue unless you just know it. Then ² which we might know as shorthand 
> for b x b as many times as the number. Then we get an 4ac, is that a new 
> character; you know a-z, aa-az, etc? You have to know that it's 
> shorthand for 4 x a x c. Then finally you get a / or just one big line 
> which you need to recognise as a ÷.
> 
> Spell out all the assumed shorthand plus symbols there and you can see 
> why it could legitimately be considered complicated.
> 

For me the most interesting thing is the ±, that one is quite rare in 
highschool maths. Here, and I assume also elsewhere, it is pronounced as 
'plus or minus'. Where the 'or' apparently means that we have to 
consider one *and* the other. An obvious question is: 'How can it be 
that an equation has more than one answer'? There is also the often 
overlooked complication that formula manipulating normally consists of 
equivalent transformations. Here we have something that isn't, it is 
more of a bifurcation resulting in two separate formulas, neither of 
which is equivalent to the original equation. It is not obvious how to 
run this process in reverse. I think I learned that one later 
separately, without being told the intimate connection to the ± in this 
formula (or more precise the boolean thing hidden in there somewhere).


Post a reply to this message

From: Invisible
Subject: Re: Games programmers
Date: 12 Sep 2008 10:01:02
Message: <48ca761e$1@news.povray.org>
>> Well, I guess there are probably people who look at something like
>>
>>    x = (-b +- Sqrt(b^2 - 4ac)/2a
>>
>> and go "OH MY GOD! That looks SO complicated!" But actually, if you 
>> know a little algebra, you discover that this contraption is actually 
>> quite straight forward.
> 
> But look at the knowledge you need for that.
> 
> Spell out all the assumed shorthand plus symbols there and you can see 
> why it could legitimately be considered complicated.

Presumably *any* language will _look_ cryptic if you don't understand 
it. The question is how easy it is or isn't to _learn_. ;-)

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


Post a reply to this message

From: scott
Subject: Re: Games programmers
Date: 12 Sep 2008 10:16:06
Message: <48ca79a6$1@news.povray.org>
> Presumably *any* language will _look_ cryptic if you don't understand it. 
> The question is how easy it is or isn't to _learn_. ;-)

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).

If you want to get more advanced, then learn to handle arrays and what & and 
* do (quite easy things to remember, not complex at all), and you're pretty 
much set to understand 99.999% of C code out there - including things like 
while(*v++ = *s++);

What's the problem?


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.