21

So, I've been programming a number of years, mainly .net, I've been looking at python recently and it just seems wrong to use variables without declaring them. It just seems dirty

Comments
  • 3
    Some people like the dirty ways ;)
  • 0
    Embrace the hate. Come to the dark side.

    Small things like that are precisely why I do a bunch of algo prototyping in python.
  • 3
    Python is free of these constraints. You know. Like a snake. Maybe python. Because the language is called....ok I drop it.
  • 3
    Yeah leaving out all the unnecessary boilerplate you write while repeating yourself at least four times (field, constructor, getter, setter) is probably a bad idea. You are paid for lines of code in the end, not for features, right?
  • 0
    @Huuugo I think OP is more talking about the fact that one can do

    foo = 3

    Rather than have to do

    int foo = 3;
  • 2
    @AngryDev my point stands. If the computer can tell you what is missing, it's boilerplate code. It doesn't add anything on the program logic, but complicates things because you have to care about the low level representation of data. Damn, if you have a number with a point in it it's obviously a float/double. Why repeat yourself all over the place and state the obvious? I am a Java developer and I honestly hate the strict typing. It's only good for ide autocompletion
  • 1
    @Huuugo I'm gonna have to disagree here. I'm also a Java user turned Python and damn do I miss my types. Because typing extends over objects as well. Not knowing what a function will return exactly until runtime can get REALLY frustrating. A repl helps, but can not replace static typing's comfiness. Looking at docs for every function call gets old quick.
  • 0
    @Huuugo so is it a float or is it a double? The amount of time I had to run code, wait for 5 minutes for it to run, to then get an exception at the end because it couldn't work with some data type when I thought I actually had another, is enough for me to really hate Python. But I don't. Even if Python is very bad, compared to other languages, at type conversion, while at the same time being type agnostic, which makes for a horrible combination, I do appreciate the small footprint of the code when I really need to cook up something fast.
  • 1
    @apisarenco I seriously don't give a damn what precision the computer is using. If I was concerned because I need to keep my bitcoin balance in it, I would say so explicitly. Same goes for integers. If it gets too big, the next bigger type should be used. The overhead of that usually doesn't matter at all.
  • 0
    @Huuugo Often times it's not about the low level representation. The advantage of strongly typed languages is that if I declare

    human bob = new human();

    I know that bob will always be a human and I can be assured that he will have all of the things I expect with a human. (Important with huge programs)

    Aside from that, if I change the type of a function (say I go from int banana() to bool banana()) then this breaks it at compiler level, and I know exactly where I need to update my code to match this (again if code is several thousands of lines you begin to appreciate these things)
  • 0
    @Huuugo there is an overhead in memory however. Actually, the overhead is 2x, if your code is well optimized otherwise. And precision is important in long algorithms, because a small loss in a lot of places piles up to quite a lot.
Add Comment