Forum Moderators: bakedjake
If you just want to play with it, then the full system (eg. on top of Windows) is a lot more fun. The language isn't extremely interesting in my personal opinion. But then, I just don't like the overly verbose Pascal type syntax. The cool part is how it interacts with the system in very unusual and powerful ways.
> Emulators of that system are also available for other OSes.
Any of those other OSes relevant to this forum?
I don't think anything relating to Oberon is really relevant to this forum, even though they appear to have a web browser. The original Oberon hardware "Ceres" never made it out of Wirths institute. But implementations of the system and the language are available for all popular OSes, and then some (there's even a .NET version).
ETH Oberon Home Page [oberon.ethz.ch].
I guess we're digressing from the actual topic of this thread, because Oberon is not a language that I would recommend to Nick_W for his requirements. I'm just kind of nostalgic about it, because I once took a class about object oriented programming with Oberon at ETH. Unfortunately I never happened to run into the master himself, though.
Its clean, OO (from the ground up, not an afterthought or wedged in like Python or Perl, respectively), consistent, has blocks, open classes, reflection/introspection, yada yada.
Consider:
a = ['bananas', 'apples', 'oranges', 'grapes']
a.each do ¦fruit¦
puts "I want to eat #{fruit}"
end
# => I want to each bananas ...
or:
0.upto(100) do ¦i¦
puts "I want ice cream!"
end
# => prints 'I want ice cream!' 101 times
or:
class Array
def sum; inject(0.0) do ¦i, n¦ n + i; end end
def avg; return 0 if self.length.zero?; sum / self.length; end
end
(0..50).map do ¦x¦ x + rand(x) end.avg
# => adds a #sum and #avg methods to Arrays, then creates an array with values 0 to 49, adds a random number between 0 and the value of the array at that index to each index in the array, then computes the average.
The decision on which language to use is dependent on what application you want to build. A language like perl is great for cgi, text processing, and gluing large applications together in enterprise systems... But you wouldn't use it to build a device driver for your new graphics card or a shoot-em-up game. Similarly for Python (or any other language); it is good for some things and bad for others. So what do you wish to do with the language?
The decision on which language to use is dependent on what application you want to build.
Ditto. There must be about a million different programming languages. Some programs, like Flash or 3DS Max, even have their own languages built in, but those are special cases. Use what's best for getting the work done.
Python was designed to be OO from the start. However, it doesn't exaggerate the principle just for the sake of it.
a.each do ¦fruit¦
puts "I want to eat #{fruit}"
end
Cool, thanks! Now I know that I don't need to have a closer look at Ruby... ;)
Does Ruby generally "wedge" the control structures into the object model like this? That's a bit too much implicit magic going on for my taste.
To each their own, of course. The mantra of the Ruby fans appears to be: "If it isn't expressed as a method of an object, then it shouldn't happen". If nothing else, then that's definitively consequent!
Talking of OO languages, I haven't seen anyone suggest Smalltalk. Maybe the Smalltalkers are just so confident they don't feel the need to promote their language; or maybe they want to keep their secret to themselves. ;)
[added: On the other hand, I haven't seen anyone promote Java, so perhaps its just to do with the cross-section of people who are reading this thread compared to the broader cross-section of programmers]
perhaps its just to do with the cross-section of people who are reading this thread
I'm sure I'm not the only one who dropped by the thread thinking that I didn't know enough languages to be much use in the advice department, but that languages are cool anyway and I might learn something. And I did :)
I also suspect that this forum does have a somewhat different spread of languages than a random sample of programmers. After all, this is the *nix forum of a webmaster site. We probably all know languages we've found useful because they are well integrated with tools of those trades. Getting Perl and/or PHP set up for these environments is easy, and it's pretty much universal advice to people getting interested in dynamic pages that they learn at least one of those. I understand Python to be pretty easy to set up for that sort of thing, too, though I still have yet to actually pick up my Python book and learn it.
I didn't really expect Lisp to come up, for example, because although I know it has been used for web development I don't think it's widely enough used for the purpose that most people here will have tried it. Of course, I assume someone here has computer interests other than just webmastering, so someone probably has. :)
File.open('somefile', 'w') do ¦fp¦
fp << "Some text\n"
end
You don't have to worry about cleanup at all, the file already knows how to do that, and does it for you. If you look inside File.open, you'll see something like this:
def self.open(filename, mode = 'r')
f = File.new(filename, mode) # create a new filehandle
if block_given? then # if you passed in a block
begin
yield f # pass the filehandle to the block
ensure
f.close # make sure the filehandle gets closed
end
else # otherwise, just return the filehandle
return f
end
end
Using iterators via #each is not any different than using a for loop:
for (i = 0; i < array.length; i++) {
printf("I want %s\n", array[i]);
}
You don't have to worry about off-by-one and other counting errors, its all taken care of for you.
I disagree that Python was designed to be OO from the start, it wasn't until very recently that you could subclass from types in C, much of the library is written in a procedural style, and how to break encapsulation is described clearly in the description of Classes. (The opinion of a particular interpreter writer agrees that Python's objects are an afterthought, and I have no reason to disagree with him.)
I feel it would be more accurate to say "Python has OO features".
Sorry, Dingman, I didn't mean my comment ("...perhaps its just to do with the cross-section of people who are reading this thread ...") like that. I just meant that the audience is primarily web developers, not general software application developers, as you pointed out; so the recommendations are biased a bit towards what is useful for web developers (even if those web developers have a lot of knowledge in other languages too).
As for Lisp, I wouldn't expect anyone to recommend it in a general context even if they have tried it. As per my previous post, languages each have their strengths. In some cases those strengths are in general application development, whereas other languages are more suited to very specific domains. My view is that Lisp is very specific to Artificial Intelligence. You'll always get those evangelists who try advocate that their favourite language is suitable for anything, but I think even Lisp advocates would admit that Lisp is very good for some things, but shouldn't be used as a general work-horse.
That's the type of argument that I'd rather try to avoid. There's no "official" definition of what exactly makes one language more OO then another. And it would be an academic distinction anyway. If you ask a Ruby (or Smalltalk) fan, then all other languages are "lesser OO". If you ask a Python programmer, then they'll just say: "I don't care, as long as it works the way I think".
My view is that Lisp is very specific to Artificial Intelligence.
I have done a lot of lisp in a 3d graphics environment in the past. Lisp is a wonderful language for its dynamic nature and the flexible data structures. Then one day I learned object oriented programming (with Oberon), and when I ran into Python a few years later, I was amazed how brilliantly it combined the best of both sides.
how do people here go about learning new languages?
To scratch an itch. I learned Python in about a day because I had an extension system in guile for an app of mine. Guile started to not be the right tool for the job, then I rewrote all the scheme code to Python. It's amazing what you can do when you really need to.
Then my C/C++ application for which I had not used any special C++ features needed a GUI. I only knew pure C, but QT was the perfect choice. Then again, I go and learn proper C++.
You'd be amazed how often u find uses for Perl in "home" use. Say, sometimes I need to rename bunch of files into same format, I just write a Perl script to do it for me.
There are unlimited applications of Perl.
Regards,
R.