Oberon Community Platform Forum
December 07, 2019, 08:26:29 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: Comparison of the C and Oberon-2 langauges  (Read 69530 times)
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« on: May 31, 2011, 04:37:31 PM »

Hi ...

Is there a document hiding somewhere that objectively compares the 2 langauges? pros and cons! Smiley

I'm not talking about the availability of C libraries -vs- Oberon modules. Just the language itself.
--
Duke
Logged

duke
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #1 on: May 31, 2011, 06:40:41 PM »

I found this - not C, but close:

http://www.modulaware.com/mdlt49.htm

Anything else? Smiley
--
Duke
Logged

duke
cfbsoftware
Full Member
***
Posts: 107


WWW
« Reply #2 on: June 01, 2011, 02:32:34 PM »

To avoid trying to "compare apples with oranges" it makes more sense to compare C++ and Oberon-2 as, unlike C, both have a number of features specifically designed to be used for object-oriented programming.

It might be fairer to compare original Oberon (or the more recent version, Oberon-07) with C.  

While preparing my presentation "ARM Embedded Development Using Oberon-07" for last week's Oberon Day 2011 symposium I attempted to get some measure of the comparative reliability of C and Oberon-07 when used for embedded software development. To do this I took the 142 rules of the MISRA-C:2004 "Guidelines for the use of the C language in critical systems" and applied them to Oberon-07. I discovered that more than 70% of the rules are not required when programming in Oberon-07. They are either already enforced by the language or are not applicable.

Examples of MISRA rules that are not applicable to Oberon-07:

  Rule 14.4: The goto statement shall not be used. (Oberon-07 does not have GOTO)

  Rule 14.5: The continue statement shall not be used. (Oberon-07 does not have CONTINUE)

Examples of MISRA rules that are enforced by the design of Oberon-07:

  Rule 14.7: A function shall have a single point of exit at the end of the function.

  Rule 16.6: The number of arguments passed to a function shall match the number of parameters.

The remaining 30% of MISRA rules that also need to be checked when using Oberon-07 include:

  Rule 2.4 (advisory): Sections of code should not be "commented out".

  Rule 20.4: Dynamic heap memory allocation shall not be used.

More information about MISRA and their guidelines can be found on their website:

  www.misra.org.uk  

The Oberon and Oberon-07 Language Reports can be downloaded from:

  www.inf.ethz.ch/personal/wirth/Articles/Oberon.html
« Last Edit: June 01, 2011, 02:34:44 PM by cfbsoftware » Logged

Chris Burrows
Astrobe v7.0 (Feb 2019): Oberon for ARM Cortex-M3, M4 and M7 Microcontrollers
http://www.astrobe.com
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #3 on: June 01, 2011, 03:36:00 PM »

To avoid trying to "compare apples with oranges" it makes more sense to compare C++ and Oberon-2 as, unlike C, both have a number of features specifically designed to be used for object-oriented programming.

It might be fairer to compare original Oberon (or the more recent version, Oberon-07) with C.

Sure! I actually meant the "C family of languages". Whatever - I was hoping to find some documentation somewhere that would say - in a nutshell - something like: "Anything that you can do in C/C++ , can be done in Oberon-x, etc, etc" Smiley  

Quote
While preparing my presentation "ARM Embedded Development Using Oberon-07" for last week's Oberon Day 2011 symposium I attempted to get some measure of the comparative reliability of C and Oberon-07 when used for embedded software development. To do this I took the 142 rules of the MISRA-C:2004 "Guidelines for the use of the C language in critical systems" and applied them to Oberon-07. I discovered that more than 70% of the rules are not required when programming in Oberon-07. They are either already enforced by the language or are not applicable.

That probably answers my question! Have you published your presentation yet? Would you think that Modula-3 would do as well?
--
Duke
Logged

duke
leledumbo
Jr. Member
**
Posts: 96



WWW
« Reply #4 on: June 01, 2011, 06:14:36 PM »

Other than that document from modulaware, I never find anything good enough. But if you have enough experience in both language families, you could feel the pros and cons yourself. For me:
  • Oberon
    • Pros
      • Ultra high compilation speed (decreases development time in waiting for the compiler to compile)
      • True modular programming (no linker errors except when interfacing with external modules)
      • Garbage collected
    • Cons
      • Limited OOP (no interfaces, single inheritance)
      • UPPERCASE keywords (it still hurts my fingers...)
      • Not really widely used
  • C++
    • Pros
      • Good marketing strategy (thanks to MS and AT&T)
      • Widely used, many ready-to-use libraries available
    • Cons
      • Still pertaining C's cumbersomeness in modularization approach (via preprocessor, module interdependency check is either difficult, requires additional pass, or impossible to do)
      • Susceptive to link-time errors
      • Super duper complex language (esp. in incoming C++0x), requires unlimited lookahead for parsing
      • Many errors that could actually be detected at compile-time, become impossible due to lack of proper semantics
Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #5 on: June 01, 2011, 07:45:23 PM »

@leledumbo  Huh

Anyway .... Thanks for your comments. I take it that outside the Oberon family of OS, you use C++ for most of your programming requirements/work?
--
Duke
Logged

duke
cfbsoftware
Full Member
***
Posts: 107


WWW
« Reply #6 on: June 02, 2011, 02:07:47 AM »

Have you published your presentation yet?
Presentations from previous Oberon days have been published on the relevant websites so I assume the same will happen again. They also filmed the whole event this time and are planning to publish some of the recordings on the website:

http://www.oberonday2011.ethz.ch/

Quote
Would you think that Modula-3 would do as well?
Probably but can't say for sure - it's more than 20 years since I last looked at it. Try asking in one of the modula-3 discussion groups / forums.
Logged

Chris Burrows
Astrobe v7.0 (Feb 2019): Oberon for ARM Cortex-M3, M4 and M7 Microcontrollers
http://www.astrobe.com
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #7 on: June 02, 2011, 04:14:32 AM »

@Chris
The Modula-3 newsgroup appears to be as quiet - if not more so - that the Oberon or Modula-2 NGs. Could be yet another adventure. Smiley Thanks.
--
Duke
Logged

duke
Dsar
Newbie
*
Posts: 40


« Reply #8 on: June 05, 2011, 10:52:01 AM »

Would you think that Modula-3 would do as well?
Modula-3 is very nice, if you were looking for a valid alternative to C++ this would be a good choice. Ada is another valid choice, but it's becoming too big for my taste. Anyway, gnat and opencm3 compilers are well maintained.

C++ is the worst language ever designed. There is a (classic) paper by Ian Joyner titled "A critique to C++", where it is widely discussed.
http://archive.adaic.com/intro/ada-vs-c/cppcv3.pdf

Some quotes from the past ;-)

 "Fifty years of programming language research, and we end up with C++ ??" - Richard A. O'Keefe

 "I invented the term 'Object-Oriented', and I can tell you I did not have C++ in mind." - Alan Kay, creator of Smalltalk

 "C++ is impeding the progress of the programming technology." - Ian Joyner

 "There are only two things wrong with C++: The initial concept and the implementation" - Bertrand Meyer, creator of Eiffel

 "C++ is an insult to the human brain." - Niklaus Wirth

 "Whenever the C++ language designers had two competing ideas as to how they should solve some problem, they said, 'OK, we'll do them both'. So the language is too baroque for my taste" - Donald Knuth

 "C++ is a horrible language. It's made more horrible by the fact that a lot of substandard programmers use it, to the point where it's much much easier to generate total and utter crap with it." - Linus Torvalds

Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #9 on: June 05, 2011, 11:12:48 AM »

Would you think that Modula-3 would do as well?
Modula-3 is very nice, if you were looking for a valid alternative to C++ this would be a good choice. Ada is another valid choice, but it's becoming too big for my taste. Anyway, gnat and opencm3 compilers are well maintained.

I just installed the Critical Mass Modula-3 compiler complete with the web-based IDE.  What a nice system! I'm loving it! The tutorial is great; as is the IDE "User Guide". This language truly deserves more exposure, IMHO.

Quote
C++ is the worst language ever designed. There is a (classic) paper by Ian Joyner titled "A critique to C++", where it is widely discussed. http://archive.adaic.com/intro/ada-vs-c/cppcv3.pdf

Until I met the Oberon-2 language, I shied away from all OOP languages. I never did go near C++. However, lately, I had a notion that I should learn C, as it seems that just about everything is written in C (or one of its derivatives). Then, my old hang-ups with the C syntax quicky surfaced again, and I got to wondering if Oberon-2 et al , can do everything that C can, and then some - OOP capabilities notwithstanding.

You've nailed it for me, though. I won't ever go near C++; and I'll learn Oberon-2 and its successors well, before investing any time with C. However, now that I've discovered Modula-3 ...  Cheesy

Thanks for the input!
--
Duke
Logged

duke
Dsar
Newbie
*
Posts: 40


« Reply #10 on: June 05, 2011, 09:25:43 PM »

Until I met the Oberon-2 language, I shied away from all OOP languages.

Well, Oberon-2 is (imho) superior to C++ because it is well designed. Anyway, learning OOP from Oberon-2 is very straightforward. The Mossenbock's book about OOP with Oberon-2 is the clearest one I've read.

I had a notion that I should learn C, as it seems that just about everything is written in C (or one of its derivatives).

I was a C programmer, some years later I switched to Ada and now I code mostly in Oberon-2 for my personal projects (I still use Ada). With these ones I learnt a lot about security and software engineering in general. Now I'm not able to think how C can be used today! I feel the emergency that all C projects should be converted to a sane language to make the world better.
With a sane language 70% of security bugs could be avoided.

Cons of C:
- No modularity.
- No strong typing.
- No knowledge of type range (char a = 1000; is legal).
- No boolean type.
- No true concept of array.
- No direct support for bounds checking.
- No safe type-casting.
- No safe union.
- No separation of unsafe code.
- No by reference parameter passing (simulated with pointers).
- No set type (C programmers use the unreadable bitwise operators for simple stuff).
- No nested procedures (useful for error recovery).
- Dangling else.
- Ternary operator.
- Broken include preprocessor (you have to use an include guard to avoid double inclusion!)
- Pointer arithmetic.
- Ability to mix expressions and statements (the most DANGEROUS and NON-SENSE feature! I've spent a lot of months for an unrevealed error in an IF expression with a = b instead of a == b. I'm still furious with it!)
- Awful and inconsistent standard library (character functions use integer parameter as character because it is also used for error reporting !!)
- ... and others omitted just to keep the list short ;-)

I don't see any pros in C, I cannot help you in this, sorry.

I got to wondering if Oberon-2 et al , can do everything that C can, and then some - OOP capabilities notwithstanding.

Oberon is also an operating system, then you can do everything. Oberon, compared to C, is less flexible and restricted. The real question is: is this flexibility really needed during programming? My answer is: No, it doesn't. The world need rules to avoid chaos.
« Last Edit: July 07, 2011, 01:17:15 PM by Dsar » Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #11 on: June 05, 2011, 10:34:07 PM »

Much obliged!    +2

--
Duke
Logged

duke
Bernhard T.
Administrator
Full Member
*****
Posts: 164


« Reply #12 on: June 06, 2011, 02:50:45 PM »

although it is not possible to apply it directly, I remember vaguely a comparison of Modula-2 and C in the Journal of Pascal Ada & Modula-2 back in the 1980ies.

Browsing through ACM pages, I found it: http://portal.acm.org/citation.cfm?id=69405
but I have no idea if/where it can be found online.


Title: Comparing Modula-2 and C.

Authors:  R. Bray  B. Fairless   R. Gile   S. Waller   R. Maxey   D. West   

Published in: Journal of Pascal, Ada & Modula-2, Volume 8 Issue 2, March/April 1989

SIGS Publications, Inc. New York, NY, USA

Maybe some brave soul has a copy and could scan the three pages.

Bernhard
 
Logged
dukester
Full Member
***
Posts: 140


On Faceflow I'm dukester


« Reply #13 on: June 06, 2011, 03:12:17 PM »

@Bernhard

Thanks for digging that up. I can almost guess what the artcle will say. Smiley

This is an uninformed opinion, but I think that the Modula/Oberon family of languages can probably compete nose-to-nose with C/C++ for most tasks. However, the availability of the various compilers, and how well they are maintained, would probably influence programmers toward the C family (or another language) and away from Modula/Oberon. The old saying still applies, I'm afraid, i.e. "You snooze; you loose!"  ;(

I've moved way from the C/C++ vs Oberon-2 comparison, to wondering how Modula-3 compares to Oberon-2 +? I installed the Critical Mass M3 system on my Xubuntu box.  It's very good! IMHO.

You might be interested in test-driving it ...  http://opencm3.net/

Thanks for the input!
--
Duke
Logged

duke
leledumbo
Jr. Member
**
Posts: 96



WWW
« Reply #14 on: June 06, 2011, 04:24:53 PM »

Quote
@leledumbo Huh

Anyway .... Thanks for your comments. I take it that outside the Oberon family of OS, you use C++ for most of your programming requirements/work?
Sorry for the long reply. Nope, I just know C++ quite deep because I like to explore programming languages. My real work uses either Java (academic, university), Pascal (everything as long as allowed, usually private and open source projects), PHP (for short time web-based app), C (if I can't say "no" to my boss).
Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!