Post #192,045
1/27/05 10:10:34 PM
|
What makes a "real" programming language?
Now that I've got your attention ... (Wait! Don't run off, I'll get back to the question.) While reviewing some code I saw something like the following: class foo {\n var $bar;\n var $baz;\n\n function foo() {\n $this->bar = '';\n $this->baz = 5;\n }\n}
This actually went on for a couple of dozen properties. I suggested the following change: class foo {\n var $bar = '';\n var $baz = 5;\n\n function foo() {\n }\n}
The programmer said that "real" programming languages don't support initializing the properties in the declaration, and just because we have to work with PHP doesn't mean we can't write it the way we would in a "real" language. The only languages I can say with complete confidence you can do this are PHP and Java. I'm sure there are others You may not like it, but I don't think anyone can say Java isn't a "real" language. The guy saying this is a .NET evangalist who probably hasn't worked in anything but MS tools and PHP. How wrong is he? Is it more common to allow initialization in the constructor, or to not allow it?
===
Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats]. [link|http://DocHope.com|http://DocHope.com]
|
Post #192,047
1/27/05 10:29:27 PM
|
I think he's deluding himself.
What are "real" languages? How long is a piece of string? What does red look like? He should stop trying to make PHP like what it ain't and take advantage of the way it does do things.
Wade.
Is it enough to love Is it enough to breathe Somebody rip my heart out And leave me here to bleed
| | Is it enough to die Somebody save my life I'd rather be Anything but Ordinary Please
| -- "Anything but Ordinary" by Avril Lavigne. |
|
Post #192,048
1/27/05 10:30:50 PM
|
No doubt
But I'd like to have a list of other languages that also do it.
===
Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats]. [link|http://DocHope.com|http://DocHope.com]
|
Post #192,052
1/27/05 11:20:17 PM
|
An anti-example.
Unicon does declarations in it's classes a different way to most other languages, so initialization *has* to be done in the constructor. But it also does the constructor different, anyway.
Wade.
Is it enough to love Is it enough to breathe Somebody rip my heart out And leave me here to bleed
| | Is it enough to die Somebody save my life I'd rather be Anything but Ordinary Please
| -- "Anything but Ordinary" by Avril Lavigne. |
|
Post #192,103
1/28/05 12:25:48 PM
|
There are plenty
Just because he doesn't know they're there doesn't mean they don't exist.
Didn't he learn about variable scope in school? If the languages he works in don't permit variables to span across the block represented by a class, they're the languages that aren't real languages, imho.
--\n-------------------------------------------------------------------\n* Jack Troughton jake at consultron.ca *\n* [link|http://consultron.ca|http://consultron.ca] [link|irc://irc.ecomstation.ca|irc://irc.ecomstation.ca] *\n* Kingston Ontario Canada [link|news://news.consultron.ca|news://news.consultron.ca] *\n-------------------------------------------------------------------
|
Post #192,049
1/27/05 10:40:36 PM
|
You can do that in C#
-- Chris Altmann
|
Post #192,050
1/27/05 10:42:26 PM
|
Perfect :-D
===
Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats]. [link|http://DocHope.com|http://DocHope.com]
|
Post #192,053
1/27/05 11:27:36 PM
|
That programmer is an idiot
He reminds me of the fact that a C programmer can write C in any language.
Yes you can, but you don't want to. Because if you do then you've thrown away the productivity benefits that are to be gained by using a higher level language than C.
I'll give even odds that his "real language" comment is covering fire for the fact that he's programming by imitating poorly understood examples, and doesn't want to admit that he doesn't really understand how to use his current language.
Actually considering what you say his background is, I'd give better than even odds of that...
Cheers, Ben
I have come to believe that idealism without discipline is a quick road to disaster, while discipline without idealism is pointless. -- Aaron Ward (my brother)
|
Post #192,055
1/27/05 11:51:47 PM
1/27/05 11:52:47 PM
|
You can do that in just about any modern language.
What planet keeps sending us this kind of programmer?
And where do I send money for the invasion fleet?
You should ask him exactly which languages are real programming languages, and then show him just how many of them support initialization at declaration.
Regards,
-scott anderson
"Welcome to Rivendell, Mr. Anderson..."
Edited by admin
Jan. 27, 2005, 11:52:47 PM EST
|
Post #192,071
1/28/05 3:18:42 AM
|
No invasion fleet, please! Just nuke it from orbit.
|
Post #192,059
1/28/05 1:14:08 AM
|
Fuel on the fire
Python: \nclass foo:\n bar = 'blah'\n baz = 0\n\n def __init__(self):\n self.bar = ''\n self.baz = 5\n\n>>> foo.bar\n'blah'\n>>> foo().bar\n''\n>>> foo().baz\n5\n>>> foo.baz\n0\n That is, by specifying the "variables" in the classdef, they become members of the class itself. However, when you instantiate foo, the __init__ "constructor" will rebind those values for the object which "self" refers to, without changing the class member values. If we took those 2 lines out of __init__, then lookups of "bar" and "baz" would return the class values. Which is neither here nor there in answering your question... ;)
|
Post #192,291
1/30/05 8:32:38 PM
|
Hey, that's neat!
I had the opportunity to learn Python for a major project. Unfortunately, the Python expert had quite a bit of language arrogance. :-/ So the learning didn't happen.
Wade.
Is it enough to love Is it enough to breathe Somebody rip my heart out And leave me here to bleed
| | Is it enough to die Somebody save my life I'd rather be Anything but Ordinary Please
| -- "Anything but Ordinary" by Avril Lavigne. |
|
Post #192,335
1/31/05 2:24:51 AM
|
It does make extensibility a snap.
One thing I love about Python is -- no, back up -- one thing I hate about other languages is that once you've defined/declared a class, it's difficult to extend objcts of that class, especially if you're another developer (and especially one who doesn't want to customize the original code). In Python, it's dead simple: "thing.new_attribute = 5"...you don't have to muck about with getters and setters, subclassing, or private/protected namespaces (unless you *want* to).
Bummer about the "expert". :(
|
Post #192,402
1/31/05 8:02:04 PM
|
He was very much in love with doing things "correctly".
Unfortunately, he had a great deal of trouble understanding when "correctly" was different from "right". Everyone else was quite a bit more sanguine about The Right Way To Do things. We had quite a row about the object API (in PHP) and how it auto-cached and lazy-loaded information. We experimented with one new object with a more CS-correct way, just to shut him up, and it wasn't a good idea. The inconvenience of one class with a wildly different interface far out-weighed any marginal benefit from the different way of doing it.
As you might have noticed, I tend to distrust over-enthusiastic people. That's what took me so long to get into Debian...
Wade.
Is it enough to love Is it enough to breathe Somebody rip my heart out And leave me here to bleed
| | Is it enough to die Somebody save my life I'd rather be Anything but Ordinary Please
| -- "Anything but Ordinary" by Avril Lavigne. |
|
Post #192,406
1/31/05 8:28:48 PM
|
Seems surprisingly like javascript
which is my current daliance. Well, actually, I have professional reasons to learn it but I'm finding its kind of fun too.
"Whenever you find you are on the side of the majority, it is time to pause and reflect" --Mark Twain
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." --Albert Einstein
"This is still a dangerous world. It's a world of madmen and uncertainty and potential mental losses." --George W. Bush
|
Post #192,411
1/31/05 9:11:18 PM
|
I kinda like JavaScript.
It keeps reminding me of what Visual BASIC should have been. Pity the DOM in most browsers tends to let it down.
Wade.
Is it enough to love Is it enough to breathe Somebody rip my heart out And leave me here to bleed
| | Is it enough to die Somebody save my life I'd rather be Anything but Ordinary Please
| -- "Anything but Ordinary" by Avril Lavigne. |
|
Post #192,420
1/31/05 10:36:00 PM
|
Yup; the name binding and scopes are very similar
|
Post #192,070
1/28/05 3:17:04 AM
|
Well, since C often does "declaration only at first use"...
...which is exactly the same thing (only at another place in the code), he apparently doesn't think C is 'a "real" programming language'! Which is funny, since that's about as "real" as it gets. Especially to those stupid wannabe-cool types that this guy sounds like. (For an EVEN MORE "real" language, IMCO, Delphi allows it too nowadays.) BTW, your last question is slightly wrongly put: Is it more common to allow initialization in the constructor, or to not allow it? Uh, I can't think of a single language that would not allow initialization in a constructor after all, that's exactly what your guy was doing. What you meant to ask is whether a language allows (or should allow) initialization in the declaration.
[link|mailto:MyUserId@MyISP.CountryCode|Christian R. Conrad] (I live in Finland, and my e-mail in-box is at the Saunalahti company.)
Your lies are of Microsoftian Scale and boring to boot. Your 'depression' may be the closest you ever come to recognizing truth: you have no 'inferiority complex', you are inferior - and something inside you recognizes this. - [link|http://z.iwethey.org/forums/render/content/show?contentid=71575|Ashton Brown]
|
Post #192,074
1/28/05 4:25:00 AM
|
Counter example
Smalltalk doesn't. So what. JavaScript does, Java does, C++ doesn't for ivars.
Its a quirk either way.
Your programmer is an idiot - probably agrees with copy paste reuse guy too. Ask him to critique that article - just to see.
"Whenever you find you are on the side of the majority, it is time to pause and reflect" --Mark Twain
"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." --Albert Einstein
"This is still a dangerous world. It's a world of madmen and uncertainty and potential mental losses." --George W. Bush
|
Post #192,083
1/28/05 8:02:46 AM
|
Great suggestion; seconded!
|
Post #192,159
1/28/05 7:16:32 PM
|
Sounds like a language holywar brewing over there
"My fav language/paradigm can beat up yours, neener neener"
________________ oop.ismad.com
|