r/Python • • Jan 05 '18

Really??

Post image
2.0k Upvotes

317 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Jan 05 '18

[deleted]

24

u/wrosecrans Jan 05 '18

Massively depends which industry.

44

u/Iggyhopper Jan 05 '18

Java Industry

8

u/[deleted] Jan 05 '18

Java has a sales and marketing budget that is effectively infinitely bigger than the PSF's.

-3

u/[deleted] Jan 05 '18

For now...

0

u/[deleted] Jan 05 '18

[deleted]

7

u/[deleted] Jan 05 '18

Generally I agree. However, we shouldn’t be developing 100k+ line applications in general (note that I’m not saying ever). Rather, we should be building smaller components and composing them into larger applications. Additionally, 100k lines of Java is probably only 30k lines of python.

To your points about dynamically typed languages and speed, I agree. Though, I wouldn’t say that the obvious solution is Java...

0

u/[deleted] Jan 05 '18

[deleted]

0

u/[deleted] Jan 05 '18

[deleted]

2

u/unruly_mattress Jan 05 '18

C# really is a very nice language. If it played more nicely with platforms other than Windows, I think it would have been an ideal choice for medium-sized projects and larger. It's a bit of a statically typed Python with a little more cluttered syntax.

As to why someone would want to add type declarations to a dynamically typed language. In my opinion static (i.e written in the code) types are convenient where the types are known while writing the code. Sometimes, however, this is not the case. Types can be created at runtime, by querying the database or reading from a .json. A Qt designer file gives you a QWidget subclass. SQLite and key-value stores hold untyped objects. Any metaclass action results in a class that's generated in runtime.

In these cases, having a static type system would make you work with it somehow. It can be generating class declarations from configuration files as part of the build process (which .NET does). It can be creating an "interface" ISomethingThatGoesInTheDatabase with subclasses DBInt, DBString, DBUserProfile, etc, thereby duplicating a class hierarchy (and yes, I've seen that happen in a Java project).

Many of these issues can be overcome by using Object in statically typed code. However, that's very frowned upon by static typing people. I think Python type annotations might hit the sweet spot - you can use them wherever they're useful, but you don't have to use them where they don't make sense.

0

u/[deleted] Jan 05 '18

[deleted]

1

u/unruly_mattress Jan 05 '18

The last time I used the .NET ORM stuff it used code generation. It doesn't surprise me to know that it's better these days, because the language designers generally make good decisions.

If you're working with two untyped systems - by which I mean systems that would work with all types - then you don't need to know what you're working with. For example, an event/notification system. The code that handles the method arguments doesn't need to know what type they are. The best you can do is treating them as Object[]; creating INotificationMethodCallArguments is much worse than just not knowing what type it is. Once someone decided to create a superclass or an interface (it's an is-a relationship, right?), you have to create classes that wrap existing classes and it becomes a huge and useless waste of time.

Likewise a storage system. It takes stuff and stores it, then retrieves it for you. You know what you're going to get, but the storage system doesn't know what it's going to give you. It should handle Objects, not IRetrievedItem. When I worked in Java, there were so many useless types.

Hence. If you know the type, by all means write it down. If you don't, don't. Don't create a new type so that you have something to write down. And while in most cases you know the type, the overhead of these useless types was a huge weight on the back of that Java team I was part of, because these types then invade normal code, conversions start happening back and forth... It's not pretty.

1

u/[deleted] Jan 05 '18

Do you feel comfortable deploying that code to production without code review, unit tests, integration tests, and passing all of the system tests?

It doesn't matter what language I use, I am going to engage a sane testing policy to ensure the highest quality product possible.

I have found that the ratio of testing to lines of code remains about the same regardless of what language I use. So I try to reduce the lines of code and redundant information in the code.

I could probably reduce your code above to a few lines of Python, and still keep it under 80 chars per column. Add a few unit tests, and it will be ready for system integration before lunch.

→ More replies (3)

-5

u/icp1994 Jan 05 '18 edited Jan 05 '18

way faster than we do in any other language.

how? no way it should be possible with equal quality of C++ codes

edit: why am I getting downvoted for saying python codes shouldn't be way faster than equivalent c++ code. expected this sub to be more mature

→ More replies (7)

-2

u/[deleted] Jan 05 '18

So people prefer writing 500k line applications in statically typed languages? Actually no, there are projects running to 1M lines of Python.

0

u/[deleted] Jan 05 '18

[deleted]

1

u/[deleted] Jan 05 '18

Far easier to refactor 1M lines of Python than 5M lines of a statically typed lnguage.a

0

u/[deleted] Jan 05 '18

[deleted]

1

u/[deleted] Jan 05 '18

Besides Static typing doesn't mean more lines if that is what you are implying.

It does if you're talking C(++) vs Python.

0

u/[deleted] Jan 05 '18

[deleted]

1

u/[deleted] Jan 06 '18

Static typing simply allows for a faster and more secure workflow in large codebases

Citations please.

→ More replies (0)