IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New 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]
New 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.

New 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]
New 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.

New 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-------------------------------------------------------------------
New You can do that in C#
--
Chris Altmann
New 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]
New 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)
New 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..."
Expand Edited by admin Jan. 27, 2005, 11:52:47 PM EST
New No invasion fleet, please! Just nuke it from orbit.
New 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... ;)
New 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.

New 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". :(
New 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.

New 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
New 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.

New Yup; the name binding and scopes are very similar
New 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]
New 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
New Great suggestion; seconded!
New Sounds like a language holywar brewing over there
"My fav language/paradigm can beat up yours, neener neener"
________________
oop.ismad.com
     What makes a "real" programming language? - (drewk) - (20)
         I think he's deluding himself. - (static) - (3)
             No doubt - (drewk) - (2)
                 An anti-example. - (static)
                 There are plenty - (jake123)
         You can do that in C# -NT - (altmann) - (1)
             Perfect :-D -NT - (drewk)
         That programmer is an idiot - (ben_tilly)
         You can do that in just about any modern language. - (admin) - (1)
             No invasion fleet, please! Just nuke it from orbit. -NT - (CRConrad)
         Fuel on the fire - (FuManChu) - (6)
             Hey, that's neat! - (static) - (2)
                 It does make extensibility a snap. - (FuManChu) - (1)
                     He was very much in love with doing things "correctly". - (static)
             Seems surprisingly like javascript - (tuberculosis) - (2)
                 I kinda like JavaScript. - (static)
                 Yup; the name binding and scopes are very similar -NT - (FuManChu)
         Well, since C often does "declaration only at first use"... - (CRConrad)
         Counter example - (tuberculosis) - (1)
             Great suggestion; seconded! -NT - (CRConrad)
         Sounds like a language holywar brewing over there - (tablizer)

I see shrieking neurons - certain they will Never be given any Work! Contemplating seppuku.
76 ms