View mode: basic / threaded / horizontal-split · Log in · Help
March 21, 2009
Re: new D2.0 + C++ language
Piotrek:
> (of course there are bugs but  when I write something in D
> I'm so glad I don't have to to do it in something else).

D is surely not a puzzle language :-)
http://prog21.dadgum.com/38.html

Well, writing D templates in functional style and lot of string mixins is a puzzle (even if they are less puzzles than some things you have to do in Forth). AST macros too can become puzzles, but I think if well designed they can be more natural to use than the current templates & string mixins.

Bye,
bearophile
March 21, 2009
Re: new D2.0 + C++ language
Rainer Deyke wrote:
> Christopher Wright wrote:
>> I was pulling numbers out of my ass.
> 
> That's what I assumed.  I'm a game developer.  I use GC.
> 
>> 0.1 seconds out of every ten is a small amount to pay for the benefits
>> of garbage collection in most situations.
> 
> GC is useless for resource management.  RAII solves the resource
> management problem, in C++ and D2.  GC is a performance optimization on
> top of that.  If the GC isn't faster than simple reference counting,
> then it serves no purpose, because you could use RAII with reference
> counting for the same effect.
> 
> (No, I don't consider circular references a problem worth discussing.)

I believe Python is using reference counting with a garbage collector, 
with the collector intended to solve the circular reference problem, so 
apparently Guido van Rossum thinks it's a problem worth discussing.

And my opinion of reference counting is, if it requires no programmer 
intervention, it's just another garbage collector. Reference counting 
would probably be a win overall if a reference count going to zero would 
only optionally trigger a collection -- you're eliminating the 'mark' 
out of 'mark and sweep'. Though I would still demand a full 
mark-and-sweep, just not as often. Nontrivial data structures nearly 
always have circular references.
March 21, 2009
Re: new D2.0 + C++ language
Weed wrote:
> Piotrek пишет:
>> Weed pisze:
>>> Weed пишет:
>>>> Hi!
>>>>
>>>> I want to offer the dialect of the language D2.0, suitable for use where
>>>> are now used C/C++. Main goal of this is making language like D, but
>>>> corresponding "zero-overhead principle" like C++:
>>> at least to something like this idea? )
>> The idea could be ok but have you written a compiler or specification?
> 
> My experience in the creation of the compilers is reduced to half-read
> book "Compilers: Principles, Techniques, and Tools".
> 
> It was easier to write the differences from D, as fully to specification
> - I hoped that receive point to some fundamental problems, but there
> seems  all to be good (excluding holy war about GC, of course)

I inferred from your original post that you had written such a compiler. 
I think probably the first thing to do, if you are serious about this, 
is to choose one essential feature of your dialect and implement that. 
Then there will be something concrete to discuss.

That isn't the normal modus operandi around here, but there doesn't seem 
to be much support for your suggestions. I think this might be less to 
do with your ideas and more that I can't really envision what you're 
talking about and how code would look with your dialect.
March 21, 2009
Re: [OT]new D2.0 + C++ language
bearophile pisze:
> Piotrek:
>> (of course there are bugs but  when I write something in D
>> I'm so glad I don't have to to do it in something else).
> 
> D is surely not a puzzle language :-)
> http://prog21.dadgum.com/38.html


Haha, I found good discussion on reddit

http://www.reddit.com/r/programming/comments/7vnm0/puzzle_languages/

Just couple of nice citations:

J language expample:
meanf=: 1 : '(0>.255<.])@:<.@(m (+/ % #)@,;.3 ])"2'
boxf=: 1 : '(0>.255<.])@:<.@((2 2$m) (+/ % #)@,;.3 ])"2'
pc=: &.:([: 2 0 1&|: 256 256 256&#:)
inter=: ( [: , 2&(({. , (+/%#))\) )"1
inter2=: ([: (<.@inter pc) |:)^:2
fit=: [: >.`<./ ,
fit1=: [: >.`<./ (,~ (,~ -))~
histogram=: <: @ (#/.~) @ (i.@#@[ , I.)

Does it look like the Matrix?

And the the one made me laugh the most:
"CSS is the puzzliest puzzle that I ever puzzled"

Every one should try CSS :D

Cheers
March 21, 2009
Re: [OT]new D2.0 + C++ language
Piotrek:

> Haha, I found good discussion on reddit<

On the other hand, D too for me becomes a puzzle language when I use many string mixins or templates in functional-style. D macros will possibly improve that situation some.


> J language expample:<

K language seems worse to me, this is a full raytracer that saves in pgm (in C++ it's about 120 lines of code written in normal style):
http://www.nsl.com/k/ray/ray.k

U:{x%_sqrt x _dot x}
S:{[r;s]:[0>d:_sqr[s 1]+_sqr[b:v _dot r 1]-v _dot v:s[0]-*r;0i;0>t:b+e:_sqrt d;0i;0<u:b-e;u;t]}
I:{[r;h;o]:[~4:*o;:[~S[r;*o]<*h;h;h _f[r]/o 1];~h[0]>l:S[r]o;h;(l;U r[0]-o[0]-l*r 1)]}
T:{[r;o;d;z;l]:[0i=*h:I[r;z]o;0.;~0>g:h[1]_dot l;0.;0i=*I[(r[0]+(r[1]**h)+d*h 1;-l);z]o;-g;0.]}
N:{[n;o;i]0{x+T[(0 0 -4.;U(i+(y%4)-n%2),n);o;_sqrt 2^-42;0i,,3#0.]U -1 -3 2.}/+4_vs!16}
R:{[k;n]"P5\n",(5:n,n),"\n255\n",_ci _.5+15.9375*N[n*1.;C[k;0 -1 0.]1.]'+|@[n _vs!n*n;0;|:]}
C:{[k;c;r]:[k=1;(c;r);((c;r*3);(,(c;r)),C[k-1;;r%2]'+c+-3 3[2_vs 2 3 6 7]*r%_sqrt 12)]}
\t q:R[3]32
"temp.pgm"6:q
\"C:\\Program Files\\IrfanView\\i_view32.exe" temp.pgm

APL-like languages are a dead-end...

Bye,
bearophile
March 22, 2009
Re: new D2.0 + C++ language
Sat, 21 Mar 2009 00:59:22 -0600, Rainer Deyke wrote:

> GC is useless for resource management.

I think this is an overstatement.  It's only abstract write buffers
where GC really doesn't work, like std.stream.BufferedFile.  In any
other resource management case I can think of GC works fine.
March 22, 2009
Re: new D2.0 + C++ language
Sergey Gromov wrote:
> I think this is an overstatement.  It's only abstract write buffers
> where GC really doesn't work, like std.stream.BufferedFile.  In any
> other resource management case I can think of GC works fine.

OpenGL objects (textures/shader programs/display lists).
SDL surfaces.
Hardware sound buffers.
Mutex locks.
File handles.
Any object with a non-trivial destructor.
Any object that contains or manages one of the above.

Many of the above need to be released in a timely manner. For example,
it is a serious error to free a SDL surface after closing the SDL video
subsystem, and closing the SDL video subsystem is the only way to close
the application window under SDL.  Non-deterministic garbage collection
cannot work.

Others don't strictly need to be released immediately after use, but
should still be released as soon as reasonably possible to prevent
resource hogging.  The GC triggers when the program is low on system
memory, not when the program is low on texture memory.

By my estimate, in my current project (rewritten in C++ after abandoning
D due to its poor resource management), about half of the classes manage
resources (directly or indirectly) that need to be released in a timely
manner.  The other 50% does not need RAII, but also wouldn't benefit
from GC in any area other than performance.


-- 
Rainer Deyke - rainerd@eldwood.com
March 22, 2009
Re: new D2.0 + C++ language
Sat, 21 Mar 2009 20:16:07 -0600, Rainer Deyke wrote:

> Sergey Gromov wrote:
>> I think this is an overstatement.  It's only abstract write buffers
>> where GC really doesn't work, like std.stream.BufferedFile.  In any
>> other resource management case I can think of GC works fine.
> 
> OpenGL objects (textures/shader programs/display lists).
> SDL surfaces.
> Hardware sound buffers.
> Mutex locks.
> File handles.
> Any object with a non-trivial destructor.
> Any object that contains or manages one of the above.
> 
> Many of the above need to be released in a timely manner. For example,
> it is a serious error to free a SDL surface after closing the SDL video
> subsystem, and closing the SDL video subsystem is the only way to close
> the application window under SDL.  Non-deterministic garbage collection
> cannot work.
> 
> Others don't strictly need to be released immediately after use, but
> should still be released as soon as reasonably possible to prevent
> resource hogging.  The GC triggers when the program is low on system
> memory, not when the program is low on texture memory.
> 
> By my estimate, in my current project (rewritten in C++ after abandoning
> D due to its poor resource management), about half of the classes manage
> resources (directly or indirectly) that need to be released in a timely
> manner.  The other 50% does not need RAII, but also wouldn't benefit
> from GC in any area other than performance.

Thanks for the explanation, it really helps to keep this picture in
mind.
Next ›   Last »
3 4 5 6 7
Top | Discussion index | About this forum | D home