News for hackers. Stuff that matters.
Re:Incrementally migrating over one million lines of code fr... by sametmax on Wednesday February 06, 2019 @02:28PM (#19098840)
Plus the UI, the file manager intagration, the daemon, the authentification, the cache... All that cross platform.
Re:Incrementally migrating over one million lines of code fr... by saagarjha on Wednesday February 06, 2019 @02:56PM (#19099171)
None of those should be written in Python, except for perhaps the cache handling code. The rest should be platform-specific.
Re:Incrementally migrating over one million lines of code fr... by barkingcat on Wednesday February 06, 2019 @05:00PM (#19100521)
Python is platform specific.
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.

Re:Incrementally migrating over one million lines of code fr... by rmdashrfstar on Wednesday February 06, 2019 @03:11PM (#19099320)
Why?
Re:Incrementally migrating over one million lines of code fr... by saagarjha on Wednesday February 06, 2019 @03:15PM (#19099365)
Because they're platform specific. For example, on macOS, the UI and file manager integration should be done in Swift or Objective-C(++), the authentication in some C-compatible language to match the security frameworks, and the daemon in some language that isn't single threaded or garbage collected.
Re:Incrementally migrating over one million lines of code fr... by chrisseaton on Wednesday February 06, 2019 @03:22PM (#19099438)
You’re talking about that it uses platform specific APIs. You can use these APIs from Python, and then there is all the logic which decides how to use the APIs and that can be in Python as well.
Re:Incrementally migrating over one million lines of code fr... by saagarjha on Wednesday February 06, 2019 @05:29PM (#19100765)
> You can use these APIs from Python

You can do it hand-written assembly too, but usually it's more trouble than it's worth.

Re:Incrementally migrating over one million lines of code fr... by chrisseaton on Wednesday February 06, 2019 @05:48PM (#19100936)
I think what we've worked out what you mean is just that if you were doing it you'd chose to do it in Objective C etc. That's not quite the same as anyone else 'should' do it.
Re:Incrementally migrating over one million lines of code fr... by sametmax on Wednesday February 06, 2019 @05:07PM (#19100591)
Not only you can do all that confortably and productively in python, but you should.

It's crossplatform, the task has not bottleneck for this vm, and it takes complexity down to one language. One language that as the very specific characteristic of being the best at nothing, but pretty good at everything, which in such an heterogenous software is what you want.

Re:Incrementally migrating over one million lines of code fr... by saagarjha on Wednesday February 06, 2019 @05:32PM (#19100797)
> the task has not bottleneck for this vm

Which is why Dropbox uses 100% of the CPU while syncing? It's pretty clear that trying to handle thousands of files is not a trivial operation. Sure, Python can do the job, but something native will probably do the job faster.

> in such an heterogenous software is what you want

No, not really. I'd rather the software work well, and I'd rate Dropbox as "passable" rather than "great".

Re:Incrementally migrating over one million lines of code fr... by sametmax on Thursday February 07, 2019 @01:43AM (#19103493)
If dropbox is passable, please point at the alternative with the same features and better perfs.

I'd say it's just a hard problem.

After all, the fs routines in python are all written in c, file watching uses the os api such as inotify, so python speed has little impact on those operations. Same for the gui. Same for the network since you only have a few connections to one server.

Dropbox doesn't even index the file content, so basically not many stri g or numerical operations. I've got 15 years of python behind me, and i'm pretty good at guessing what workload it's going to be slow at. This is not one of those.

Many people tried to compete with dropbox. None of them won, because eventually, their software either can't match the features, the perfs, the availability, the price, or the ease of use.

I should know, i tried to escape dropbox, as i don't like the company ethic stance, and tried many alterntive.

Dropbox is just very, very good.

Re:Incrementally migrating over one million lines of code fr... by saagarjha on Thursday February 07, 2019 @04:01AM (#19103970)
> If dropbox is passable, please point at the alternative with the same features and better perfs.

iCloud Drive works pretty well for me.

> After all, the fs routines in python are all written in c, file watching uses the os api such as inotify, so python speed has little impact on those operations. Same for the gui. Same for the network since you only have a few connections to one server.

You'll notice that these aren't the things I mentioned as things you shouldn't be doing in Python, aside from the GUI, which I will maintain should not be done in Python. Writing parts of Dropbox in Python is fine, but there are places where they really shouldn't.

Re:Incrementally migrating over one million lines of code fr... by Shinkirou on Thursday February 07, 2019 @04:23AM (#19104053)
iCloud is not available on every single OS.
Re:Incrementally migrating over one million lines of code fr... by saagarjha on Thursday February 07, 2019 @04:38AM (#19104101)
It's available on Windows (though, it's not great because it uses the wrong tools on this platform), macOS, and iOS, which is a sizable portion of the market.