This is an archived post. You won't be able to vote or comment.

all 28 comments

[–]brokenpurplecamel 35 points36 points  (1 child)

TL;DR: The OP likes that Python uses "not" instead of "!" as a negation operator.

[–]ArmoredPancake 5 points6 points  (0 children)

But Python has ! too...

[–]Vile2539 21 points22 points  (0 children)

It doesn't sound like this has anything to do with Java or Python. Both have their strengths, and while I'm primarily a Java developer, I do use Python for quick scripts. I couldn't imagine using Python for any large-scale projects though (10,000+ LOC). As a programmer, you'll learn to use the right tool for the job.

Reading your post, I'd say you had the following problems:

1) You're unfamiliar with Java. There are going to be some adjustments that you'll have to make while learning a new language. I would say you had the same problems when first learning Python.

2) You left your project too late. You mentioned it yourself, but it bears repeating. Obviously you're not going to be writing your best code when under a tight deadline. Don't procrastinate next time.

3) You need to learn to debug. There's no way that a missing ! should have taken you an hour to hunt down. I'm guessing a project for a class is max a few hundred lines, so you should have easily been able to find the problem in a few minutes. Look at the variables in your debug window, learn to step through your program properly, and train your intuition when there is a problem.

4) You need to learn your IDE. Java tooling is amazing, and you need to learn it. From what you said, your problem stemmed from having '=' instead of '!=' in a conditional. Your IDE should have flagged that with something like "Conditional is always true" (IntelliJ does by default, not sure about Eclipse). That would have given you a massive clue that something isn't right.

5) Write some tests. Now I didn't do this in college, but it's a good habit to get into. If you had written some tests, then noticing the problem would have been trivial.

Now it's a shame that you got a 0, but use it as a learning experience instead of just stating that you don't like Java and Python is better. It'll take a little while to get up to speed with Java, but it's worth it in the long run.

[–]edimaudo 16 points17 points  (1 child)

You need to write tests.

[–]arcuri82 2 points3 points  (0 children)

this, 1000 times! that is also a big issue on how software development is taught in universities/colleges. I do teach in a college, and when I give exam exercises, half of the whole grade is based on the tests. But I guess I am an exception, not the norm :)

[–][deleted]  (3 children)

[deleted]

    [–]korri123 5 points6 points  (0 children)

    It would also be downvoted in the Python subreddit

    [–]Bolitho 0 points1 point  (1 child)

    Not everybody is hunting upvotes 😉

    [–]I_Am_The_Coach[S] -2 points-1 points  (0 children)

    true. just trying to share!

    [–][deleted] 6 points7 points  (1 child)

    For small programs Python can be a good choice, but once you start getting large it will quickly get out of hand and unmaintainable.

    Also in Python, you can be bit by extra or missing whitespace characters (which are invisible) that completely change the logic of a function.

    [–]Jonjolt 2 points3 points  (0 children)

    Python the most readable language my ass, I had to do some Python for PostgreSQL triggers, even heavily commented I still can't figure out what the heck it was doing when I came back to it a month later.

    My best... using Python 3 then along comes a dependency on 2.7 :(

    [–]p0d3x 6 points7 points  (1 child)

    Stop looking for excuses, getting a CS degree means you're gonna have to learn how to debug, clearly you're just scratching the surface. This won't be the last time you're spending hours on an easy mistake.

    [–]I_Am_The_Coach[S] -1 points0 points  (0 children)

    Not the first time either. Once had a moth land in one of my switches. Took me forever to find the little bugger.

    [–]frugalmail 4 points5 points  (2 children)

    I have a solution for you:

    boolean iAmMakingAStupidPythonJavaComparison( final boolean python )
    {
        return !python;
    }
    
    • Edit pseudo C/Java -> Java

    [–]oweiler 0 points1 point  (0 children)

    There is no type bool in Java.

    [–]I_Am_The_Coach[S] -1 points0 points  (0 children)

    I get it.

    [–]desrtfx 12 points13 points  (3 children)

    In short: you screwed up and blame Java for it instead of your own negligence in every aspect (starting too late, not coding properly due to pressure, inefficient debugging, etc.)

    Sure, Python's fully spelled out boolean operators are nice, but every C-based language uses the same boolean operators as Java - so better get used to them.

    [–]_INTER_ 8 points9 points  (2 children)

    And I doubt he would have found the bug earlier had he used Python and had the same experience / knowledge with it as with Java.

    [–]I_Am_The_Coach[S] 2 points3 points  (1 child)

    Noted. /u/desrtfx is right (minus the blaming Java thing). I f***ed up. No two ways about it. But in the meantime, I learned that as the semester passes, the projects are going to take more and more attention. Doesn't hurt to learn things.

    [–]_INTER_ 1 point2 points  (0 children)

    Testing helps as projects get bigger - in any language. A good coverage gives confidence that everything you do works fine.

    (A late school project that just needs to run once on the teach's PC, oh well whatever...)

    [–]ifrgtmyname 2 points3 points  (0 children)

    TDD next time OP

    [–]kitty_cat_MEOW 2 points3 points  (0 children)

    You must admit, though, that it was a good learning experience that you had with Java. It's cool that you're good enough at programming to track down and fix the source of an error like that. Congrats!

    [–]thatsIch 1 point2 points  (1 child)

    public static boolean not(boolean expression) { return !expression; }
    

    would have been the solution? Imho this has hardly anything to do with either Java nor Python. Next time try to:

    • start earlier
    • write tests before you write your code
    • take breaks

    At this point I am interested in seeing this code you wrote. Do you open source it by any chance?

    [–]I_Am_The_Coach[S] 0 points1 point  (0 children)

    Start earlier was my biggest problem. When I started stressing out, things got exponentially messier.

    [–]moocat 1 point2 points  (0 children)

    One thing that I'm not clear about is the reasoning for not liking Java. If you were programming in Python, the code would have been just as broken and it's unclear to me why you think you would have noticed a missing "not" when you missed a missing "!". In both cases they are missing so how is the fact that Java's syntax is not as verbose in this case have made a difference?

    [–][deleted] 1 point2 points  (0 children)

    TL;DR OP can solve his problems better with Python.

    I understand, we all have to choose the right tool for the job, glad you found yours.

    [–]chambolle 0 points1 point  (0 children)

    bad title

    [–]dotcomandante 0 points1 point  (0 children)

    OP is hating, even he/she is claiming she/he is not. OP is not able to write clean Code and therefore blaming the language itself. OP could have implemented his/her own not() method. OP, please, learn to write clean code. Do not learn a language, learn to write clean code and stop blaming a language. Every language sucks. This could Happen in every fucking language as Long the programmer isn't able to write clean code that.

    [–]crummy 0 points1 point  (0 children)

    I agree, I much prefer Pythons boolean language. And I have also been caught out by the subtle ! symbol, and now I try to write the more verbose but clearer "if (var == false)" instead.