POV-Ray : Newsgroups : povray.off-topic : Why is Haskell interesting? Server Time
4 Sep 2024 19:20:58 EDT (-0400)
  Why is Haskell interesting? (Message 48 to 57 of 87)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Orchid XP v8
Subject: Re: Why is Haskell interesting?
Date: 28 Feb 2010 16:49:27
Message: <4b8ae4e7$1@news.povray.org>
>> Heh. If you mean "why isn't it some random symbol?" then the answer is 
>> "you can only use symbols for *binary* functions, not *unary* functions 
>> such as NOT".
> 
>   How do you negate an integral or floating point value, then?

Haskell possesses exactly *one* unary operator: unary minus. (Because, 
let's face it, not having this would just be annoying.) This is 
hard-wired into the language spec, however. You cannot define new unary 
operators.

The existence of the unary minus operator causes the following glitch:

   (5+) is a function.
   (5-) is a function.
   (5*) is a function.
   (5/) is a function.
   (+5) is a function.
   (-5) is a number.
   (*5) is a function.
   (/5) is a function.

Spot the odd one out. (There's a library function named "subtract" so 
that you can write "subtract 5" instead of "(-5)" to get a function.)

And it *is* unary minus, not part of the numeric literal syntax; for 
example "-x" works just as well as "-5" does.

(Saying "-x" is equivilent to saying "negate x". In particular, since 
unary minus is a syntax quirk, you can't define it directly. You define 
"negate" directly, and the compiler does the rest. Also, just for 
giggles, the default implementation of binary minus is "x - y = x + 
(negate y)"...)

So there - aren't you sorry you asked?

You may also have noticed that "sin -5" doesn't work. That's because 
it's interpretted as *binary* minus, i.e. "sin - 5", which obviously 
doesn't type-check. And *that* is why you have to say "sin (-5)". 
Annoying, isn't it?

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


Post a reply to this message

From: nemesis
Subject: Re: Why is Haskell interesting?
Date: 28 Feb 2010 17:15:01
Message: <web.4b8aea70b2efd740fa5d1ec00@news.povray.org>
Orchid XP v8 <voi### [at] devnull> wrote:
> Neeum Zawan wrote:
>
> >  Now you know how lots of people feel when they have to learn UNIX
>
> ls, cp, mv, rn and friends. Becuase, let's face it, adding two octets to
> cp to make copy would be a crime...

there were no visual text editors back then.  You entered chars and there was a
lag before they were printed.  The less chars, the less the chance of errors.
Kinda like the choice of bits too.


Post a reply to this message

From: Orchid XP v8
Subject: Re: Why is Haskell interesting?
Date: 28 Feb 2010 17:30:35
Message: <4b8aee8b$1@news.povray.org>
>> ls, cp, mv, rn and friends. Becuase, let's face it, adding two octets to
>> cp to make copy would be a crime...
> 
> there were no visual text editors back then.  You entered chars and there was a
> lag before they were printed.  The less chars, the less the chance of errors.
> Kinda like the choice of bits too.

When I was briefly in the local council offices, I went into their 
central computer room.

Now, this was 1997 or so, but I am not kidding, EVERYTHING WAS BROWN! Do 
you have any idea how long ago they stopped making computers in brown 
and cream?!?

They had a machine with a big green screen - you know, the kind where 
you can actually *see* the scanlines, and text takes a split second or 
two to actually fade off the screen. (And you can see what the most 
common message is, because it's permanently burned into the phosphor.)

Anyway, when you type on the clunky keyboard, there's a sort of 2-second 
delay, and then the character appears on the screen. Apparently the 
mainframe you're operating is actually 60 miles down the road, connected 
over some kind of telephone link. And the terminal is a *real* dumb 
terminal. o_O

I have no idea what kind of system it runs - it wasn't Unix, or at least 
didn't appear to be. But if you type in something like "lx 37f7h.b" or 
similar, the huge line printer next to it suddenly goes crazy and starts 
printing people's benefits cheques.

It wouldn't surprise me if that's how the council's computer systems 
*still* work...

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


Post a reply to this message

From: Warp
Subject: Re: Why is Haskell interesting?
Date: 28 Feb 2010 17:33:27
Message: <4b8aef37@news.povray.org>
Orchid XP v8 <voi### [at] devnull> wrote:
>    (+5) is a function.

  But I thought you said you couldn't have symbols as unary functions.

-- 
                                                          - Warp


Post a reply to this message

From: nemesis
Subject: Re: Why is Haskell interesting?
Date: 28 Feb 2010 17:35:00
Message: <web.4b8aeeacb2efd740fa5d1ec00@news.povray.org>
Orchid XP v8 <voi### [at] devnull> wrote:
> >> Perhaps you're forgetting that Haskell is also 20 years old?
> >
> >   Hence a complete newcomer as programming languages are concerned.
>
> Not nearly as new as the likes of Java, Python, Ruby, etc. But sure, not
> as ancient as Lisp or C...

I believe Haskell is older than those.  Haskell was to be a kind of open
reimplementation of Miranda, which was developed in the early 80's.  It adopted
most of Miranda's syntax, and if some of that sounds weird, it is because C++
was still being developed back then as well...


Post a reply to this message

From: Orchid XP v8
Subject: Re: Why is Haskell interesting?
Date: 28 Feb 2010 17:36:41
Message: <4b8aeff9$1@news.povray.org>
Warp wrote:
> Orchid XP v8 <voi### [at] devnull> wrote:
>>    (+5) is a function.
> 
>   But I thought you said you couldn't have symbols as unary functions.

It's a curried function.

If you take any N-argument function and call it with 1 argument, you get 
a new (N-1)-argument function as the result. Since (+) is a 2-argument 
function, giving it one argument (here 5) yields a new 1-argument function.

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


Post a reply to this message

From: Orchid XP v8
Subject: Re: Why is Haskell interesting?
Date: 28 Feb 2010 17:37:55
Message: <4b8af043$1@news.povray.org>
nemesis wrote:
> Orchid XP v8 <voi### [at] devnull> wrote:
>>>> Perhaps you're forgetting that Haskell is also 20 years old?
>>>   Hence a complete newcomer as programming languages are concerned.
>> Not nearly as new as the likes of Java, Python, Ruby, etc. But sure, not
>> as ancient as Lisp or C...
> 
> I believe Haskell is older than those.  Haskell was to be a kind of open
> reimplementation of Miranda, which was developed in the early 80's.  It adopted
> most of Miranda's syntax, and if some of that sounds weird, it is because C++
> was still being developed back then as well...

Apparently Miranda was released 1985, making it "only" 5 years older 
than Haskell. So even Miranda is "only" 25 years old.

To me, 25 years sounds like a hell of a long time in computing terms. 
But what do I know?

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


Post a reply to this message

From: nemesis
Subject: Re: Why is Haskell interesting?
Date: 28 Feb 2010 18:10:00
Message: <web.4b8af76ab2efd740fa5d1ec00@news.povray.org>
Orchid XP v8 <voi### [at] devnull> wrote:
> nemesis wrote:
> Apparently Miranda was released 1985, making it "only" 5 years older
> than Haskell. So even Miranda is "only" 25 years old.

still, older than all of those, born in the 90's from C and Unix ideas mostly.

> To me, 25 years sounds like a hell of a long time in computing terms.
> But what do I know?

It is in terms of processing power, but not in how people tap that processing
power.  Things evolve a lot slower in the software side, thanks to the same old
ideas that drag around...


Post a reply to this message

From: Invisible
Subject: Re: Why is Haskell interesting?
Date: 1 Mar 2010 04:26:08
Message: <4b8b8830$1@news.povray.org>
Darren New wrote:
> Orchid XP v8 wrote:
>> just mildly curious to know whether you can implement your own 
>> tokenising rules or not.
> 
> You're actually reading the input from the file. How could you *not* 
> implement your own tokenizing rules?

If it hands the input to you one token at a time, then it's already been 
split into tokens. If, on the other hand, it lets you take one character 
at a time, then you can do whatever you want.


Post a reply to this message

From: Invisible
Subject: Re: Why is Haskell interesting?
Date: 1 Mar 2010 04:46:20
Message: <4b8b8cec$1@news.povray.org>
>>> Hell, even Fortran is OO for the last 10 years.
>> People use Fortran? I thought that was only for scientific applications. 
> 
> And scientists aren't people?

[There's gotta be a joke in there somewhere...]

Scientific applications are a vanishingly small market segment.

>> Look at job adverts, or websites which talk about programming.
> 
> That's not "mainstream", that's "popular". :-)

There's a difference?

>> If you specifically want a binary tree, the simplest and most logical 
>> OO way would be to make leaves and branches different subclasses.
> 
> Not especially. What about a branch with only one child node?

Why would a branch have only one child? I've not seen that in too many 
algorithm descriptions. Usually a node has 0 or 2 children, not 1.

> And yes, even if leaves and branches are separate classes, it doesn't 
> mean that they both aren't of type "treenode", or the leaf could be a 
> subclass of branch or vice versa.

Sure, depending on what kind of tree you want, leaf and branch aren't 
necessarily sibling classes.

>> I meant I've never seen it done like that in an OO language.
> 
> You've never seen a N-ary tree in an OO language that used the same 
> class for branches and leaves?  Wow.

I haven't seen an N-ary tree in an OO language. ;-) Only strictly 
*binary* trees.

>> My point is that something like a parse tree usually doesn't need to 
>> be dynamically extensible. If you make an extension to the language, 
>> you typically need to rewrite all the code for processing the parse 
>> tree anyway, so the fact that it's monolithic isn't too much of an issue.
> 
> I disagree. The whole point of giving you the list of passes was showing 
> you how modular each pass can be, as well as showing you how modular 
> each parse node type needs to be.

Well, I guess no matter what I say everybody will conclude that I'm just 
a moron who doesn't know what he's talking about anyway, so...

>> And you can take a C++ program and use pointer arithmetic to access 
>> private member variables. Does that mean C++ doesn't provide 
>> encapsulation?
> 
> Yes.

Right. So any programming language that runs on a digital computer 
inherantly lacks encapsulation then?

That's a stupid definition. Encapsulation is about whether the language 
tries to limit your access to the internal implementation of an object, 
not about whether it's physically possible to circumvent the restriction 
by some suitably elaborate route.

> What is this?
> 
>    (lambda (x) (x + 1))
> 
> It's a lambda expression.
> 
>    y = (lambda (x) (x + 1))
> 
> What is y?  It's a closure.

I still don't get it. (But then, I don't even know what language that is...)

>> OK. So in what way does this mean that "functions are not first-class"?
> 
> I didn't say it did. I said that everything in Javascript is an object. 

OK. So even a function is an object. Since objects are first-class, that 
means objects are first class.

> OK, you said
>  > The difference is that Haskell functions work on data, while 
> Smalltalk only has objects. In other words, you can't invoke a function 
> without knowing what object that "function" is a method of. (This is 
> also the case for Javascript, btw.)

You wanna go back and check that?

YOU wrote this paragraph, not me. ;-)

>> I can imagine there are product written in Java that somebody has to 
>> support, or that there are Java compilers that somebody has to 
>> support. But the Java language itself?
> 
> Well, no, there's nobody who has to support the spec, as such. I meant 
> there are major systems where someone is paid to make sure the Java it's 
> based on keeps working.

And this isn't the case for Haskell?

As I said, the likes of Galois and Well Typed make their money primarily 
designing systems where correctness is vital. What kind of systems do 
you suppose those are?

(It's also conspicuous that both Galois and Well Typed employ people who 
are also GHC developers... so maybe that's your answer!)


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.