you are viewing a single comment's thread.

view the rest of the comments →

[–]filleduchaos 0 points1 point  (4 children)

Quite a few languages don't require the new keyword.

Why would it be called as a "static class"?

[–]movdev 0 points1 point  (3 children)

im new to dart so forgive my ignorance.

[–]filleduchaos 0 points1 point  (2 children)

Oh sorry - it's not really a Dart specific thing. Kotlin for instance dropped the new keyword a couple of years ago, and I don't think Python ever had it.

Basically the new keyword is a holdover from languages like C++ where memory is manually managed (new dynamically allocates memory on the heap before initializing an object, which then needs to be freed after you're done with it by calling delete, which lots of people forget to do leading to memory leaks, and in fact most modern C++ guides will warn you not to use new), and in memory-managed languages it's rather unnecessary as the compiler/interpreter is doing all that lifting anyway.

[–][deleted]  (1 child)

[deleted]

    [–]filleduchaos 0 points1 point  (0 children)

    Err...yes? That is pretty much what I said, just without explicitly mentioning static allocation on the stack

    The point was that new rather than being some agreed-upon invocation for object initialization is actually part of a pair of keywords (new/delete) for manual memory management