Odd design decisions?

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

Re: Odd design decisions?

Postby RoadieRich » Sun Dec 18, 2011 5:16 pm UTC

sourmìlk wrote:And I don't like that it makes separation of interfaces and implementations mandatory.

Except that's the way it should be done in C++ anyway. Declare your class in a .h that anyone can see, define it in a .cpp that you can complie and distribute as a binary. That way, you don't end up with duplicate definitions when you try to reuse old code.
roband wrote:Mav is a cow.

UniJam 2012: Inter-university Games Jam hosted by Nottingham Trent University DevSoc.
nlug: Nottingham Linux User Group
DevSoc: The Nottingham Trent University Software Development Society
User avatar
RoadieRich
The Black Hand
 
Posts: 1030
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Somewhere only we know

Re: Odd design decisions?

Postby Yakk » Sun Dec 18, 2011 8:28 pm UTC

sourmìlk wrote:Why the hell does objective C use brackets with the same frequency Lisp uses parentheses?
It is their message passing to objects syntax. Objective C message passing isn't calling a C function, and they didn't override that syntax. It is based off an older, more object oriented language than C++, from a smaller and more civilized age.
And why did they abandon constructors?
Abandon? I don't see any constructors in the C language. What constructors did they have to abandon?
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
User avatar
Yakk
 
Posts: 10039
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Odd design decisions?

Postby EvanED » Sun Dec 18, 2011 8:32 pm UTC

And destroy the ability to do any inlining involving your class, even for things like setters and getters?

(As the Mozilla people are finding, LTO is expensive.)
EvanED
 
Posts: 3767
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI

Re: Odd design decisions?

Postby RoadieRich » Sun Dec 18, 2011 11:46 pm UTC

EvanED wrote:And destroy the ability to do any inlining involving your class, even for things like setters and getters?

(As the Mozilla people are finding, LTO is expensive.)

LTO? The only definition I can find is http://en.wikipedia.org/wiki/Linear_Tape-Open.
roband wrote:Mav is a cow.

UniJam 2012: Inter-university Games Jam hosted by Nottingham Trent University DevSoc.
nlug: Nottingham Linux User Group
DevSoc: The Nottingham Trent University Software Development Society
User avatar
RoadieRich
The Black Hand
 
Posts: 1030
Joined: Tue Feb 12, 2008 11:40 am UTC
Location: Somewhere only we know

Re: Odd design decisions?

Postby EvanED » Mon Dec 19, 2011 1:05 am UTC

Link-time optimization
EvanED
 
Posts: 3767
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI

Re: Odd design decisions?

Postby Jplus » Tue Dec 20, 2011 2:57 pm UTC

MHD wrote:D does templated metaprogramming about twice as well as C++.
(...)

Jplus wrote:(...)
Anyway, I'll have a look into your claim that D has stronger generics than C++.

Alright, I had a look at D, and this is my first impression. "Templates" in D seem to be a different beast from templates in C++. In D, they serve as the solution to two problems at the same time: static metaprogramming and type generics. In C++ on the other hand, templates mostly serve as a way to achieve type generics while static metaprogramming is mostly done using the C preprocessor language. I say "mostly", because there is such a thing as "template metaprogramming" in C++, which Alexander Stepanov prefers to call "ugly hacks".

The D approach to template metaprogramming looks arguably more elegant than the C++ approach, so in that sense MHD was right. However, one could argue that you shouldn't use the same syntactic element of a language for two different purposes. It would be most elegant and most powerful to have static introspective type functions, as a superior alternative to template metaprogramming. Since neither C++ nor D comes close to this ideal solution, both are in a sense ugly. Besides, D doesn't seem any more powerful than C++ in its capabilities to replace type functions.

I'm not sure whether it was MHD's intention to also claim that D has stronger generics than C++. Either way, I haven't seen a reason yet to think such a claim would be valid. At this point it's rather unclear to me what are the differences between C++' and D's generic capabilities, and I'm wondering whether I could for example write a class template in D -- or what would be the equivalent of such a thing. It seems that templates in D can be used to generate a function, a constant or something else, depending on other factors.

Overall, types and operations seem to be better separated (more orthogonal) in C++ and Haskell than in D, but I might be wrong.
Hey, like coding? Perhaps you should check out the red spider project.
Feel free to call me Julian. J+ is just an abbreviation.
User avatar
Jplus
 
Posts: 1091
Joined: Wed Apr 21, 2010 12:29 pm UTC

Re: Odd design decisions?

Postby Yakk » Tue Dec 20, 2011 3:01 pm UTC

Static metaprogramming is mostly done in macros in C++ in your world?

I don't want to live there. :)
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
User avatar
Yakk
 
Posts: 10039
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Odd design decisions?

Postby Jplus » Tue Dec 20, 2011 3:22 pm UTC

In the C++ world, static metaprogramming is divided into two categories: template metaprogramming and preprocessor metaprogramming. However, most of the applications of templates in C++ are not considered metaprogramming, because they define runtime behaviour. As such, generic programming (and functional programming) is distinguished from template metaprogramming. Have a look at http://www.boost.org/doc/libs/?view=categorized to see what I mean: most of the libraries use templates, but only a small portion is considered metaprogramming.
Hey, like coding? Perhaps you should check out the red spider project.
Feel free to call me Julian. J+ is just an abbreviation.
User avatar
Jplus
 
Posts: 1091
Joined: Wed Apr 21, 2010 12:29 pm UTC

Re: Odd design decisions?

Postby Yakk » Tue Dec 20, 2011 3:28 pm UTC

I think you think your post was in reply to mine. But it reads as if you are responding to someone who said something very different than what I said. So I'm confused.

I, personally, find metaprogramming using templates to be much less insane than metaprogramming using macros.

As an overly anal aside, with "as if" clauses, other than diagnostics -- the C++ standard mostly defines run time behavior. So by "static metaprogramming" you mean "compile time diagnostics only"? I guess that does fit the definition. :) And I find compile-time diagnostic generation via templates far nicer than via macros...
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
User avatar
Yakk
 
Posts: 10039
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Odd design decisions?

Postby sourmìlk » Wed Dec 21, 2011 5:43 am UTC

RoadieRich wrote:Except that's the way it should be done in C++ anyway. Declare your class in a .h that anyone can see, define it in a .cpp that you can complie and distribute as a binary. That way, you don't end up with duplicate definitions when you try to reuse old code.


I know it _should_ be that way. I just don't like that it's mandatory.

Yakk wrote:It is their message passing to objects syntax. Objective C message passing isn't calling a C function, and they didn't override that syntax. It is based off an older, more object oriented language than C++, from a smaller and more civilized age.
And why did they abandon constructors?

That doesn't really answer my question: why use brackets rather than the more convention object.method() thing? And why do we have to name the parameters when calling a function?

Abandon? I don't see any constructors in the C language. What constructors did they have to abandon?

Every C-like OO language I'm familiar with has constructors. It seems like taking a large step backwards to omit them.
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.
User avatar
sourmìlk
If I can't complain, can I at least express my fear?
 
Posts: 6405
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong

Re: Odd design decisions?

Postby Yakk » Wed Dec 21, 2011 2:29 pm UTC

Because smalltalk is older than object.method(), and objective-C's OO is based off smalltalk?

Objective-C is a smalltalk inspired object oriented extension to C. It isn't a C++ derived language (be it Java or whatever else), which is what you seem to be familiar with. (C++ style OO is based off of yet another language, but what made it famous was C++. Maybe there is a popular language that is based off of Simula instead of C++ but has C++ style syntax? I don't know of it, and it might be hard to determine...)

Objective-C is older than C++. Wondering why it removed features that C++ has is like wondering why dick van dyke didn't make a snookie joke.
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
User avatar
Yakk
 
Posts: 10039
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Odd design decisions?

Postby Jplus » Wed Dec 21, 2011 7:43 pm UTC

Yakk wrote:I think you think your post was in reply to mine. But it reads as if you are responding to someone who said something very different than what I said. So I'm confused.

I, personally, find metaprogramming using templates to be much less insane than metaprogramming using macros.

As an overly anal aside, with "as if" clauses, other than diagnostics -- the C++ standard mostly defines run time behavior. So by "static metaprogramming" you mean "compile time diagnostics only"? I guess that does fit the definition. :) And I find compile-time diagnostic generation via templates far nicer than via macros...

Now I'm confused too. Are you suggesting that template metaprogramming can be used for (exactly) the same kind of thing as preprocessor metaprogramming? Because I think they serve different purposes. By removing one of them, you'll lose expressive power.

Yakk wrote:Maybe there is a popular language that is based off of Simula instead of C++ but has C++ style syntax?

C++.
Hey, like coding? Perhaps you should check out the red spider project.
Feel free to call me Julian. J+ is just an abbreviation.
User avatar
Jplus
 
Posts: 1091
Joined: Wed Apr 21, 2010 12:29 pm UTC

Re: Odd design decisions?

Postby korona » Wed Dec 21, 2011 8:15 pm UTC

Jplus wrote:Now I'm confused too. Are you suggesting that template metaprogramming can be used for (exactly) the same kind of thing as preprocessor metaprogramming? Because I think they serve different purposes. By removing one of them, you'll lose expressive power.

Could you give an example where preprocessor metaprogramming archives something that cannot be expressed more elegant with template metaprogramming?
There are only a few cases where using the preprocessor actually makes sense i.e. including platform specific code or __LINE__, __FILE__, ... magic.
korona
 
Posts: 116
Joined: Sun Jul 04, 2010 8:40 pm UTC

Re: Odd design decisions?

Postby Yakk » Wed Dec 21, 2011 8:19 pm UTC

Jplus wrote:
Yakk wrote:I think you think your post was in reply to mine. But it reads as if you are responding to someone who said something very different than what I said. So I'm confused.

I, personally, find metaprogramming using templates to be much less insane than metaprogramming using macros.

As an overly anal aside, with "as if" clauses, other than diagnostics -- the C++ standard mostly defines run time behavior. So by "static metaprogramming" you mean "compile time diagnostics only"? I guess that does fit the definition. :) And I find compile-time diagnostic generation via templates far nicer than via macros...
Now I'm confused too. Are you suggesting that template metaprogramming can be used for (exactly) the same kind of thing as preprocessor metaprogramming? Because I think they serve different purposes. By removing one of them, you'll lose expressive power.

I was talking about stuff like BOOST PREPROCESSOR -- serious metaprogramming in the preprocessor.

Are you talking about #pragma once and #ifndef THIS_HEADER_FILE_IS_INCLUDED as preprocessor metaprogramming?
Yakk wrote:Maybe there is a popular language that is based off of Simula instead of C++ but has C++ style syntax?

C++.

:p~
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.
User avatar
Yakk
 
Posts: 10039
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Odd design decisions?

Postby Jplus » Wed Dec 21, 2011 9:38 pm UTC

while (true) {
korona wrote:Could you give an example where preprocessor metaprogramming archives something that cannot be expressed more elegant with template metaprogramming?
There are only a few cases where using the preprocessor actually makes sense i.e. including platform specific code or __LINE__, __FILE__, ... magic.

Yakk wrote:I was talking about stuff like BOOST PREPROCESSOR -- serious metaprogramming in the preprocessor.

Are you talking about #pragma once and #ifndef THIS_HEADER_FILE_IS_INCLUDED as preprocessor metaprogramming?

}

;)

For serious: I was talking about Boost.Preprocessor too. Since that library serves a different purpose than the various Boost template metaprogramming libraries, I don't see why we're still having a discussion about this.
Hey, like coding? Perhaps you should check out the red spider project.
Feel free to call me Julian. J+ is just an abbreviation.
User avatar
Jplus
 
Posts: 1091
Joined: Wed Apr 21, 2010 12:29 pm UTC

Re: Odd design decisions?

Postby EvanED » Wed Dec 21, 2011 9:43 pm UTC

korona wrote:
Jplus wrote:Now I'm confused too. Are you suggesting that template metaprogramming can be used for (exactly) the same kind of thing as preprocessor metaprogramming? Because I think they serve different purposes. By removing one of them, you'll lose expressive power.

Could you give an example where preprocessor metaprogramming archives something that cannot be expressed more elegant with template metaprogramming?
There are only a few cases where using the preprocessor actually makes sense i.e. including platform specific code or __LINE__, __FILE__, ... magic.

Variadic templates before C++11. Providing a "nicer" (for some definition) facade on the use of a template.
EvanED
 
Posts: 3767
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI

Previous

Return to Coding

Who is online

Users browsing this forum: No registered users and 10 guests