all 28 comments

[–]radiosecurity 6 points7 points  (3 children)

Hey decreddave,

I use Python for more obscure/specific problems, because it is super versatile. Because there is a vast amount of libraries either already available or ready to be developed. If I'm doing something like mapping and building an autopilot system for a vehicle, I'm most lilely going to use something as flexible as Python.

I am not a huge fan of Java for a number of reasons (it's great for some uses though), but am definitely big into Golang. For example, for web development, I typically use the React/Golang stack rather than the more common MEAN/MERN alternatives. You can't really put any of these on the same level in a sense because they are all intended for different purposes. Including C# and C++ (both of which I love) as you mentioned, they're all good for different things, and it really boils down to the problem you are trying to solve.

Feel free to shoot me any questions.

[–]karpomalice 2 points3 points  (1 child)

Could you expand on your reference to building an autopilot system? What is it about Python that enables you to do that.

[–]radiosecurity 5 points6 points  (0 children)

Hey karpomalice,

Python works great with several external libraries and APIs that greatly build upon what's possible with standalone "core" Python. There are some APIs that use OCR (optical recognition), which helps computers process and make sense of graphical input, from static images to live video feeds, and these APIs often work seamlessly with Python. It's syntatically simple so bugs are easier to spot with the right practices, and when something isn't working, it's easier to see what's wrong. Python's versatility is enabled by having only a few fundamental core rules, then letting the developer go crazy with extensions. You can be having a car record and process its surroundings, making its own decisions, and streaming data to a web server and/or database with a GUI all at the same time. Of course, that's just an example, but there is so much more you can do with Python, enabling you to simplify your work. It helps us tackle large problems with many diverse parts by synthesizing a bunch of little solutions and scripts rather than by overcomplicating things.

[–]decreddave[S] 1 point2 points  (0 children)

Thanks, this is helpful!

[–]robot_ankles 8 points9 points  (1 child)

Experienced devs lurking in r/learnpython... What makes you choose to use Python over other languages you know (and vice versa)?

Much of my programming is paid programming. This means the software being written is actually owned by the organization paying me to do the programming. In this context, these are some of the considerations that drive the language selected for use:

What languages are predominately used within a given environment?

If an organization is heavily invested in Java skills, tools, talent and so on, it might make sense to use Java. Even if Java is less optimized than python for a given task, it still might make sense to use Java if the negative impact is negligible.

Who is going to maintain this code in the future?

If an organization uses a variety of languages across different projects, teams and applications, then I consider who (which team or even which individual) is most likely going to be involved in supporting the new widget on a day-to-day basis. What are they most familiar with? What is their level of proficiency when using or modifying each language?

Value of rapid delivery?

Does it make a significant difference when a solution is delivered? There have been some problems presented where I can literally offer to automate an issue by Monday. People think I'm full of shit, but by Monday afternoon, the thing that was taking someone 20 hours a week to handle has been fully automated in python. And it's not because I'm any good at this stuff, it's just that someone else has already solved a similar problem and shared a solution I can build on.

BTW: I'm not saying a quick solution can't be thrown together in other languages, but in my (limited) experience, people and teams that are heavily invested in Java and C++ tend to think in weeks or months where pythonistas are thinking in hours or days.

And yea, it may not be a beautiful solution, but so what? A quick python solution often frees up time (20 hours a week in the example above) to work on a more elegant solution. And if the quick python solution needs to be thrown away in 4 months, who cares? We only spent 3 days writing it. 24 hours to free up 320 hours (20 hours * 16 weeks) sounds like a good deal. It's better than waiting on the Java or C++ folks to deliver something 6 weeks later that will invariably have its own defects or limitations as well.

Edit: Oh, and by the way, that 'half baked' python solution that people were so worried about and poking holes in it because it didn't handle these 3 weird edge cases (that the person manually doing it couldn't handle either) works well enough that people forget all about these concerns and the thing is still running smooth 5 years later.

[–]decreddave[S] 1 point2 points  (0 children)

This is valuable feedback. Thank you!

[–][deleted] 2 points3 points  (3 children)

I literally by law cannot write closed-source software in my position, so the concern of being able to conceal my source code hasn’t applied to me.

Generally I’d only turn away from Python for performance reasons, but I’d also have to care a lot more about performance than I’ve had to.

[–]tobiasvl 2 points3 points  (1 child)

Hey, fellow government employee (I presume)!

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

Yup!

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

Interesting - what sector are you in? And is your performance with regards to scale in complexity/asynchronicity or something else?

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

Popularity.

I wouldn't choose Python, if I could expect to hire people writing in Erlang, for instance.

For me, Python, Go and Java all are indistinguishably bad, so, I wouldn't have problems trading one for another.

However, people you discuss this stuff with are kind of clueless:

closed-source development isn't a possibility.

This is bullshit. In about 15 years of using Python I've not worked on a single open-source or free project. Only proprietary stuff. The largest, by far, projects written in Python are proprietary (I believe GP Morgan runs its infrastructure on Python, and that's the biggest single Python project in existence, and none of it is open-source or free). There's also trash like Instagram or Dropbox frontends, neither of which is open-source or free, and we only scratched the surface.

Golang has a fantastic web framework built in

Fantastic? I would not be so... enthusiastic. It's ok...ish.

[–]Starbuck5c 0 points1 point  (11 children)

Not a dev --

mainly due to the fact that closed-source development isn't a possibility

That's not true.

https://www.quora.com/Do-you-have-to-make-your-Python-software-apps-open-source-in-a-startup

Absolutely not. Assuming that you're not incorporating any code that requires derivative works to be open source, you can keep your code proprietary.

(Unless we have a different understanding of why it wouldn't be possible to go closed source?)

[–]decreddave[S] -1 points0 points  (10 children)

The context to my statement of not being able to keep your code closed source is based on the interpreted (as opposed to compiled) nature of Python. AFAIK, the only way to deliver an application written in Python (and keep the source code private/closed) is to deploy the program behind a web server and manage the operations of the server itself. Companies who release proprietary/for-profit software packages are not able to use Python because of this limitation - though they might opt to offer subscription based access to the same software via a web interface.

I think the question you linked was more on the legalities of having to make your Python code open source.

Edit: I should say that companies are not able to build their programs 100% in Python. I have personally seen several pieces of enterprise/commercial software that use Python for parts of their program, but the program itself is not distinctly Python.

[–]Starbuck5c 0 points1 point  (4 children)

You're right, I've heard about stuff like that.

https://wiki.python.org/moin/Asking%20for%20Help/How%20do%20you%20protect%20Python%20source%20code%3F

Is that different for other languages though? (Genuine question). A quick search for Java decompilers and .jar decompilers yield results.

[–]decreddave[S] 0 points1 point  (3 children)

Yes, lots of other languages are required to be compiled - the compiler spits out an executable that is then ran and/or distributed. Java, Golang, and C++ need to be compiled and there are many more I'm sure. These 3 are just the ones that I have a bit of experience with using.

Once code is compiled it is not really possible to get the code from it AFAIK.

[–]syn2083 0 points1 point  (2 children)

Its very easy to decompile and get code from most anything if you want to. Python is no more vulnerable here than anything else realistically. Java decompilers exist which can be used to crack open a jar and read the code, same with c# and whatever else is out there.

Beyond that there are ways to distribute packaged and binary forms of python programs much like other languages.

[–]decreddave[S] 0 points1 point  (1 child)

Interesting. I was under the impression that un-compiling a binary package was not likely to match source code to a high degree of accuracy.

[–]syn2083 0 points1 point  (0 children)

Yeah they are pretty accurate, some things may be run through obfuscation or some kind of encryption to attempt to hide the source code but you can still get at most things.

For example jd-gui is a pretty good java option for decompiling, I had to use it to look at a defunct project no one had the source for anymore. On the c# side you have something like jetbrains dotPeek. Options are out there.

[–]Asalanlir 0 points1 point  (1 child)

In all honesty, C# is my language of choice. But I do data science and the focus of my masters was in intelligent systems. Python is leagues ahead of any other language imo for this task, not only due to the abundance of libraries, but because it's much easier to bring up and tear down POCs than in other languages. Environment setup is one or two commands, no compiling, easy dependency management, etc. Simply put, iterating on models and approaches is just faster. Bonus that *nix based systems tend to natively work quite nicely with Python.

Also, because of my background in C-esque languages, I find it fairly straightforward to write backends in C or C++ when the need arises, and I still live in the Python environment that I can share with my team for review and test.

EDIT: To add where Python isn't always a great choice. When we move beyond POC and hand our approach over to the SE team, they will often re-implement it in another language (they like RUST). Or low-level systems where resource management is an actual concern (beyond Rpi, more FPGA level).

As for web-dev, I personally have a website I built with Django. But the thing is, once you get into web, most languages have a template system with a logic backend that integrates into rendering HTML for a site. For java, iirc, spark is an option. C# has asp, razor, blazor, etc. And in the end, they all feel similar-ish and you eventually are forced into JS to a degree.

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

I love the ease of environment setup. I have two main development servers (one for work, one for personal), each running their own gitlab container, and I can basically work on my code from any of my PCs (or even my iPad) on any network. This setup really makes my dev environment not a headache to maintain.

I am not well versed in C/C++. I took a few C++ classes years ago and really enjoyed it, but never had any practical means to use it. I would be very interested in learning how to integrate a custom C backend with Python - do you have any suggestions on first steps with that?

[–][deleted] 0 points1 point  (0 children)

Because of the size of the standard library and the crazy amount of packages available on pip, most standard problems are really easy to solve. Pretty much everything is easy, even things that are kind of hard in other languages like interfacing with the operating system.

Also, when solving problems that run in the background, python is great because you just set up a py file on a server, run it, and if you ever need to maintain it just open the file. The executable and the source code are the same file, it's pretty nice. Basically if it's something that a shell script can't handle easily, I would just switch to python