Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #68766

Re: a style question:

From Bartc <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: a style question:
Date 2015-08-31 18:40 +0100
Organization A noiseless patient Spider
Message-ID <ms23eh$ubu$1@dont-email.me> (permalink)
References (1 earlier) <6e9323cb-1dff-4bff-b19a-d4b1da735ffb@googlegroups.com> <ms1bf1$peo$1@dont-email.me> <87zj17tzq5.fsf@bsb.me.uk> <ms1m9d$3rs$1@dont-email.me> <87twrftsuw.fsf@bsb.me.uk>

Show all headers | View raw


On 31/08/2015 15:50, Ben Bacarisse wrote:
> Bartc <bc@freeuk.com> writes:
>> On 31/08/2015 13:21, Ben Bacarisse wrote:

>>> I.e. what is, in your view, the proper way to write that?
>>
>> I like using keywords to specify exactly what is being done. Perhaps
>> not as long-winded as this, but along these lines:
>>
>> define template ......
>> instantiate template ....
>>
>> Then there is no excuse for not knowing what is happening. (Better
>> than trying to infer what is being done from a mess of punctuation and
>> syntax.)
>
> But you did not show an equivalent, so of course you can imply that it
> can be simpler.  Show, in your language, the instantiation of a generic
> type with two parameters -- one a non-standard real type and the other a
> constant value.

I would have to fully understand what it means, and unfortunately I 
don't. I guess it's some sort of specialisation, something like a C 
macro, but more ambitious. But I'm not a fan of macros either! (I 
suppose there's nothing to stop the C++ writer from mixing in macros 
here as well, just to make the code even more challenging.)

 > The simplest syntax is likely to be very similar to
 > C++, but do show how much better you can make it.

Also, you can't take a feature out of context like this and demand the 
equivalent in another language. I've chosen to deal with it by not 
having the feature. In that case there /is/ no syntax; what can be simpler?!

If someone had the job of translating a program to Pascal, say, which do 
you think they would prefer to work from: C++, or my language that 
doesn't have any hairy features?

>> While my dynamic language doesn't have templates; it doesn't really
>> need them as you effectively get generics for free.
>
> No, you get them at a price, but you don't show the code, so I have no
> idea what the price is.  It may be that the type can't even be
> specified.  I can't tell yet.

What type is being specified? See, I still don't know what the code is 
supposed to be doing! Does BezierPathSimple<real_32_t, GREEN> expand to 
a type definition?

And no, with a dynamic language, the type isn't specified and isn't 
needed when doing generics. You don't even thing about it (so I was 
using generics, polymorphism and all that in the 1980s, and didn't even 
know).

So there is no cost in terms of complicated syntax and debugging. There 
might be a cost in performance, if it all has to be sorted out at 
runtime. But that also depends on the implementation; I think it's more 
worthwhile getting interpreted languages up to speed, than devising more 
and more complicated compiled ones.

>> Neither of these are as offensive to me as typical C++ code is.
>
> Yes, I know that.  I'm just pointing out how odd that criterion is in
> such a technical field.

In your opinion, which is the more elegant language: Algol68, Haskell or 
whatever it was, or C++? Be honest!

Even in a technical area, there must be a limit to how unwieldy, 
unfriendly, long-winded and ugly a syntax can be before people start to 
complain. Don't forget that a HLL is supposed to allow you to 
effortlessly write beautiful, clear code compared with assembly. Then 
you look at C++ and realise something has gone badly wrong!


-- 
Bartc

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

a style question: G G <gdotone@gmail.com> - 2015-08-31 02:30 -0700
  Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-08-31 21:40 +1200
  Re: a style question: jt@toerring.de (Jens Thoms Toerring) - 2015-08-31 09:52 +0000
  Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 03:24 -0700
    Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 11:50 +0100
      Re: a style question: Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-31 13:21 +0100
        Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 05:41 -0700
        Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 14:55 +0100
          Re: a style question: Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-08-31 15:50 +0100
            Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 18:40 +0100
      Re: a style question: Melzzzzz <mel@zzzzz.com> - 2015-08-31 17:46 +0200
        Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 17:27 +0100
          Re: a style question: Melzzzzz <mel@zzzzz.com> - 2015-08-31 18:42 +0200
      Re: a style question: Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-08-31 17:41 +0000
        Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 15:33 -0700
          Re: a style question: Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-09-01 08:34 +0000
      Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-09-01 07:40 +1200
        Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 21:36 +0100
          Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-09-01 08:51 +1200
            Re: a style question: Bartc <bc@freeuk.com> - 2015-08-31 22:37 +0100
              Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 15:24 -0700
                Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-09-02 19:37 +1200
          Re: a style question: jt@toerring.de (Jens Thoms Toerring) - 2015-08-31 23:33 +0000
            Re: a style question: Bartc <bc@freeuk.com> - 2015-09-01 01:13 +0100
              Re: a style question: Ian Collins <ian-news@hotmail.com> - 2015-09-01 18:21 +1200
              Re: a style question: jt@toerring.de (Jens Thoms Toerring) - 2015-09-01 15:23 +0000
                Re: a style question: Bartc <bc@freeuk.com> - 2015-09-01 18:06 +0100
                Re: a style question: Jorgen Grahn <grahn+nntp@snipabacken.se> - 2015-09-01 20:39 +0000
                Re: a style question: jt@toerring.de (Jens Thoms Toerring) - 2015-09-01 20:45 +0000
                Re: a style question: Bartc <bc@freeuk.com> - 2015-09-01 22:53 +0100
            Re: a style question: Malcolm McLean <malcolm.mclean5@btinternet.com> - 2015-08-31 17:51 -0700

csiph-web