 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 14.08.2012 14:25, schrieb Invisible:
>>> According to the Great Language Shootout, C# Mono is 3x slower than C.
>>> (Then again, Haskell is 2x slower...)
>>
>> A factor of 3x compared to what is probably the fastest
>> more-or-less-high level language doesn't sound that bad to me, given how
>> much easier it is to program anything serious in it. (You don't want to
>> write a GUI program in C, do you?! You'd at least want C++)
>
> My point is, adding a low-level feature to shave off 0.02% runtime
> overheard in a language which already has 200% overhead seems... odd.
I wouldn't be surprised if your estimate of 0.02% is a good deal off the
mark.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
> The C# design /is/ pretty solid for a modern language. Much more solid
> at least than the current Java language.
"More elegant than Java" is a bit like saying "cooler than the surface
of the Sun". :-P
> Oh, and don't bother to mention Haskell in this context; you've done a
> fair share of ranting about that language already to disqualify it for
> the position of "an elegant design that solves everything [without
> accumulating non-elegant layers of additional features]".
So what do you think Haskell solves inelegantly?
It's no secret that the libraries lack vast swathes of important
functionality, or that some of the build tools leave a lot to be
desired. But the core language itself? It isn't perfect, but it's a
damn-site more elegant than any other programming language I've ever
laid eyes on.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> >> Valid point. But in a commercial setting, pretty irrelevant.
> >
> > It will become relevant when Microsoft inevitably stops supporting XP.
> >
> > It might not happen next month, or even next year, but the clock is
> > ticking.
> What do you mean "when"? This has already happened.
> http://en.wikipedia.org/wiki/Windows_XP
> "Mainstream support ended 14 April 2009."
It still gets security patches, doesn't it?
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 14.08.2012 14:57, schrieb Invisible:
>> Oh, and don't bother to mention Haskell in this context; you've done a
>> fair share of ranting about that language already to disqualify it for
>> the position of "an elegant design that solves everything [without
>> accumulating non-elegant layers of additional features]".
>
> So what do you think Haskell solves inelegantly?
>
> It's no secret that the libraries lack vast swathes of important
> functionality, or that some of the build tools leave a lot to be
> desired. But the core language itself? It isn't perfect, but it's a
> damn-site more elegant than any other programming language I've ever
> laid eyes on.
That may well be true, and I actually believe it, but as soon as you
want to do some serious programming you'll /need/ more than that elegant
core; you'll need those libraries of which /you/ yourself said that
various of them suck for this and that reason and none of them gives you
exactly what you need.
An elegant core language may be nice to have, but if as a consequence it
takes you ages to get the job done, unless you make use of plenty
non-elegant language extensions or libraries, it doesn't /really/
qualify as "a simpler, more elegant design that solves everything".
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> So what do you think Haskell solves inelegantly?
>>
>> It's no secret that the libraries lack vast swathes of important
>> functionality, or that some of the build tools leave a lot to be
>> desired. But the core language itself? It isn't perfect, but it's a
>> damn-site more elegant than any other programming language I've ever
>> laid eyes on.
>
> That may well be true, and I actually believe it, but as soon as you
> want to do some serious programming you'll /need/ more than that elegant
> core; you'll need those libraries of which /you/ yourself said that
> various of them suck for this and that reason and none of them gives you
> exactly what you need.
>
> An elegant core language may be nice to have, but if as a consequence it
> takes you ages to get the job done, unless you make use of plenty
> non-elegant language extensions or libraries, it doesn't /really/
> qualify as "a simpler, more elegant design that solves everything".
Right. So you're saying the fact that nobody has sat down and written a
comprehensive set of libraries makes the language "non-elegant" and
"poorly designed"?
Seriously, what?
Haskell does not have the rich set of libraries that C# has because it
wasn't developed by a multi-billion dollar global mega corporation. It
was developed by three beardy guys in a shed on day. If it ever becomes
popular, we'll see more libraries being developed for it. If (as seems
more likely) it never becomes really popular, then we won't. But either
way, this has nothing to do with whether the language is well-designed
or not.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>>> Valid point. But in a commercial setting, pretty irrelevant.
>>>
>>> It will become relevant when Microsoft inevitably stops supporting XP.
>
>> What do you mean "when"? This has already happened.
>
>> "Mainstream support ended 14 April 2009."
>
> It still gets security patches, doesn't it?
Er... I'm not sure, actually. Perhaps so.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 2012-08-14 04:31, Invisible a écrit :
> On 14/08/2012 02:01 AM, Darren New wrote:
>
>> It probably lets you return an opaque reference to
>> something you can't see the type of, but I doubt it lets you return a
>> type that you can't see.
>
> module Foobar (Foo (..), foobar) where
>
> data Foo = Foo Int deriving Show
> data Bar = Bar Int deriving Show
>
> foobar :: Foo -> Bar
> foobar (Foo x) = Bar x
>
> Notice how Bar is not exported, yet foobar is exported, and its return
> type is Bar.
Correct me if I'm wrong, but apart from showing that the standard
seemingly allows it, how would you use that in a real world scenario?
By exporting foobar, you intend to use it somewhere else in your code,
right? Which means there's another piece of code somewhere that expects
to receive something of type bar, without knowing what type bar actually is!
How does that work?
--
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/* flabreque */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/* @ */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/* gmail.com */}camera{orthographic location<6,1.25,-6>look_at a }
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 14/08/2012 13:11, Warp a écrit :
>> IIRC, C++ does not duplicates the class function members (not even
>> > pointers to them) in each instance. Only the actual class (as 1 pointer)
>> > is stored within each instance. The virtual function is just an index.
>> > The first virtual/inheritance cost a pointer in the class. The next are
>> > free.(in fact, with RTTI, even without inheritance, you might already
>> > have that pointer: so no additional cost)
> But if your class were eg. the size of one pointer, then adding any virtual
> functions would double its size.
Tetracapilli... if you compile with RTTI (default for most, including
gnu), an instance of an empty class is already the size of a pointer: to
the class description.
Adding any virtual function in such case would not increase the size of
the instance.
Also, remember that even if the root class is size of a pointer, its
children can only get the same size or larger. If every layer adds a
pointer, the second layer is already the size of two: one proper, one
from parent field (and a third for RTTI)
Removing RTTI <==> no dynamic_cast<>,... might break some code, yet it's
possible (for tight embedded system, including the Embedded C++ spec,
which are just PITA and was made for very low memory system).
In Embedded C++, there is no multiple inheritance, no C++ cast (neither
down or up), no mutable attribut, no namespace, no exception, no
templates and no stdio.
Usage of EC++ is low, but that's might already be too much. It's kind of
C on very fascist mode.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> module Foobar (Foo (..), foobar) where
>>
>> data Foo = Foo Int deriving Show
>> data Bar = Bar Int deriving Show
>>
>> foobar :: Foo -> Bar
>> foobar (Foo x) = Bar x
>
> Correct me if I'm wrong, but apart from showing that the standard
> seemingly allows it, how would you use that in a real world scenario?
>
> By exporting foobar, you intend to use it somewhere else in your code,
> right? Which means there's another piece of code somewhere that expects
> to receive something of type bar, without knowing what type bar actually
> is!
>
> How does that work?
Well, you're right in that you cannot write any code which explicitly
expects Bar. You can pass the result to any function that works with
/all/ types, or any function that works with any showable type. If the
module exported some functions that expect Bar as input, you can pass
the result to them. But you can't write that in a type signature,
which... yeah, is a bit silly.
My point wasn't so much that this is a something anybody is likely to
want to do. My point was a counter-example to the "that's obviously
impossible" argument. It's /not/ impossible at all.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
As with any language, my WTF list:
- Unsigned integers have names prefixed with "u", and signed integers
have no prefix. Except byte, which is the other way around: "byte" and
"sbyte". WTF?
- The "char" type works with Unicode. Well done. Oh, but wait... It only
stores 16 bits, and yet Unicode actually requires 24 bits to represent a
single code-point. So this "Unicode character" only actually covers the
Basic Multilingual Plane. FAIL!
- "As of C# 2.0, it is also possible to have an array in a structure."
(Erm, why the HELL would it not be possible to do that before??)
- "x & y" performs a Boolean-OR if the arguments are Bools, and a
bitwise-OR if they are integers. The same goes for all the other logical
operators. Except NOT, which has "!x" for Bools and "~x" for integers. WTF?
- "x + y" performs addition. Unless either argument is a string, in
which case the other is converted to a string as well (if not a string
already) and the strings are concatenated. Unless both arguments are
delegates, in which case they are concatenated. (I guess there's a
/reason/ the Java guys claim that operator overloading is evil!)
- Goto? Seriously? Well, I suppose /technically/ that's not actually a
WTF...
- Anonymous delegates /and/ lambda functions?
- A delegate is a thing which is called when an event is fired, but an
event /is/ a delegate?? (In fairness, this is probably a Wikibooks WTF
rather than anything to do with the design of C#.)
- Extension methods. Just... what??
- A non-generic queue is called Queue, and a generic queue is called
Queue<T>. And yet, for the other container types, the generic and
non-generic versions have completely different, unrelated names. (I
guess that's backwards compatibility for you... oh, wait.)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 2012-08-14 04:27, Invisible a écrit :
> Actually, I've never seen Windows 2000 used anywhere, ever. Not in
> people's homes, not in places of work. Indeed, if it weren't for that
> course my employer sent me on, I wouldn't even know it /exists/... It
> never seemed to be really popular.
>
My employer used it on all its desktops and laptops when they upgraded
from Windows 95. So from 2000 to 2005, or thereabouts, you had close to
400,000 users worldwide, in just one company.
My bank also _still_ uses it for the teller PCs. (I suppose bank
tellers are a dying breed, so they figured it was not worth it to
develop a new standard image to be deployed across the country...
--
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/* flabreque */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/* @ */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/* gmail.com */}camera{orthographic location<6,1.25,-6>look_at a }
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le 2012-08-14 07:56, Invisible a écrit :
>>> Valid point. But in a commercial setting, pretty irrelevant.
>>
>> It will become relevant when Microsoft inevitably stops supporting XP.
>>
>> It might not happen next month, or even next year, but the clock is
>> ticking.
>
> What do you mean "when"? This has already happened.
>
> http://en.wikipedia.org/wiki/Windows_XP
>
> "Mainstream support ended 14 April 2009."
Corporate is NOT mainstream. You can bet your ass off that if Bank Of
America, HSBC, LuftHansa, or the Deptartment of Defense finds a weird
problem in XP, they still have ways fo making MS cough up a patch for them.
IBM still unofficially supports OS/2 for the same reason.
--
/*Francois Labreque*/#local a=x+y;#local b=x+a;#local c=a+b;#macro P(F//
/* flabreque */L)polygon{5,F,F+z,L+z,L,F pigment{rgb 9}}#end union
/* @ */{P(0,a)P(a,b)P(b,c)P(2*a,2*b)P(2*b,b+c)P(b+c,<2,3>)
/* gmail.com */}camera{orthographic location<6,1.25,-6>look_at a }
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Le_Forgeron <lef### [at] free fr> wrote:
> Tetracapilli... if you compile with RTTI (default for most, including
> gnu), an instance of an empty class is already the size of a pointer: to
> the class description.
I don't know how to explain this more clearly than I have already done.
If a class has no virtual functions, it will have no vtable pointer.
RTTI has nothing to do with this.
If you have, for example, one int as its member, the size of the class
will be typically 4 bytes.
Now add a virtual function to the class: Suddenly its size is 8 bytes
(16 if compiling a 64-bit binary). The size of the class has doubled
(quadrupled in 64-bit systems).
This is the reason why vtables are added only to classes that have virtual
functions.
> In Embedded C++, there is no multiple inheritance, no C++ cast (neither
> down or up), no mutable attribut, no namespace, no exception, no
> templates and no stdio.
That sounds like a pretty useless C++.
(Why no namespaces or templates? What do those have anything to do with
embedded systems?)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Invisible <voi### [at] dev null> wrote:
> - Unsigned integers have names prefixed with "u", and signed integers
> have no prefix. Except byte, which is the other way around: "byte" and
> "sbyte". WTF?
Why would you expect bytes to be signed by default?
> - The "char" type works with Unicode. Well done. Oh, but wait... It only
> stores 16 bits, and yet Unicode actually requires 24 bits to represent a
> single code-point. So this "Unicode character" only actually covers the
> Basic Multilingual Plane. FAIL!
I'm assuming it uses UTF-16.
> - "x + y" performs addition. Unless either argument is a string, in
> which case the other is converted to a string as well (if not a string
> already) and the strings are concatenated. Unless both arguments are
> delegates, in which case they are concatenated. (I guess there's a
> /reason/ the Java guys claim that operator overloading is evil!)
Using operator+ for string concatenation is pretty common. I have never
had any kind of confusion with it. (You would have to come up with a
really artificial example to deliberately make it confusing.)
Automatically converting the right hand side to a string sounds more
dubious to me. Sounds like it may easily be done inadvertently, causing
all kinds of bugs.
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 14/08/2012 06:38 PM, Warp wrote:
> Invisible<voi### [at] dev null> wrote:
>> - Unsigned integers have names prefixed with "u", and signed integers
>> have no prefix. Except byte, which is the other way around: "byte" and
>> "sbyte". WTF?
>
> Why would you expect bytes to be signed by default?
I don't know about "default", but a consistent naming scheme would be
nice...
>> - The "char" type works with Unicode. Well done. Oh, but wait... It only
>> stores 16 bits, and yet Unicode actually requires 24 bits to represent a
>> single code-point. So this "Unicode character" only actually covers the
>> Basic Multilingual Plane. FAIL!
>
> I'm assuming it uses UTF-16.
Perhaps actual /strings/ allow storing all possible Unicode code-points.
However, char, the type of a single character, apparently covers the BMP
only. If you're going to go to all the trouble of actually supporting
Unicode, why not support the whole thing?
> Using operator+ for string concatenation is pretty common. I have never
> had any kind of confusion with it. (You would have to come up with a
> really artificial example to deliberately make it confusing.)
>
> Automatically converting the right hand side to a string sounds more
> dubious to me. Sounds like it may easily be done inadvertently, causing
> all kinds of bugs.
Yeah, sounds like more the sort of thing you'd expect in a scripting
language.
OTOH, it appears that it's the only autoconversion that can happen.
Pop quiz: if x is a string and y is a delegate, does it do delegate
concatenation or string concatenation?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 14.08.2012 15:12, schrieb Invisible:
>>> So what do you think Haskell solves inelegantly?
>>>
>>> It's no secret that the libraries lack vast swathes of important
>>> functionality, or that some of the build tools leave a lot to be
>>> desired. But the core language itself? It isn't perfect, but it's a
>>> damn-site more elegant than any other programming language I've ever
>>> laid eyes on.
>>
>> That may well be true, and I actually believe it, but as soon as you
>> want to do some serious programming you'll /need/ more than that elegant
>> core; you'll need those libraries of which /you/ yourself said that
>> various of them suck for this and that reason and none of them gives you
>> exactly what you need.
>>
>> An elegant core language may be nice to have, but if as a consequence it
>> takes you ages to get the job done, unless you make use of plenty
>> non-elegant language extensions or libraries, it doesn't /really/
>> qualify as "a simpler, more elegant design that solves everything".
>
> Right. So you're saying the fact that nobody has sat down and written a
> comprehensive set of libraries makes the language "non-elegant" and
> "poorly designed"?
I did not say THAT.
What I did say is that if nobody has sat down and written a
comprehensive set of libraries, this prevents the lange from being a
language that "solves everything" - and, consequentially, from
qualifying as "a simpler, more elegant design that solves everything".
What I also did imply is that if anybody would indeed sit down and write
a comprehensive cover-all set of libraries, there would likely be quite
a number of them that would be non-elegant to use; and if those
libraries would form a part the language's way of "solving everything",
then THEY would disqualify the combo (core language + libraries) from
qualifying as that "simpler, more elegant design that solves everything".
> Haskell does not have the rich set of libraries that C# has because it
> wasn't developed by a multi-billion dollar global mega corporation. It
> was developed by three beardy guys in a shed on day. If it ever becomes
> popular, we'll see more libraries being developed for it. If (as seems
> more likely) it never becomes really popular, then we won't. But either
> way, this has nothing to do with whether the language is well-designed
> or not.
Right. But it has something to do with whether the language "solves
everything" [for practical purposes].
Can you easily model a state machine in Haskell? If not, then it doesn't
solve everything.
Can you easily write a GUI in Haskell? If not, then it doesn't solve
everything.
Can you easily write an OS kernel in Haskell? If not, then it doesn't
solve everything.
Just three things that immediately spring to my mind; I'm sure there's
gazillions of others out there.
As soon as you have libraries (or other language extensions) for all
conceivable purposes, we'll talk again - about elegancy then.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 14.08.2012 23:06, schrieb Orchid Win7 v1:
> Perhaps actual /strings/ allow storing all possible Unicode code-points.
> However, char, the type of a single character, apparently covers the BMP
> only. If you're going to go to all the trouble of actually supporting
> Unicode, why not support the whole thing?
Do you have any idea what "the whole thing" means in case of Unicode?
Hint: There's more to Unicode than just ~1 million code points with
glyphs mapped to some of them.
> Pop quiz: if x is a string and y is a delegate, does it do delegate
> concatenation or string concatenation?
Provided it doesn't raise an error, obviously you'll get string
concatenation, because you can't convert strings to delegates.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> Perhaps actual /strings/ allow storing all possible Unicode code-points.
>> However, char, the type of a single character, apparently covers the BMP
>> only. If you're going to go to all the trouble of actually supporting
>> Unicode, why not support the whole thing?
>
> Do you have any idea what "the whole thing" means in case of Unicode?
>
> Hint: There's more to Unicode than just ~1 million code points with
> glyphs mapped to some of them.
Sure. But if you can't even /write down/ those code-points, that's kinda
limiting.
(It also strikes me that if the String type /can/ hold them all and Char
/can't/, that has interesting implications for trying to iterate over a
String one Char at a time...)
>> Pop quiz: if x is a string and y is a delegate, does it do delegate
>> concatenation or string concatenation?
>
> Provided it doesn't raise an error, obviously you'll get string
> concatenation,
Yes.
> because you can't convert strings to delegates.
No.
From what I can tell, it never tries to convert a string to anything
else, but it /does/ try to convert anything else to a string.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> Right. So you're saying the fact that nobody has sat down and written a
>> comprehensive set of libraries makes the language "non-elegant" and
>> "poorly designed"?
>
> I did not say THAT.
>
> What I did say is that if nobody has sat down and written a
> comprehensive set of libraries, this prevents the lange from being a
> language that "solves everything" - and, consequentially, from
> qualifying as "a simpler, more elegant design that solves everything".
Haskell is an elegant, beautiful language. In the vast majority of
cases, it lets you write your application logic in a very concise,
reliable and maintainable way.
For a language to be /useful/, you need more than just the language. You
need libraries. You need a build system. You need packaging and
distribution. You need profiling and debugging tools. You need
documentation systems. And probably a number of other things too.
For the most part, Haskell lacks these. This does not change the fact
that the Haskell /language/ is elegant and beautiful.
I don't doubt that C# almost certainly has /far/ more plentiful
libraries. (As does Java, C++, C, Python, Ruby, or really /any/
programming language that mainstream programmers use.) That doesn't mean
that the design of the C# /language/ is clean or beautiful.
> What I also did imply is that if anybody would indeed sit down and write
> a comprehensive cover-all set of libraries, there would likely be quite
> a number of them that would be non-elegant to use
And why would that be the case?
> Right. But it has something to do with whether the language "solves
> everything" [for practical purposes].
I was referring only to the design of the language itself, not the
libraries that go with it, nor any of the various other tools required
to make a language generally useful. It's no secret that Haskell fails
spectacularly on that count.
> Can you easily model a state machine in Haskell? If not, then it doesn't
> solve everything.
This is trivial.
> Can you easily write a GUI in Haskell? If not, then it doesn't solve
> everything.
This could be made trivial, but currently it isn't supported
particularly well.
(E.g., writing a GTK application is fairly simple. Getting the GTK
libraries to work in the first place is not simple.)
> Can you easily write an OS kernel in Haskell? If not, then it doesn't
> solve everything.
This has been done at least once before.
Note also that there is now a project that lets you run the Haskell
runtime on bare metal (or rather, on the Xen virtualisation platform)
without an OS. Apparently this was developed as part of a commercial
system, so somebody is using it for real.
> As soon as you have libraries (or other language extensions) for all
> conceivable purposes, we'll talk again - about elegancy then.
Right, because how elegant a language is depends on how many libraries
it has. Oh, wait - no it doesn't.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 14/08/2012 03:42 PM, Invisible wrote:
> - The "char" type works with Unicode. Well done. Oh, but wait... It only
> stores 16 bits, and yet Unicode actually requires 24 bits to represent a
> single code-point. So this "Unicode character" only actually covers the
> Basic Multilingual Plane. FAIL!
Oh great. Apparently "char" doesn't store a code-point at all, it stores
a code-unit.
For anything in the BMP, these are effectively the same thing. For
anything outside that range, *you* must manually write the code to
decode UTF-16 into actual code-points (which then do not fit into a "char").
Well done. :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 13/08/2012 01:08 PM, Invisible wrote:
> I think perhaps my biggest criticism of C# is that there doesn't seem to
> be an introduction anywhere. I can read about isolated features of the
> language on MSDN, but nowhere can I seem to find a coherent introduction...
I downloaded the C# "language specification". Rather than being an
actual specification (which would usually be a dense, incomprehensible
document supplying a rigorous mathematical definition of the language
for use by compiler implementers), it seems that /this/ is the
comprehensible introduction that actually explains stuff. Weird...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 15.08.2012 10:11, schrieb Invisible:
>> Right. But it has something to do with whether the language "solves
>> everything" [for practical purposes].
>
> I was referring only to the design of the language itself, not the
> libraries that go with it, nor any of the various other tools required
> to make a language generally useful. It's no secret that Haskell fails
> spectacularly on that count.
I'm reiterating: I don't doubt that the Haskell /core language/ is
simple and elegant. I doubt that it "solves everything".
As soon as you've dealt with the "solves everything" part, we'll talk
again, and see if the "simple and elegant" also applies to that one. My
claim is that the combo isn't possible.
THAT is the point I'm trying to get through to you.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> I was referring only to the design of the language itself, not the
>> libraries that go with it, nor any of the various other tools required
>> to make a language generally useful. It's no secret that Haskell fails
>> spectacularly on that count.
>
> I'm reiterating: I don't doubt that the Haskell /core language/ is
> simple and elegant. I doubt that it "solves everything".
It solves every problem of core application logic. It doesn't solve the
problem of talking to the outside world. (That's the job of the
libraries, and once they currently don't do so well.)
> As soon as you've dealt with the "solves everything" part, we'll talk
> again, and see if the "simple and elegant" also applies to that one. My
> claim is that the combo isn't possible.
>
> THAT is the point I'm trying to get through to you.
You somehow believe that writing a bunch of libraries would make the
language no longer elegant?
Well, I guess since it's unlikely to ever happen, we'll never know...
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 14/08/2012 03:42 PM, Invisible wrote:
> As with any language, my WTF list:
On the other hand, it seems they certainly did a fair few things right.
It's messy in there, but it does have moments of hope.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 14/08/2012 03:42 PM, Invisible wrote:
> As with any language, my WTF list:
Enums. Urgh. An enumeration is supposed to be a type that can only take
on the specified set of values. Except that in C#, an enumeration can
take on /any/ integer value. It's just that some of these values also
have friendly names. *sigh*
What, no bitfield type? :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 15.08.2012 09:56, schrieb Invisible:
>> Hint: There's more to Unicode than just ~1 million code points with
>> glyphs mapped to some of them.
>
> Sure. But if you can't even /write down/ those code-points, that's kinda
> limiting.
>
> (It also strikes me that if the String type /can/ hold them all and Char
> /can't/, that has interesting implications for trying to iterate over a
> String one Char at a time...)
As soon as you think of combining diacritics, you'll see that this type
of limitation is actually inevitable, even with a way to hold any
code-point value in a char: You can, for instance, hold the canonical
representation of Lowercase A + Acute Accent in a char (because it has a
dedicated code point, U+00E1), but you can't do the same with the
canonical representation of Lowercase A + Double Acute Accent (because
that's the sequence U+0061 U+030B) - or with the non-canonical
representation of A + Acute Accent, for that matter (U+0061 U+0301).
>>> Pop quiz: if x is a string and y is a delegate, does it do delegate
>>> concatenation or string concatenation?
>>
>> Provided it doesn't raise an error, obviously you'll get string
>> concatenation,
>
> Yes.
>
>> because you can't convert strings to delegates.
>
> No.
>
> From what I can tell, it never tries to convert a string to anything
> else, but it /does/ try to convert anything else to a string.
Yes, exactly.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 15.08.2012 11:46, schrieb Invisible:
> On 14/08/2012 03:42 PM, Invisible wrote:
>
>> - The "char" type works with Unicode. Well done. Oh, but wait... It only
>> stores 16 bits, and yet Unicode actually requires 24 bits to represent a
>> single code-point. So this "Unicode character" only actually covers the
>> Basic Multilingual Plane. FAIL!
>
> Oh great. Apparently "char" doesn't store a code-point at all, it stores
> a code-unit.
>
> For anything in the BMP, these are effectively the same thing. For
> anything outside that range, *you* must manually write the code to
> decode UTF-16 into actual code-points (which then do not fit into a
> "char").
Uh... why does this come as a surprise to you?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> Hint: There's more to Unicode than just ~1 million code points with
>>> glyphs mapped to some of them.
>>
>> Sure. But if you can't even /write down/ those code-points, that's kinda
>> limiting.
>>
>> (It also strikes me that if the String type /can/ hold them all and Char
>> /can't/, that has interesting implications for trying to iterate over a
>> String one Char at a time...)
>
> As soon as you think of combining diacritics, you'll see that this type
> of limitation is actually inevitable
I guess combining characters are The Real WTF...
(No, wait - that's the BOM.)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 15.08.2012 12:36, schrieb Invisible:
>>> I was referring only to the design of the language itself, not the
>>> libraries that go with it, nor any of the various other tools required
>>> to make a language generally useful. It's no secret that Haskell fails
>>> spectacularly on that count.
>>
>> I'm reiterating: I don't doubt that the Haskell /core language/ is
>> simple and elegant. I doubt that it "solves everything".
>
> It solves every problem of core application logic. It doesn't solve the
> problem of talking to the outside world. (That's the job of the
> libraries, and once they currently don't do so well.)
Neither does it solve every problem of core application logic in a
/practical/ manner. At least that's the impression I get from your
occasional rants. So for those things you'll need libraries, too.
>> As soon as you've dealt with the "solves everything" part, we'll talk
>> again, and see if the "simple and elegant" also applies to that one. My
>> claim is that the combo isn't possible.
>>
>> THAT is the point I'm trying to get through to you.
>
> You somehow believe that writing a bunch of libraries would make the
> language no longer elegant?
I believe that writing a sufficient bunch of libraries to care for all
needs would make the /combo/ non-elegant in various places.
That said, if the core language was /that/ simple, elegant and
cover-all, how come nobody has managed to put an easy-to-use cover-all
library for X yet? (X := any feature already implemented in multiple
libraries but with different severe limitations to each of them. Dunno
which example it was you did your rant over - mutable lists or some such?)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> - The "char" type works with Unicode. Well done. Oh, but wait... It only
>>> stores 16 bits, and yet Unicode actually requires 24 bits to represent a
>>> single code-point. So this "Unicode character" only actually covers the
>>> Basic Multilingual Plane. FAIL!
>>
>> Oh great. Apparently "char" doesn't store a code-point at all, it stores
>> a code-unit.
>>
>> For anything in the BMP, these are effectively the same thing. For
>> anything outside that range, *you* must manually write the code to
>> decode UTF-16 into actual code-points (which then do not fit into a
>> "char").
>
> Uh... why does this come as a surprise to you?
I guess I'm used to using a programming language where a Char is...
well... any valid Unicode code-point, and once you set the encoding of a
file handle, the library does all necessary encoding and decoding,
whether it's UTF-8, UTF-16, Latin-1 or whatever.
Still, I suppose it's better than char = unsigned byte. :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>>> I'm reiterating: I don't doubt that the Haskell /core language/ is
>>> simple and elegant. I doubt that it "solves everything".
>>
>> It solves every problem of core application logic. It doesn't solve the
>> problem of talking to the outside world. (That's the job of the
>> libraries, and once they currently don't do so well.)
>
> Neither does it solve every problem of core application logic in a
> /practical/ manner. At least that's the impression I get from your
> occasional rants. So for those things you'll need libraries, too.
So what application logic problems aren't solved by Haskell then?
>> You somehow believe that writing a bunch of libraries would make the
>> language no longer elegant?
>
> I believe that writing a sufficient bunch of libraries to care for all
> needs would make the /combo/ non-elegant in various places.
And I believe you're wrong.
The purpose of a library is to make stuff easy, after all...
> That said, if the core language was /that/ simple, elegant and
> cover-all, how come nobody has managed to put an easy-to-use cover-all
> library for X yet? (X := any feature already implemented in multiple
> libraries but with different severe limitations to each of them. Dunno
> which example it was you did your rant over - mutable lists or some such?)
If C is so great for writing operating systems, where are there so many
different, incompatible operating systems? :-P
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 15.08.2012 12:48, schrieb Invisible:
> On 14/08/2012 03:42 PM, Invisible wrote:
>> As with any language, my WTF list:
>
> Enums. Urgh. An enumeration is supposed to be a type that can only take
> on the specified set of values. Except that in C#, an enumeration can
> take on /any/ integer value. It's just that some of these values also
> have friendly names. *sigh*
Erm... did you actually /try/ this??
Trying to assing an int to an enum variable, I get a "Cannot implicitly
convert [...]" error for any integer value other than 0. (Don't ask me
why they did allow it for 0 though.)
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> Enums. Urgh. An enumeration is supposed to be a type that can only take
>> on the specified set of values. Except that in C#, an enumeration can
>> take on /any/ integer value. It's just that some of these values also
>> have friendly names. *sigh*
>
> Erm... did you actually /try/ this??
Quoting Microsoft's C# language specification:
"Each enum type has a corresponding integral type called the
underlying type of the enum type. [...] The set of values that an enum
type can take on is not limited by its enum members. In particular, any
value of the underlying type of an enum can be cast to the enum type and
is a distinct valid value of that enum type."
> Trying to assing an int to an enum variable, I get a "Cannot implicitly
> convert [...]" error for any integer value other than 0. (Don't ask me
> why they did allow it for 0 though.)
Perhaps you can't /implicitly/ convert, but try writing an /explicit/
cast. According to the spec, that's supposed to work.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 15.08.2012 13:06, schrieb Invisible:
>>>> Hint: There's more to Unicode than just ~1 million code points with
>>>> glyphs mapped to some of them.
>>>
>>> Sure. But if you can't even /write down/ those code-points, that's kinda
>>> limiting.
>>>
>>> (It also strikes me that if the String type /can/ hold them all and Char
>>> /can't/, that has interesting implications for trying to iterate over a
>>> String one Char at a time...)
>>
>> As soon as you think of combining diacritics, you'll see that this type
>> of limitation is actually inevitable
>
> I guess combining characters are The Real WTF...
Nope. You just can't do without them for plenty of purposes, because
coding each conceivable combo as a single character would have the
Unicode code space explode (and make comprehensive Unicode fonts even
more scarce). You'd be surprised how many diacritics some languages
stack even on one single character, or how many different diacritics
there are for the IPA phonetic notation.
> (No, wait - that's the BOM.)
Nope, the BOM is quite sane.
First, it is a legal Unicode codepoint, indicating a zero-width
non-breaking space. While this may sound weird to have, it does allow
you to suppress kerning, as well as lots of other stuff that might
happen to pairs of characters (just think of properly implemented arabic
script, where a character's glyph depends not only on the character
itself, but also on its neighbors).
Second, it is suggested to prepend this Unicode character (which by
definition doesn't do any harm) to any text stream that leaves a
program's boundaries.
Why not mandate a canonical byte ordering? Simple: As long as the next
program to pick up the data runs on the same machine (and hence uses the
same byte ordering), re-ordering would just add unnecessary overhead.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 15.08.2012 13:37, schrieb Invisible:
>>> Enums. Urgh. An enumeration is supposed to be a type that can only take
>>> on the specified set of values. Except that in C#, an enumeration can
>>> take on /any/ integer value. It's just that some of these values also
>>> have friendly names. *sigh*
>>
>> Erm... did you actually /try/ this??
>
> Quoting Microsoft's C# language specification:
>
> "Each enum type has a corresponding integral type called the
> underlying type of the enum type. [...] The set of values that an enum
> type can take on is not limited by its enum members. In particular, any
> value of the underlying type of an enum can be cast to the enum type and
> is a distinct valid value of that enum type."
>
>> Trying to assing an int to an enum variable, I get a "Cannot implicitly
>> convert [...]" error for any integer value other than 0. (Don't ask me
>> why they did allow it for 0 though.)
>
> Perhaps you can't /implicitly/ convert, but try writing an /explicit/
> cast. According to the spec, that's supposed to work.
You're right there. I guess it's to provide support for bitfield-style
use of enums.
Note that one of the design goals of C#, AFAIK, was to provide a
comparatively easy migration path from C/C++.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 15.08.2012 13:10, schrieb Invisible:
>>>> I'm reiterating: I don't doubt that the Haskell /core language/ is
>>>> simple and elegant. I doubt that it "solves everything".
>>>
>>> It solves every problem of core application logic. It doesn't solve the
>>> problem of talking to the outside world. (That's the job of the
>>> libraries, and once they currently don't do so well.)
>>
>> Neither does it solve every problem of core application logic in a
>> /practical/ manner. At least that's the impression I get from your
>> occasional rants. So for those things you'll need libraries, too.
>
> So what application logic problems aren't solved by Haskell then?
Operating on mutable lists (or whatever it was you tried back then, and
ran into a set of libraries that all did it in a different way
unsuitable for your needs so you resorted to a rant), for instance?
>>> You somehow believe that writing a bunch of libraries would make the
>>> language no longer elegant?
>>
>> I believe that writing a sufficient bunch of libraries to care for all
>> needs would make the /combo/ non-elegant in various places.
>
> And I believe you're wrong.
>
> The purpose of a library is to make stuff easy, after all...
Still, not every library succeeds in that job to a degree that it can be
called "simple and elegant". And sometimes that's not due to design
flaws in the library, but due to the underlying language standing in the
way.
>> That said, if the core language was /that/ simple, elegant and
>> cover-all, how come nobody has managed to put an easy-to-use cover-all
>> library for X yet? (X := any feature already implemented in multiple
>> libraries but with different severe limitations to each of them. Dunno
>> which example it was you did your rant over - mutable lists or some
>> such?)
>
> If C is so great for writing operating systems, where are there so many
> different, incompatible operating systems? :-P
Because there's no such thing as a simple, elegant cover-it-all, maybe?
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
clipka <ano### [at] anonymous org> wrote:
> Trying to assing an int to an enum variable, I get a "Cannot implicitly
> convert [...]" error for any integer value other than 0. (Don't ask me
> why they did allow it for 0 though.)
If it works like C++ enums, then enumerated constants will implicitly cast
to integrals, though (and integrals can be cast explicitly to enums).
While this is useful oftentimes (there are many, many situations where
an enumerated list of names is much handier than writing integral constants),
there are othertimes where strongly-typed enums would be more desirable.
C++11 added strongly-typed enums to the language (in addition to the existing
weakly-typed ones). If an enumerated type is not intended to be used as
an integral, then you can now say so. (You can also specify its underlying
type if you want.)
--
- Warp
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
>> So what application logic problems aren't solved by Haskell then?
>
> Operating on mutable lists (or whatever it was you tried back then, and
> ran into a set of libraries that all did it in a different way
> unsuitable for your needs so you resorted to a rant), for instance?
Haskell's library support for mutable arrays is a mess. But we're still
talking about bad library design, not bad language design.
>> The purpose of a library is to make stuff easy, after all...
>
> Still, not every library succeeds in that job to a degree that it can be
> called "simple and elegant". And sometimes that's not due to design
> flaws in the library, but due to the underlying language standing in the
> way.
Sure. And my argument is that if a language is designed well, you can
use it to write powerful libraries which are simple and easy to use.
(And if a language is designed poorly, you often can't do that.) Hence
why good language design is so important.
>> If C is so great for writing operating systems, where are there so many
>> different, incompatible operating systems? :-P
>
> Because there's no such thing as a simple, elegant cover-it-all, maybe?
Most of this stuff is due to social, organisational, economic and other
reasons, not language design.
Your core argument appears to be that a useful programming language
necessarily has to be badly designed. I reject that. The fact that all
of the widely used languages are badly designed doesn't mean that bad
design is a necessary attribute.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 1:06, Invisible wrote:
> My point being that everybody acts like "oh, of /course/ you can't possibly
> do that", when in fact you can.
You can't possibly do it in a language where you are actually declaring your
types. You *can* return types that are private or anonymous. You just can't
declare a function that returns a private type.
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 3:17, clipka wrote:
> If you want to give such guarantees, you can't handle variables of types for
> which you have no declaration, because obviously you can't tell whether they
> can do A, B, C and D or not.
To be fair, I suspect Haskell just treats that declaration as if you're
returning Object in C#. In other words, haskell I suspect doesn't let you
return a value whose type you can't see, but instead of making that illegal,
it essentially inserts a cast for you to an opaque supertype. (So to speak,
of course, since Haskell isn't OO.)
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 3:46, Invisible wrote:
> ...and yet, in my Haskell snippet, a type is not exported, yet still you can
> convert it to a string, because that interface is implemented.
Then you've exported the interface, not the type. C# can already do that.
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 5:57, Invisible wrote:
> So what do you think Haskell solves inelegantly?
Does it do hierarchies of types (like windows) nicely, where you don't have
to go back and fix every use of an object when you add another one to the
hierarchy?
Does it interface well to low-level stuff without having to write wrappers?
Does it handle threads running on various address spaces (i.e., distributed
processing) well?
How is it on the code generation part? Can you write programs that emit code
that it then loads back in? Can you write programs that notice your SQL
schema has changed and modifies the running program to account for that?
Can you compile and distribute Haskell code, let other people use it, and
then release new object code that is compatible with the existing code
people already wrote and compiled without breaking things? If John writes
code and releases the object code, then Mary subclasses that, and you're
using Mary's object code in your program, does John releasing new object
code require you to get Mary to help you use John's new code?
How elegantly does it interface to dynamic languages like javascript?
How elegantly does it handle the types in SQL tables? Stuff like nullable
big decimals? Strings in various locales?
How easy is it to parse and compile, such that you could do so on a
keystroke by keystroke basis? When you make a mistake, is it easy for the
compiler to pinpoint where you made the mistake? Is it easy for the IDE to
know when it's safe to recompile the code or whether you're still typing?
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Am 16.08.2012 01:00, schrieb Darren New:
> On 8/14/2012 1:06, Invisible wrote:
>> My point being that everybody acts like "oh, of /course/ you can't
>> possibly
>> do that", when in fact you can.
>
> You can't possibly do it in a language where you are actually declaring
> your types. You *can* return types that are private or anonymous. You
> just can't declare a function that returns a private type.
Or, more precisely, you can't declare a /non-private/ function that
returns a private type.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 1:31, Invisible wrote:
> So what happens if you say "override" on a method that isn't virtual?
I suspect it's a compile-time error.
> Heh. And I thought Haskell was the only language stupid enough to claim that
> the reading the formal language specification is a good way to learn how to
> program with it...
Most languages lack a formal spec. C# gets close. Hermes actually generates
the compiler based on the formal spec, so yeah.
>> Sure. When you load the subclass, it just re-JITs the superclass.
> It actually does that?
It would have to, if it noticed the call isn't actually virtual. Some JITs
do it, some don't.
>> Basically, subclasses or anything compiled at the same time as this class.
> I guess it makes sense once you realise it means OR, not AND.
Yep.
>>>> Yes. Well, what would you expect? A public method that returns a value
>>>> of a type you can't see the declaration of?
>>>
>>> Haskell lets you do exactly that, yes.
>>
>> No it doesn't.
>
> O RLY?
So show me a function that returns a value of a type I can't see.
>
>> It probably lets you return an opaque reference to
>> something you can't see the type of, but I doubt it lets you return a
>> type that you can't see.
>
> module Foobar (Foo (..), foobar) where
>
> data Foo = Foo Int deriving Show
> data Bar = Bar Int deriving Show
>
> foobar :: Foo -> Bar
> foobar (Foo x) = Bar x
>
> Notice how Bar is not exported, yet foobar is exported, and its return type
> is Bar.
So you declare foobar returning an interface that support Show, which is
what you've done.
> Remember, Haskell functions deal with known types ALL THE TIME. Any time you
> call id :: x -> x, it takes a value of unknown type, and returns it
> unchanged. So for Haskell, having some data of a type that you can't "see"
> is no big deal at all. (With the minor detail that you now can't declare
> anything as returning Bar as its result, because that name is not in scope.)
>
Well, I'm not sure how this differs from C#. Declare it returning Object,
and you're done. That's basically what you're doing. You're saying "here's
something, I don't know what it is, so you don't get to use it as that type,
but as some more abstract type.
>>> I guess I'm just spoiled. In Haskell, there are precisely 2 sorts of
>>> type;
>>> everything is either an algebraic data type or a function type. C# has
>>> 5 of
>>> fundamentally different sorts of type, all with different semantics.
>>
>> Well, actually, everything's an object.
>
> Except that no, no it isn't. Apparently only values of reference types are
> considered "objects". :-P
Uhhhh, no. Everything is an object. Really. Some classes are value classes,
and some classes are reference classes, but every value is an object.
>
> You could /almost/ say "everything's a class", except that no, we have enums
> and stuff which aren't considered "classes".
Of course they're classes. If you want, you can even look up what their
superclass is. For example, 23 is of class System.Integer32 or some such.
>>> I especially love how enumerations are a different type but no, not
>>> really, because obviously they're actually just integers...
>>
>> No they aren't. Especially not the way Haskell defined "type". :-)
>
> Right. So enumerations aren't integers, and that's why you define the
> corresponding integer value of each case right there in the definition? :-P
They correspond to integers. They aren't integers. I *do* think Java did
that one much better.
> If you have real enumerations, why do you need a special-case for bool?
Because you have syntax in the language that uses specific types, like "if"
statements. Having bool being a special enumeration is no more odd than
having a function that accepts one specific enumeration type as an argument
and not any generic enumeration.
> (The same argument applies to Haskell: Why the HELL did they special-case
> the list type, when you can trivially define it manually? What there they
> thinking??)
They were thinking you needed special syntax.
Hermes, for example, does not have a string type. But if you have an enum
where each name is one character long, you can make an array of that value
by sticking it inside quotes. Which I thought was kind of cute.
> OK, whatever. I haven't really explored it all that much yet, but it doesn't
> appear to compare well to Eiffel.
What doesn't, C#? There are various things Eiffel does theoretically
better, if they're actually implemented.
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 4:19, clipka wrote:
> That's quite a stupid thing to do, because you then can't tell at
> compile-time whether some other function expecting a parameter of type "Bar"
> actually gets passed such a type when using (in C++ style pseudocode):
I think the problem is more that Haskell is functional rather than OO, so
the stuff people do by having private classes in OO languages is stuff
Haskell does by having opaque types. So instead of
f.x()
accessing the private values inside f, in Haskell you write
x(f)
at which point you want to be able to pass around an "f" without being able
to look inside f.
So it's Andrew's category error, mapping the wrong concepts onto what he
already knows.
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 7:16, Invisible wrote:
> Well, you're right in that you cannot write any code which explicitly
> expects Bar. You can pass the result to any function that works with /all/
> types, or any function that works with any showable type. If the module
> exported some functions that expect Bar as input, you can pass the result to
> them. But you can't write that in a type signature, which... yeah, is a bit
> silly.
That's what I was saying. You can't return type Bar if you haven't made it
exposed. You can declare that foo returns a Bar, but you can't actually use
Bar. It gets the equivalent of being upcast to "object" or to whatever
interface you've defined it to be. So the fact that you can't return an
opaque Bar is no hinderance - declare foo to return the appropriate
interface or Object.
> My point wasn't so much that this is a something anybody is likely to want
> to do. My point was a counter-example to the "that's obviously impossible"
> argument. It's /not/ impossible at all.
By that reasoning, it's possible to do it in C#:
return (Object) Bar;
return (Showable) Bar;
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 1:32, Invisible wrote:
> On 14/08/2012 02:01 AM, Darren New wrote:
>> It's an excellent OO language that expects to have runtime and OS
>> support around.
>
> ...and yet, they claim it can be used for embedded systems, which don't even
> /have/ an OS?
You can use Sing#, which is apparently just like C# except with extra stuff.
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 4:52, clipka wrote:
> I guess you've heard of code re-use through delegation, no?
Then every type of screen item has to delegate that call to something else,
and every time the superclass adds a function, then all subclasses have to
write code to delegate it properly.
If you automate that process, guess what you just invented?
> I do agree that at least inheritance among interfaces would be nice to have,
I don't know of any language that implements inheritance and interfaces that
doesn't allow interfaces to inherit. Quite honestly, that would make almost
no sense.
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 4:15, Warp wrote:
> clipka<ano### [at] anonymous org> wrote:
>> As current widespread belief is that virtually all multiple inheritance
>> use cases can be covered with the interface approach, it seems to make
>> sense to avoid this extra overhead.
>
> Only if you don't mind the need for code repetition with interfaces.
I might have asked this before, but do you have any good (hopefully generic)
examples of where MI really helps out?
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On 8/14/2012 1:40, Invisible wrote:
> So if a class tries to implement both interfaces, it can't provide different
> implementations for these two distinct methods merely because their names
> clash?
That depends on your language. Java? I don't think so. C#? Definitely. But
then you can't invoke the interface call without specifying which one you
mean, so there's no ambiguity.
> According to the Great Language Shootout, C# Mono is 3x slower than C. (Then
> again, Haskell is 2x slower...)
So, an open source clone is slow, thus the version Microsoft uses that
compiles down to optimized native code must be also?
>>> Arguably you could have the compiler detect where dynamic binding is
>>> and is
>>> not needed. That requires whole-program analysis, however.
>>
>> That's what Eiffel does.
>
> Sure. Because Eiffel doesn't support dynamic linking.
Yep. That's what (for example) Sing# does too.
>> Sure there is, because you recompile the code while it's running.
> That sounds remarkably hard to get right...
No harder than compiling it in the first place while it's running. Why is it
harder to re-JIT than to JIT?
--
Darren New, San Diego CA, USA (PST)
"Oh no! We're out of code juice!"
"Don't panic. There's beans and filters
in the cabinet."
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|
 |