Discussion:
M2 for iPhone?
(too old to reply)
Lee
2009-04-05 05:05:39 UTC
Permalink
is there any M2 compiler for writing iPhone apps?
b***@gmail.com
2009-04-10 22:05:07 UTC
Permalink
Post by Lee
is there any M2 compiler for writing iPhone apps?
Not right now, but I am working on a compiler with native Cocoa
support which hooks directly into the Objective-C runtime. Initially
it will generate objc sources, in any event it will work with both
Cocoa and Cocoa Touch and thus allow iPhone development in Modula-2.
More info is at

http://www.sunrisetel.net/software/devtools/objective-modula-2.shtml
Marco van de Voort
2009-04-11 12:19:47 UTC
Permalink
Post by b***@gmail.com
Post by Lee
is there any M2 compiler for writing iPhone apps?
Not right now, but I am working on a compiler with native Cocoa
support which hooks directly into the Objective-C runtime. Initially
it will generate objc sources, in any event it will work with both
Cocoa and Cocoa Touch and thus allow iPhone development in Modula-2.
More info is at
http://www.sunrisetel.net/software/devtools/objective-modula-2.shtml
Hmm, are those limitations really necessary? I can live without local
modules and WITH, but the other stuff...

Where do these limitations come from?
b***@gmail.com
2009-04-12 07:55:57 UTC
Permalink
Hi Marco, thanks for your interest
Post by Marco van de Voort
Post by b***@gmail.com
http://www.sunrisetel.net/software/devtools/objective-modula-2.shtml
Hmm, are those limitations really necessary? I can live without local
modules and WITH, but the other stuff...
Where do these limitations come from?
See the FAQ under question "Why the omissions of Modula-2 features?"

http://www.sunrisetel.net/software/devtools/objective-modula-2.shtml#objm2-faq

Essentially, this is about getting the compiler done sooner. I am not
inclined to add local modules, but I might well add subrange types and
indices at a later stage.

As for variant records, you will find that when you write Cocoa code,
you are going to use Cocoa collection classes and as a result you will
rarely even use any record types at all. The only cases where I use
structs in my Objective-C code is when I need to map to some POSIX
data structures which are structs.

Please consider that this is not a commercial project and there are no
sponsors at present, I need to make the best of the time I can set
aside for this and the most important thing is to get a working
compiler done sooner rather than later. Although, I decided to leave
these features out for now, that doesn't mean it has to be final.

I acknowledge that there is value in a full M2 feature set for
backwards compatibility. Yet, right now, it is more important to get a
working compiler completed.

thanks again for your interest and understanding.
Marco van de Voort
2009-04-13 19:22:51 UTC
Permalink
Post by b***@gmail.com
Hi Marco, thanks for your interest
(I'm mainly are interested btw because FPC also wrestles with COCOA support,
and is adapting some extensions. While I have macs, I'm not a true macer,
but I follow it from a distance)
Post by b***@gmail.com
Post by Marco van de Voort
Where do these limitations come from?
See the FAQ under question "Why the omissions of Modula-2 features?"
Sorry that I missed that.
Post by b***@gmail.com
As for variant records, you will find that when you write Cocoa code,
you are going to use Cocoa collection classes and as a result you will
rarely even use any record types at all. The only cases where I use
structs in my Objective-C code is when I need to map to some POSIX
data structures which are structs.
I believe in data and GUI-frontend separation. If I would want to do Obj-C
all over, I would use Obj C to begin with.

Such incompabilities effectively kill realworld code reuse and retargeting.
If you don't want reuse, why use an existing language at all?

I don't have significant M2 codebases, but a similar situation with Pascal
would cost me a couple of hundred thousands lines.
Post by b***@gmail.com
Please consider that this is not a commercial project and there are no
sponsors at present, I need to make the best of the time I can set
aside for this and the most important thing is to get a working
compiler done sooner rather than later. Although, I decided to leave
these features out for now, that doesn't mean it has to be final.
Clear. I hope that leaving it out and reintroducing it later doesn't cause
heavy rewrites.
b***@gmail.com
2009-04-14 08:06:02 UTC
Permalink
Post by Marco van de Voort
(I'm mainly are interested btw because FPC also wrestles with COCOA support,
and is adapting some extensions.
When I started this project I considered Pascal, Modula-2 and Oberon
as replacements for C in Objective-C to create the new superset. I did
talk to some folks at the FPC and GNU Pascal projects but they were
not interested in the Smalltalk style syntax and thought a bridge
would be better to support Cocoa and GNUstep.

I had tried out several Cocoa bridges, initially Apple's AppleScript
bridge (aka AS Studio), then briefly Apple's Java bridge, eventually
PyObjc and the bridge for OpenMCL. The experience was never
satisfactory though. First it is inefficient and wasteful in several
ways because the bridge has to constantly translate between two
otherwise incompatible object systems. Second, the whole philosophy
and expressive power of the Smalltalk derived syntax gets lost, which
is the only reason why Objective-C was attractive to me in the first
place. I really like the Smalltalk side of Objective-C, I abhor the C
side of it.

So my verdict was that the Objective-C hybrid approach was in
principle the right thing to do, it just had to be done using a
different base language, ideally a language from the Pascal family. At
the time, not many people shared this view, but today there are
several projects where this idea is being pursued. I guess people have
started to realise that supporting Cocoa and GNUstep is not just about
using the API but that the Smalltalk bits are worth preserving in
their own right.
Post by Marco van de Voort
While I have macs, I'm not a true macer, but I follow it from a distance)
Well, its not just a Mac thing. GNUstep is available on just about any
*nix platform and there is a Windows implementation called Cocotron.
Then there is WebObjects and the iPhone. Also, there is PoCC, a
portable Objective-C compiler with its own runtime and class library,
entirely unrelated to any of the OpenStep based libraries and there
are quite a few Objective-C folks who implement and use their own
class libraries.
Post by Marco van de Voort
Post by b***@gmail.com
As for variant records, you will find that when you write Cocoa code,
you are going to use Cocoa collection classes and as a result you will
rarely even use any record types at all. The only cases where I use
structs in my Objective-C code is when I need to map to some POSIX
data structures which are structs.
I believe in data and GUI-frontend separation.
I don't share the view that Objective-C classes are for GUI frontends
only. There is the Foundation framework which has dynamic strings and
collection classes. Cocoa and GNUstep are built on top of this, but it
is a very powerful and pleasant to work with class library in its own
right. In fact there is a separate open source (and BSD licensed)
implementation of the Foundation framework which people use to write
non-GUI software. A friend of mine has written an experimental
telephony server for Linux in Objective-C, using only the Foundation
classes.
Post by Marco van de Voort
If I would want to do Obj-C
all over, I would use Obj C to begin with.
Many people who get started with Objective-C are indeed only doing so
because they want to use one of the GUI frameworks. For example, if
you want to write applications for the iPhone, at present Objective-C
is the only choice.

However, you will find that many developers who have used Objective-C
for a while begin to realise and appreciate the advantages of the
Smalltalk concepts in the language, even many of those who don't like
the Smalltalk derived syntax at first. There are more and more new
languages being designed and implemented which use the same concepts
and syntax, for example F-script, Io, Nu and of course Objective
Modula-2. You might be surprised, but I get quite a bit of email from
folks who want to implement their own Objective-X languages. There is
clearly more to it that plugging into Cocoa or GNUstep.

Not everybody likes the C part of Objective-C, apparently ;-)
Post by Marco van de Voort
Such incompabilities effectively kill realworld code reuse and retargeting.
I personally would much rather recode stuff using Foundation
collection classes, but yes, if you want to migrate a very large code
base, then this will not always be an option, at least not in the
short term. But perhaps it would be worthwhile looking into writing a
translation tool, which can convert things like sources with variant
records directly into collection classes.
Post by Marco van de Voort
If you don't want reuse, why use an existing language at all?
Well, designing a new language entirely from scratch may be a little
more effort than using an existing one you're familiar with and modify
it to your needs.

I have also played with some design based on C, basically using C
flavoured syntax but Modula-2 semantics, in particular strict type
checking and modules with data encapsulation. Another idea I decided
not to pursue was to create Objective-D, using the D language as a
base.
Post by Marco van de Voort
I don't have significant M2 codebases, but a similar situation with Pascal
would cost me a couple of hundred thousands lines.
Well, I had once offered my assistance to the Free Pascal folks to
create a specification for an "Objective" extension to Free Pascal
following the same approach. Using an existing compiler as a base has
its own challenges, but there wouldn't be any need to remove existing
language features to reduce workload then, because these features are
already implemented.
Post by Marco van de Voort
Post by b***@gmail.com
Please consider that this is not a commercial project and there are no
sponsors at present, I need to make the best of the time I can set
aside for this and the most important thing is to get a working
compiler done sooner rather than later. Although, I decided to leave
these features out for now, that doesn't mean it has to be final.
Clear. I hope that leaving it out and reintroducing it later doesn't cause
heavy rewrites.
I think it will be fairly easy to add to the front-end. Also, I wrote
all the code with the idea in mind that those features might need to
be added later and so I try to avoid shooting myself in the foot. For
example if you look at the EBNF grammar, production #34 "array-index"

http://www.sunrisetel.net/software/papers/objm2/ObjM2-Parser-Grammar.pdf

you will see that I retained the general format for array indices
[ 0 .. max ] and simply reject anything that isn't zero. The zero
could later be replaced by const-expression and source code conforming
to the current grammar won't need to be changed if sub range indices
are reintroduced.

At the back-end side, yes it will be quite a bit of work to add the
omitted features. Because the initial back-end will generate Objective-
C source code, only local procedures require some additional
processing, anything else can be mapped 1:1. If and when the omitted
features (or some of them) are reintroduced, they cannot be mapped
1:1, which is the main reason why I decided to leave them out for now
in the first place.

Then again, I hope to be able to write an LLVM back-end later, so this
will require rewriting anyway. Hopefully, by that time the project
will have gained some code contributors ;-)
Marco van de Voort
2009-04-14 12:34:15 UTC
Permalink
Post by b***@gmail.com
Post by Marco van de Voort
(I'm mainly are interested btw because FPC also wrestles with COCOA support,
and is adapting some extensions.
When I started this project I considered Pascal, Modula-2 and Oberon
as replacements for C in Objective-C to create the new superset. I did
talk to some folks at the FPC and GNU Pascal projects but they were
not interested in the Smalltalk style syntax and thought a bridge
would be better to support Cocoa and GNUstep.
Correct. For me COCOA and Objective C are an annoyance. I would have
prefered a normal API.
Post by b***@gmail.com
First it is inefficient and wasteful in several
ways because the bridge has to constantly translate between two
otherwise incompatible object systems.
I considered this not really a problem since GUI is slow anyway.
Post by b***@gmail.com
Second, the whole philosophy and expressive power of the Smalltalk derived
syntax gets lost, which is the only reason why Objective-C was attractive
to me in the first place. I really like the Smalltalk side of Objective-C,
I abhor the C side of it.
I just want to make apps. Also, for me Mac is only a secondary target. I
just want Mac GUI and maybe access to some of the Foundation stuff that is
more geared toward the OS, and couldn't care less for the rest.
Post by b***@gmail.com
At the time, not many people shared this view, but today there are several
projects where this idea is being pursued. I guess people have started to
realise that supporting Cocoa and GNUstep is not just about using the API
but that the Smalltalk bits are worth preserving in their own right.
If I wanted Smalltalk, I'd use smalltalk, not Pascal/M2.
Post by b***@gmail.com
Post by Marco van de Voort
While I have macs, I'm not a true macer, but I follow it from a distance)
Well, its not just a Mac thing. GNUstep is available on just about any
*nix platform and there is a Windows implementation called Cocotron.
Yes. And it's like saying that OS X is not really about Mac because there is
Darwin. A small group of (often Mac-connected) believers use it, but that is
a far cry from the hordes of OS X users. The same for Obj-C.

Probably the mono/.NET use on Mac is bigger than the Objective_C use on
windows.
Post by b***@gmail.com
Post by Marco van de Voort
Post by b***@gmail.com
structs in my Objective-C code is when I need to map to some POSIX
data structures which are structs.
I believe in data and GUI-frontend separation.
I don't share the view that Objective-C classes are for GUI frontends
only. There is the Foundation framework which has dynamic strings and
collection classes.
Correct. But I just want to also compile my programs for the Mac, not for
Objective C. I am not interested in Obj-C or Smalltalk or GnuStep. Since
KDE or Gnome are the prime GUIs on *nix, not gnustep.

I've got own classes, routines, generics etc for that. I only have to live
with Cocoa (and maybe some of the multimedia frameworks) because I have to.
Post by b***@gmail.com
Post by Marco van de Voort
If I would want to do Obj-C all over, I would use Obj C to begin with.
Many people who get started with Objective-C are indeed only doing so
because they want to use one of the GUI frameworks. For example, if
you want to write applications for the iPhone, at present Objective-C
is the only choice.
(for us, the unwillingness of Apple to support Carbon on 64-bit has been the
trigger. However I'm still in dubio if I would bother to support Mac. As
said I'm only monitoring the Cocoa efforts)
Post by b***@gmail.com
However, you will find that many developers who have used Objective-C
for a while begin to realise and appreciate the advantages of the
Smalltalk concepts in the language, even many of those who don't like
the Smalltalk derived syntax at first.
Spare me!. I have been sitting on the same desk with a smalltalk,Step and
Next fanboy for 2 years. He also always was trying me to convince me of the
beauty, but I never saw it. Maybe because I am not looking for beauty, but
just want to get work done.
Post by b***@gmail.com
Not everybody likes the C part of Objective-C, apparently ;-)
I don't like either part. But I like the C part better, because that I can
interface at least.
Post by b***@gmail.com
Then again, I hope to be able to write an LLVM back-end later, so this
will require rewriting anyway. Hopefully, by that time the project
will have gained some code contributors ;-)
Note that the sb is working on that with FPC too. The same person that does
the general Mac support and the extensions needed for the bridge.
b***@gmail.com
2009-04-14 15:27:23 UTC
Permalink
I would have prefered a normal API.
I tend to think that what is "normal" is in the eyes of the
beholder ;-)
I considered this not really a problem since GUI is slow anyway.
especially when the garbage collector kicks in, which will have all
the more work to do and take longer in a bridged application because
there are twice as many objects to trace and collect. Oh well :-)
I just want to make apps.
So do I. My main work is on telephony servers and telecommunications
protocols, the GUI work I do is just for control panels to control and
configure those servers. Yet, I prefer the Smalltalk style.
Unfortunately, in real-time apps, going Smalltalk for the whole lot
isn't an option. A hybrid language like Objective-C or Objective
Modula-2, or even Io or Nu, is much better suited to my needs and
preferences in that it gives me the best of both worlds.
Also, for me Mac is only a secondary target.
Same here, my bread and butter target is BSD, in fact often embedded
BSD. Still, I prefer Io, Nu, and the Smalltalkish bits of ObjC over C,
embedded C++, or even Mod51. I should probably be using Erlang for my
telecom work, but I tried that already and it's just not my cup of
tea.
I just want Mac GUI and maybe access to some of the Foundation stuff that is
more geared toward the OS, and couldn't care less for the rest.
Fair enough, but that doesn't mean everybody else has to see Objective-
C in the same way. Luckily, we live in a world of choice. For some,
Objective-C is a nuisance to do native GUI programming on the Mac, for
some others it is a tool of choice, for yet others it is an
inspiration to build their own tool of choice, such as CLIPS, F-
Script, Io, Nu, ObjM2 and a new flavour of Ruby which also plugs
directly into the objc runtime without a bridge. Those who like these
programming environments all have their own reasons why they like them
and why they prefer them over what you consider "normal".
If I wanted Smalltalk, I'd use smalltalk, not Pascal/M2.
So tell me, what is it that makes it acceptable to derive and use
languages from the Simula style of OOP, and what is it that makes it
unacceptable to do the same thing using the Smalltalk flavour of OOP
as a starting point?

If you are using Pascal with OO extensions today, the chance is that
the OO extensions are a derivative of the Simula OO style, so in your
own words, you would have to tell yourself "If I wanted Simula, I'd
use Simula, not Pascal" and switch to Simula, unless that is, there
might be something else you like about a Pascal dialect with Simula
style OO added to it. Well, guess what, there is something else I like
about a dialect of a language of the Pascal family with Smalltalk OO
added to it. Same thing in principle, different preferences, that's
all.
Yes. And it's like saying that OS X is not really about Mac because there is
Darwin. A small group of (often Mac-connected) believers use it, but that is
a far cry from the hordes of OS X users. The same for Obj-C.
I am not sure what you are trying to tell us there. I pointed out that
a) you _can_ use Objective-C for other things than writing GUI apps
for the Mac and b) that there are people who _do_ just that. Just
because 99 guys use some tool for one thing doesn't mean that the one
guy who uses it for some other thing is wrong or to be belittled.

In fact, the way things are going with the iPhone, you will soon have
to revise your perception and call Objective-C an iPhone development
language, because it looks very much like iPhone developers are going
to vastly outnumber Mac developers at some point, or perhaps they do
already, I don't know.
Post by b***@gmail.com
Post by Marco van de Voort
If I would want to do Obj-C all over, I would use Obj C to begin with.
Precisely what I did, with the emphasis on "to begin with". At some
point I wanted to move on. And I am not the only one. Search for the
developers of other languages following the ObjC blueprint, they all
started out with Objective-C "to begin with" and at some point they
decided they want something augmented or modified to better suit their
preferences. And in the process of creating their own new tool, they
provide choices for many others. What's the problem with that anyway?
(for us, the unwillingness of Apple to support Carbon on 64-bit has been the
trigger. However I'm still in dubio if I would bother to support Mac. As
said I'm only monitoring the Cocoa efforts)
Well, I hope you don't blame me for Apple's not wanting to do 64-bit
Carbon. I promise you, I have had nothing to do with it ;-)
Spare me!. I have been sitting on the same desk with a smalltalk,Step and
Next fanboy for 2 years. He also always was trying me to convince me of the
beauty, but I never saw it. Maybe because I am not looking for beauty, but
just want to get work done.
I wasn't trying to evangelise you. I merely presented a different
viewpoint. To you Cocoa and GNUstep are simply GUI APIs and I
acknowledged that. Fair enough. But you should grant the same courtesy
to me and those who like the Smalltalk derived syntax and philosophy,
not because its on the Mac, but for their own merit. We have a right
to choice just as you do, and we deserve better than to be called Mac
or NeXT zealots simply because of our choices.
I don't like either part. But I like the C part better, because that I can
interface at least.
Haha, its not like you can't interface to it, you just have to learn
the C API of the objc runtime, no smalltalk syntax involved there,
just foreign C function calls. This way you won't need a bridge, nor
any language extensions. In fact this would look more "normal" to you,
than it would look to me. :-)

myArray := _objc_msg_send(NSArray, "initWithContentsOfFile:",
pathname);
Post by b***@gmail.com
Then again, I hope to be able to write an LLVM back-end later, so this
will require rewriting anyway. Hopefully, by that time the project
will have gained some code contributors ;-)
Note that the sb is working on that with FPC too. The same person that does
the general Mac support and the extensions needed for the bridge.
Nice choice. LLVM is indeed looking very good. I wouldn't be surprised
to see it become the mainstream compiler back end for just about
anything which is neither MSFT nor GNU.
Marco van de Voort
2009-04-14 20:13:28 UTC
Permalink
Post by b***@gmail.com
I would have prefered a normal API.
I tend to think that what is "normal" is in the eyes of the
beholder ;-)
Well, at the risk of making this a yes/no discussion, I simply thinking an
OS api is an OS api and should be relatively language (and their runtime
system) independant. However current trends are otherwise (with .NET, Obj-C,
and Java (Sun)). Avoiding Python on Linux is nearly impossible (though I
try).
Post by b***@gmail.com
I considered this not really a problem since GUI is slow anyway.
especially when the garbage collector kicks in, which will have all
the more work to do and take longer in a bridged application because
there are twice as many objects to trace and collect. Oh well :-)
Assuming both _have_ garbage collection.
Post by b***@gmail.com
I just want to make apps.
So do I. My main work is on telephony servers and telecommunications
protocols, the GUI work I do is just for control panels to control and
configure those servers. Yet, I prefer the Smalltalk style.
Unfortunately, in real-time apps, going Smalltalk for the whole lot
isn't an option. A hybrid language like Objective-C or Objective
Modula-2, or even Io or Nu, is much better suited to my needs and
preferences in that it gives me the best of both worlds.
Interesting. Till now I had the feeling it was more about syntax/semantics
than hybrid properties. Btw, I'm in machine vision, so I like a bit of speed
too :)

But then I don't get the compilation to obj-c part. That is a long way ahead
then. Good luck :-)
Post by b***@gmail.com
Also, for me Mac is only a secondary target.
Same here, my bread and butter target is BSD, in fact often embedded
BSD
I'm FPC's FreeBSD maintainer, though I do Linux and Windows too. Currently
I'm more a general RTL and lower level classes man though. (and I spend way
to little time on that even)
Post by b***@gmail.com
Still, I prefer Io, Nu, and the Smalltalkish bits of ObjC over C, embedded
C++, or even Mod51. I should probably be using Erlang for my telecom work,
but I tried that already and it's just not my cup of tea.
I tried a lot over the years. I still like Delphi best, though I can survive
on C++ too. Java and C# too in strictly business ocmputing, though that is
more go with the flow (not bad enough to resist) than love.

I don't really like any of the currently popular general purpose scripting
languages, since for my feeling they don't add much. I usually jump right
from Object Pascal/C++ to domain specific languages (that really incorporate
modelling from the problem domain)

I've tried my share of estoric languages, the unavoidable Lisp, a bit of
Haskell etc, but I always got the feeling that they lacked general
purposeness (focussing more on math and other algorithmical complex
computing), and too little on daily tasks. Academic programmer's equivalent
of a crosswords puzzle so to speak.

I never did Ada, but saw a lot of it over the years by looking sideways from
Pascal. Seems to suffer from the C++ problem of extreme language size.

And while I support nearly all choices they made individually, I disagree
with the sum of them(though Delphi isn't exactly lightweight anymore these
days, it still pales compared to these beasts)
Post by b***@gmail.com
If I wanted Smalltalk, I'd use smalltalk, not Pascal/M2.
So tell me, what is it that makes it acceptable to derive and use
languages from the Simula style of OOP, and what is it that makes it
unacceptable to do the same thing using the Smalltalk flavour of OOP
as a starting point?
Reality? ( :-) )

I know where OO came from. I just never saw the use of the smalltalk way.
However said collegue (which was/is a friend of me btw) said it was because
I was to hung up on control, and judge everything by its ability to make
large projects in it.

That could be. I'm more the engineering, and less the computer
scientist type.
Post by b***@gmail.com
about a dialect of a language of the Pascal family with Smalltalk OO
added to it. Same thing in principle, different preferences, that's
all.
The hybrid Modula2 - Smalltalk is what I find surprising. Modula2 is as
strong typed and static as it gets. Smalltalk, euh, well isn't.

But back to the point, while I generally are fond of M2 and Pascal
(including OO variants), IMHO the importance of language, while not
negiable, is overrated. I use Pascal, not Modula2 because I liked the
compiler best. (though admitted, conceptually they are nearly the same). I
used Topspeed Modula2 before, which is why still monitor this group.

One should also see this discussion in the light of my horror when Apple
picked a language dependant API (that happened to be Objective C), and not
purely as a Objective C rant.
Post by b***@gmail.com
In fact, the way things are going with the iPhone, you will soon have
to revise your perception and call Objective-C an iPhone development
language, because it looks very much like iPhone developers are going
to vastly outnumber Mac developers at some point, or perhaps they do
already, I don't know.
The most programmed language in the world is Excel macro language/VBScript.
Still I don't have an immediate urge to venture into that realm.

While the iPhone is a marketeer's wet dream, it is btw not necessarily that
big from a programmers POV. The programming metier is not homogenous. At
least not yet, and not the next decade.
Post by b***@gmail.com
I wasn't trying to evangelise you. I merely presented a different
viewpoint. To you Cocoa and GNUstep are simply GUI APIs and I
acknowledged that. Fair enough. But you should grant the same courtesy
to me and those who like the Smalltalk derived syntax and philosophy,
not because its on the Mac, but for their own merit.
When didn't I do that? I just said _I_ didn't see the beauty.
Post by b***@gmail.com
We have a right to choice just as you do, and we deserve better than to be
called Mac or NeXT zealots simply because of our choices.
That is a different thing. I called you on simple facts about GNUsteps
usability in the wider world. And facts remain facts. Objective C only plays
a small role outside the Mac world. It's like saying that Pascal is great
because you can use UCSD on Apple II.
Post by b***@gmail.com
I don't like either part. But I like the C part better, because that I can
interface at least.
Haha, its not like you can't interface to it, you just have to learn
the C API of the objc runtime, no smalltalk syntax involved there,
just foreign C function calls. This way you won't need a bridge, nor
any language extensions. In fact this would look more "normal" to you,
than it would look to me. :-)
myArray := _objc_msg_send(NSArray, "initWithContentsOfFile:",
pathname);
I really like your example, which is another reason why IMHO COCOA fails as
an OS api. Even though it might make me sound like a bigot. When do you call
objc_msg_send and when objc_msg_send_stret?
Post by b***@gmail.com
Post by b***@gmail.com
Then again, I hope to be able to write an LLVM back-end later, so this
will require rewriting anyway. Hopefully, by that time the project
will have gained some code contributors ;-)
Note that the sb is working on that with FPC too. The same person that does
the general Mac support and the extensions needed for the bridge.
Nice choice. LLVM is indeed looking very good. I wouldn't be surprised
to see it become the mainstream compiler back end for just about
anything which is neither MSFT nor GNU.
I'm a bit scared. I do like LLVM, but I don't like the possible
ramifications of Apple adopting it. I'm a bit afraid that Apple will use it
to exert even more control over 3rd party developers. A bit like Java phones
that don't allow apps that are not signed, under the guise of "security".
b***@gmail.com
2009-04-15 12:55:43 UTC
Permalink
an OS api is an OS api and should be relatively language (and their runtime
system) independant. However current trends are otherwise (with .NET, Obj-C,
and Java (Sun)). Avoiding Python on Linux is nearly impossible (though I
try).
Until not that long ago OS APIs were assembly based, you had to stick
parameters into certain CPU registers and initiate a software
interrupt. At some point higher level language APIs were added while
the assembly APIs were still kept around Eventually, the assembly APIs
were dropped. Somebody probably complained about that in the same
manner you are now complaining about the dropping of higher level
assembly APIs (C is after all an assembly notation for the PDP-11,
augmented with some higher level language control flow constructs).
Somebody else might just call this progress.

Let's be honest, OS APIs have never been language independent, they
were always centered around whatever language flavour was chosen by
the OS implementors as a base. Initially it was all assembly based,
then IBM mainframes started to have IBM language based APIs, DEC had
an API which was in a way language independent but all languages on
the VAX had to get language extensions to support all the calling
conventions, in fact this was not unlike what I am doing with
Objective Modula-2, just that the calling conventions on VMS aren't
Smalltalkish.

Then only reason why the C calling standards (and very similar ones
like Pascal) look "normal" is because in recent decades most vendors
have copied the Unix model and used C or Pascal (or derivatives
thereof) as implementation languages. In other words, the way APIs
have come to look is more or less accidental and clearly not language
independent.

To claim otherwise would be like saying that communication in English
is language independent because English is very widespread.

I think the changes in OS APIs is part of a regular cycle by which new
concepts are introduced, some concept becomes de facto standard as
everybody adopts it, finally to be challenged and replaced by another
new concept when the cycle repeats itself. It's called progress ;-)
Interesting. Till now I had the feeling it was more about syntax/semantics
than hybrid properties. Btw, I'm in machine vision, so I like a bit of speed
too :)
To a language purist (isnt there a bit of a language purist in all of
us perhaps?) when first beign presented the idea of a "hybrid"
language, it is probably an appalling idea. But think about it, we
have had inline assembly capabilities within C and Pascal compilers
for ages. Also, interfaces to SQL are often realised as a kind of
inline SQL statement sequence. The Smalltalk derived message syntax in
Objective-C can be viewed as inline Smalltalk. This sort of thing is
fairly common and rather practical. When you look at it this way, the
notion of a hybrid language may no longer seem so outlandish.

When you work with Objective-C over time you realise that separating
control flow and data structures and handle one of them in a
precedural imperative language and the other in a Smalltalk like
language is actually quite practical and useful. Imperative languages
are simply speaking better at control flow and certainly they are
faster at it. On the other hand higher level languages like Smalltalk
generally make it easier to handle complex dynamic data structures.
Dividing these two sub-domains by mixing the respective features in a
single language can really make a difference.

Before I started with Objective-C I often had this dilemma that I
would rather use an imperative language for a project because of one
constraint, but rather use a higher level language because of another.
With a hybrid like Objective-C I no longer have to make this choice, I
get both in one.

It may seem odd from a language purist's point of view but it is
really practical when you use it, so over time you simply stop caring
about the oddity of it all. Brad Cox, the creator of Objective-C once
told me that when they designed the language that was precisely their
aim, they didn't think of it as a new language at all, but they simply
wanted some contraption that did something they wanted to do. The
outcome was good enough to catch on and become a language in its own
right, but it wasn't actually intended to be a language.
But then I don't get the compilation to obj-c part. That is a long way ahead
then. Good luck :-)
Well, maybe I should clarify this a bit. Anything in the Objective
Modula-2 source code which is conventional Modula-2 will come out as
vanilla C, but anything that uses the language extensions will come
out as its respective Objective-C equivalent.

For example

DEFINITION MODULE MyClass : SuperClass;

IMPORT SuperClass;

...

END MyClass.

will come out

#import "SuperClass.h"

@interface MyClass : SuperClass {

'''

}

...
@end

But

WHILE x > 0 DO
...
END;

will come out

while (x>0) {
...
}

This is a little easier to do than to generate assembly level code or
even virtual machine code because you don't have to keep track of
registers, you don't have any pipelining and scheduling issues, you
don't have to manage the stack frames. Most of the Modula-2 subset
features map more or less 1:1 into C, all of the Objective Modula-2
extensions map 1:2 to Objective-C extensions. The only thing which
requires some special attention are M2 name mangling and local
procedures.

In my experimental compiler (used for testing syntax during the design
phase) I have used a text template engine which I wrote for generating
configuration files to generate output. I wrote a bunch of C and ObjC
templates, one for each production in the target C grammar where each
of the non-terminals are placeholders, then I used the template engine
to replace the placeholders recursively until all constructs are C.

This has two benefits. It's less work than writing a traditional code
generator and it is useful as a verification tool to check if the
output is equivalent to the input, because the mappings are fairly
straight forward between M2 and C (other than for local procedures).
This will later come in very handy when writing the LLVM generator and
trying to figure out any bugs then (for example: do we have a silly
bug like forgotten to pop something from the stack, or do we have a
conceptual error in the translation scheme?)
I'm FPC's FreeBSD maintainer,
cool, do you have any coroutines support (or library) for FPC that
works on FBSD?
more go with the flow (not bad enough to resist) than love.
I understand the feeling.
I don't really like any of the currently popular general purpose scripting
languages, since for my feeling they don't add much. I usually jump right
from Object Pascal/C++ to domain specific languages (that really incorporate
modelling from the problem domain)
It seems to me that many if not most of those scripting languages are
meant for web development. I don't do web development, so I was never
surprised that those languages didn't seem to suit my needs much.
I never did Ada, but saw a lot of it over the years by looking sideways from
Pascal. Seems to suffer from the C++ problem of extreme language size.
I agree. One of the main reasons that made Modula-2 attractive was its
simplicity, but ISO Modula-2 is almost as bad as Ada and C++, not
quite, but definitely no longer simple enough to be appealing to me.
Oberon on the other hand seems just a tad too simplistic. At the very
least I would want to keep unsigned integers, enumerations and
separation of definition and implementation modules, if only for
reasons of readability and documentation.
And while I support nearly all choices they made individually, I disagree
with the sum of them
Haha, well said, that's the trouble with language design, right there.
There is always a good reason to add one more bit, but you can never
seem to figure out where you should have stopped adding more stuff.
That could be. I'm more the engineering, and less the computer
scientist type.
In respect of Objective-C (and by extension Objective Modula-2) it
looks the exact opposite, like I said, the Objective-C way of
hybridisation is purely practical and rather unscientific.
The hybrid Modula2 - Smalltalk is what I find surprising. Modula2 is as
strong typed and static as it gets. Smalltalk, euh, well isn't.
That's precisely why a hybrid makes sense. It wouldn't be of much
added utility if you combine two toolkits which have identical tools
in them. It will however increase utility if you combine two toolkits
which have different tools in them.

As for static and dynamic typing, Objective-C has both. If you use the
type "id" (the equivalent in Objective Modula-2 is called OBJECT, then
its dynamically typed, but if you use the actual type identifier of an
actual class, then it is statically typed.

I use dynamic typing in Objective-C only where one would use generics
in Pascal, M2 or C++. If you have the choice of dynamic typing when
you want it, then you don't need generics, but you still get static
typing for all other usage scenarios.

Like I said before, the hybrid is not about just mixing features,
stirr them and end up with a melange. Each feature set has its well
defined problem domain, Modula-2 for all the control flow and simple
scalar operatings like say calculating the index for a bucket in a
hash table. the Smalltalk side is for creating and managing non-scalar
data structures. With this separation it makes perfect sense that the
Modula-2 part should always be strictly typed and that the Smalltalk
part gives you the option to choose either static or dynamic typing.

In fact this is not limited to static versus dynamic typing, Objective-
C (and by derivation Objective Modula-2 as well) gives you choices on
a case by case basis where in most other languages the choice has been
made for you by the language designer.

In fact, Objective-C gives you the choice which garbage collection
scheme you want to use on a per object basis. You simply send a
message to it and depending on the message it is either reference
counted or automatic. In all other languages I know of, it is either
all garbage collected or nothing is. Again, I found the ability to
choose on a per object basis to be very helpful in practise.

This level of choice on a per item basis in Objective-C is something I
do not want to miss now and it is at least in part a result of the
language being a hybrid of two unlikely marriage partners. So, yes, it
does make perfect sense to marry Modula-2 and Smalltalk, maybe not
from a language purist's point of view but definitely from a
practicality and usability point of view.
But back to the point, while I generally are fond of M2 and Pascal
(including OO variants), IMHO the importance of language, while not
negiable, is overrated. I use Pascal, not Modula2 because I liked the
compiler best. (though admitted, conceptually they are nearly the same). I
used Topspeed Modula2 before, which is why still monitor this group.
I can agree to that only for situations where the languages are at
least broadly similar, that is when they use comparable paradigms.
When you cross paradigm boundaries, then the different paradigm of the
other language may make a very big difference. But, in principle, yes
its not the language as such, it is about the paradigm or set of
paradigms that the language is based on. In the case of Pascal,
Modula-2, Oberon, Ada you have a very similar set of paradigms, even
from there to the C and C++ or Java, the paradigms are relatively
similar. But there are languages with fundamentally different
paradigms, Smalltalk being one of them, and if you know how to make
use of that, then it will make a significant difference.

But that is not necessarily to say that one paradigm is superior to
another. Sometimes it also has to do with how a given paradigm matches
your way of thinking and working. Sometimes a new paradigm can lead
you to change the way you think and work and the outcome may be
positive, but sometimes a paradigm just isn't compatible with the way
you like to do your stuff.
The most programmed language in the world is Excel macro language/VBScript.
Still I don't have an immediate urge to venture into that realm.
What I meant to say was that your perception of what Objective-C is
may have to change because it seemed to be based entirely on what the
majority of people who use it use if for. Consequently, if the
majority of people who use it use it for something different, then
your perception would have to shift. Ergo, Objective-C might soone
have to be perceived as "the iPhone development language" because it
may turn out that most folks using it will use it for that. You may
then say, that it doesn't make sense to base one's perception of a
language on what others are using it for, but that was actually the
point I was trying to make ;-)
That is a different thing. I called you on simple facts about GNUsteps
usability in the wider world. And facts remain facts. Objective C only plays
a small role outside the Mac world. It's like saying that Pascal is great
because you can use UCSD on Apple II.
This is precisely where you are mistaken, you have an idea based on
what you think the majority of folks who use it are doing and what
those people are and how they fit into some box (eg. Apple fanboy) and
you dismiss anything that doesn't fit that perception.

GNUstep was created when SUN Microsystems and NeXT worked together on
OpenStep. Back then Apple was a pure Pascal shop and the iPhone was
not even a remote possibility. Objective-C and OpenStep was all the
rage at SUN before they decided they wanted to exercise more control
and created Java. OpenStep was the number one development platform in
the financial industry, too. WebObjects was very widespread. Heck,
DELL's ordering system was running entirely on Objective-C. Michael
Dell, dropped it with sorrow not for technical reasons but for
political reasons after Aplle acquired NeXT.

Yes, the acquisition and adoption of NextStep by Apple may have been
both a blessing and a curse. On the one hand it has added many more
users, on the other hand it has also led to the other areas in which
the environment was very strong and widespread before to be pushed
into the background. But that doesn't mean that anybody who picks up
Objective-C or its object system or the class libraries has to follow
this trend. It is perfectly reasonable to use this environment for non-
Mac non-GUI stuff and for its own merits. And it is equally reasonable
for somebody to write a clone for Windows (e.g. Cocotron) as it is for
somebody to write a .NET clone for *nix systems (e.g. Mono).
I'm a bit scared. I do like LLVM, but I don't like the possible
ramifications of Apple adopting it. I'm a bit afraid that Apple will use it
to exert even more control over 3rd party developers. A bit like Java phones
that don't allow apps that are not signed, under the guise of "security".
Luckily there is a significant difference. The Java license doesn't
allow you to fork, the LLVM project's BSD style license does. So, if
Apple goes too bossy on the whole thing and upset developers in the
process, there'll be a fork.
Marco van de Voort
2009-04-15 16:09:54 UTC
Permalink
Post by b***@gmail.com
an OS api is an OS api and should be relatively language (and their runtime
system) independant. However current trends are otherwise (with .NET, Obj-C,
and Java (Sun)). Avoiding Python on Linux is nearly impossible (though I
try).
Until not that long ago OS APIs were assembly based, you had to stick
parameters into certain CPU registers and initiate a software
interrupt.
They mostly still are (the true userland->kernel transitions). Nowadays they
are just wrapped in basic procedural wrappers. Note that even stuff like
Java's JNI and dot NET relies on procedural interfaces to reach code outside
their VMs. C++, or any other static compiler's code must be wrapped mostly
(either in COM or flatenned using procedural headers) to work.

So pretending that this is just about merry old geezers Pascal and C is a
gross simplification. It goes for every development system that wants to
remain independant, and keep using its own tried and tested object model and
virtual machine, rather than the vendors choice.
Post by b***@gmail.com
Somebody probably complained about that in the same
manner you are now complaining about the dropping of higher level
assembly APIs (C is after all an assembly notation for the PDP-11,
augmented with some higher level language control flow constructs).
Then you misunderstand my point. It is more about free choice of language
and development tools than about PDP-11.
Post by b***@gmail.com
Somebody else might just call this progress.
I never saw limitations of freedom, and user rights a matter of freedom.

I'm no GNU bigot, but as independant developer I prefer to make the choice
of toolchain myself, because of MY (and my customers) requirements, not
settle for the thing the OS vendor thinks is good for me.

If the OS vendor has the user/programmers interest at heart at all, and is
not simply trying to gain ground against e.g. independant tool vendors.
(like MS with
.NET) over its own users heads.
Post by b***@gmail.com
Let's be honest, OS APIs have never been language independent, they
were always centered around whatever language flavour was chosen by
the OS implementors as a base.
No. I don't agree with that. That might have been an influence, but it was
usually chosen so that an as broad audience could use it with absolutely
minimal extensions (like e.g. calling convention).

And exactly that annoys me with COCOA (and to a lesser degree with .NET,
since they at least still provide nearly all API's procedural. It seems more
that .NET is a higher level system on top of the more basic API, and MS
gives the user the choice)

Academic OSes have been different and more integrated (to prove concepts)
more often, but the big, widely used OSes this was the usually case.
Post by b***@gmail.com
Then only reason why the C calling standards (and very similar ones
like Pascal) look "normal" is because in recent decades most vendors
have copied the Unix model and used C or Pascal (or derivatives
thereof) as implementation languages. In other words, the way APIs
have come to look is more or less accidental and clearly not language
independent.
I don't make this point based on history, but on effective outcome, namely
that it shuts out large groups of people with their own tooling.

Be it procedural users, or higher level languages that want to keep their
own, proven, and portable runtime system and have to make do with ugly
bridges. Even if they are Smalltalkish.

Maybe I should have said language-implementation dependant btw, instead of
language.
Post by b***@gmail.com
To claim otherwise would be like saying that communication in English
is language independent because English is very widespread.
Is this an attempt to prove the old proverb that one can prove anything with
a well chosen analogy? :-)
Post by b***@gmail.com
I think the changes in OS APIs is part of a regular cycle by which new
concepts are introduced, some concept becomes de facto standard as
everybody adopts it, finally to be challenged and replaced by another
new concept when the cycle repeats itself. It's called progress ;-)
I don't buy that. If that was the case, they could just let users make up
their own minds and maintain a basic API as well as a higher level one.

But for Apple, with its relatively small custom software market it might be
worthwhile, since it is more about HW sales than software. Shame, but it
might kill 3rd party development for Mac, except for the ones that target
Mac exclusively. And even there will be a certain shakeout, as not everybody
will want to invest to reinvent the wheel in Objective C again.
Post by b***@gmail.com
Interesting. Till now I had the feeling it was more about syntax/semantics
than hybrid properties. Btw, I'm in machine vision, so I like a bit of speed
too :)
To a language purist (isnt there a bit of a language purist in all of
us perhaps?) when first beign presented the idea of a "hybrid"
language, it is probably an appalling idea.
Not to me, since I don't consider myself a purist. As said, I think too much
of the difference between development system are sought in the language
itself. (rather than in library, VM/object model and compiler).

I do keep an eye open for hybrids. But I'm more interest if that is in the
context of a certain domainspecific goal, than in the general case.

In the general case it is often pretended a best of both worlds combination that
IMHO rarely delivers, because both sides limit the choices for the other.
Post by b***@gmail.com
But think about it, we
have had inline assembly capabilities within C and Pascal compilers
for ages. Also, interfaces to SQL are often realised as a kind of
inline SQL statement sequence. The Smalltalk derived message syntax in
Objective-C can be viewed as inline Smalltalk. This sort of thing is
fairly common and rather practical. When you look at it this way, the
notion of a hybrid language may no longer seem so outlandish.
Well, the first two are geared towards a specific problem domain. The first,
lowlevel machine interfacing, and the other one for RDBMS. (albeit one that
I find a bit doubtful, since SQL databases are in general less compatible to
eachother as most people tend to think).

Moreover, in the case of lowlevel functionality like internal assembler, one
also has to take into account that these are generally toolchains that are
entirely self contained, and often written (and bootstrapping) in them
selves. This means that their libraries are written in these languages, also
the lower level part (like exception/interrupt handling)

Quite a lot of the more lowlevel features of Free Pascal were primarily
meant for runtime library implementation reasons, not for enduser use.
Post by b***@gmail.com
Before I started with Objective-C I often had this dilemma that I
would rather use an imperative language for a project because of one
constraint, but rather use a higher level language because of another.
With a hybrid like Objective-C I no longer have to make this choice, I
get both in one.
We shall see. I sincerely hope you get the best of both worlds, and not the
worst of them.

(snip explanation compiling to Objective C)

Indeed I missed that the C basis is of course still there in Obj C. I assume
imperative modules are also still supported? (based on your namemangling
remark).

And yes, a codegenerator is a horrible amount of work. Even just the
maintaining and minor improvement (to e.g. optimization) But it also makes
you independant, flexible and well integrated.

There is no silver bullet here. Both approaches have their reasons. The HLL
generation route has the advantage that is quicker to implement and more
readily access to many architecture (though not entirely at zero cost as
often advocated)

Even FPC is not entirely self contained since it uses binutils, except on
Windows.
Post by b***@gmail.com
This has two benefits. It's less work than writing a traditional code
generator and it is useful as a verification tool to check if the
output is equivalent to the input, because the mappings are fairly
straight forward between M2 and C (other than for local procedures).
This will later come in very handy when writing the LLVM generator and
trying to figure out any bugs then (for example: do we have a silly
bug like forgotten to pop something from the stack, or do we have a
conceptual error in the translation scheme?)
If you support local procedures, the array thing is probably a minor
annoyance indeed.
Post by b***@gmail.com
I'm FPC's FreeBSD maintainer,
cool, do you have any coroutines support (or library) for FPC that
works on FBSD?
No. I don't really program embedded for FreeBSD/Linux atm. If you know a C
one, it probably can be ported.
Post by b***@gmail.com
I don't really like any of the currently popular general purpose scripting
languages, since for my feeling they don't add much. I usually jump right
from Object Pascal/C++ to domain specific languages (that really incorporate
modelling from the problem domain)
It seems to me that many if not most of those scripting languages are
meant for web development. I don't do web development, so I was never
surprised that those languages didn't seem to suit my needs much.
I've done webdevelopment professionally in the past, but used Delphi once
and ASP.NET the other time.

The problem of these scripting languages systems is that its fun if you
make a quick website, but for real webapps (like the auction sites for cars
that we made, every error costs Eur 40000+), determinism, and validation
makes them IMHO unfit.

I can see their use if you work internally in an organisation, and there is
always somebody you for some minor apps that interfaces to an
handful tables. Every second too much is wasted, and every bit of control is
redundant due to their simplicity and limited scope.
Post by b***@gmail.com
I use dynamic typing in Objective-C only where one would use generics
in Pascal, M2 or C++. If you have the choice of dynamic typing when
you want it, then you don't need generics
Ah, what is the substitute for the static validation generics in static
languages more or less guarantee?

(outlook on obj-m2 <-> static M2 hybrid implementation)

I can't agrue those points, since I don't know enough about the,. It's just
that I never have seen one that actually works, so forgive me my cynism.
Post by b***@gmail.com
In fact, Objective-C gives you the choice which garbage collection
scheme you want to use on a per object basis. You simply send a
message to it and depending on the message it is either reference
counted or automatic. In all other languages I know of, it is either
all garbage collected or nothing is. Again, I found the ability to
choose on a per object basis to be very helpful in practise.
Hmm. It is usually so yes, but that is a VM/GC strategy choice rather than a
language choice I think. It is often more the installed base of existing
code than the language spec that sets the initial choices in stone.
Post by b***@gmail.com
similar. But there are languages with fundamentally different
paradigms, Smalltalk being one of them, and if you know how to make
use of that, then it will make a significant difference.
But that is not necessarily to say that one paradigm is superior to
another. Sometimes it also has to do with how a given paradigm matches
your way of thinking and working. Sometimes a new paradigm can lead
you to change the way you think and work and the outcome may be
positive, but sometimes a paradigm just isn't compatible with the way
you like to do your stuff.
I never got a kick out of new paradigms as many others do. Sometimes I like
certain paradigms inside a specific application (like the Lispy dialect of
my calculator), but it rarely the revelation others seem to experience no
matter how I apply myself.
Post by b***@gmail.com
The most programmed language in the world is Excel macro language/VBScript.
Still I don't have an immediate urge to venture into that realm.
What I meant to say was that your perception of what Objective-C is may
have to change because it seemed to be based entirely on what the majority
of people who use it use if for. Consequently, if the majority of people
who use it use it for something different, then your perception would have
to shift. Ergo, Objective-C might soone have to be perceived as "the
iPhone development language" because it may turn out that most folks using
it will use it for that. You may then say, that it doesn't make sense to
base one's perception of a language on what others are using it for, but
that was actually the point I was trying to make ;-)
Sufficient to say that in general the main focus of a toolchain is often the
best tended to, and the presence on other targets less. And it is hard to
remain productive without peers that do things you also would do.
Post by b***@gmail.com
This is precisely where you are mistaken, you have an idea based on
what you think the majority of folks who use it are doing and what
those people are and how they fit into some box (eg. Apple fanboy) and
you dismiss anything that doesn't fit that perception.
Well, those are your words, not mine.
Post by b***@gmail.com
Yes, the acquisition and adoption of NextStep by Apple may have been
both a blessing and a curse. On the one hand it has added many more
users, on the other hand it has also led to the other areas in which
the environment was very strong and widespread before to be pushed
into the background.
I think all non vendor support dialects, and toolchains made by independant
vendors have taken a serious hit in the last ten years. I don't think that
Apple not adopting Obj-C would have avoided that for Objective C.
Post by b***@gmail.com
But that doesn't mean that anybody who picks up
Objective-C or its object system or the class libraries has to follow
this trend. It is perfectly reasonable to use this environment for non-
Mac non-GUI stuff and for its own merits. And it is equally reasonable
for somebody to write a clone for Windows (e.g. Cocotron) as it is for
somebody to write a .NET clone for *nix systems (e.g. Mono).
Yes. And I give the same lecture to people that mention Mono to me when we
are discussing .NET's ties with Windows.
Post by b***@gmail.com
I'm a bit scared. I do like LLVM, but I don't like the possible
ramifications of Apple adopting it. I'm a bit afraid that Apple will use it
to exert even more control over 3rd party developers. A bit like Java phones
that don't allow apps that are not signed, under the guise of "security".
Luckily there is a significant difference. The Java license doesn't
allow you to fork, the LLVM project's BSD style license does. So, if
Apple goes too bossy on the whole thing and upset developers in the
process, there'll be a fork.
Of LLVM, but not of the control of Apple over the access. If you can't
install the forked LLVM (because it has become a part of the OS), you can
fork till you turn blue without fixing this problem.
b***@gmail.com
2009-04-15 18:55:10 UTC
Permalink
Post by Marco van de Voort
Then you misunderstand my point. It is more about free choice of language
and development tools than about PDP-11.
My point was that the way OS APIs have come to look like across
platforms is an accident of history which might have turned out
differently.

At some point the standard on workstations was Lisp, everything was
Lisp, there was no way you could call the OS from Pascal or C, there
wasn't anything but Lisp anyway. Evidently, the Unix model has
replaced this but in a paralell universe where history turned the
other way, the Lisp OS approach might have prevailed, might have been
copied by anybody else, might have become truly ubiquitous. In that
universe the OS APIs would all be Lisp and that would be what people
would call "normal". There would probably be other programming
languages around, but they would all use Lisp calling conventions and
hook into the OS in the way Lisp does.

You don't think that in 50 or 100 or 500 years from now OS APIs will
still be the same we recognise today, do you? I don't. Given enough
time something will come along that fundamentally changes the whole
game.So I am not too nervous when new things aren't always entirely
backwards compatible. Change is part of life.
Post by Marco van de Voort
I don't buy that. If that was the case, they could just let users make up
their own minds and maintain a basic API as well as a higher level one.
Well, different vendors bet on different models and some models
survive, some don't, sometimes vendors don't survive. The Lisp vendors
all disappeared, many of the Unix vendors survived. Users exercise
their choices by using whichever products they want to use. This is
how we got where we are now.
Post by Marco van de Voort
I do keep an eye open for hybrids. But I'm more interest if that is in the
context of a certain domainspecific goal, than in the general case.
To me what I do in vanilla C when I write ObjC code is as much domain
specific as that which I have inlined assembly in the past. Likewise
for those bits which I use the OO extensions for. Just because the
code is interleaved doesn't mean that each part of the code cannot be
domain specific in respect of different problem domains. For me the
one problem domain is flow control and scalar calculations, the other
is modelling and managinag more complex data structures.

I prefer to use something like vanilla C or Pascal or Modula-2 for the
former and the Smalltalk derived extensions and class system in ObjC
for the latter. Other people have different preferences, fair enough,
but as far as separation by problem domain goes, I am doing the very
same thing: different language for a different problem domain, I just
draw the boundaries differently.
Post by Marco van de Voort
In the general case it is often pretended a best of both worlds combination that
IMHO rarely delivers, because both sides limit the choices for the other.
Well, I don't know for other hybrids, but as far as ObjC is concerned
I can say from years of using it that it does indeed deliver, that is,
it does for me. The reasons why I want to replace the C base with
somehting else have to do with C itself, not anything that the hybrid
can be held responsible for. If you mix C with whatever else, you will
of course inherit from C, including that which you'd rather not have
inherited, for example the absence of modules (in ObjC only classes
are modules, the rest is just like C).
Post by Marco van de Voort
Post by b***@gmail.com
With a hybrid like Objective-C I no longer have to make this choice, I
get both in one.
We shall see. I sincerely hope you get the best of both worlds, and not the
worst of them.
Maybe you misunderstand my situation. I have been using ObjC for many
years and what I said reflects my experiences using it. That is, I do
know that I _do_ get the best of both out of it because I have done
vanilla C, vanilla Smalltalk and ObjC.

Modula-2 and C are similar enough that I can say that replacing C with
M2 as the base language will be very similar to Objective-C, mostly it
will add data encapsulation for anything that isn't a class and it
will give me a stricter type checking regime for the non-OO bits,
which are the main reasons why I am pursuing this. Personal preference
has something to do with it of course but that alone wouldn't justify
the effort of writing a compiler. In any event, I think that based on
the experience with ObjC, I do know quite well, what I am going to get
from the new hybrid
Post by Marco van de Voort
Indeed I missed that the C basis is of course still there in Obj C. I assume
imperative modules are also still supported? (based on your namemangling
remark).
Absolutely, that's one of the main reasons why I wanted M2 as the base
language instead of C.
Post by Marco van de Voort
And yes, a codegenerator is a horrible amount of work. Even just the
maintaining and minor improvement (to e.g. optimization) But it also makes
you independant, flexible and well integrated.
There is no silver bullet here. Both approaches have their reasons. The HLL
generation route has the advantage that is quicker to implement and more
readily access to many architecture (though not entirely at zero cost as
often advocated)
Indeed, I am taking the HLL route simply to get started sooner, no
particular preference.
Post by Marco van de Voort
If you support local procedures, the array thing is probably a minor
annoyance indeed.
It would of course be easier to leave local procedures out to get
started even faster, but that's one of those things that always upsets
me about C (that I don't have local functions), so this is something I
definitely didn't want to sacrifice, not even temporarily.
Post by Marco van de Voort
Post by b***@gmail.com
cool, do you have any coroutines support (or library) for FPC that
works on FBSD?
No. I don't really program embedded for FreeBSD/Linux atm. If you know a C
one, it probably can be ported.
There is GNU pth and libtask. I use libtask because its lightweight
and I don't
need many of the fancier features in pth, but GNU Modula-2 uses pth
and Gaius seems
quite happy with it. GNU pth is probably more portable.
Post by Marco van de Voort
Ah, what is the substitute for the static validation generics in static
languages more or less guarantee?
If I understand the question correctly, you want to know how do you
ensure that the class written with dynamic typing in order to handle
different types of data can actually handle the data its being passed.

The answer is you have introspection methods to figure out what is
being passed and how to deal with it. There are several ways to do
that. One approach is delegation. That is to say, you have a
dynamically typed class that looks like it handles all data types but
it actually delegates the work to statically typed classes that
actually handle them. For data types you don't handle you can do error
handling/notification. The possibilities are manyfold. I actually
don't use dynamic typing a lot, but there are situations where it does
make life easier.
Post by Marco van de Voort
(outlook on obj-m2 <-> static M2 hybrid implementation)
I can't agrue those points, since I don't know enough about the,. It's just
that I never have seen one that actually works, so forgive me my cynism.
Well, it does work in ObjC. Anything that is not OO is just vanilla C,
and all the variables
static, on the stack or on the heap, they are all statically typed,
just that C compilers don't enforce types very strictly. But that is
not a property of the hybrid, its a property of C, so if you replace
the C base with something that does enforce types more rigorously,
e.g. M2, or even Pascal, then that is what you get. Heck you could
make a C base language that does enforce typing. The enforcement by
the compiler is not suddenly going to fail simply because there are OO
features added with classes for which typing is optionally dynamic
(under programmer control).

say you have ...

int index;

MyClass *foo = [[MyClass alloc] initWithFoo: foobar];

id *bar = foo;

for (index = 0; index < someMax; index++) {

[foo doSomethingWithNumber: index];

[bar doSomeOtherThing];

} // end for


the vanilla C variable index is statically typed (although th C
compiler is rather lax about it), class foo is statically typed, class
bar is dynamically typed (id)

if you replace the C base language with M2, it becomes ...

VAR
index : INTEGER;
foo : MyClass;
bar : OBJECT;

...

foo := [[MyClass alloc] initWithFoo: foobar];
bar := foo;

FOR index := 0 TO someMax DO

[foo doSomethingWithNumber: index];

[bar doSomeOtherThing];

END; (* FOR *)

now vanilla M2 variable index is not only statically typed but
strictly enforced, too. class foo remains statically typed as it was
in ObjC, class bar remains dynamically typed as it
was in ObjC.

There is no reason why the OO semantics would magically mess up the
non-OO semantics. There is a very clear separation between the two
domains. The non-OO stuff remains exactly as it is in vanilla M2, the
OO stuff remains exactly as it is in ObjC.
Post by Marco van de Voort
Hmm. It is usually so yes, but that is a VM/GC strategy choice rather than a
language choice I think. It is often more the installed base of existing
code than the language spec that sets the initial choices in stone.
As far as I can see, many of the languages around these days are
designed specifically to have gc, or not to have it. The only language
I know of where you can just link to a library and get gc as a result
of that is C with the Boehm collector. But even then, everything is
being collected.

Its typically everyting is or nothing is, even if you can make the
choice for your program once. Likewise with dynamic and static typing,
it is usually all static or all dynamic. Likewise, many OO languages
follow an everything-is-an-object paradigm, even for things like index
variables for a for-loop, doesn't seem to make sense to me.

What I was getting at is that in ObjC the general notion is that you
decide on a per item, not a per program basis, what you want, scalar
or object, statically or dynamically typed, manually or automatically
collected. I have come to find this very useful in practise.
Post by Marco van de Voort
I never got a kick out of new paradigms as many others do. Sometimes I like
certain paradigms inside a specific application (like the Lispy dialect of
my calculator),
Same here. Perhaps that's why I like the hybrid approach of ObjC, I
don't have to jump ship, I can pick which paradigm I want to use and
do so _not_ on an all-or-nothing basis, but on a per code snippet
basis, all within the same program. Works well for me.
Post by Marco van de Voort
Sufficient to say that in general the main focus of a toolchain is often the
best tended to, and the presence on other targets less. And it is hard to
remain productive without peers that do things you also would do.
But this ignores the fact that ObjC and OpenStep was created many many
years ago for other uses than what is mainstream today, which was my
point. Apple may have added features and classes towards a new focus,
but that doesn't mean that the whole lot loses its suitability for
those things that were focus many years ago. The language and the
frameworks haven't changed that dramatically, they have added a bit of
syntactic sugar and more classes, but essentially, the whole thing is
still functionally the same it was when all the Wallstreet who is who
used it to model their financial stuff with it.
Post by Marco van de Voort
Of LLVM, but not of the control of Apple over the access. If you can't
install the forked LLVM (because it has become a part of the OS), you can
fork till you turn blue without fixing this problem.
I think Apple can impose this kind of control on a phone, but not
elsewhere. If you cannot use any other compiler than Apple's, not
because there is nobody who wants to build one, but because Apple
doesn't allow it, I think that would probably kill the platform. I
might be wrong but I don't think that is the direction they are going.
Marco van de Voort
2009-04-18 16:20:41 UTC
Permalink
On 2009-04-15, ***@gmail.com <***@gmail.com> wrote:

( I got a bit more clarity about your reasons for Objective M2 now. And
while I'm not (yet) in the ObjC/Smalltalk camp, assuming I were, I
understand and underwrite them.

Let's focus on the OS interface part of the discussion. (the first few and
last paragraph)
)
Post by b***@gmail.com
Post by Marco van de Voort
Then you misunderstand my point. It is more about free choice of language
and development tools than about PDP-11.
My point was that the way OS APIs have come to look like across
platforms is an accident of history which might have turned out
differently.
Well, I do not agree. A few systems that were mostly academic-only, like the
LISP workstation (AI labs mostly), and Oberon are IMHO bad examples.

And the reason why LISP didn't prevail is not sheer coincidence, but because
the procedural (which is IMHO totally not the same as Unix-) way was simply
an acceptable compromise for a computer community fragmented over a
gazillion languages and runtime systems, and LISP with its very specific
demands and engine not. Except on my HP calculator that is.
Post by b***@gmail.com
Well, different vendors bet on different models and some models
survive, some don't, sometimes vendors don't survive.
I hope the ones that try to force languages on the users don't make it.
Post by b***@gmail.com
The Lisp vendors all disappeared, many of the Unix vendors survived.
Yes. Microsoft and IBM. However Microsoft is not very active in Unix land
anymore (or after say 1990), and IBM distributes a third party product
(Linux) as much as its own Unix (AIX).

Sun is on the verge of being taken over, one of Santa Cruz offspring, SCO ,
is in bankruptcy procedings, the other is Novell which is peddling Linux,
HPUX is on lifesupport due to longliving contracts, but HPs main business is
windows servers. Wind River stopped major BSD development afaik.

Short: Old Unix is dead.
Post by b***@gmail.com
Users exercise their choices by using whichever products they want to use.
This is how we got where we are now.
I consider that a bit naieve. They can vote with their feet of course, but
in general there are more reasons to be attached to a platform than just
language and interfacing.
Post by b***@gmail.com
I prefer to use something like vanilla C or Pascal or Modula-2 for the
former and the Smalltalk derived extensions and class system in ObjC
for the latter. Other people have different preferences, fair enough,
but as far as separation by problem domain goes, I am doing the very
same thing: different language for a different problem domain, I just
draw the boundaries differently.
We'll see. I meant a bit more domainspecific btw ;_)
Post by b***@gmail.com
it does for me. The reasons why I want to replace the C base with
somehting else have to do with C itself, not anything that the hybrid
can be held responsible for. If you mix C with whatever else, you will
of course inherit from C, including that which you'd rather not have
inherited, for example the absence of modules (in ObjC only classes
are modules, the rest is just like C).
Clear, and I of course fully agree with that.
Post by b***@gmail.com
Post by Marco van de Voort
Post by b***@gmail.com
With a hybrid like Objective-C I no longer have to make this choice, I
get both in one.
We shall see. I sincerely hope you get the best of both worlds, and not the
worst of them.
Maybe you misunderstand my situation. I have been using ObjC for many
years and what I said reflects my experiences using it.
I think I did yes. It is more replacing the C underpinnings of Obj-C with M2
than developing a new hybrid concept. It makes more sense now, thanks.
Post by b***@gmail.com
Post by Marco van de Voort
Indeed I missed that the C basis is of course still there in Obj C. I assume
imperative modules are also still supported? (based on your namemangling
remark).
Absolutely, that's one of the main reasons why I wanted M2 as the base
language instead of C.
Clear, so we got that part sorted out.
Post by b***@gmail.com
Post by Marco van de Voort
If you support local procedures, the array thing is probably a minor
annoyance indeed.
It would of course be easier to leave local procedures out to get
started even faster, but that's one of those things that always upsets
me about C (that I don't have local functions), so this is something I
definitely didn't want to sacrifice, not even temporarily.
Maybe I should clarify that:

The ugly problem is the passing nested procs as procvar to something else,
while they can still access their parents variables. At least in Pascal.
(and Borland style Pascals, FPC included don't do that properly). How is
that in M2? I wasn't as deep into such details yet when I did M2.
Post by b***@gmail.com
Post by Marco van de Voort
No. I don't really program embedded for FreeBSD/Linux atm. If you know a C
one, it probably can be ported.
There is GNU pth and libtask. I use libtask because its lightweight and I
don't need many of the fancier features in pth, but GNU Modula-2 uses pth
and Gaius seems quite happy with it. GNU pth is probably more portable.
libtask is MIT/BSD, GNU is LGPL. Since for embedded applications you'd want
to statically link, licensewise I'd prefer libtask.
Post by b***@gmail.com
Post by Marco van de Voort
Ah, what is the substitute for the static validation generics in static
languages more or less guarantee?
If I understand the question correctly, you want to know how do you
ensure that the class written with dynamic typing in order to handle
different types of data can actually handle the data its being passed.
Yes, and as much of it without running it, since testing all codepaths for
every build is often hard in reasonably sized apps. IOW how do I avoid
programmer errors.
Post by b***@gmail.com
I actually don't use dynamic typing a lot, but there are situations where
it does make life easier.
I think that is the answer: You don't mass apply it, only when needed.

(skipped parts about the hybrid. As said I missed the part that statical C
is fully in Obj C).
Post by b***@gmail.com
Post by Marco van de Voort
Hmm. It is usually so yes, but that is a VM/GC strategy choice rather than a
language choice I think. It is often more the installed base of existing
code than the language spec that sets the initial choices in stone.
As far as I can see, many of the languages around these days are
designed specifically to have gc, or not to have it. The only language
I know of where you can just link to a library and get gc as a result
of that is C with the Boehm collector. But even then, everything is
being collected.
( I don't see btw why it wouldn't work for Pascal and/or most other static
languages, and afaik there are people that do such things in Delphi, though
I don't know on what scale. Some might need a bit more runtime library
adaption than C (to avoid trouble with automated types), but not too much)
Post by b***@gmail.com
Post by Marco van de Voort
Sufficient to say that in general the main focus of a toolchain is often the
best tended to, and the presence on other targets less. And it is hard to
remain productive without peers that do things you also would do.
syntactic sugar and more classes, but essentially, the whole thing is
still functionally the same it was when all the Wallstreet who is who
used it to model their financial stuff with it.
True. But the point is if I'm a non-Mac stepper, my circle gets awfully
small.
Post by b***@gmail.com
Post by Marco van de Voort
Of LLVM, but not of the control of Apple over the access. If you can't
install the forked LLVM (because it has become a part of the OS), you can
fork till you turn blue without fixing this problem.
I think Apple can impose this kind of control on a phone, but not
elsewhere. If you cannot use any other compiler than Apple's, not
because there is nobody who wants to build one, but because Apple
doesn't allow it, I think that would probably kill the platform. I
might be wrong but I don't think that is the direction they are going.
I think it is, albeit very slowly and phased. And maybe the initial reasons
where more architecture independance related, and making a start with
avoiding legacy software that inhibits that. (with all Mac arch conversions
m68k->ppc32->ppc64->x86->x86_64 (soon)).

But the result is still the same: making choice harder.
Chris Burrows
2009-04-19 04:34:18 UTC
Permalink
Post by Marco van de Voort
Post by b***@gmail.com
Post by Marco van de Voort
If you support local procedures, the array thing is probably a minor
annoyance indeed.
It would of course be easier to leave local procedures out to get
started even faster, but that's one of those things that always upsets
me about C (that I don't have local functions), so this is something I
definitely didn't want to sacrifice, not even temporarily.
The ugly problem is the passing nested procs as procvar to something else,
while they can still access their parents variables. At least in Pascal.
(and Borland style Pascals, FPC included don't do that properly). How is
that in M2? I wasn't as deep into such details yet when I did M2.
The problem does not arise. In M2 (and Oberon) procedure types are
restricted to procedures that are not local to another procedure and that
are not standard procedures.

--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/modula2
Marco van de Voort
2009-04-19 10:23:37 UTC
Permalink
Post by Chris Burrows
Post by Marco van de Voort
The ugly problem is the passing nested procs as procvar to something else,
while they can still access their parents variables. At least in Pascal.
(and Borland style Pascals, FPC included don't do that properly). How is
that in M2? I wasn't as deep into such details yet when I did M2.
The problem does not arise. In M2 (and Oberon) procedure types are
restricted to procedures that are not local to another procedure and that
are not standard procedures.
Ok clear, thanks

As said Borland pascal's don't have it either (though the Turbo Vision
framework uses a similar feature assembler assisted, depending on programmer
discipline). I'm told it is quite handy for a general foreach like
construct, but I don't have real own experience with it.
Martin Whitaker
2009-04-16 13:27:29 UTC
Permalink
Post by b***@gmail.com
I agree. One of the main reasons that made Modula-2 attractive was its
simplicity, but ISO Modula-2 is almost as bad as Ada and C++, not
quite, but definitely no longer simple enough to be appealing to me.
This seems a bit of an overstatement. Leaving aside the standard library
(which is probably not relevant for your purpose), the base ISO M2 standard added

- COMPLEX and LONGCOMPLEX data types
- exception handling
- module termination
- constant constructors (in PIM these were only allowed for sets)

Compared to Ada or C++, this is not a huge step in complexity. Don't forget
that the OO and Generics extensions are optional, not part of the base language.

The ISO standard may be lengthy, but that is because it tries to remove all
ambiguity. As anyone who had to maintain code across a range of pre-ISO
compilers will tell you, there is a lot of ambiguity in PIM. Every effort was
made by the ISO committee to maintain backwards compatibility with existing
code, but it was often not possible to find common ground across all the
different compilers.

Martin
b***@gmail.com
2009-04-16 16:39:44 UTC
Permalink
Post by Martin Whitaker
Compared to Ada or C++, this is not a huge step in complexity. Don't forget
that the OO and Generics extensions are optional, not part of the base language.
My comment was geared at the complete ISO standard, including optional
parts, but fair enough.
Post by Martin Whitaker
The ISO standard may be lengthy, but that is because it tries to remove all
ambiguity.
That's alright, I don't necessarily have gripes with the lengthy
specification.

However, I do think that Wirth was right to remove a number of things
in Oberon. I personally think he went a little too far, but in
principle I agree.

As for ISO extensions, the ivory-toweredness of it all is best
illustrated by the fact that COMPLEX is built-in but nothing to handle
multibyte characters. More likely than not, somebody who requires a
complex data type will have a preference for FORTRAN anyway and won't
be won over. But in this day and age, multi-byte characters are an
absolute must. They clearly got their priorities wrong on. There was
also a proposal to add BCD which was withdrawn by the authors to avoid
feature creap, the complex camp should have followed their example,
but they were like little kids in a candy shop.

Perhaps ISO should change their charter for programming language
standardisation, establish a rule that the first standard must not
define language extensions but stick to clarification only. Extensions
should only be permitted in a revised standard to be followed no
earlier than a given number of years later. After all it is called
ISO, with S for standardisation, not IDO with D for design. But I
digress.
Martin Whitaker
2009-04-19 20:39:57 UTC
Permalink
Post by b***@gmail.com
Post by Martin Whitaker
Compared to Ada or C++, this is not a huge step in complexity. Don't forget
that the OO and Generics extensions are optional, not part of the base language.
My comment was geared at the complete ISO standard, including optional
parts, but fair enough.
So I would encourage you to base your work on the ISO standard. You don't have
to implement the entire standard - it specifically allows for conforming
implementations to have limited compliance (see section 4.10 if you have a
copy of the standard).
Post by b***@gmail.com
Post by Martin Whitaker
The ISO standard may be lengthy, but that is because it tries to remove all
ambiguity.
That's alright, I don't necessarily have gripes with the lengthy
specification.
However, I do think that Wirth was right to remove a number of things
in Oberon. I personally think he went a little too far, but in
principle I agree.
There are a few things I could live without (local modules for example), but I
think he went much too far. For low level applications, unsigned integer types
are essential. For both low and high level applications, the abstraction and
type-safety provided by sub-ranges, enumerations, and sets are hugely beneficial.
Post by b***@gmail.com
As for ISO extensions, the ivory-toweredness of it all is best
illustrated by the fact that COMPLEX is built-in but nothing to handle
multibyte characters. More likely than not, somebody who requires a
complex data type will have a preference for FORTRAN anyway and won't
be won over. But in this day and age, multi-byte characters are an
absolute must. They clearly got their priorities wrong on. There was
also a proposal to add BCD which was withdrawn by the authors to avoid
feature creap, the complex camp should have followed their example,
but they were like little kids in a candy shop.
The converse argument for COMPLEX is that unless you offer a language with a
built-in complex data type, you stand no chance of winning over the FORTRAN
users. I agree with you though - this is almost certainly a lost cause.

It is not true that the ISO standard doesn't support multi-byte characters -
it is carefully written to avoid specifying any particular character coding
(apart from one gotcha, which I'll come back to). What is true is that it only
supports one built-in character type, on the basis that there is no sensible
number between one and infinity.

In the late '80s / early '90s, there was no real consensus on how to support
large character sets - Unicode was by no means universally accepted. The M2
standardisation committee did liase with another ISO committee that was
charged with developing cross-language standards for character coding, but it
was clear that they weren't going to come up with a solution within the
required timescale for publishing the M2 standard.

So the chosen solution was to allow the language to support an unspecified
native character coding. It was expected that implementations would gradually
evolve towards supporting multi-byte character codes (apart from
implementations targetting embedded systems, which would no doubt stick with
single byte character codes).

The gotcha is the requirement that an implementation must support "SET OF
CHAR". This is a bit impractical for large character sets, and I think has to
be ignored for multi-byte character codes.
Post by b***@gmail.com
Perhaps ISO should change their charter for programming language
standardisation, establish a rule that the first standard must not
define language extensions but stick to clarification only. Extensions
should only be permitted in a revised standard to be followed no
earlier than a given number of years later. After all it is called
ISO, with S for standardisation, not IDO with D for design. But I
digress.
Actually this was pretty much the guiding principle for M2 standardisation
(the OO and Generics extensions did follow later, and anyway are not part of
the base standard). Clarification has to include resolving ambiguities (which
inevitably leads to some people being upset!) and fixing portability issues
(for example, address arithmetic in PIM didn't map well to the 8086 segmented
address space). Only two major changes were approved at the start of the
standardisation process:

- it was considered that a modern programming language needed to
support exceptions and finalisation

- it was considered that the "standard" library modules described in
later editions of PIM were not adequate for real applications

(personally I agree with both of these decisions - when I started using M2, I
had to roll my own solution to both of the above, and I'm sure many other
people did the same)

It was originally intended that exceptions and finalisation would be supported
via library modules - it was only after repeated attempts to achieve this were
deemed too ugly to live that these features made it into the language proper.
I suspect that if anyone had realised how much grief this was going to cause,
it would have been ruled out at the very beginning.

COMPLEX made it in very late in the standardisation process (it had been
rejected earlier). I was quite surprised it was accepted.

Martin
b***@gmail.com
2009-04-20 04:48:06 UTC
Permalink
Post by Martin Whitaker
So I would encourage you to base your work on the ISO standard.
There is a related Q in the Objective Modula-2 FAQ. In a nutshell,
right now, the priority must be on getting a working compiler for the
general public completed. Afterwards, I don't rule out partial
compliance.
Post by Martin Whitaker
You don't have to implement the entire standard - it specifically allows for
conforming implementations to have limited compliance
Yes, I vaguely remember.
Post by Martin Whitaker
There are a few things I could live without (local modules for example), but I
think he went much too far. For low level applications, unsigned integer types
are essential.
Absolutely.
Post by Martin Whitaker
For both low and high level applications, the abstraction and
type-safety provided by sub-ranges, enumerations, and sets are hugely beneficial.
I am sympathetic to arrays always starting at index 0. Back in the day
when I used Pascal as a student I might have used some arrays starting
with index 1, but since then I never used nor ever needed indices to
start with anything but zero. That is not to say that I don't favour
automatic bounds checking (inserted by the compiler).

As for enumerations, I would not want to use any imperative language
which doesn't have them. I'd rather have operator precedence removed
than enumeration types. This alone was reason enough for me never to
want to use Oberon.

The often stated reason that enumeration members may cause name
conflicts even when imported qualified is bogus. Just qualify the
member identifiers, problem solved:

TYPE status = (failure, success); => status.failure, status.success

It makes the program more readable, too. I might actually use this at
some stage.

But to me the worst of all the Oberon omissions has got to be the
combination of interface and implementation. This totally violates my
sense of tidiness and readability of code.

For one, anything that forces the hordes of lazy bugger programmers to
write at least some code (ever heard or read the phrase "dude, it's
self-explanatory) is a good thing.

Second, implementation detail should not be visible at all, NEVER!
Mixing the two only increases clutter, it's like a book going to print
with all the author's scribbled notes still in. Yes, I can try to
ignore them when reading the book, but I'd rather prefer not to have
to do that. The focus should be on what is convenient for the reader
when reading, not what is convenient for the author when writing. Same
with software.

As a library author I am happy to make this extra effort for the
library user. As a library user I want the author to put in the effort
to write a proper interface description for me. If he is too lazy and
cannot be bothered to do that, screw him!
Post by Martin Whitaker
It is not true that the ISO standard doesn't support multi-byte characters
What I meant is a built in type that represents multi-byte characters
and libraries with operations/manipulations for objects of that type,
e.g. UNICHAR. At some point if you generalise too much, you leave all
the hard work to the user who then basically has to implement his own
multi-byte library from scratch. The language doesn't prevent him from
doing that, but it doesn't exactly provide him with the tools he needs
either, he's got to roll his own.
Post by Martin Whitaker
In the late '80s / early '90s, there was no real consensus on how to support
large character sets - Unicode was by no means universally accepted. The M2
standardisation committee did liase with another ISO committee that was
charged with developing cross-language standards for character coding, but it
was clear that they weren't going to come up with a solution within the
required timescale for publishing the M2 standard.
It is notable that there was never anybody from JIS who attended any
of the ISO WG13 meetings nor am I aware of any correspondence. Japan
did vote against the standard though, perhaps they expected others to
do the hard work for them. Other multi-byte character set using
countries weren't even nominally involved.
Post by Martin Whitaker
So the chosen solution was to allow the language to support an unspecified
native character coding. It was expected that implementations would gradually
evolve towards supporting multi-byte character codes
But how many years has it been since? There could have well been an
addendum to the standard for proper multi-byte support in M2
afterwards.
Post by Martin Whitaker
(apart from implementations targetting embedded systems, which would no doubt stick
with single byte character codes).
That is a misperception. I do embedded work. These days many embedded
devices have built-in web servers to provide an interface to configure
them. Many products are localised for China, Japan, Korea and Taiwan
and we do need multi-byte character support on them.
Post by Martin Whitaker
The gotcha is the requirement that an implementation must support "SET OF
CHAR". This is a bit impractical for large character sets, and I think has to
be ignored for multi-byte character codes.
It is impractical already to assume that CHAR should be extended to
include multi-byte character sets. It is far more practical to have
separate types for single-byte and multi-byte character sets, not just
for the reason you are giving.
Post by Martin Whitaker
Only two major changes were approved at the start of the
   - it was considered that a modern programming language needed to
     support exceptions and finalisation
   - it was considered that the "standard" library modules described in
     later editions of PIM were not adequate for real applications
(personally I agree with both of these decisions - when I started using M2, I
had to roll my own solution to both of the above, and I'm sure many other
people did the same)
As I had mentioned earlier in this thread, there is always a good
reason why to add one more feature but you can never tell at which
point you should have stopped adding.

I personally think that anything that is not just a clarification of
PIM should not have been accepted into the base standard, as a matter
of principle. Standardisation comittee meetings are horse trading
gatherings. Pandorra's box was one of top referred to items in WG13
disussions. If you establish a principle that nothing can be added
than that's it, nobody can expect any favours to sneak something in,
as evidently was the case with COMPLEX.

A small and simple base standard that is very close to the language as
introduced and presented in all the published books, most notably PIM,
but also secondary literature, has the benefit that you can expect
almost every compiler to become compliant fairly soon after the
standard is published. Add too much new stuff and either implementors
won't bother at all, or they will put it off for so long that the
standard becomes a paper tiger and the language will eventually fall
into decline because everybody is sitting on the fence. One can only
shrug considering that OF ALL PEOPLE, it was the Modulans who couldn't
resist feature creep in their standard. If they couldn't, then who can?
Chris Burrows
2009-04-20 08:04:16 UTC
Permalink
Post by b***@gmail.com
The often stated reason that enumeration members may cause name
conflicts even when imported qualified is bogus. Just qualify the
TYPE status = (failure, success); => status.failure, status.success
It makes the program more readable, too. I might actually use this at
some stage.
Language design questions such as these always have to be considered in the
complete context to be sensibly discussed. They can rarely ever be properly
judged in isolation.

e.g. for Modula-2 that might well be a satisfactory approach. However, in
the case of Oberon, once the decison had been made to require the explicit
qualification of all imported types it becomes less satisfactory. i.e. it
would result in something of the sort:

result := FileSystem.status.success;

This is starting to become uncomfortably unwieldy.

However, that is just one example - there are numerous arguments both for
and against enumerations. For my part (despite tendencies towards a
perfectionist-obsessed personality ;-)) I appreciate that a language design
is never going to be all things to everybody. I am eternally thankful that I
am fortunate enough to be able to derive great satisfaction from programming
in *both* Modula-2 with enumerations and Oberon without. The alternative
doesn't bear thinking about ...

--
Chris Burrows
CFB Software

Armaide: ARM Oberon-07 Development System
http://www.cfbsoftware.com/armaide

Lilith and Modula-2
http://www.cfbsoftware.com/modula2
b***@gmail.com
2009-04-20 08:43:58 UTC
Permalink
    result := FileSystem.status.success;
And why would that be any worse than:

FILESYSTEM_STATUS_SUCCESS,
FILESYSTEM_STATUS_LOOP_IN_PATH,
FILESYSTEM_STATUS_INVALID_DIRECTORY,
....
Marco van de Voort
2009-04-20 09:44:19 UTC
Permalink
Post by b***@gmail.com
    result := FileSystem.status.success;
FILESYSTEM_STATUS_SUCCESS,
FILESYSTEM_STATUS_LOOP_IN_PATH,
FILESYSTEM_STATUS_INVALID_DIRECTORY,
It isn't. But such regimes are for languages with a global namespace.

With modular languages the enum names are usually not in such format, and
qualification is only done when a name-clash is expected. (and the enum
typesafety avoids the worst errors even then, contrary to some other
languages where enum is type compat with int(eger)).
b***@gmail.com
2009-04-20 12:02:01 UTC
Permalink
Post by Marco van de Voort
Post by b***@gmail.com
    result := FileSystem.status.success;
FILESYSTEM_STATUS_SUCCESS,
FILESYSTEM_STATUS_LOOP_IN_PATH,
FILESYSTEM_STATUS_INVALID_DIRECTORY,
It isn't. But such regimes are for languages with a global namespace.
With modular languages the enum names are usually not in such format, and
qualification is only done when a name-clash is expected.
unless you use Oberon, which is modular but all imported identifiers
are _always_ qualified. The point of the example was to say that it
would have been preferable to have FileSystem.status.success instead
of not having any enumeration at all.

Should I add qualified enumeration types to my compiler, I would most
certainly want to allow import such that all three possibilities are
possible, that is "stat := success;", "stat := status.success;" and
"stat := FileSystem.status.success;".

There is also the technique of aliased import ...

IMPORT FileSystem.status As fstat;

leading to "stat := fstat.success"

I have experimented with aliased import and found it quite useful. I
might use it in a future version. I left it out mostly because I am
still not sure if it should be implemented as a textual replacement
(hiding it from the parser) or not.

What I am saying is that removing enumeration types altogether seems
to me the worst amongst the possible ways to deal with enumeration
member name clashes.
Marco van de Voort
2009-04-22 09:14:08 UTC
Permalink
Post by b***@gmail.com
Post by Marco van de Voort
It isn't. But such regimes are for languages with a global namespace.
With modular languages the enum names are usually not in such format, and
qualification is only done when a name-clash is expected.
unless you use Oberon, which is modular but all imported identifiers
are _always_ qualified.
But then it doesn't hurt to also export them to the module scope. Such
compromise was probably not orthogonal enough, but the alternative (hordes
of untyped integer constants) doesn't sound appealing either.
Post by b***@gmail.com
There is also the technique of aliased import ...
IMPORT FileSystem.status As fstat;
leading to "stat := fstat.success"
I have experimented with aliased import and found it quite useful. I
might use it in a future version. I left it out mostly because I am
still not sure if it should be implemented as a textual replacement
(hiding it from the parser) or not.
Text substitution is not M2 in spirit IMHO. I'd expect fstat to be a local
symbol (though alias for an external), and thus it should collide with
attempts to redefine it, to avoid surprises or weird errors msgs when sb
tries to redefine fstat (or imports it after the alias from another module)
Post by b***@gmail.com
What I am saying is that removing enumeration types altogether seems
to me the worst amongst the possible ways to deal with enumeration
member name clashes.
I agree fully there.
b***@gmail.com
2009-04-23 03:19:52 UTC
Permalink
Post by Marco van de Voort
Post by b***@gmail.com
unless you use Oberon, which is modular but all imported identifiers
are _always_ qualified.
But then it doesn't hurt to also export them to the module scope. Such
compromise was probably not orthogonal enough, but the alternative (hordes
of untyped integer constants) doesn't sound appealing either.
The problem is that the way in which enumeration members have been
referenced has not been orthogonal to begin with. On the one hand
there is one compound type, RECORD, the members of which are always
referenced qualified (Blob.foo, Blob.bar, Blob.baz), well, unless a
WITH DO scope is used; on the other hand there is another compound
type, enumerations, the members of which are not referenced qualified.

It would have been orthogonal design if enumeration type members had
been treated just like record type members from the very start.

TYPE Blob = (foo, bar, baz);

=> Blob.foo, Blob.bar, Blob.baz

and perhaps

WITH Blob DO
=> foo, bar, baz
END; (* WITH *)

If this orthogonality had been used right from the start (say in
Pascal), then it would only have been a logical step to carry this
into Modula-2 with both qualified and unqualified import ...

FROM Blobs IMPORT Blob; => Blob.foo, Blob.bar, Blob.baz

IMPORT Blobs; => Blobs.Blob.foo, Blobs.Blob.bar, Blobs.Blob.baz

just the same as record types are treated.

Note that nobody complained that record type member names are
"unwieldy" in Oberon. In fact WITH DO, the instrument which would have
allowed to make those record member identifiers less "unwieldy" has
been omitted in Oberon. That is to me the proof in the pudding that
the reason given, that enumeration import may cause name collisions,
is bogus, because if that truly was the reason, then record types
should also have been omitted. Clearly this is a circular argument,
enumerations are omitted because Wirth and Gutknecht didn't want them,
it was based on personal taste of the designers alone.

Consequently, if you do not share this personal taste of Messrs Wirth
and Gutknecht, and you are seriously concerned about the possibility
of name collisions when importing enumerations, then you have to look
for a more serious solution to the problem. It seems to me that going
back to the beginnings and ask the questions "Why are record members
qualified and enumeration members are not?!" is precisely the kind of
question Messrs Wirth and Gutknecht should have asked.

Since they did not seem to have had any problem with the
"unwieldiness" of

module.record.member

then there is absolutely no reason why they should have had a problem
with the "unwieldiness" of

module.enumeration.member

In any event, this would have been an orthogonal solution to the
problem of enumeration member name collisions in an Oberon fashion. In
Modula-2 there would have been the additional option of unqualified
import, omitting the module name.
Chris Burrows
2009-04-23 06:27:56 UTC
Permalink
Post by b***@gmail.com
enumerations are omitted because Wirth and Gutknecht didn't want them
Note that Gutknecht has incorporated enumerated types in the design of his
latest language, Zonnon:

http://www.zonnon.ethz.ch/

--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/modula2
b***@gmail.com
2009-04-23 11:15:01 UTC
Permalink
Post by Chris Burrows
Post by b***@gmail.com
enumerations are omitted because Wirth and Gutknecht didn't want them
Note that Gutknecht has incorporated enumerated types in the design of his
http://www.zonnon.ethz.ch/
Interesting. Thanks for sharing that.

The Zonnon report states "Some features have been reintroduced from
earlier members of the Pascal language family, for example the
definition, implementation pairs and enumeration types from
Modula-2 ..."

I also notice that cardinal is back, too.

I can only interpret this in one way: Gutknecht realised that omitting
enumerations and unsigned integers, and combining interface and
implementation modules in Oberon was a mistake.

It is also interesting to see that Zonnon does use qualified
identifiers for enumeration type members: "Names in separate
enumerations need not be different as their use is always qualified.
So for example NumberKind.Oct is distinct from Month.Oct."

Some other interesting things I saw ...

A modifier for variables "immutable", Objective Modula-2 has
<*READONLY*> (as a pragma) for the same purpose.

A modifier for classes "refines", Objective Modula-2 has "EXTENDS" for
the same purpose.

I like Gutknechts choice of words better, and may borrow them.
Especially with "EXTENDS" we had never ending discussions whether it
was a suitable choice because it didn't reflect the refinement aspect.
Why did nobody think of "REFINES" I wonder :-)

Reserved words in Zonnon are all-lowercase with all-uppercase
synonyms, I was thinking about doing just that myself to appease some
of the Pascal users who have written in complaining about uppercase
reserved words. And this definitely encourage me do actually go and do
it.

Oh dear, I will have to fiddle with that minimal perfect hash
algorithm yet _again_ ...

But anyway, Zonnon looks rather interesting. Unfortunately, the
compiler is for Windows only, no *nix version for it, :-(
Chris Burrows
2009-04-23 13:20:49 UTC
Permalink
Post by b***@gmail.com
But anyway, Zonnon looks rather interesting. Unfortunately, the
compiler is for Windows only, no *nix version for it, :-(
It's written for the .NET framework so the command-line compiler also runs
under Mono on *inux. On the download page look for:

"For Mono/Rotor (Eclipse plugin)
A Linux/Windows version of the Zonnon command line compiler working on
Mono."

http://www.zonnon.ethz.ch/compiler/download.html

--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/modula2
Rob Solomon
2009-06-21 19:58:37 UTC
Permalink
Does Zonnon require visual studio, or merely support it?

I do not have visual studio.

If I wanted to learn C, I would not be interested in zonnon.



On Thu, 23 Apr 2009 22:50:49 +0930, "Chris Burrows"
Post by Chris Burrows
Post by b***@gmail.com
But anyway, Zonnon looks rather interesting. Unfortunately, the
compiler is for Windows only, no *nix version for it, :-(
It's written for the .NET framework so the command-line compiler also runs
"For Mono/Rotor (Eclipse plugin)
A Linux/Windows version of the Zonnon command line compiler working on
Mono."
http://www.zonnon.ethz.ch/compiler/download.html
Chris Burrows
2009-06-22 00:32:01 UTC
Permalink
Post by Rob Solomon
On Thu, 23 Apr 2009 22:50:49 +0930, "Chris Burrows"
Post by Chris Burrows
Post by b***@gmail.com
But anyway, Zonnon looks rather interesting. Unfortunately, the
compiler is for Windows only, no *nix version for it, :-(
It's written for the .NET framework so the command-line compiler also runs
"For Mono/Rotor (Eclipse plugin)
A Linux/Windows version of the Zonnon command line compiler working on
Mono."
http://www.zonnon.ethz.ch/compiler/download.html
Does Zonnon require visual studio, or merely support it?
I do not have visual studio.
If I wanted to learn C, I would not be interested in zonnon.
See my reply in the new discussion that you started with subject "zonnon"

Chris

Rob Solomon
2009-06-21 20:44:52 UTC
Permalink
Does Zonnon require visual studio, or does it merely integrate w/ it?

If I wanted to learn C, I would not be interested in Zonnon.

Thanks


On Thu, 23 Apr 2009 22:50:49 +0930, "Chris Burrows"
Post by Chris Burrows
Post by b***@gmail.com
But anyway, Zonnon looks rather interesting. Unfortunately, the
compiler is for Windows only, no *nix version for it, :-(
It's written for the .NET framework so the command-line compiler also runs
"For Mono/Rotor (Eclipse plugin)
A Linux/Windows version of the Zonnon command line compiler working on
Mono."
http://www.zonnon.ethz.ch/compiler/download.html
Marco van de Voort
2009-04-24 12:58:24 UTC
Permalink
Post by b***@gmail.com
Reserved words in Zonnon are all-lowercase with all-uppercase
synonyms, I was thinking about doing just that myself to appease some
of the Pascal users who have written in complaining about uppercase
reserved words. And this definitely encourage me do actually go and do
it.
I'd expect the only thing to appease Pascal users would be to make the
language case insensitive again. At least this one :-)
Chris Burrows
2009-04-20 13:40:23 UTC
Permalink
Post by b***@gmail.com
Post by Chris Burrows
result := FileSystem.status.success;
This is starting to become uncomfortably unwieldy.
FILESYSTEM_STATUS_SUCCESS,
FILESYSTEM_STATUS_LOOP_IN_PATH,
FILESYSTEM_STATUS_INVALID_DIRECTORY,
....
It wouldn't. However, two wrongs don't make a right.

Chris.
b***@gmail.com
2009-04-21 09:31:37 UTC
Permalink
Post by Chris Burrows
Post by b***@gmail.com
Post by Chris Burrows
result := FileSystem.status.success;
This is starting to become uncomfortably unwieldy.
FILESYSTEM_STATUS_SUCCESS,
FILESYSTEM_STATUS_LOOP_IN_PATH,
FILESYSTEM_STATUS_INVALID_DIRECTORY,
....
It wouldn't. However, two wrongs don't make a right.
If you only have two or three numeric codes to map to human readable
names, then you can live without enumerations and use CONST
declarations ...

CONST failure = 0; success = 1; => IMPORT Status; => Status.failure,
Status.success

However, if you have a large number of numeric codes to map, like say
50 or 100 or more, then having to explicitly assign numeric values to
each name is not only inconvenient but more importantly it is error
prone as the code is being maintained with codes removed and added.
For example, if you have a means to let the compiler assign values
automatically, then there won't be any accidental duplicates or typos,
such as hitting 0 instead of 9 somewhere etc.

At the very least I would need some kind of type-less enumeration, say
something like ...

MODULE Blob;

ENUM
null = 0, foo, bar, baz, bam, bob, poo, bah, ding, dong, boing,
maxBlob;
END (* ENUM *)

...
END Blob.

then

...
IMPORT Blob;
...
a := Blob.foo; b := Blob.bar; c := baz; d := bam; .....

IF x => Blob.maxBlob THEN ...

Note that if the first element is zero as in this example, then the
last element is automatically assigned the number of elements before
the last, so you can use that to let the compiler count the number of
values in your set. I use this pattern very often in my code and I do
have fairly large sets of numeric codes, e.g. 50 or more. The compiler
automatically assigns the number of items value, which avoids silly
bugs when adding or removing an element.

Especially, in open source projects this is utterly important because
somebody else comes along to add some stuff and forgets to also
increase the value for the number of items.

In my bread and butter job I deal with tons of status codes, usually
hundreds of them (e.g. ISDN protocol), they are most often numbered
consecutively with some gaps in between sometimes, but again, it
reduces the likelihood of bugs if the compiler can automatically
assign most of the values for you.

I have spent hundreds of hours debugging badly written C code where
this kind of thing was the number one trouble spot because the
original author of the code apparently had never heard of enums. Many
C programmers have no idea what enumerations are and they write bug
ridden code because of it.

As far as I am concerned, enumerations are absolutely essential. I
won't work without them, and if forced to at gun point, I'd rather
leave this line of work and open a restaurant.
Chris Burrows
2009-04-21 13:31:35 UTC
Permalink
Post by b***@gmail.com
As far as I am concerned, enumerations are absolutely essential. I
won't work without them
I guess we'll just have to agree to disagree then. For me they fall into the
category 'can be nice to have but can make do without'. However, if you are
interested in more extensive arguments for and against, here are some links
to a couple of articles and some extensive discussions:

ACM SIGPLAN Notices Vol 25, Issue 7 July 1990
Programming Without Enumerations in Oberon. C Lins.
http://portal.acm.org/citation.cfm?id=382642

The benefits of enumerated types in Modula-2. Mark Cashman.
ACM SIGPLAN Notices Vol 26, Issue 2 Feb 1991
http://portal.acm.org/citation.cfm?id=122183

Another defence of enumerated types. Markku Sakkinen
ACM SIGPLAN Notices Vol 26, Issue 8 Aug 1991
http://portal.acm.org/citation.cfm?id=122600

comp.lang.oberon
Subject: Wirth says: No enumeration types
Nov 1996
http://groups.google.com.au/group/comp.lang.oberon

Blackbox Component Pascal mailing list
Subject: Named Integers
Nov 2004
http://www.lrz-muenchen.de/~BlackBox/archive/2004/subject.html

--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/modula2
b***@gmail.com
2009-04-21 13:46:11 UTC
Permalink
if you are interested in more extensive arguments for and against, here
I have read pretty much everything I could find on the subject
including most of the sources you list, however, I did not see any
convincing argument in the face of the problem domain I have
described. I don't think that Wirth, Gutknecht or any of the authors
of those papers have spent any time on debugging C code written by C
programmers who don't use enumerations.

The contrast is very stark. I challenge any of the scholars to do a
study on how many bugs per lines of code you can find on average in C
code, written with and without enumerations. I would be extremely
surprised if any such study would not show that the code written
without enumerations has significantly more bugs. Like I said, this is
my personal experience from years of cleaning up after messy people
and when it comes to debugging, experience in the field beats academic
papers any day of the week.
Chris Burrows
2009-04-22 00:14:08 UTC
Permalink
Post by b***@gmail.com
I challenge any of the scholars to do a
study on how many bugs per lines of code you can find on average in C
code, written with and without enumerations. I would be extremely
surprised if any such study would not show that the code written
without enumerations has significantly more bugs.
Any conclusions drawn from such a study would only be relevant to C. Do we
really need to be convinced that it is easy to write buggy code in C???

--
Chris Burrows
CFB Software
http://www.cfbsoftware.com/modula2
b***@gmail.com
2009-04-22 02:25:20 UTC
Permalink
Post by b***@gmail.com
I challenge any of the scholars to do a
study on how many bugs per lines of code you can find on average in C
code, written with and without enumerations. I would be extremely
surprised if any such study would not show that the code written
without enumerations has significantly more bugs.
Any conclusions drawn from such a study would only be relevant to C.  Do we
really need to be convinced that it is easy to write buggy code in C???
I am specifically talking about bugs that would not be there if
enumerations had been used where the compiler assigned values
automatically. C is an ideal target for measuring the likelihood of
bugs caused by the absence of enumerations because although the
language does have enumerations and some C programmers actually use
them, there is a culture amongst C programmers not to use them, thus
you do have a control group within the same language which means you
can establish that those bugs are only caused because enumerations
have not been used, not because of other factors, since everything
else is the same. If you used Pascal or Modula-2 code to study, you
would not have a control group because there is no culture not to use
enumerations. Oberon doesn't have any enumerations, so you don't have
a control group for enumerations being used.

There is no point arguing that people do not make mistakes when doing
repetitive tasks. Writing a _large_ list of CONST declarations is a
repetitive task and without automatic assignment of values by the
compiler, people will make an error sooner or later. It would be
rather folly to suggest that Oberon programmers are somehow magically
immune from this particular type of human fallibility.
Martin Whitaker
2009-04-20 19:52:04 UTC
Permalink
Post by b***@gmail.com
Post by Martin Whitaker
So I would encourage you to base your work on the ISO standard.
There is a related Q in the Objective Modula-2 FAQ. In a nutshell,
right now, the priority must be on getting a working compiler for the
general public completed. Afterwards, I don't rule out partial
compliance.
Yes, all I'm saying is that if you make your initial compiler a subset of ISO
M2 rather than a subset of (some version of) PIM M2, it will be easier to
achieve fuller compliance later.

[snip]
Post by b***@gmail.com
I am sympathetic to arrays always starting at index 0. Back in the day
when I used Pascal as a student I might have used some arrays starting
with index 1, but since then I never used nor ever needed indices to
start with anything but zero. That is not to say that I don't favour
automatic bounds checking (inserted by the compiler).
I often used arrays starting at other indices. But even more useful were
arrays indexed by an enumeration.

[snip]
Post by b***@gmail.com
But to me the worst of all the Oberon omissions has got to be the
combination of interface and implementation. This totally violates my
sense of tidiness and readability of code.
I'm with you 100% on this one!
Post by b***@gmail.com
Post by Martin Whitaker
It is not true that the ISO standard doesn't support multi-byte characters
What I meant is a built in type that represents multi-byte characters
and libraries with operations/manipulations for objects of that type,
e.g. UNICHAR. At some point if you generalise too much, you leave all
the hard work to the user who then basically has to implement his own
multi-byte library from scratch. The language doesn't prevent him from
doing that, but it doesn't exactly provide him with the tools he needs
either, he's got to roll his own.
There is nothing to stop you implementing CHAR as a multi-byte type. And if
you choose Unicode as your character coding, and support compact storage of
subranges, the user would be able to declare something like

TYPE ASCII = CHAR [0C..127C];

and have single byte character variables as well.

[snip]
Post by b***@gmail.com
Post by Martin Whitaker
So the chosen solution was to allow the language to support an unspecified
native character coding. It was expected that implementations would gradually
evolve towards supporting multi-byte character codes
But how many years has it been since? There could have well been an
addendum to the standard for proper multi-byte support in M2
afterwards.
As noted, the standard already allows for proper multi-byte support. As for
further standardisation work, well, M2 was already losing popularity by the
time the initial standard was published. And working on the standard was a
pretty thankless task.
Post by b***@gmail.com
Post by Martin Whitaker
(apart from implementations targetting embedded systems, which would no doubt stick
with single byte character codes).
That is a misperception. I do embedded work. These days many embedded
devices have built-in web servers to provide an interface to configure
them. Many products are localised for China, Japan, Korea and Taiwan
and we do need multi-byte character support on them.
Nowadays, yes. Back when the M2 standard came out perceptions were different.
And as you noted, there was no active participation by the CJK countries in
the standardisation process to provide a different perspective.

[snip]
Post by b***@gmail.com
A small and simple base standard that is very close to the language as
introduced and presented in all the published books, most notably PIM,
but also secondary literature, has the benefit that you can expect
almost every compiler to become compliant fairly soon after the
standard is published. Add too much new stuff and either implementors
won't bother at all, or they will put it off for so long that the
standard becomes a paper tiger and the language will eventually fall
into decline because everybody is sitting on the fence. One can only
shrug considering that OF ALL PEOPLE, it was the Modulans who couldn't
resist feature creep in their standard. If they couldn't, then who can?
Yes, but which published book were you going to choose, and whose
interpretation of it? There were significant differences between the four
editions of PIM, and then each compiler introduced its own variations. And PIM
had inherent assumptions about the machine architecture which did not hold
true for all systems that might be targeted. And it was arguments about such
minutia just as much as arguments about the new stuff that bogged down the
standardisation process.

Martin
Marco van de Voort
2009-04-22 08:04:56 UTC
Permalink
Post by Martin Whitaker
Post by b***@gmail.com
start with anything but zero. That is not to say that I don't favour
automatic bounds checking (inserted by the compiler).
I often used arrays starting at other indices. But even more useful were
arrays indexed by an enumeration.
Yes. Specially subranges of them. That's a construct that exists a lot in my
programs.
Post by Martin Whitaker
Post by b***@gmail.com
sense of tidiness and readability of code.
I'm with you 100% on this one!
No contest here, but this is a home game :-)
Post by Martin Whitaker
There is nothing to stop you implementing CHAR as a multi-byte type. And if
you choose Unicode as your character coding, and support compact storage of
subranges, the user would be able to declare something like
TYPE ASCII = CHAR [0C..127C];
and have single byte character variables as well.
Does the literal assignment (and maybe other conversions and operations)
still work for such beasts? That is always the problem of homegrown
stringtypes.
Marco van de Voort
2009-04-20 07:27:46 UTC
Permalink
On 2009-04-19, Martin Whitaker <***@martin-whitaker.me.uk> wrote:

(interesting read skipped)
Post by Martin Whitaker
The gotcha is the requirement that an implementation must support "SET OF
CHAR". This is a bit impractical for large character sets, and I think has to
be ignored for multi-byte character codes.
Is there a requirement that specifies how a set is to be implemented? IOW
does it allow sparse sets e.d. ? That was proposed as an escape during a
similar discussion in c.l.p.ansi-iso IIRC.
Martin Whitaker
2009-04-20 19:59:26 UTC
Permalink
Post by Marco van de Voort
(interesting read skipped)
Post by Martin Whitaker
The gotcha is the requirement that an implementation must support "SET OF
CHAR". This is a bit impractical for large character sets, and I think has to
be ignored for multi-byte character codes.
Is there a requirement that specifies how a set is to be implemented? IOW
does it allow sparse sets e.d. ? That was proposed as an escape during a
similar discussion in c.l.p.ansi-iso IIRC.
Indeed, the standard allows a set to be implemented in any way (PACKEDSET was
introduced to allow the user to force a bit-mapped implementation for use in
low level programs). So yes, there is an escape, but then the standard is
forcing the implementor to use that escape...
Loading...