Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Exams

Name: Anonymous 2006-12-19 0:33

Hey /prog/

Had a programming examination today. I'm a second year comp. eng student at McMaster in Canada, and man, the kind of grief the exam gave my friends and I was..haha it was rough.

But as I was looking at the questions on the exam (for reference, it was basically Java, & C++), I had to ask myself: "What the hell is so great about OO programming?"

When it comes to Java, it bothers me that all objects are passed by ref, that casts are only checked at run-time, and just, well the overall slugishness I seem to feel when I'm trying to develop code. Is it wrong to feel a lack of interest (and a lack of a good mark) in a course I'm supposed to be enjoying, and paying for out of my own pocket?

I'm not going to pretend I'm a whiz kid at programming, I know there are members of /prog/ who could laugh at the questions had they seen the exam.

Anyways, I wanted to hear from you guys, share your experiences of crappy setbacks in college/uni from comp sci/software eng/comp eng, etc.

Name: Anonymous 2006-12-19 0:48

fucking trolls...

Name: Anonymous 2006-12-19 0:57

>>2
Troll?
There are questions being asked throughout the post.

I want to hear from others about rough times at school in the past, so I don't feel like I'm the only one. Questioning a language != a troll post.

Name: Anonymous 2006-12-19 1:06

What the hell is so great about OO programming? is a troll. Anyway, I have been trolled so I answer: it's good because you can write efficient crap fast that will solve your problem. Yes, functional programming or whatever can be better, but it's 10 x slower to write with for most people.

it bothers me that all objects are passed by ref ==> why, moron? it's cheaper than pass them by value.

Name: Anonymous 2006-12-19 1:26

>>4
It wasn't meant to come across as a troll, I apologize for that.

Passing an object by reference may be cheaper than by value, but I struggle with lists being a collection of object references. If I want a method to return that list, I get stuck with a copy of the same references I sent to the method.

How am I supposed to make sure that object references aren't being shared?

Name: Anonymous 2006-12-19 3:30

What the hell is so great about OO programming?
Nothing. It's just another way to organise your program.

Is it wrong to feel a lack of interest (and a lack of a good mark) in a course I'm supposed to be enjoying
As trite as it may sound: welcome to the world of Java and C++.

It's a pity that money and masochism go hand-in-hand.

Name: Anonymous 2006-12-19 4:29

Is it wrong to feel a lack of interest (and a lack of a good mark) in a course I'm supposed to be enjoying, and paying for out of my own pocket?
Academia has a way of making almost everything boring.

As far as exams involving programming, the big marks go to those code-writing questions. Don't be tempted to jump in and start writing code immediately. Come up with an approach, then an algo, and _then_ write your code. I've given a few substandard answers in the past because I rushed in, but I've learned my lesson.

What really bugs me about writing code on paper is that paper doesn't lend itself well to the way I do things. For example, I like putting in my brackets first, and then filling them with content, but you can't really do that on paper.

Name: Anonymous 2006-12-19 4:34

>>1
I understand your questions.

What the hell is so great about OO programming?
Not much. It's a good way not to fuck up, but there are others. It's a good idea to create independent structures, units or objects that maintain their own data. Note, though, that the only difference between MyClass.Lol(myobj) and myobj.Lol() is syntax.

The reason why they're all hyped on OO is that OO was the previous business shit that kept every manager busy wanking to OO. Businessmen (who can be distinguished by three features: rule this industry, have no fucking idea of it, and always have to fuck everything up) are obsessed with OO because they read in a magazine that it's so great because "it increases your company's productivity by enabling software architects to benefit from code reutilization and information hiding, creating a smooth flow of work that will maximize your business profits and help creating enterprise-ready scalable business solutions implementing your business logic". That's business-speak, get used to hating it because you will, all your life.

When it comes to Java, it bothers me that all objects are passed by ref
Java is useless, but all objects passed by ref is a good thing. It's easier to understand in languages such as Python. Passing by reference means more efficiency (copying is slower and creates objects in memory which probably have to be garbage collected afterwards), it means you don't have to define a copy operation for each object (remember copying objects is not always as easy as copying each property: the object may have open files, etc., stuff you can't or don't want to happily copy), and it allows for certain magic that you'll discover in due time.

casts are only checked at run-time
Java's type system is made of anal and shit. Don't expect it to do anything right. But get used to dynamic typing. In a decent language, this is possible:

i = 1
i = "Now I'm a string, lol"

# Let's create a class right now and here
class MyClass(object):
    def Method(self):
        return "I lol'd"

# A completely different class now; doesn't inherit from MyClass or anything
class MyClass2(object):
    def Method(self):
        return "Yoshinoya"

# Let's create a function here
def CallMethod(x):
    print x.Method()

i = MyClass()
CallMethod(i) # "I lol'd"
i = MyClass2()
CallMethod(i) # "Yoshinoya"
# Note that CallMethod doesn't expect x to be of any particular type. All it requires is that it has a method "Method" to call.

# More fun: A function which returns a class? In Mother Russia it's possible.
def CreateClass(inherits, method1):
    class NewClass (inherits): # Inherited class is passed by the caller
        MyMethod = method1 # They pass us this method, we use it here
    #Return the newly-created class to the caller
    return NewClass

# Create a class like MyClass and MyClass2 with this method:
def TempMethod(self):
    return "What? Method? Function? It's actually the same."
MyClass3 = CreateClass(object, TempMethod)
i = MyClass3()
print i.MyMethod() # "What? Method? Function? It's actually the same."



the overall slugishness I seem to feel when I'm trying to develop code
That's because Java sucks. It's about as unproductive as C, only slower and more annoying to work with. Not only the language is flawed in more ways than I have time to explain, but the standard library is pure hell. When you have to instantiate three classes with long names to print a fucking line of text on a file, something is wrong.

Is it wrong to feel a lack of interest (and a lack of a good mark) in a course I'm supposed to be enjoying
It's not wrong. Stay away from Java or you'll end up hating this trade. For low-level/speed-critical/VROOM VROOOM stuff use C; for everything else, I recommend Python, Ruby, LISP, Haskell, etc.; real languages. You'll find them so much more interesting and fun to learn and use. Python (what I used in my example) and Ruby (similar set of features) are more traditional approaches (though take "traditional" with a grain of salt), while LISP is more powerful but less uh... conventional, and Haskell is a pure functional programming language.


>>2
Meta-troll


>>5
I struggle with lists being a collection of object references.
That's what makes them efficient. Careful with mutable objects though.

If I want a method to return that list, I get stuck with a copy of the same references
Very simple stuff in a decent language. If your elements have a copy() method, and you have a language which supports functional programming features, you could try returning something like map(MyClass.copy, mylist). But you rarely need to copy every element of a list, really. You can post a short description of what you wanted to do and why you needed copies, and I'll help you.


>>6 is a wise person.


>>7
What really bugs me about writing code on paper is that paper doesn't lend itself well to the way I do things. For example, I like putting in my brackets first, and then filling them with content, but you can't really do that on paper.
I feel your pain! This is exactly what I do and why I hated programming exams.

Name: Anonymous 2006-12-19 4:43

>>8
By the way, I'd like to clarify/fix what I said here:
If your elements have a copy() method, and you have a language which supports functional programming features, you could try returning something like map(MyClass.copy, mylist)
That's only if all of mylist is MyClass, but for lists holding different types of objects with copy() method, you can do something like map(lambda x: x.copy(), mylist) .

Name: Anonymous 2006-12-19 4:58

Java makes me feel physically ill

Name: Anonymous 2006-12-19 5:53

>>8
For low-level/speed-critical/VROOM VROOOM stuff use C; for everything else, there is Mastercard.

Name: Anonymous 2006-12-19 6:32

>>6
>>7
Thanks guys for the encouragement, especially >>8

Haha I was talking to a friend of mine who is a senior, and he said the course was considered a bird course back when he took it. The course was taught by a friend of Xiaolin Wu, (haha I don't know the whole story, he came up with some clever algo for line antialiasing, and him and his professor friends like to grief us newbie students)

Admittedly, my enthusiasm for programming/networks/hardware is a lot larger than my knowledge base, and I feel so, so much better after listening to you guys, and now knowing that there are more enjoyable ways to further knowledge in this field.


>>8
I have to ask: I've lurked for awhile on /prog/, and I've seen people praise the languages you mentioned, and knock the bloated languages like Java and C++.

How come my school is teaching us those languages?  Haha, I feel a tad bitter knowing I'm paying not to learn with the best tools available.

Name: Anonymous 2006-12-19 6:48

How come my school is teaching us those languages?
Becuase many university teachers have no flipping idea either. Another reason may be wanting to teach you what will get you money (admittedly, because of stupid businessmen, it's easy to get a job doing Java or C++, and it's hard to get one doing Python or Ruby - for now).

Name: Anonymous 2006-12-19 11:49

Becuase many university teachers have no flipping idea either.
Those that can, do. Those that can't, teach.

The unfortunate result is too many Java-mills pumping out shitty programmers with NFI. So there has to be a special exception above for Java where those that can't teach or use Java.

Name: Anonymous 2006-12-19 12:43

>>14

In good universities, most teachers are also active researchers in their fields.

Name: Anonymous 2006-12-19 17:09

>>1
Comp Eng at McMaster!  Say Hi to Simon Haykin for me!

Name: Anonymous 2006-12-19 17:19

>>8
You can return class objects in java..

Name: Anonymous 2006-12-20 6:28

>>17
But are classes closures and can you create them in run time?

Name: Anonymous 2006-12-20 9:39

hoho, i go to mcmaster as well ;) but not for comp. sci.

Name: Anonymous 2006-12-20 9:45

>>18
Why the fuck would you want to do that.

Name: Anonymous 2006-12-20 10:45

>>20
Is dat sum Blub Paradox?

Name: lol !2M06AER3HA 2006-12-20 10:47

I say you do it.

Name: Anonymous 2006-12-20 17:04

>>20
For real stuff. A different way of doing things that, when mastered, will make you more productive. More productive means you finish earlier and then you can slack off. Slacking off is any good programmer's favourite sport.

Name: Anonymous 2006-12-21 5:45

C   and   AJAX!

Name: Anonymous 2006-12-21 5:47 (sage)

opera mini fails it for posting my post to the wrong thread

Name: Anonymous 2006-12-21 7:53

>>23
Sounds like some technique that makes up for inadequacies of worthless languages.  Not enough though, so use Haskell.

Name: Anonymous 2006-12-25 21:07

>>23

Examples or GTFO

Name: Anonymous 2006-12-26 1:43

There are plenty of reasons but if you have to ask /prog/ you're a total tard.

Name: Anonymous 2006-12-26 16:56

>>28
there are also plenty of reasons to use Windows Vista according to Microsoft, but this is still crap according to me...

Name: Anonymous 2006-12-26 17:24

I just finished a college level class in Java and here's what pretty much came out of it:

-OO and class-based programming works good because you can separate your program into neat pieces, and you can work on one piece without such modifications screwing up the other pieces in the process.  This way, several people can each program their own class for a bigger program and the only puzzle to solve is the naming of the stuff that plugs each class together.  That's good.

--Making GUIs in Java is a pain in the ass.  I haven't yet looked at the C++ way yet (my teacher was challenging himself to make me prefer Java over C++) but I sure as hell didn't like the way Java handled things, especially with NetBeans, which created a clusterfuck of a code that didn't resemble anything I had seen before.  If there is a VB-style way of making GUIs with a .height, a .width, a .left and a .top, I haven't seen it in Java yet...  That sucks.

Name: Anonymous 2006-12-26 17:58

My Java Gui experience goes about as far as dumping a few widgets into North in a JToolbar, dropping a panel into centre, and a statusbar into south with swing; but I believe that if you want co-ordinates and stuff, try GridBagLayout in swing. Apparently it's not the best way of doing it though. The slightly abstract Java way of doing it allows the renderer a bit of flexibility in the case of small screens and stuff.

Name: Anonymous 2006-12-26 21:09

>>30
OO and class-based programming works good because you can separate your program into neat pieces, and you can work on one piece without such modifications screwing up the other pieces in the process.
For which OO is not even necessary. OO is about functions keeping different states, and class inheritance, which is often (but not necessarily) offered by OO languages. Not less, not more.

Making GUIs in Java is a pain in the ass.
Making GUIs in pretty much anything that's not Visual Basic or similars is a pain in the ass, and doing anything in Java is a pain in the ass, so making GUIs in Java is a pain in the ass squared.

If there is a VB-style way of making GUIs with a .height, a .width, a .left and a .top, I haven't seen it in Java yet
Try HTML, then serve your application through a web server. No, I'm serious. "GUI" in 5 seconds, acceptable for some applications, plus you get a distributed application.

Name: Anonymous 2006-12-27 1:15

>>32
HTML: GUI in 5 seconds, server side installation, settings and writing something useful in 1 month. It was a bigger PITA than using Qt or Gtk when I did it.

Name: Anonymous 2006-12-27 8:09 (sage)

HTML+Perl: GUI in 5 seconds, server side installation and settings in 0 seconds, thinking of something useful to write in 1 month, actually writing it in 15 seconds.

Name: Anonymous 2006-12-27 9:23

>>34
seconded (also, in before PERL HAS TEH PUNCTUATIONS I CANT USE IT)

Name: Anonymous 2006-12-27 13:49

>>34
all right, I'll write some big stuff in Perl, with image processing included...

Name: Anonymous 2006-12-27 19:15

Consider Python, Ruby.

Name: Anonymous 2009-01-14 12:54

LISP

Name: Anonymous 2009-03-06 9:09


The smart kids write.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List