News for hackers. Stuff that matters.
Re:Incrementally migrating over one million lines of code fr... by saagarjha on Wednesday February 06, 2019 @05:30PM (#19100774)
…no?
Re:Incrementally migrating over one million lines of code fr... by chrisseaton on Wednesday February 06, 2019 @05:52PM (#19100963)
You can write platform specific code in Python. You can get the current operating system and you can write an if statement comparing against operating systems you want to write specific code for.
Re:Incrementally migrating over one million lines of code fr... by saagarjha on Wednesday February 06, 2019 @10:26PM (#19102747)
> You can write platform specific code in Python.

It's clearly not designed for doing anything advanced, though: it's not like you can get access to platform-specific APIs outside of the basics without doing a lot of work.

Re:Incrementally migrating over one million lines of code fr... by sametmax on Thursday February 07, 2019 @02:37AM (#19103680)
Quite the contrary, it is easy to call system api from python. That's why we have so many python wripmers for c code.

You have the stdlib ctypes of course, but also pypy's cffi for an even better story.

We even have specialized ready to use tools for those, such as pywin32 to manipulate the windows api and registry, pyqt to leverage the c++ qt lib and all it's tooling, or watchdog to survey file changes, using the native api when possible.

In fact, mac and linuxes implement natively of lot of tools in their os for this reason.

There is also a reason it's one of the few languages allowed in prod at google. It's the best at nothing, but it's damn good at most things.

Re:Incrementally migrating over one million lines of code fr... by saagarjha on Thursday February 07, 2019 @04:05AM (#19103980)
> You have the stdlib ctypes of course, but also pypy's cffi for an even better story.

Not something I would call seamless.

> pyqt to leverage the c++ qt lib and all it's tooling

This isn't native.

> mac and linuxes implement natively of lot of tools in their os for this reason

Generally command line scripts, which is something that Python is good at.

> There is also a reason it's one of the few languages allowed in prod at google.

What Google allows in production has only an oblique relevance to whether it should be used for a specific task.

Re:Incrementally migrating over one million lines of code fr... by DrJosiah on Thursday February 07, 2019 @12:01AM (#19103124)
ctypes is a thing, and gives you access to the world of runtime-loadable libraries on your platform. Beyond that, C modules for Python by hand, SWIG, Cython (can take Python 3.x annotations now), etc., are not bad at all.

Can you explain how platform-specific stuff takes "a lot of work" with Python, and wouldn't with some other language that is not Python?

Re:Incrementally migrating over one million lines of code fr... by saagarjha on Thursday February 07, 2019 @03:58AM (#19103957)
> Can you explain how platform-specific stuff takes "a lot of work" with Python, and wouldn't with some other language that is not Python?

Sure, just look at a modern Cocoa app written in Swift, or Android one in Java, and compare it to the amount of work you'd have to do to shoehorn Python in there.

Re:Incrementally migrating over one million lines of code fr... by viraptor on Thursday February 07, 2019 @06:33AM (#19104549)
Re:Incrementally migrating over one million lines of code fr... by DrJosiah on Thursday February 07, 2019 @01:26PM (#19107169)
That doesn't look bad. I might actually want to write apps now.
Re:Incrementally migrating over one million lines of code fr... by viraptor on Thursday February 07, 2019 @03:22PM (#19108199)
Missing /s. Yes - I meant there are nice options.
Re:Incrementally migrating over one million lines of code fr... by DrJosiah on Thursday February 07, 2019 @11:23PM (#19111513)
viraptor makes a very compelling case for at least 1 option for mobile apps in Python.

About 15.5 years ago while I was still a grad student, I released a (horribly designed, mostly self-experimentation) editor in Python + wxPython that I initially wrote to run on Windows. I didn't run it regularly in Linux or OS X until 2008, and it all just worked. OS X was a little laggy with my editor, but hey, write once run on 3 platforms.

Python is really solid on multi-platform, because there are so many Python users already using every platform that want to bring Python there.