Random thought #1

30 views
Skip to first unread message

James Coplien

unread,
Mar 11, 2012, 10:25:08 AM3/11/12
to dci-ev...@googlegroups.com
A random thought:

Restricted OO is about syntax: the form of local expression. Full OO is about semantics: the meaning of system execution.

Critique and discuss.

Trygve Reenskaug

unread,
Mar 11, 2012, 2:05:07 PM3/11/12
to dci-ev...@googlegroups.com
I'm not a computer scientist, but  I see from the Wiki that the words syntax, semantics, pragmatics have any number of meanings in any number of deep layers. I only feel slightly comfortable with their simplest and most vulgar meaning. (Their semantics?) Many, many years ago, I heard the words syntax, semantics, pragmatics in connection with Algol-60.The syntax  is defined with BNF and specifies the set of all legal Algol-60 texts. A piece of Algol-60 code behaves in a certain way when it is executed. This is called its semantics. Right? There is knowledge about good ways to write Algol programs, isn't that pragmatics???

The UML metamodel syntax is formally expressed as class diagrams. The runtime semantics is expressed informally using English prose. Constraints are expressed in a separate language: OCL, The namespace for  OCL expressions consists of the terms defined in the syntax.

I can't see a way to express restricted OO using BNF.  Nor can I see formal constraint expressions that distinguishes between inner and environment objects.

When POJO code is executed, it  gives rise to a certain behavior. That's its semantics, AFAIU.
Restricted OO is a restriction on this behavior. Sounds like semantics to me.

Syntax, semantics, pragmatics, and form.

Clarify and discuss.

Risto Välimäki

unread,
Mar 11, 2012, 3:37:18 PM3/11/12
to dci-ev...@googlegroups.com

I can't comment on #2, since I don't know aspect oriented programming. However, I agree with this #1.

Restricted OO is also called "class-oriented" programming, and yes, quite often it's just about the "object-oriented syntax" without the slighest understanding about the semantics.

Ask 10 random "OO"-programmers about why they use OO (or CO) instead of ie. procedural or functional programming. I'll bet that about 9 of them mentions code re-use but not the real world modelling and user/stakeholders mental models.

Syntax matters too. I've been working for more than 4 months now on an odd subject for a software engineer: PLC automation programming. It has been possible to write PLC programs in real OO ways, but the syntax has been designed only procedural (an structural) programming in mind.
Recently they (CoDeSys et al) have added syntax for OO too (eg. Methods and Properties), and they think they have just invented the OO in PLC, which is not true (although it requires now less imagination to do OO in PLC). The funny thing on PLC programming is that Objects in PLC tend to have quite literal counterparts in the real world. For example a DieselEngine object ("functionblock instance") corresponds to the real world object "diesel engine".

-Risto

James Coplien

unread,
Mar 11, 2012, 3:46:19 PM3/11/12
to dci-ev...@googlegroups.com

On Mar 11, 2012, at 7:05 , Trygve Reenskaug wrote:

I can't see a way to express restricted OO using BNF.  Nor can I see formal constraint expressions that distinguishes between inner and environment objects.

When POJO code is executed, it  gives rise to a certain behavior. That's its semantics, AFAIU.
Restricted OO is a restriction on this behavior. Sounds like semantics to me.

Then every program has semantics. But not all code expresses those program semantics. My argument here is more about intentionality rather than anything about Turing-completeness. 

I got to thinking about this with respect to Alan Kay's original computational model for OO: that if every object did its own thing right, you counted on the emergent behavior to just make the right thing happen. That's not well-defined program semantics, even though individual object semantics are well-designed.

DCI gives an explicit voice to system-level semantics.

Class code is just a form of expressing local semantics: it is, in fact, not the semantics itself. If it were, then we could do perfect testing. The semantics are much more than that code, because you have to unroll all possible combinations of that code in time. So it is merely an expression of its form: that's syntax.

That's where my "argument" tries to take off from.

rune funch

unread,
Mar 12, 2012, 5:05:18 AM3/12/12
to dci-ev...@googlegroups.com
I believe that given all the data classes it would be possible to express C and I using BNF, of course that would express only the intended program but the intended program would be a subset of the resulting grammar. Thus I can agree to restricted OO being a syntax for the program. However as Trygve made clear distinguishing between language syntax and program/system syntax might be hard to potentially impossible for the masses especially if already caught in class thinking.

That said I like the idea of seeing data as the terminals of the program grammar and contexts as non terminals (ie the relation between the terminals) that supports my idea of using contexts for far more than system operations and also using contexts in the what the system is part. Eg. as I've done for the Account in the Marvin examples.

I think it's a bit to ambitious to call C and I or fullOO for the semantics of the program. To my best knowledge there exist no formal way to express semantics as side human language and models/math combined and as you said it Jim being able to express the full semantics should open the door to perfect testing.
C and I do improve our testing capabilities because we can reduce what would have been a complex graph to one with a single path when looking at control structures taking data into account it becomes different. I can easily express the grammar for a division expression using BNF

div : NUMBER '/' NUMBER

(where number is a terminal) I can also show the algorithm used at machine level to do the math but that does not tell me that for all x x/0 is illegal nor does it tell me the meaning of x/y. It does tell me how I can get to the meaning of those epressions so I do agree that it helps grasp the semantics but not that it is the semantics

James Coplien

unread,
Mar 12, 2012, 6:11:20 AM3/12/12
to dci-ev...@googlegroups.com

On Mar 12, 2012, at 10:05 , rune funch wrote:

so I do agree that it helps grasp the semantics but not that it is the semantics


Grumble.

But there's still something here — I think, something very powerful and concise can be said.

What is it?
Reply all
Reply to author
Forward
0 new messages