r/programming • • Jun 27 '18

Python 3.7.0 released

https://www.python.org/downloads/release/python-370/
2.0k Upvotes

383 comments sorted by

340

u/[deleted] Jun 28 '18

I'm glad for the improvements to typing and the new data classes. Here's hoping that the recent push for optional static checking will prove helpful to those building larger apps using Python.

71

u/joshuaavalon Jun 28 '18

There is a backport of the data classes for 3.6 if you want to use it.

21

u/ProfessorPhi Jun 28 '18

Isn't attrs still superior?

54

u/dhiltonp Jun 28 '18

Attrs definitely has more features (slots comes to mind), but I think it looks a little wonky.

(full disclosure, I haven't used attrs just read the docs)

@dataclass
class InventoryItem:
    name: str
    unit_price: float
    quantity_on_hand: int = 0

vs.

@attr.s
class InventoryItem:
    name: str = attr.ib()
    unit_price = attr.ib(type=float)
    quantity_on_hand = attr.ib(type=int, default=0)

Does PyCharm recognize type annotations when they're set via attr.ib(type=float)?

16

u/ProfessorPhi Jun 28 '18

Nope, pycharm and attrs support isn't great :(, though attrs does have slots. Agreed it's wonky, it's like ordered dict before 3.5 was obnoxious.

13

u/OctagonClock Jun 28 '18

PyCharm 2018.2 EAP has new attrs support, actually.

→ More replies (1)

6

u/bluetech Jun 28 '18

The annotations-based syntax works with attrs too (you need to set auto_attribs=True).

1

u/PeridexisErrant Jun 30 '18

IIRC you can also use @attr.dataclass for the first one (a shortcut for the auto_attribs=True arg).

The dataclass example won't work on a backport before Python 3.6 though, as those versions don't have variable annotations.

8

u/virgoerns Jun 28 '18

It is, PEP even mentions attrs and says that new mechanism is for simpler cases.

→ More replies (2)

0

u/[deleted] Jun 28 '18

[deleted]

17

u/jarshwah Jun 28 '18

CPython 3.6 has ordered dictionaries, but that is an implementation detail. 3.7 guarantees it in the spec. So it’ll work for CPython 3.6 which is the most popular implementation by far.

0

u/[deleted] Jun 28 '18

[deleted]

22

u/jarshwah Jun 28 '18

Yes that’s correct. When people talk about python they’re overwhelmingly referring to CPython. Other implementations like Pypy and micropython would not have to have ordered dictionaries for their 3.6 but they would for their 3.7.

11

u/[deleted] Jun 28 '18 edited Jun 28 '18

Pypy has actually had it for a while (it was brought to CPython from Pypy for 3.6). Other implementations though yeah

6

u/Ph0X Jun 28 '18

I mean they all could, but are not guaranteed to. You have to check implementation detail for each individually. But in 3.7 and above no matter what you use, you will have it.

-61

u/leftofzen Jun 28 '18

To me, a non-Python user, this whole type checking this is hilarious and farcical. Python is made with dynamic typing as a feature and it's lack of type checking (at least until run time) is one of it's strengths. To now start static type checking - why even bother; you may as well use a real language with first class static typing support. Bolting it on as an after thought still makes me laugh hehe.

25

u/pandubear Jun 28 '18

I haven't used Python's typing (mypy?), but... options are good, no? Like, you don't have to use mypy if you don't want to. But Python has a lot of strengths, and if someone wants to use those strengths but also get types, what's wrong with that?

While I haven't used mypy, I've used TypeScript a ton, and if mypy is half as good as TypeScript, I'm glad it exists.

44

u/[deleted] Jun 28 '18

Python is made with dynamic typing as a feature and it's lack of type checking (at least until run time) is one of it's strengths.

Dynamic typing is the easiest type system to implement in languages, and that's why scripting languages tend to prefer it. It has very significant costs, and the supposed benefits to the programmer are dubious at best. Static typing is technically better for a large number of reasons, but lately programmers have adopted the idea that "easy" is favorable over "good".

7

u/Dreadgoat Jun 28 '18

Dynamic vs. Static is not a question of what is better, it's a question of what problem you are trying to solve.

Do you need a lot of small highly flexible purpose-built scripts in an environment where the same data is likely to be passed around many formats (e.g. The Web)?
Dynamic good. Static bad.

Do you need large rigorous algorithms, high performance, do you expect to share your tools, do you need more control under the hood?
Static good. Dynamic bad.

Making Python able to do both is great for Planet Python. It's also extremely difficult to implement. Dynamic typing systems aren't easier to implement than static ones, it's just that it's a very early design decision that impacts a lot of how the compilers are written. Trying to do both is what is truly challenging.
While this is an impressive thing for any language, it also creates a bit of an identity crisis and potentially puts in danger of becoming bloated.

For me, personally, if I'm at a point in my Python project where I'm thinking that I need a strong static type-system, that's the point where I say to myself, "Python wasn't the right tool for this job."
Of course I've also started projects with static typing and later regretted the loss in flexibility upon realizing that the project has no need for static typing.

1

u/[deleted] Jun 28 '18

I think that's unfair to say that people just use dynamic typing is just used because it's easy to implement. Dynamic languages are often easier to learn which is likely part of the reason why python is good for beginners. Also dynamic languages can make it quicker to write code since you don't have to write out type declarations. This is useful for small scripts where you don't really need many benefits from static typing.

1

u/[deleted] Jun 29 '18

Is something good for beginners because it is easy? I see this often asserted as something that is intuitively true, but I really don't think that it is. Good languages for beginners are the ones that are strict and explicitly tells you that you're doing something wrong, rather than silently trying to guess your intention and automatically try to fix subtle errors. This is not a favor to the student

→ More replies (28)

23

u/ThePantsThief Jun 28 '18

Why is he being downvoted?

hehe.

Oh.

37

u/TTGG Jun 28 '18

And probably for "real language".

2

u/leftofzen Jun 28 '18

I don't get it, is there some inside joke I'm missing?

17

u/mogranjm Jun 28 '18

The majority of the comment was good and valid, but he was a bit of an asshole in the last two sentences

2

u/Mooks79 Jun 28 '18

As I noted directly to them, seems a rather strong pro-Python contingent on reddit who downvote anything negative about Python (or positive about languages deemed competitors) - whether or not it’s said reasonably.

1

u/NAN001 Jun 28 '18

In fact it's mostly because people vote depending on whether they agree or not.

3

u/dzikakulka Jun 28 '18

No, I don't agree with that downvoted

3

u/NAN001 Jun 28 '18

You did downvote me you bastard.

4

u/alexthelyon Jun 28 '18

I don't see the downside. You get flexibility when you need it and you get type checking when you need it. I use type checking on the 10-20% of the most relied on, complicated, or data-intensive code.

Then, since the IDE supports static analysis, it catches silly mistakes or errors before they even have a chance to become a bug which improves Dev efficiency a lot. It's also useful to make sure you use proper data structures (ex deque instead of list).

3

u/[deleted] Jun 28 '18

and it's lack of type checking (at least until run time) is one of it's strengths

And this is a "strength" how, exactly? You enjoy the guessing game instead of having precise autocompletion in your IDE? Have too much spare time to waste?

Bolting it on as an after thought still makes me laugh hehe.

What's wrong with improving an IDE support at least for a bunch of common libraries?

Apparently you're one of those who think that type systems are for "checking", "correctness" and all that crap. They're not. They're for this little autocompletion and "jump to definition" thingies on your IDE, primarily. The rest is of a much lesser importance - performance, "correctness", documentation, and so on.

6

u/MrPigeon Jun 28 '18

So...C and other early languages being statically typed was all done in anticipation of the IDEs we would have 40 years later? That's completely backwards. IDEs make use of a feature which exists for performance and determinism, not the other way around.

What's wrong with improving an IDE support at least for a bunch of common libraries?

Agreed here, but I think the other guy was referring to bolting features on to Python itself. Which is kind of an odd complaint itself, since every language I can think of has had multiple releases with new features.

Unless you've been sarcastic this whole time and it's gone right over my head...

4

u/[deleted] Jun 28 '18

So...C and other early languages being statically typed was all done in anticipation of the IDEs we would have 40 years later?

Firstly, ctags and similar tools existed long before the modern IDEs. Secondly, back than priorities were different, typing existed for performance primarily.

IDEs make use of a feature which exists for performance and determinism, not the other way around.

And? Priorities are different now. Most people do not care too much about performance. Especially if we're talking about Python.

but I think the other guy was referring to bolting features on to Python itself

You cannot improve IDE support without fixing a language.

1

u/Homoerotic_Theocracy Jun 28 '18

Everything Python is is "stuff bolted onto it after the fact"; in that sense it's quite the dynamic C++ and guess what C++ also now has support for dynamic typing.

1

u/[deleted] Jun 28 '18

Any statically typed language have support for dynamic typing, by definition, since dynamic typing is a subset of a static typing.

→ More replies (13)

154

u/artoonie Jun 28 '18

Finally! I'm only one version behind now.

53

u/eyal0 Jun 28 '18

Major or minor?

159

u/DaemonXI Jun 28 '18

Integer.

7

u/[deleted] Jun 28 '18

32-bit or 64-bit?

6

u/crozone Jun 28 '18

Doesn't matter, I just hope it all works

12

u/calonolac Jun 28 '18

Melodic

38

u/_tpr_ Jun 28 '18

PEP 553, Built-in breakpoint()

Awesome! That's going to be much more convenient. Putting import ipdb; ipdb.set_trace() is a hassle. This will probably make all of the JavaScript developers I work with more likely to use the debugger.

PEP 557, Data Classes

These are going to be much nicer and more obvious-looking than using a named tuple.

-11

u/AnnoyingOwl Jun 28 '18

I don't want to be mean or anything, but it's 2018 why aren't they using PyCharm?

7

u/robhaswell Jun 28 '18

Because people have preferences.

1

u/bythenumbers10 Jun 28 '18

Yeah, there are a couple of IDEs that offer breakpoint functionality. If they need it, they can take their pick.

0

u/[deleted] Jun 28 '18

[deleted]

→ More replies (9)

25

u/robhaswell Jun 28 '18

I'm glad of the asyncio.run() addition, hopefully more libraries will be written asynchronously by default from now on and integrate with synchronous code using this.

5

u/jnwatson Jun 28 '18

Can you be more specific? I haven't heard anything about that.

1

u/robhaswell Jun 28 '18

I was speculating on the use-case.

107

u/AnnoyingOwl Jun 28 '18

As someone who's day job has not been Python for a while (has been: Java, Ruby, Scala, TypeScript) and I only use it in side projects occasionally...

  1. Data classes, yay! Good step.

  2. More typing support: awesome, this was such a nice inclusion.

  3. Context... necessary, but not sure it will save the dumpster fire that is asyncio stuff in Python.

21

u/[deleted] Jun 28 '18

Is asyncio that bad? I think there are cosmetic issues, like particular API decisions such as naming and confusing and somewhat redundant coroutine/future concepts. Functionally though it at least performant as advertised.

7

u/jnwatson Jun 28 '18

My team has almost completed the transition to asyncio, and it wasn't bad at all.

I think a design option that everybody misses is you don't actually have to run the event loop on the main thread, so you can do blocking stuff on main thread or (if from async town) a ThreadExecutor, and call_soon_threadsafe to run futures on the event loop from blocking code.

2

u/kallari_is_my_jam Jun 29 '18

So what you're saying is basically this: https://hackernoon.com/threaded-asynchronous-magic-and-how-to-wield-it-bba9ed602c32

But what about the overhead of GIL in a multithreaded environment? Aren't you sacrificing performance whenver the OS tries to switch threads?

3

u/jnwatson Jun 29 '18

Yep.

The problem with the GIL isn't the overhead of switching, it is that it is held whenever a Python operation is going on, reducing the number of things that can actually run at a time.

Essentially this approach is no more expensive than the old multithreading style, and gets better the more things you switch to async. The key is that you don't have to switch all at once.

22

u/[deleted] Jun 28 '18

The issue is that there are way too many alternatives. And also you can't mix async code with blocking code and expect it to normally. Which means you should only use async versions of common libs. If I wanted easy scalability and async code execution I wouldn't probably use python to begin with. It will probably take years before the async stuff becomes the norm.

7

u/alexeiz Jun 28 '18

And also you can't mix async code with blocking code and expect it to normally. Which means you should only use async versions of common libs.

This is not a problem with asyncio per se. Asynchronous and synchronous programming models are not compatible no matter what language or async framework you use.

5

u/NAN001 Jun 28 '18

Could you expand on not being able to mix async code and blocking code. I know that one is supposed to call async functions so that functions are cooperative with the event loop, but even if a blocking function is called, it blocks the event loop, which can't be worse than not using async at all, right?

5

u/PrinceOfUBC Jun 28 '18

it blocks the event loop, which can't be worse than not using async at all, right?

If you block the event loop, you might as well not write async code. More cognitive overhead for little gains.

3

u/13steinj Jun 28 '18

Getting, running, and closing the event loop is a sync operation.

So in otherwords if I have 3 async functions that only update visuals using animations but I want the main thread to continue with it's logic (ex, I pressed submit, logic is that on this form you cant go back, async updates are the animations moving you to the thank you page).

I can't submit my 3 coroutines in my function, I have to write two functions, and make sure I call the logic before the animations, and be okay with the fact that I will have to wait for the animations to complete before any new code runs on the thread that holds the event loop. In comparison, in JS/C#, the event loop is handled for us, and gets executed in a microtask queue (C#, afaik, on a specially made thread, JS, on next available execution tick, because JS is generally single threaded), thus any async code does not block the thread that it is called from.

In Python, that can be solved by manually creating a thread/process (depends on what the loop actually blocks on, and I hope it's the thread because if it is the process hoooooooooah boy this workaround is inefficient), setting an event loop on it, and submitting coroutines with the respective "threadsafe" method for the usual not-threadsafe method.

Python's coroutines also arent Tasks/Promises like in C#/JS, which limits code style and use by having to manually wrap the coroutines. A quick comparison to JS (because writing out the C# equivalent will take some time):

JS:

async function aworkbro(a, b) { /* do stuff */ } // aworkbro is the "async function" (coroutine maker)
var special = {};
async function main() {
  var soon = aworkbro(1, 99);
  // soon is both the executing, instantiated coroutine
  // (we can await on it if we want to) and the Promise(Task)
  // (we can append callback / cancellation code)
  var later = soon.then(callback, errcallback).then(handler);
  var result = await soon; // wait for soon to and return the result of it in this async function
  special.handled_result = await later; // wait for all callbacks to complete.
  return result; //return the original result
}
main();
// other sync code, runs separately from the async call

Whereas this has no good equivalent in Python:

async def aworkbro(a, b): # aworkbro is the "async function" (coroutine maker)
    # do stuff
async def main():
    coro = aworkbro()
    # coro is the instantiated coroutine, does not execute. We can not add callbacks.
    # We can either submit it to the event loop, which we won't, because
    # we will lose all access to it bar being able to cancel it
    # outside the event loop, or we can and will wrap it in a Task
    task = asyncio.create_task(coro) # schedule the coroutine as a task for the next available context switch (execution tick) in the event loop
    # the task can have callbacks added
    task.add_done_callback(callback)
    task.add_done_callback(erriferrcallback)
    task.add_done_callback(handler)
    # but can't be waited
    # await task goes kaboom
    # cancelling the task submits an error to the coroutine, (coroutines are really just super special generators in Python)
    # meaning it would be handled *by* the error callback!
    # so we can't properly do this unless we write code overly explicitly
    # we can wait on the coroutine
    result = await coroutine # fuck scheduling, do now.
    # but this also executes our callbacks when task notices, and any results of them are lost!
    return result
# did I mention how we have to have a running loop in our thread for task creation to work, and well, for all async execution to work? We can either manually create our loop and reuse it, or use asyncio.run. for ease, we will do the latter
asyncio.run(aworkbro)
# other sync code, but creating and waiting on the loop is synchronous, so it will wait until the async code is fully complete
# we can solve this by using pythons threading. But I think this example is complicated enough already

2

u/bobindashadows Jun 28 '18

If you stall your event loop you aren't accepting incoming requests.

Say your blocking operation is "read a file" and it takes 100ms sometimes. Then your client's very first TCP SYN packet will sit in your server's kernel network queue for 100ms. All before your server even bothers to tell the client "yes, let's start a TCP session."

Your framework might handle accepting TCP for you, but it won't read packets 3-N from the client until those 100ms are up.

If you had no event loop and many threads, you have all the multithreading problems but definitely no massive latency stalls. Occasional deadlocks though.

11

u/linuxtinkerer Jun 28 '18

Looks nice. Data classes are a good addition, so now you won't have to muck around with __slots__. I don't really get the rationale for preserving insertion order in dictionaries though.

10

u/weeeeezy Jun 28 '18

I’ve had several use cases where insertion order in dictionaries mattered for me. I resorted to using OrderedDict collection but then I lost all the benefits of defaultdict.

13

u/linuxtinkerer Jun 28 '18

I understand that there are still use cases for OrderDict, but I think it's dumb to make an implementation detail a part of the language specification.

9

u/BossOfTheGame Jun 28 '18

Definitely not, ordering dicts by default gives at least two major advantages: (1) consistency in the iteration of items across all platforms and (2) consistency in the string representation of dictionaries. I have a feeling this change will silently cut down on a lot of headaches (at least until someone goes to run 3.7 code in an earlier version).

4

u/shevegen Jun 28 '18

I like ordered Hashes - ruby has the Hashes ordered too (hashes = dictionaries), but in many ways I agree with linuxtinkerer here. Some implementation detail should not necessarily become part of an official specification people have to adhere to.

→ More replies (2)

114

u/[deleted] Jun 28 '18

I wish I could use it, but so many APIs and software packages my company uses are still on 2.7 ...

6

u/dagmx Jun 28 '18

What libs do you depend on that aren't on 3 yet?

41

u/[deleted] Jun 28 '18

Biggest example: any software package from Autodesk

17

u/dagmx Jun 28 '18

Sure, I work in cg too but they're shifting to python 3 for 2020 and there should be a preview release next year. We'd have a release sooner but the switch from qt 5.6 to 5.12 was deemed more important.

It's coming soon and we should be bracing for it.

32

u/[deleted] Jun 28 '18

It's coming soon and we should be bracing for it.

Nothing to brace for here, more like eagerly awaiting.

yes, it's coming in 2020...you know, cuz 2.7 is EOL. Nothing like waiting until you're literally forced to update.

2

u/dagmx Jun 28 '18

Well we still need to brace for it in terms of porting studio pipelines. Idk about your studio, but we have a lot of code to go through to get over that hurdle.

The qt4 to qt5 port was difficult enough.

1

u/agumonkey Jun 28 '18

Maya ?

What about Houdini btw ?

1

u/[deleted] Jun 28 '18

Last I checked, Houdini was also 2.7

→ More replies (1)

4

u/[deleted] Jun 28 '18

There’s still a good amount of commercial software that’s python 2, at least that I’ve randomly come across. There’s probably little incentive for some of the companies to migrate until they have to or until a customer that has enough leverage requests or demands it.

Shitty, yes.

1

u/13steinj Jun 28 '18

Reddit's backend (even with the redesign) runs on Pylons, and would need a decent amount of rewrite to work with Pyramid, not to mention Py3.

-40

u/Homoerotic_Theocracy Jun 28 '18

Python 3 was a humungeous mistake.

The small advantages that breaking backwards compatibility gave them really was not worth the huge cost and effort everyone now has in having to maintain separate python 2 and python 3 versions of each library during the transition state. The overwhelming majority of new features of Python 3 could have been added to python 2 instead of breaking backwards compatibility and most of the breaking centres around a few elegance things; it absolutely wasn't worth the huge cost of switching for a lot of things.

66

u/[deleted] Jun 28 '18

Vendors not updating their software for a decade is a humongous mistake.

27

u/Homoerotic_Theocracy Jun 28 '18

It's not a matter of "just updating"; it's about having to maintain two different independent branches of everything related to Python while the transition is going on.

Do you honestly think that a software distribution can just "update" to Python3 and call it good? Just remove Python2 and install Python3 and that is that? Fedora needs to employ someone full time to basically be responsible for the python2/python3 situation and the problems that s/he faces are far from trivial.

13

u/[deleted] Jun 28 '18

Do you honestly think that a software distribution can just "update" to Python3 and call it good?

No, I think they should maintain and end-of-life py2 version and continue long term development on a py3 version. It's their damn job to move on in a proper manner. It should be part of the calculation at all times.

They've literally had a decade to fix it, and there's plenty of options in maintaining something across Python versions.

The article you linked mentions OpenStack, a piece of software that didn't exist before Python 3. That it's not compatible is just fucking ridiculous and completely unforgivable. This mindset is exactly the same as when people get their data stolen because some moron decided it was too expensive to upgrade from Windows XP. Software isn't forever, that's a fundamental truth of the industry.

3

u/Homoerotic_Theocracy Jun 28 '18

No, I think they should maintain and end-of-life py2 version and continue long term development on a py3 version. It's their damn job to move on in a proper manner. It should be part of the calculation at all times.

Yeah, and that's what causing them so much money and time as well as all the porting.

Do you honestly think it's trivial if you have a major python2 project to now have to rewrite 50 000 LoC to python3 and making sure that all the subtleties are right to ensure now regressions sneak in and then maintain both at the same time? You think that's without cost and a matter of "just move new development to python 3"?

I just checked and DNF alone has 37 531 LoC in its Python2 files. Do you honestly think that the porting of all that to Python3 was cheap?

They've literally had a decade to fix it, and there's plenty of options in maintaining something across Python versions.

And they did fix it; that's not the problem; it's not a matter of whether they fixed it; everyone fixed it.

It's a matter of that it cost them a huge amount of manhours and thus money that could've gone to actual development that absolutely wasn't worth the small benefits of python3 The manhours put into porting and double maintaining all that stuff will never be recouped by the small quality-of-life changes of py3 over py2; the human species will either end itself in a nuclear war or python4 will come around or people will just stop using python before this happens; it's about cost versus benefit.

The article you linked mentions OpenStack, a piece of software that didn't exist before Python 3. That it's not compatible is just fucking ridiculous and completely unforgivable.

No, it's just a fact that to this day the py2 version of almost all big pypi packages get more downloads than the py3; you cannot not make a py2 version and just "Oh, new project; I'm only going to use py3"; if you have to choose between either version you have to choose py2 even this day and not everyone has the manpower and luxury to maintain two different versions in two different programming languages of everything. You're living in an ydillic dream world where what you can do is magically not constrained by money and time.

This mindset is exactly the same as when people get their data stolen because some moron decided it was too expensive to upgrade from Windows XP. Software isn't forever, that's a fundamental truth of the industry.

Yeah, and guess what, MS is also pushing out upgrades for no other reason than to make money while they could've been made backwards compatibily to older versions.

Are your really challenging the idea that the upgrade system of Windows isn't in the best interest of the user? Neither was python3. This is the problem with a BDFL; he ultimately still treats it as his baby despite the significant corporate investment in it now and he just wanted to start fresh and clean thing up but it hasn't been cost-effective for the enterprise consumers at all.

5

u/[deleted] Jun 28 '18

No reason to update if it works. And Python 3 the first half decade was just an unusable mess. And after that the py3-ecosphere was a mess in transition. In this decade, Python 3 became only around 8-9 Years later a useable solution for mature projects. So why bother because of soem years delay.

16

u/[deleted] Jun 28 '18

No reason to update if it works.

This mindset is why mission critical software all over the world still runs on Windows XP.

3

u/ahua77 Jun 28 '18

Well it works, what's wrong with it? Python 2 is still being maintained.

7

u/[deleted] Jun 28 '18

Not for long.

1

u/yawkat Jun 28 '18

I mean you can blame the ecosystem for not following through but it's not like it was unexpected.

19

u/Fushoo Jun 28 '18

Don't know why you are being downvoted. Backwards compatability is very important for large projects and big companies.

Imagine the outrage if Java 8 broke Java 7.

6

u/_jay Jun 28 '18

And php. While people love to shit on it, it makes the money because so much effort is put into keeping stuff working between versions.

5

u/glassFractals Jun 28 '18

PHP has actually gotten pretty okay over time, especially since PHP7.

3

u/yawkat Jun 28 '18

There was a huge outcry over compatibility with Java 9 but it's still somehow better than the py2->py3 transition.

4

u/NekoiNemo Jun 28 '18

Yeah, the difference is - Going from Java X -> 9 requires just light refactoring, and the only things that really break are hacks (like modules not allowing you to randomly declare things in someone else's packages). And Python 2 -> 3 completely breaks pretty much everything more complex than Hello World.

Hence why Java 9 compatibility got some muffled grumbling (not an "outcry"), and Python 3 compatibility led to 2.7 still being maintained and actively used even 10 (!!!) years after 3 came out.

→ More replies (1)

10

u/Homoerotic_Theocracy Jun 28 '18

There is a time and a place to break it but breaking it should be done for good reason and to really solve some big longstanding problems and a major version upgrade should not be taken lightly.

In a lot of cases breaking it has been the life-saver of the project like with OS X which broke everything but what it broke was broken anyway and it completely revitalized MacOS.

Python3 broke it in a way that people were forced to maintain separate python2 and python3 versions of everything and software distributions had to face very annoying problems for small quality of life things and it just wasn't worth it.

11

u/OctagonClock Jun 28 '18

Python 3's break was done for a good reason (to fix strings), and that was incredibly worth it.

13

u/Homoerotic_Theocracy Jun 28 '18

They could have easily added utf8 strings separately and just used the syntax u"utf8string"

You think it's totally worth it because you're not the one who has to pay an extra employee purely to sit on top of the python2/3 problem or suddenyl have to maintain two versions of your important projects. From a monetary standpoint of commercial python usage it as definitely not worth it and people lost money over it.

7

u/chason Jun 28 '18

That would have been awful for people who need all of their software to work with unicode

→ More replies (1)
→ More replies (3)

0

u/[deleted] Jun 28 '18

[deleted]

41

u/[deleted] Jun 28 '18

For example: anything from Autodesk

32

u/[deleted] Jun 28 '18

Or Docker. I’d love to use Python 3 but have to specify pip2

20

u/Aeon_Mortuum Jun 28 '18

Facebook's React Native also requires a Python 2 installation

13

u/Klathmon Jun 28 '18

that's more google's fault for gyp not working with python 3.

4

u/p2004a Jun 28 '18 edited Jun 28 '18

But Google mostly stopped using GYP. They moved chromium and other stuff to GN so why would they want to pour time into making GYP better? And it's open source so if you care, you can improve it and add Python 3 support, that's what open source is about, right?

6

u/Klathmon Jun 28 '18

And IIRC the node group is hard at work at it (as they are probably the biggest gyp user at this point), but the more likely outcome is that node will move away from gyp just like google did (there's a reason they chose to move to another system rather than try to update gyp).

I honestly don't mind gyp using py2, it does require a separate install over everything else on the box, but it works well once setup and I think breaking backwards compat with all node native modules to upgrade to py3 would cause more issues than it would solve (and could lead to the same split we saw with py2 and py3).

1

u/Pakaran Jun 29 '18

What are you referring to? I use Python 3 in Docker with no issues every day.

66

u/[deleted] Jun 28 '18

Yes really. Mine too. Companies have a lot of old code and there's not much incentive to upgrade it to Python 3 for basically zero benefit.

Actually, it's a big risk because these scripts are generally "tested" by using them and reporting bugs. Upgrade to Python 3 and due to its dynamic typing you're probably going to introduce a load of bugs.

Also I have noticed even some big new projects, e.g. Tensorflow, target Python 2 first and then add Python 3 support later.

The idea that the 2/3 mess is over is unfortunately not true.

31

u/vivainio Jun 28 '18

The "zero benefit" is not true anymore

20

u/peeves91 Jun 28 '18

The old motto "if it ain't broke don't fix it" is applied heavily here.

71

u/[deleted] Jun 28 '18

It kind of is, if the code works fine and isn't being updated, which is the case for a lot of corporate code.

1

u/anacrolix Jun 28 '18

Example?

4

u/1wd Jun 29 '18

One project at Facebook:

... simply ran 2to3 on the code and fixed a few things that it complained about. When they ran the resulting code, they found it was 40% faster and used half the memory.

→ More replies (1)

2

u/vivainio Jun 28 '18

Types and asyncio come to mind first

4

u/13steinj Jun 28 '18

Types aren't beneficial to every developer. Asyncio has severe usability issues, I'd rather use gevent in an async manner.

7

u/remy_porter Jun 28 '18

I'm writing software for a Large Tech Company™ as an outside contractor- and I have to communicate with a messaging system, and they have two libraries I could use to do it: JavaScript and Python2.

And the Python lib is a mess.

-1

u/[deleted] Jun 28 '18

That has nothing to do with Python 3.7.

7

u/remy_porter Jun 28 '18

But it does have something to do with people who are still stuck on 2.7, which is the specific thread chain this comment is in.

3

u/[deleted] Jun 28 '18

Feels more like the "java 10 is out - meh I'm still on 6" issue which is common for big companies. Also you seem to have a code quality problem as well which kinda indicates that no one cares about the Python lib.

3

u/remy_porter Jun 28 '18

And yet, I'm still forced to use it. And it's still on 2.7. Thus my code is still on 2.7. And without naming names, this is the kind of company that tends to be considered a forward-thinking trend-setter pushing the boundaries of technology forward.

Just not for this specific tool.

→ More replies (4)
→ More replies (2)

2

u/agumonkey Jun 28 '18

I've seen some news about Google AppEngine going py3 too .. would only accelerate things.

2

u/Urtehnoes Jun 28 '18

For my company, it's all of our django apps that are still on ancient django (like 1.5 or earlier). It's such a slog to upgrade them to all the newer versions, especially because the newest django (2.0+) doesn't friggin support our Oracle version. It's taken me months now for just one app to upgrade/re-write it in Python3.6/Django 1.11. Hopefully 3.7 doesn't require many changes.

1

u/[deleted] Jun 28 '18

Fuck, if ESRI can make the transition, so can everyone else.

0

u/[deleted] Jun 29 '18

[deleted]

1

u/TheGRS Jun 29 '18

Well I don't speak for reddit, but I was pretty into the Python community around that time. I started out using only 2.7 and figured 3 was a pipe dream and that I couldn't find great support for the things I was trying to do, but things changed pretty rapidly from there. But as I said, I totally believe that places are stuck on this version and may always be until they replace whatever it is entirely.

20

u/XtremeGoose Jun 28 '18

Now I just need the anaconda people to add a python 3.7 package.

7

u/Morwenn Jun 28 '18

Is the new importlib.resources module enough to replace common uses of pkg_resources? I feel like I'm dragging pkg_resources in virutally every project bigger than a simple script, so that would be welcome.

4

u/13steinj Jun 28 '18

Based on the minimal migration guide, I hope so.

13

u/1ogica1guy Jun 28 '18

Just starting to learn Python properly now, and this is a huge morale booster.

Thanks, Python team, for the amazing efforts and amazing results.

2

u/turbov21 Jun 28 '18

That breakpoint() command looks awesome.

1

u/Andrew1431 Jun 28 '18

If I was going to learn Python, would it make sense to just pick the latest version, or will there be a lot of unsupported packages?

-88

u/wavy_lines Jun 28 '18

Can we all take a moment to acknowledge how large numbers of people (including me) have come to realize in recent years what a bad idea dynamic typing was?

131

u/xonjas Jun 28 '18

I don't think dynamic typing is a bad idea. I think taking a tool that is useful in certain scenarios and environments and applying it broadly to problems it doesn't suit is a bad idea.

The large the codebase, and the more developers working on it, the higher the cost of dynamic typing. Architecting a system with dynamic typing is a skill also, and many devs working with dynamic languages have not learned it well. If you write python or ruby like a java or c# dev, you're going to be in for a bad time.

There are benefits to dynamic typing. Particularly for small projects, where the lack of a type system is less of a hindrance, and prototypes, where the flexibility allows for easy changes. There are also problems that dynamic typing is particularly suited to solving. There's a reason why the majority of popular webapp frameworks run on dynamic languages (rails, wordpress, django, laravel). When twitter learned the hard way that writing all their middleware in ruby was a bad idea and rewrote the majority of their software in scala, they never moved away from rails because the dynamic type system suited dynamic content generation very well.

Dynamic typing is a very sharp knife; it's important that it's not used as a screwdriver.

56

u/Homoerotic_Theocracy Jun 28 '18

I don't think dynamic typing is a bad idea. I think taking a tool that is useful in certain scenarios and environments and applying it broadly to problems it doesn't suit is a bad idea.

Dynamic typing seems like a worse and worse idea the more flexible static type systems become.

Static typing seems horrible if all you have is C or Go but when you have Idris you suddenly feel that the scope of the problem of "I know this is safe but I cannot prove this to the compiler." is a lot smaller.

I also love Racket's static type system; it's actually completely fine with giving two branches of an expression a different type altogether and the resulting type will be the union of both but of course for it to type check the consumer of that expression must be able to handle the union of both. and be able to handle both types.

But if you have a function that can print both strings and characters to the stdout there is absolutely no harm in passing it an expression that either evaluates to a string or a character and it wil statically verify that this is okay.

Of course a type system as flexible as that of Typed Racket does not give you a lot of the performance benefits of static typing as it cannot in the general case erase type info at runtime because it needs it to make branches; it only can with confidence tell you that your code does not contain type errors.

28

u/xonjas Jun 28 '18

Yeah, I agree, the more expressive your type system is, the more useful it is.

At the same time, languages like python and ruby are going to have an important and deserved place in a programmers toolbox until languages like Irdis are widely supported and mainstream.

8

u/Homoerotic_Theocracy Jun 28 '18

Well truth be told that place seems to mostly be "dealing with lack of knowledge"; in an ideal world of infinite time and knowledge the demand would probably be lower but the main niche those languages fill over powerful type systems like that of Idris is that not everyone has the type to master the somewhat complex subject matter required to grok the type system. It's not mainstream because the learning curve is too high.

5

u/xonjas Jun 28 '18

That might be correct, but I think it's hard to say at this point. Idris is very young, even if it were to become mainstream, it's way too young for it to have reached that point yet. Mainstream isn't just popularity either, it's availability of libraries, api support, job openings, etc.

I think that some of the learning curve will get sanded away eventually. The big languages with slow inertia will start integrating ideas from cutting edge type systems. That knowledge will eventually become ingrained in the 'culture' of mainstream programming languages and each idea folded in is one less hurdle.

I think we'll also see more type systems where more and more of the typing workload is handled automatically, paired with better IDE integration so that generated typing is applied as the code is being written.

7

u/Homoerotic_Theocracy Jun 28 '18

That might be correct, but I think it's hard to say at this point. Idris is very young, even if it were to become mainstream, it's way too young for it to have reached that point yet. Mainstream isn't just popularity either, it's availability of libraries, api support, job openings, etc.

It's certainly older than Rust or Go and those seem to be more mainstream.

6

u/cephalopodAscendant Jun 28 '18

In addition to what xonjas mentioned about sponsorship, I can think of another possible factor. Rust and Go both use C-like syntax and are trying to fill the niche of "C/C++ but better", which naturally attracts a lot of attention. In contrast, Idris is based on Haskell, which is already fairly niche itself, and from what I've seen, the people who use Haskell seem to be pretty content with it.

10

u/Homoerotic_Theocracy Jun 28 '18

I love how Go calls itself a "systems programming language" but has a garbage collector and absolutely no low level control and can't even fork because multithreaded garbage collecting mutexes.

If someone ever used Go for something that person used C for prior it was either a terrible idea to use C for it or a terrible idea now to use Go for it and if someone is seriously switching from C to Go I'm inclined to think both.

Go has nothing to do with C or C++; it's a worse Java.

6

u/xonjas Jun 28 '18

I thought Idris 1.0 was released last year (although I could very well be wrong). Rust and Go also both have the benefit of very large organisations pushing them forward.

→ More replies (1)

2

u/JanneJM Jun 28 '18

If you use a language interactively - and it's a common enough use case for python - static typing is a fairly big friction point.

10

u/[deleted] Jun 28 '18

static typing is a fairly big friction point.

Why? Statically typed languages work perfectly with REPLs.

→ More replies (2)

8

u/Homoerotic_Theocracy Jun 28 '18

Why exactly?

I don't have a lot of problems with ghci or utop in that regards.

→ More replies (6)

5

u/-TrustyDwarf- Jun 28 '18

F# and C# Interactive (fsi / csi) are used quite extensively.. especially fsi.

4

u/CircusAct Jun 28 '18

I use Scala in the ammonite repl regularly.

1

u/Thaxll Jun 28 '18

Static typing seems horrible if all you have is C or Go

Care to elaborate? What's the problem with Go?

33

u/Homoerotic_Theocracy Jun 28 '18

That the type system is not expressive and you feel there are things you can't do with it you can with dynamic typing. Like something as simple as sorting a sequence of strings by their length in Go is extremely unwieldy due to the limits of the type system.

Python lacks a type system so we just have: fruits.sort(key=len); this will fail at runtime if the types don't match up but they will here.

Rust or Haskell have a more expressive type system that can easily handle this: In rust we have fruits.sort_by_key(|s|s.len()); since the type of sort_by_key is the scary: (&mut [A], f : F) where F : FnMut(A) -> B, B : Ord this is all great and type checks out so we can be confident that no type errors will manifest at runtime.

10

u/asdfkjasdhkasd Jun 28 '18 edited Jun 28 '18

For anyone wondering what the scary type means, the real signature is:

pub fn sort_by_key<K, F>(&mut self, f: F) 
where
    F: FnMut(&T) -> K,
    K: Ord, 

We take a mutable reference to self, which is like an array but we have permission to mutate it, since we're going to sort it.

Then we take a function, called F, where F is a FnMut which means we must be allowed to call it multiple times and it's allowed to have internal state. The function takes a reference to a T which is the type of the thing in the array/vector/slice, and then returns a type K. And we declare that K must implement an ordering so that we can sort it.

4

u/Thaxll Jun 28 '18

I understand your point, the lack of generics in this case let the implementation up to the dev, but it's not that bad, it's actually very simple:

https://play.golang.org/p/3en4TyRblVr

I'm sure Go will have generics "soon" and overcome those.

17

u/Homoerotic_Theocracy Jun 28 '18 edited Jun 28 '18

Well the implementation you give me there to deal with the type system can never be efficient.

Note how it has to index the slice in the comparison function while sorting. In order to deal with the type system it can't be given a generic function so it has to get a function of a fixed type that takes two indices and produces a bool always no matter the type that is actually being sorted.

This means that it cannot already re-order future elements while sorting and that it probably has to cache and store the comparison results because the sort destroys the "words" slice which makes the indices invalid so it probably has some kind of strategy where it first compares all the indices and stores those and then starts destructively sorting the slice.

The other part of it is that the type signature itself accepts an interface{} which throws any and all static type checking out of the window so basically we're back to dynamic typing in order to deal the lack of generics.

In the Rust example there is no possibility of runtime type errors; if something other than a mutable reference to slice is passed it won't work, if the slice has the wrong elements for the key function it won't work; if what the key function returns cannot be ordered it won't work either all at compile time.

→ More replies (10)

9

u/[deleted] Jun 28 '18

There are also problems that dynamic typing is particularly suited to solving.

Mind naming a couple?

4

u/yawkat Jun 28 '18

I mean I don't disagree with you, dynamic typing is nice for small projects, but

Architecting a system with dynamic typing is a skill also, and many devs working with dynamic languages have not learned it well.

is not a very good argument. If people are worse at architecture in a language, that means a language has failed in its goal (or is being used for the wrong domain, as you say).

4

u/redditthinks Jun 28 '18

I don't think there's any significant benefit to dynamic typing if you have inferred types which is the case in many languages now. I would not use a dynamic language in anything that isn't a single-file script nowadays.

-5

u/wavy_lines Jun 28 '18 edited Jun 28 '18

The only scenario where dynamic typing is not bad is for small throw away scripts. You kind of said yourself, except indirectly, in a sugar-coated kind of way.

Architecting a system with dynamic typing is a skill also

No shit? Getting yourself out of a hole you dug yourself into takes special skills. That doesn't mean you are smart if you can do it. It just means you were stupid for digging yourself into the hole in the first place.

If you write python or ruby like a java or c# dev, you're going to be in for a bad time.

If you write a non-trivial application in python or ruby you're in for a bad time.

The only sane way to write python code now is with type annotations. Any other way is just bad.

There's a reason why the majority of popular webapp frameworks run on dynamic languages (rails, wordpress, django, laravel).

The reason is that people thought writing web apps in dynamic languages would be more enjoyable. But it's turning out to be a mistake.

Here, let me quote your next sentence to prove my point:

When twitter learned the hard way that writing all their middleware in ruby was a bad idea and rewrote the majority of their software in scala

So there you have it. Twitter had a reason to write everything in Ruby, but then it turned out to be a bad idea.

Why are you even arguing with me? Do you actually disagree with anything concrete I'm saying, or are you just upset with my tone?

they never moved away from rails because the dynamic type system suited dynamic content generation very well.

Are you sure that's why? Maybe they still kept some parts in ruby because it was just "good enough" and they did not want to spend time to migrate it?

Dynamic typing is a very sharp knife; it's important that it's not used as a screwdriver.

That's a strange way of putting it.

Something more suitable to be described as a sharp-knife would be manual memory layout and pointer arithmetic in C; it gives you great power but requires very delicate care, and should be avoided when not needed.

To me dynamic typing is a large hammer. It requires care when using it because you never know when it will just screw everything up. If you just need to hammer some large object one time, go ahead and use it.

Otherwise, just say no.

7

u/peterfirefly Jun 28 '18

The only scenario where dynamic typing is not bad is for small throw away scripts.

It is also quite nice in properly typed languages as long as it is only used sparingly during development.

There are Haskell and ML variants that allow that.

https://downloads.haskell.org/~ghc/7.8.1/docs/html/users_guide/defer-type-errors.html

https://people.mpi-sws.org/~rossberg/hamlet/

10

u/Miserable_Fuck Jun 28 '18

Getting yourself out of a whole you dug yourself into takes special skills. That doesn't mean you are smart if you can do it. It just means you were stupid for digging yourself into the whole in the first place.

Stop being an asswhole

→ More replies (1)

17

u/Yubifarts Jun 28 '18

I love dynamic typing so long as it's also strongly typed, but that's my preference.

23

u/wavy_lines Jun 28 '18

I've already argued this in another thread, but allow me to repeat myself.

Python's typing is not "strong" in any meaningful sense. You can create an instance of any object and then just randomly start adding and remove attributes to it in runtime.

Say you have a class called Point and in the constructor it defines self.x and self.y and documents them to be numbers.

Now somewhere in the code you can check any object to see if it's an instance of Point using isinstance(obj, Point). Do you think you can guarantee that obj.x and obj.y are present and set to numbers? No! Because anyone can just take any object and remove the attributes you're looking for and add new attributes you weren't expecting.

That's hardly 'strong' typing.

>>> obj1 = Point(10, 5)
>>> obj1
<__main__.Point object at 0x101b15da0>
>>> obj1.x
10
>>> obj1.y
5
>>> delattr(obj1, 'x')
>>> obj1.x
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'Point' object has no attribute 'x'
>>> 

11

u/caramba2654 Jun 28 '18

Not that anyone sane would do that. Just because it can be done it doesn't mean it should be done.

And if you try searching Github for any code that does what you described, I don't think you'll find any instances of it.

15

u/wavy_lines Jun 28 '18

Why are you assuming it to be insane? How do you think ORM libraries work?

I'm not saying anything here about weather it's good or bad. I'm just pointing out that Python is not strongly typed because the type almost means nothing and you can do whatever the hell you want to the object.

You don't have to call delattr or setattr. Just simply take any instance and assign fields to it:

some_object.some_field_1 = <Some-Value>

It doesn't even have to be malicious. It could be an honest mistake. You thought some_object was an instance of some class that does have some_field_1 and nothing about the language runtime would even warn you that you're doing anything wrong.

27

u/caramba2654 Jun 28 '18

But strong typing doesn't reflect what attributes an object has. Strong typing means that there's no automatic coercion of a value of type A to a value of type B. And Python works exactly like that. So by definition Python is strongly typed.

What you should be claiming instead is that Python is dynamically typed, which is the property that allows you to add and remove attributes to an object.

→ More replies (15)

2

u/THeShinyHObbiest Jun 28 '18

What about in a language like Ruby? If :some_field_1= isn't defined on that object, then the example you've given will explode.

2

u/wavy_lines Jun 28 '18

I haven't used Ruby but if it's you say then that's a good thing.

It would be much better though if there was a compile to catch the problem at compile time.

2

u/[deleted] Jun 28 '18

Not that anyone sane would do that. Just because it can be done it doesn't mean it should be done.

But you can't do any useful static analysis because of such things.

3

u/Yubifarts Jun 28 '18

Whilst there's no formal definition or committee which defines strong or static typing, I feel your comment concerns what is considered the "static"/"dynamic"-ness of the language, which is orthogonal to the "strong"/"weak" dichotomy.

I don't have an issue with what you describe. That indeed looks like a descriptive example usage of a dynamically typed language.

For my personal preferences, I dont like working with a weak type system. You cant do print('a'+0) in python without getting an error, which I like, because it removes a large class of "gotchas" which occur in php/javascript and the likes.

Regardless if it's strong or weakly typed, I'd say using a linter with dynamic languages is basically required. It largely solves the issues you'll have with typos and types you'll encounter in a dynamic language, albeit not perfectly. Similar to how you won't want to ignore compiler warnings in a statically typed, weak language ala C

6

u/wavy_lines Jun 28 '18

I feel your comment concerns what is considered the "static"/"dynamic"-ness of the language

It doesn't. See my other comment here: https://www.reddit.com/r/programming/comments/8ue8st/python_370_released/e1fglcy/

Note that the definitions people throw around for "strongly" and "weakly" typed are all informal and there doesn't seem to be any real standard definition for these terms. I suppose a certain book or blog post popularized a certain definition and reddit somehow adopted that.

If you check wikipedia, there seems to be no agreed upon definition: https://en.wikipedia.org/wiki/Strong_and_weak_typing

See also: http://wiki.c2.com/?StronglyTyped

4

u/[deleted] Jun 28 '18

Why, exactly? It'd be interesting to see all the arguments for dynamic typing, out of the actual experience, not parroting some weird gurus.

12

u/woztzy Jun 28 '18

I don't think the people downvoting you have any real experience with a statically-typed language with an expressive type system (i.e., pretty much any typed functional programming language).

People who keep parroting that dynamic and static type systems are just "different tools to have in your toolbox" and that they're beyond comparison are insulting the field of programming language theory, and we could extend that argument to using assembly where we would otherwise use C.

This answer addresses a few misconceived notions people seem to have about static type systems.

3

u/[deleted] Jun 28 '18

You make some good points but this idea that dynamic typing has no place in programming is ridiculous. Languages like lisps and Erlang are languages that are better off being dynamically typed and fulfill niches better than strongly typed languages can.

1

u/Dreadgoat Jun 28 '18

Dynamic languages are semantically closer to natural language.

That's the advantage. High readability.

You can rattle off a million technical reasons why static can do everything dynamic can and better, and you would be technically correct, but that doesn't change the fact that my co-worker can read my 20-line PHP script more easily than the equivalent 5-line Haskell script.

6

u/Pazer2 Jun 28 '18

Natural languages are full of difficult to understand rules and exceptions. Not exactly a good fit for a programming language.

2

u/Dreadgoat Jun 28 '18

Difficult to understand for computers but naturally intuitive for humans.

The reason good dynamic languages are so highly praised (case in point: python) is because of the enormous difficulty in bridging that gap.

A bad programmer can only think like a human.
A passable programmer can think like a computer.
An excellent programmer can trick the computer into expressing itself like a human so that even the bad programmer can maintain code easily.

When I was teaching programming I loved Python the most. Not because it's great to program in, but because it made grading so much easier. It instantly turned stupid and/or inexperienced students into passable programmers thanks to its enforced whitespace and the compromise between dynamic but semi-strong typing.

1

u/Dodobirdlord Jun 30 '18

This is an argument that extends at least back to Knuth's Literate Programming and probably further. Given the staggering adoption and success of notebook-style live editing environments among all fields of analytical research and data science I would hesitate to claim that the issue is settled.

0

u/dpc_pw Jun 28 '18 edited Jun 28 '18

For a lot of people, Java/C/C++ are the only "statically typed languages" they've seen and that's the reason they prefered and still prefer dynamic typing.

C/C++/Java are just so awful... All this talking about "quick prototyping" is mostly "avoiding shitshow of Java OOP and boilerplate it causes and avoiding debugging Segfaults in C/C++.

10

u/[deleted] Jun 28 '18

C/C++/Java are just so awful...

Oh, really? Did you ever have a chance to use any decent IDE? Did not you like the code discoverability enabled by types?

You read code far more than you write it.

So, even if all the statically typed languages but C++ and Java disappeared overnight, I'd still prefer them to Python / Javascript. Yes, their type systems are primitive and cumbersome, but they're still enabling the most important feature of the static typing - a precise code navigation.

3

u/Pazer2 Jun 28 '18

C/C#/C++ are the only "statically typed languages" I've used, and they are the reason I prefer not using dynamic typing. So many compiler guarantees... It's wonderful.

1

u/SmugDarkLoser5 Jun 28 '18

Lol at c having compiler guarantees.

-2

u/[deleted] Jun 28 '18

Nope. Exactly the opposite. Years of doing Java and C and now many years with Python I wouldn't go back to static typing. Strong but dynamic is the sweet spot.

14

u/Matthew94 Jun 28 '18

Strong but dynamic is the sweet spot.

Static with type inference is the sweet spot.

10

u/wavy_lines Jun 28 '18

static with generics and tagged unions and function types

2

u/lookatmetype Jun 28 '18

Aka, unless you're Haskell you suck

→ More replies (1)

10

u/[deleted] Jun 28 '18

Mind elaborating on this? Mind naming a single feature of dynamic typing that make it "superior"?

5

u/wavy_lines Jun 28 '18

Java sucks, I won't argue with that. Specially around 10 years ago.

Not all languages are Java.

Kotlin and Swift have powerful yet flexible static type system. D also has a powerful and flexible type system and it's been around for more than 10 years.

Python style "dynamic" is far far from the sweet spot. Also the "strong typing" label is bogus because python's type system does not even define what fields are available on an instance of a class. A struct is the most basic/simple type and yet Python (before 3.6) had no way to even declare it.

2

u/raze4daze Jun 28 '18

Just gonna chime in as a fanboy here: Java 8+ is really nice to use, but yeah 7 and below is just tragic. I really dig Kotlin as well.

Just my opinion.

→ More replies (2)

-20

u/[deleted] Jun 28 '18

Duck typing is a useful tool, lots of people use it. Get over it

25

u/wavy_lines Jun 28 '18

"lots of people use it".

What a completely useless argument.

7

u/awj Jun 28 '18

You mean like this one, that says the same thing in 10x as many words?

Can we all take a moment to acknowledge how large numbers of people (including me) have come to realize in recent years what a bad idea dynamic typing was?

5

u/wavy_lines Jun 28 '18

Lots of people do something vs lots of people starting to realize they were wrong after years of experience.

Yea totally the same?

-1

u/Ajm_Joha Jun 28 '18

That's good

-6

u/arbitrarycivilian Jun 28 '18

Oh look, a modern language is slowly catching up to where ML was over thirty years ago. Yay?

14

u/[deleted] Jun 28 '18

You just described pretty much every "new" language "innovation" of the last 30 years or so. AFAIC the first symptom of industry-wide dementia happened when SGML/XML was chosen over Common Lisp and s-expressions.

The terminal illness settled in when Javascript was invented and actually embraced as a thing that could be used to develop large applications.

It's like watching a never-ending film loop of a kid riding his bicycle into a telephone pole.

7

u/[deleted] Jun 28 '18

Javascript is like watching the kid ride his bike into a cactus farm.

1

u/shevegen Jun 28 '18

Right - but remember the jackass people did it and made lots of small videos. And people loved those videos too, back in the day.

There is actually some awesomeness associated when you jump into cactus - look at youtube videos for that! It's very dumb and also very amusing at the same time.

-4

u/shevegen Jun 28 '18

If ML was so awesome ...

... it would be on TIOBE place where python is.

Since ML it is not, uhm ... enjoy the retro-feel of the programming world, dude!

1

u/aejt Jun 30 '18

Yeah, because popularity definitely equals how well thought out a language is! JS is the best thought out language ever!

It's not like more or less all the top10 languages are implementing more and more ML features nowadays!

-12

u/not_perfect_yet Jun 28 '18

Meh.

I guess I'm not a professional and just some guy on the internet, but I don't like half of these. The obviously good ones are obviously good (who doesn't like deterministic things or more language support in docs). The dataclass and annotation debates have been done to death, so I'll not repeat them here.

The insertion-order preservation nature of dict objects is now an official part of the Python language spec.

This is neat, but depending on how prominently it's advertised and adoption of 3.7, it can take years for this to be reliable.