Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.forth > #53194
| From | anton@mips.complang.tuwien.ac.at (Anton Ertl) |
|---|---|
| Newsgroups | comp.lang.forth |
| Subject | Re: Object-Oriented Programming is Bad |
| Date | 2016-12-08 09:58 +0000 |
| Organization | Institut fuer Computersprachen, Technische Universitaet Wien |
| Message-ID | <2016Dec8.105831@mips.complang.tuwien.ac.at> (permalink) |
| References | <4ca00d44-3973-4ddc-8572-6616882b0252@googlegroups.com> <tZKdnYcLYucW19XFnZ2dnUU7-UfNnZ2d@supernews.com> |
Andrew Haley <andrew29@littlepinkcloud.invalid> writes:
>Some things are just not modelled well as objects: for a silly
>example, Java has a function which calculates sin x, and because
>everything is a method you have to write Math.sin(x), which makes no
>sense at all.
This has nothing to do with objects, though, but something with how
Java resolves scoping. See how we can have "sin" without any
qualifier in the main method below:
public class Aufgabe1{
public static double sin(double x) {
return Math.sin(x);
}
public static void main(String[] args) {
System.out.println(sin(1.));
}
}
It's unclear to me why "import java.lang.Math" does not allow me to
refer to Math.sin with sin, though.
>You could implement sin x as passing a message to a
>number x which calculates its own sine, but that means that a number
>has to know how to calculate every possible mathematical function.
>No, from a code organization point of view this is a terrible idea: it
>makes much more sense to have a library of trig functions.
Sorry, I don't see any difference in code organization from that. Now
you have a Math class that contains all this stuff, and if you made
them methods of the Double class, the organization would not change
much.
A bigger issue for Java is probably the support for overloading and
automatic conversion, and the lack of support for
method-not-understood. To get the same functionailty, you would have
to add sin (and every other such function) to java.lang.Number, too,
with an implementation like:
Double sin() {
return doubleValue().sin();
}
With a method-not-understood mechanism, all of these definitions in
Number could be subsumed by one:
Double notUnderstood(Method m) {
return doubleValue().m()
}
(or maybe a bunch for different arities).
Anyway, yes, if you only support sin for doubles, as in Java, objects
don't buy anything.
- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: http://www.forth200x.org/forth200x.html
EuroForth 2016: http://www.euroforth.org/ef16/
Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Object-Oriented Programming is Bad Julian Fondren <julian.fondren@gmail.com> - 2016-12-07 03:23 -0800
Re: Object-Oriented Programming is Bad Mark Wills <markwills1970@gmail.com> - 2016-12-07 09:06 -0800
Re: Object-Oriented Programming is Bad "HAA" <someone@microsoft.com> - 2016-12-09 11:03 +1100
Re: Object-Oriented Programming is Bad Alex <alex@rivadpm.com> - 2016-12-09 00:17 +0000
Re: Object-Oriented Programming is Bad "HAA" <someone@microsoft.com> - 2016-12-10 10:14 +1100
Re: Object-Oriented Programming is Bad hughaguilar96@gmail.com - 2016-12-09 19:54 -0800
Re: Object-Oriented Programming is Bad "Robert L." <No_spamming@noWhere_7073.org> - 2016-12-10 06:44 +0000
Re: Object-Oriented Programming is Bad Julian Fondren <julian.fondren@gmail.com> - 2016-12-10 00:37 -0800
Re: Object-Oriented Programming is Bad polymorph self <jackvanc3@gmail.com> - 2016-12-11 06:39 -0800
Re: Object-Oriented Programming is Bad Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-10 03:38 -0600
Re: Object-Oriented Programming is Bad november.nihal@gmail.com - 2016-12-11 08:57 -0800
Re: Object-Oriented Programming is Bad hughaguilar96@gmail.com - 2016-12-11 10:19 -0800
Re: Object-Oriented Programming is Bad Paul Rubin <no.email@nospam.invalid> - 2016-12-11 13:25 -0800
Re: Object-Oriented Programming is Bad hughaguilar96@gmail.com - 2016-12-11 17:39 -0800
Re: Object-Oriented Programming is Bad november.nihal@gmail.com - 2016-12-11 17:49 -0800
Re: Object-Oriented Programming is Bad hughaguilar96@gmail.com - 2016-12-11 20:31 -0800
Re: Object-Oriented Programming is Bad november.nihal@gmail.com - 2016-12-12 07:01 -0800
Re: Object-Oriented Programming is Bad Paul Rubin <no.email@nospam.invalid> - 2016-12-11 21:50 -0800
Re: Object-Oriented Programming is Bad polymorph self <jackvanc3@gmail.com> - 2016-12-11 06:20 -0800
Re: Object-Oriented Programming is Bad Paul Rubin <no.email@nospam.invalid> - 2016-12-07 09:26 -0800
Re: Object-Oriented Programming is Bad Andrew Haley <andrew29@littlepinkcloud.invalid> - 2016-12-07 11:44 -0600
Re: Object-Oriented Programming is Bad anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2016-12-08 09:58 +0000
Re: Object-Oriented Programming is Bad Bernd Paysan <bernd@net2o.de> - 2016-12-21 21:18 +0000
Re: Object-Oriented Programming is Bad gavinschuette@gmail.com - 2016-12-21 23:00 -0800
Re: Object-Oriented Programming is Bad franck.bensusan@gmail.com - 2016-12-21 09:41 -0800
Re: Object-Oriented Programming is Bad gavinschuette@gmail.com - 2016-12-21 23:00 -0800
csiph-web