POV-Ray : Newsgroups : povray.off-topic : Enter the compiler Server Time
6 Oct 2024 12:25:24 EDT (-0400)
  Enter the compiler (Message 7 to 16 of 26)  
<<< Previous 6 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Thomas de Groot
Subject: Re: Enter the compiler
Date: 5 Mar 2015 03:30:23
Message: <54f8141f$1@news.povray.org>
On 4-3-2015 22:18, Orchid Win7 v1 wrote:
> Sometimes I honestly wonder if I should ever have been released into the
> community. Did you know, the other day I accidentally inhaled my own
> saliva instead of swallowing it? How can anybody be this retarded??

Oh well, been there, done that... :-)

At some point, we have all been loose at large far too long for our own 
or for other's good. ;-)
-- 
Thomas


Post a reply to this message

From: scott
Subject: Re: Enter the compiler
Date: 5 Mar 2015 03:41:00
Message: <54f8169c$1@news.povray.org>
>> An interesting read, so it turns out you are actually quite good at C#
>> programming then :-)
>
> Well, yeah, I did just spend the last 2 years writing C# code every
> single day. ;-)

Maybe you mentioned it but I forgot, what language are you writing the 
"compiler" in then? You can write C# code to generate, assemble and run 
code dynamically can't you? I started work on a raytracer once where the 
user typed in the scene as pseudo-C# code and then it compiled it an ran 
it to render the scene - it wasn't a security hole, more like a security 
chasm :-)

> C++, however, still scares me a little bit. For example, consider the
> following:
>
>    std::stringstream buf(user_data);
>    buf >> file_offset;
>
> ...yeah, it turns out file_offset was declared as a 32-bit integer
> rather than a 64-bit integer. (Because C doesn't define the size of
> things, it's just left as implementation-dependent. Yay!)

Yes, at least in C# you have Int32 Int64, and the MS IDE would probably 
give you a red squiggly line under something like that if you got it wrong.

I stopped using C++ a long time ago precisely for these sort of things 
that you miss and it screws everything up. Also I got so used to the 
autocomplete and help for C# in the MS IDE that the C++ one is painful 
to use now.


Post a reply to this message

From: Orchid Win7 v1
Subject: Re: Enter the compiler
Date: 5 Mar 2015 13:29:09
Message: <54f8a075$1@news.povray.org>
On 05/03/2015 08:40 AM, scott wrote:
>>> An interesting read, so it turns out you are actually quite good at C#
>>> programming then :-)
>>
>> Well, yeah, I did just spend the last 2 years writing C# code every
>> single day. ;-)
>
> Maybe you mentioned it but I forgot, what language are you writing the
> "compiler" in then?

The compiler is written in Haskell.

It probably wouldn't be hard to write the back-end in C# either - but 
the front-end would be nightmarishly horrific to write in anything less 
powerful than Haskell. (And even then, it's going to be quite hard.)

If, by some miracle, the compiler ever becomes self-hosting [which I 
consider extremely unlikely], then it will be possible to compile 
Haskell code to C# from within C#.

Actually, it's surprising how similar the C# and JavaScript backends 
have ended up being. Like, they both get driven by the same data 
structures. You could realistically write a compiler that spits out one 
or the other at the flick of a switch. (Assuming the front-end existed, 
which it doesn't.)

> You can write C# code to generate, assemble and run
> code dynamically can't you?

You *can*, in two different ways.

There's a "code DOM" that is a fancy system for generating 
syntactically-correct C# source code. (I.e., it lets you save text to a 
file, and then compile it how you could compile any other C# code.) I 
*think* they added the ability to programmatically compile it from 
within a running C# application now.

Or you can generate raw MS CIL directly, which is instantly useable. 
(But it means you have to comprehend low-level CIL stuff.)

At the moment, my computer just outputs ordinary C# source code, which 
VisualStudio can then compile. (Or, more likely, complain about.)

> I started work on a raytracer once where the
> user typed in the scene as pseudo-C# code and then it compiled it an ran
> it to render the scene - it wasn't a security hole, more like a security
> chasm :-)

Sounds a bit like the self-extracting POV-Ray scene I wrote a while 
back... ;-)

>> ...yeah, it turns out file_offset was declared as a 32-bit integer
>> rather than a 64-bit integer. (Because C doesn't define the size of
>> things, it's just left as implementation-dependent. Yay!)
>
> Yes, at least in C# you have Int32 Int64, and the MS IDE would probably
> give you a red squiggly line under something like that if you got it wrong.

Or Haskell, which gives you Int8, Int16, Int32, Int64 (and Integer, 
actually). Or Pascal. Or Smalltalk. Or Eiffel. Or, really, just about 
any programming language less ancient than C.

Considering that C was invented explicitly for the purpose of writing an 
operating system, it seems weird that it doesn't define bit-sizes, 
considering how utterly fundamental those are to all systems programming...

> I stopped using C++ a long time ago precisely for these sort of things
> that you miss and it screws everything up. Also I got so used to the
> autocomplete and help for C# in the MS IDE that the C++ one is painful
> to use now.

Yeah, as soon as you start editing C++ code, VisualStudio becomes a 
paperweight. You can't look up definitions of anything [because that's 
equivalent to solving the Halting Problem], you can't find usages of it 
[same reason], you certainly can't auto-rename stuff, it's impossible to 
determine which include file a certain identifier comes from or what 
it's type might be... It's just a painful experience.

Oh, and just because it compiles on Windows does *not* mean it will 
compile (or link) on Linux. For a start, if you are so incautious as to 
add a new source file to the project, you now have to manually edit the 
makefile [several times - because the first edit will never, ever be 
correct]. Then there's the fact that VS accepts

   template1<template2<FUBAR>>

whereas GCC demands that there must be a space (because ">>" is an 
operator)... The fun never ends!

Sometimes, I like to show people the source code to our file-analysis 
program, and then the corresponding 10-line program in Haskell. ;-)


Post a reply to this message

From: Orchid Win7 v1
Subject: Re: Enter the compiler
Date: 5 Mar 2015 13:37:20
Message: <54f8a260$1@news.povray.org>
On 03/03/2015 10:45 PM, Orchid Win7 v1 wrote:
> It's a tad verbose (!!), but it works. The protocol is that every
> top-level Haskell constant becomes a
>
> public static Thunk<...> OB_XXX = ...
>
> Any top-level constant that's a *function* also gets a
>
> public static T0 FN_XXX(Thunk<T1> arg1, Thunk<T2> arg2, Thunk<T3> args)
> {
> ...compiled code...
> }

...yeah, that doesn't actually work.

Haskell allows you to declare a "constant" who's type is polymorphic. C# 
does not.

For example:

   data MinHeap x = Empty | Node x (MinHeap x) (MinHeap x)

   empty :: MinHeap x
   empty = Empty

You *think* you can do this:

   public abstract class TC_MinHeap<Tx> {...}

   public sealed class VC_Empty<Tx> : TC_MinHeap<Tx> {...}

   public sealed class VC_Node<Tx> : TC_MinHeap<Tx> {...}

   public static readonly TC_MinHeap<Tx> OB_empty = new VC_Empty<Tx>();

Alas, that won't work. Outside of VC_Empty, the Tx variable is 
out-of-scope. The only way is to create a generic *method*:

   public static TC_MinHeap<Tx> OB_empty<Tx>()
   {
     return new VC_Empty<Tx>();
   }

Annoyingly, that means creating a brand-new VC_Empty<Tx> object for 
every possible type Tx. [And possibly several identical ones for a given 
type, if OB_empty gets accessed more than once.] Damned phantom types! :-P

The native C version, of course, can just tell the type system to go 
take a walk. I don't think you can do that in C#. (Well, short of 
casting everything to Object, and that's just not funny...)


Post a reply to this message

From: Thomas de Groot
Subject: Re: Enter the compiler
Date: 7 Mar 2015 03:16:02
Message: <54fab3c2$1@news.povray.org>
On 5-3-2015 9:30, Thomas de Groot wrote:
> On 4-3-2015 22:18, Orchid Win7 v1 wrote:
>> Sometimes I honestly wonder if I should ever have been released into the
>> community. Did you know, the other day I accidentally inhaled my own
>> saliva instead of swallowing it? How can anybody be this retarded??
>
> Oh well, been there, done that... :-)
>
> At some point, we have all been loose at large far too long for our own
> or for other's good. ;-)

Incidentally, did you know that this happened to you as a direct cause 
from human evolution? It is one of the less pleasant side effects of 
going from a four legs locomotion to an upright two legs walk. This 
resulted in a cross-over path for air and food in our throat.

-- 
Thomas


Post a reply to this message

From: Stephen
Subject: Re: Enter the compiler
Date: 7 Mar 2015 05:17:05
Message: <54fad021$1@news.povray.org>
On 07/03/2015 08:15, Thomas de Groot wrote:
> On 5-3-2015 9:30, Thomas de Groot wrote:
>> On 4-3-2015 22:18, Orchid Win7 v1 wrote:
>>> Sometimes I honestly wonder if I should ever have been released into the
>>> community. Did you know, the other day I accidentally inhaled my own
>>> saliva instead of swallowing it? How can anybody be this retarded??
>>
>> Oh well, been there, done that... :-)
>>
>> At some point, we have all been loose at large far too long for our own
>> or for other's good. ;-)
>
> Incidentally, did you know that this happened to you as a direct cause
> from human evolution? It is one of the less pleasant side effects of
> going from a four legs locomotion to an upright two legs walk. This
> resulted in a cross-over path for air and food in our throat.
>

Sinuses, the one that causes people trouble, (The maxillary sinus, I 
think) has its drainage channels in the wrong place for an upright 
posture. They are more suited to a four legged one. Or so I was told.
So if you ever want to use a steam inhaler. It is better to lie face 
down on a bed with your head over the edge to get the best position.

-- 

Regards
     Stephen


Post a reply to this message

From: Thomas de Groot
Subject: Re: Enter the compiler
Date: 7 Mar 2015 07:14:58
Message: <54faebc2$1@news.povray.org>
On 7-3-2015 11:16, Stephen wrote:
> On 07/03/2015 08:15, Thomas de Groot wrote:
>> On 5-3-2015 9:30, Thomas de Groot wrote:
>>> On 4-3-2015 22:18, Orchid Win7 v1 wrote:
>>>> Sometimes I honestly wonder if I should ever have been released into
>>>> the
>>>> community. Did you know, the other day I accidentally inhaled my own
>>>> saliva instead of swallowing it? How can anybody be this retarded??
>>>
>>> Oh well, been there, done that... :-)
>>>
>>> At some point, we have all been loose at large far too long for our own
>>> or for other's good. ;-)
>>
>> Incidentally, did you know that this happened to you as a direct cause
>> from human evolution? It is one of the less pleasant side effects of
>> going from a four legs locomotion to an upright two legs walk. This
>> resulted in a cross-over path for air and food in our throat.
>>
>
> Sinuses, the one that causes people trouble, (The maxillary sinus, I
> think) has its drainage channels in the wrong place for an upright
> posture. They are more suited to a four legged one. Or so I was told.
> So if you ever want to use a steam inhaler. It is better to lie face
> down on a bed with your head over the edge to get the best position.
>

I didn't know that one. There is also all that trouble in the back and 
feet...

-- 
Thomas


Post a reply to this message

From: Stephen
Subject: Re: Enter the compiler
Date: 7 Mar 2015 07:34:52
Message: <54faf06c$1@news.povray.org>
On 07/03/2015 12:14, Thomas de Groot wrote:
>> Sinuses, the one that causes people trouble, (The maxillary sinus, I
>> think) has its drainage channels in the wrong place for an upright
>> posture. They are more suited to a four legged one. Or so I was told.
>> So if you ever want to use a steam inhaler. It is better to lie face
>> down on a bed with your head over the edge to get the best position.
>>
>
> I didn't know that one. There is also all that trouble in the back and
> feet...

I don't know how true it is. I was told it by someone who had a lot of 
trouble with them and had a lot of the cartilage removed from his nose. 
But everyone I've told says it is a more effective way of steaming your 
head. A downside is that you must have trust in your household that they 
won't give you a skelp. :-)

Don't talk to me about feet. I am a martyr to my feet. ;-)

-- 

Regards
     Stephen


Post a reply to this message

From: Thomas de Groot
Subject: Re: Enter the compiler
Date: 7 Mar 2015 07:52:42
Message: <54faf49a$1@news.povray.org>
On 7-3-2015 13:34, Stephen wrote:
> On 07/03/2015 12:14, Thomas de Groot wrote:
>>> Sinuses, the one that causes people trouble, (The maxillary sinus, I
>>> think) has its drainage channels in the wrong place for an upright
>>> posture. They are more suited to a four legged one. Or so I was told.
>>> So if you ever want to use a steam inhaler. It is better to lie face
>>> down on a bed with your head over the edge to get the best position.
>>>
>>
>> I didn't know that one. There is also all that trouble in the back and
>> feet...
>
> I don't know how true it is. I was told it by someone who had a lot of
> trouble with them and had a lot of the cartilage removed from his nose.
> But everyone I've told says it is a more effective way of steaming your
> head. A downside is that you must have trust in your household that they
> won't give you a skelp. :-)

LOL. Better be careful indeed and lock the door. As far as evolution is 
concerned, we still are in the process of change I am told: number and 
size of teeth; shape of the lower jaw; just to mention a few things that 
are changing very rapidly, in terms of centuries if not decades.

>
> Don't talk to me about feet. I am a martyr to my feet. ;-)
>

Yeah, I know what you mean... ;-)
-- 
Thomas


Post a reply to this message

From: Stephen
Subject: Re: Enter the compiler
Date: 7 Mar 2015 09:30:13
Message: <54fb0b75$1@news.povray.org>
On 07/03/2015 12:52, Thomas de Groot wrote:
> LOL. Better be careful indeed and lock the door. As far as evolution is
> concerned, we still are in the process of change I am told: number and
> size of teeth; shape of the lower jaw; just to mention a few things that
> are changing very rapidly, in terms of centuries if not decades.

Add medicines to that and you'll get a strange mix.

It ain't natural. I tell you. :-)

-- 

Regards
     Stephen


Post a reply to this message

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

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