News for hackers. Stuff that matters.
Re:Are dynamic languages going to replace static languages? ... by kgeist on Wednesday August 04, 2021 @01:56AM (#28057672)
There's now a trend to add gradual typing and type hints to dynamic languages, while at the same time, "static" languages are incorporating ideas from dynamic languages. So the end result is a symbiosis, not opposition.
Re:Are dynamic languages going to replace static languages? ... by joelbluminator on Wednesday August 04, 2021 @03:01AM (#28058086)
I think dynamic code bases can have the choice now. Python has hints, JS can gradually turn to Typescript. Ruby got Sorbet. It's nice to have a choice. I personally don't like types but yeah if some monolith grows to uncontrollable size like Shopify/Stripe it makes sense to type certain areas.
Re:Are dynamic languages going to replace static languages? ... by lionkor on Wednesday August 04, 2021 @03:21AM (#28058227)
I've always wondered, and maybe you can clear this up, why? What about static typing is "worse", so to speak?
Re:Are dynamic languages going to replace static languages? ... by blacktriangle on Wednesday August 04, 2021 @09:17AM (#28060652)
Fundamental difference between static and dynamic: static typing disallows writing a certain set of perfectly valid programs while also having the advantage of disallowing many invalid programs. So the question becomes: how badly do you want to work in that space that is not permitted by static systems?

And that space is where your data itself is highly dynamic. When you just want to represent data as maps, do generic operations on maps, then spit out more maps back to something else. This description applies to many many real world systems, particular in the more business-type domains.

Another space where dynamic really shines is dealing with relational data in a relational way. Relations are just sets of maps, the most natural thing in the world to work with dynamically. In a dynamic language I can just write code that peaks into the map, transforms certain fields, then passes the whole thing on down the line. I don't care what combination of selects and joins got me that relation, and in reality there will be many, I want to reuse my functions regardless. Although this is where more structural type systems can help ease the pain over nominal type systems.

I feel like this is a great blog post talking about the downsides of static typing in a real world system: https://lispcast.com/user-wizard-scenario/. I appreciate that the author has real world experience with both Haskell and Clojure and comes from that perspective.

Ultimately I'd say that if a program can be written in a static language, it should be, however some programs deal with information that just defies fitting into your type system without herculean efforts. Just like static languages will look down on dynamic languages for reimplementing poor ad-hoc type checking, dynamic languages can also look down on static languages for poorly reimpelmenting dynamic behavior with a bunch of functions mapping Any to Any.

Re:Are dynamic languages going to replace static languages? ... by joelbluminator on Thursday August 05, 2021 @04:13AM (#28071139)
Thanks for the link. Finally somebody using actual comprehensible examples to build a case.
Re:Are dynamic languages going to replace static languages? ... by joelbluminator on Wednesday August 04, 2021 @03:46AM (#28058376)
Hard to explain. It's more verbose and restrictive. Ruby is the complete opposite, you can do anything you want. I know what people say about Monkey Patching but what Rails did with ActiveSupport is mostly beautiful. I can see the advantages in types I'm not denying them. I am just so comfortable with Ruby/Rails and js I never bothered looking deeply into anything else. The Java I did in college, and then the experiments I did with Spring framework a couple of years ago (tried a couple of todo apps) made it clear to me it's not my thing. Ruby/Rails made programming actually fun. It may have improved since then but I think even getting a shell (like Rails console) was difficult with Spring. Maybe if I stuck to Spring for months or years I would have felt differently, impossible to tell most of the time because we usually stick to what we like and avoid delving too deep into what we don't like. Spring was just a massive complicated thing, or at least that's the impression I got. People go on and on about Rails being magical, I suspect most of them have a very vague understanding of how Spring actually works under the hood. Not to mention those hundreds of Beans you need to get to know, I dread those! I can see myself doing Go or Swift, something not too verbose, but again, I don't really care for performance (it's not at the top of my wish list as a web developer) that much or types. So to sum it up: I just like Ruby/Rails and not a big Java fan. I know there are many other static languages to choose from but life is short, I am happy doing my thing with Ruby. If I have to jump ship it will probably be to Python.
Re:Are dynamic languages going to replace static languages? ... by omegalulw on Thursday August 05, 2021 @07:03AM (#28072076)
I absolutely disagree with the assertion that static typing is restrictive. It's not, though of course you need to be more verbose. But you are doing this largely for correctness so it's a worth tradeoff. Needing overly generic types or no type restrictions is very strong code smell.
Re:Are dynamic languages going to replace static languages? ... by jimsimmons on Wednesday August 04, 2021 @03:25AM (#28058248)
It’s slow and cumbersome to write. Makes code verbose and harder to read.
Re:Are dynamic languages going to replace static languages? ... by skohan on Wednesday August 04, 2021 @04:30AM (#28058633)
Yeah this might be true of Java, but I think for modern languages with good type inference it adds a lot to readability without much cost in terms of verbosity.

After working with more strongly typed languages, it actually seems crazy to go back to JS or Python and not have type information in function signatures. Like how are people supposed to read code and understand what this function is allowed to take?

Re:Are dynamic languages going to replace static languages? ... by joelbluminator on Wednesday August 04, 2021 @04:33AM (#28058646)
Functional programmers also say "how can I go back to mutable state and OOP". The fact is people get stuff done in many different ways and paradigms. You found what works for you and that's good, stick to it. Others found theirs.
Re:Are dynamic languages going to replace static languages? ... by arcturus17 on Wednesday August 04, 2021 @05:08AM (#28058839)
You can annotate types in Python and Typescript.

Before that large companies like Google got around it by annotating in the comments. It may be an inferior solution but huge codebases serving hundreds of millions of users have worked this way.

Re:Are dynamic languages going to replace static languages? ... by gefhfff on Wednesday August 04, 2021 @05:24AM (#28058956)
Huge code bases serving hundreds of millions have been written in wasm, so...? Bad argument
Re:Are dynamic languages going to replace static languages? ... by arcturus17 on Wednesday August 04, 2021 @05:29AM (#28058990)
There was no argument, the commenter was just asking “how”.
Re:Are dynamic languages going to replace static languages? ... by kaba0 on Wednesday August 04, 2021 @05:54AM (#28059143)
Modern Java is not what people may remember. It has var keyword for local type inference, lambdas, etc.
Re:Are dynamic languages going to replace static languages? ... by einherjae on Wednesday August 04, 2021 @03:33AM (#28058296)
Except that very verbosity may make it easier to read, as the types themselves may supply further information to the reader about what the variable actually means.
Re:Are dynamic languages going to replace static languages? ... by jim-jim-jim on Wednesday August 04, 2021 @05:52AM (#28059134)
I think this is noisy.

  f(x: a, y: b): c = ...
I think this is nice.

  f :: a -> b -> c
  f x y = ...
Signatures are useful as self-documentation, and keeping them separate makes that easy to scan.

It also comes down to the compiler. If you're "annotating" your code with type "sugestions," but don't get any ironclad guarantees from it, then it's reasonable to question whether it's even worth the effort. I may be misremembering things, but "typed" versions of Python and Scheme aren't particularly rigorous.

Re:Are dynamic languages going to replace static languages? ... by user-the-name on Wednesday August 04, 2021 @05:43AM (#28059076)
Verbosity aids readability a lot of the time.
Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @04:55AM (#28058772)
A static type system requires the programmer to think about the types. It distracts and takes up mental space, especially when one is returning to old code and "just" want to quickly add a small feature that sound simple in concept but first require that one parse the thought process behind the old code.
Re:Are dynamic languages going to replace static languages? ... by dragonwriter on Wednesday August 04, 2021 @05:31AM (#28059002)
> A static type system requires the programmer to think about the types.

Dynamic code requires the programmer to think about the same things; what static typing requires is communicating that thought to the type-checker through a constrained language (in the best cases, with robust type inference, this can be no additional cost for substantial fractions of a code base, though). On the other hand, it also provides fairly immediate feedback on the correctness of the information so communicated, and cam leverage it in dev tooling, so there is a benefit with the cost.

Re:Are dynamic languages going to replace static languages? ... by scrollaway on Wednesday August 04, 2021 @06:54AM (#28059534)
Like others have said, dynamically typed languages still require you to think about the types, except that now you don't have the automatic hints the IDE can provide you, the guarantee of safety once your code compiles etc.

Typed codebases are far better to return to than untyped ones. Anyone who doesn't think so has probably not tried a good, typed language with a good IDE.

Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @08:27AM (#28060182)
It is interesting that so many people believe, and strongly enough to downvote, that you must think about types when programming. A claim that people can't program unless they are thinking about types.

I have provided examples in other comments where types is about as far away from my mind when writing complex programs. In terms of guarantee of safety, system and integration tests do that. Types are not based on customer requirements, nor do they verify that the program do what I get paid to do. A type is simply a limited set of automatic restrictions and tests to very that those restrictions are followed.

Re:Are dynamic languages going to replace static languages? ... by jerf on Wednesday August 04, 2021 @09:21AM (#28060694)
Because the claim "you're not thinking about types" is absurd. You can't pass a LoggedInUser to a thing expecting a URL. You can't pass a AccountIterator to a thing expecting a UUID. You can't pass a function closure to a thing expecting a string. And so on.

You have to be thinking about types, because the computer can't. Since your programs work (I assume), and computers can't be doing this for you, by process of elimination, you're the one thinking about types.

What is actually happening is either that you've so deeply internalized it you don't realize it any more than you think about individual muscle contractions while walking, or you don't recognize what "thinking about types" means. For instance, I imagine an obvious riposte to my first paragraph would be "But if the code expects a URL and I pass it an LoggedInUser, I can set it up so the LoggedInUser can yield or function as a URL", which is in fact precisely "thinking about types" because you just changed the type of your LoggedInUser.

(You want to see someone who is truly "not thinking about types", go help someone learn programming for the first time, who truly innocently tries to pass a User to something expecting a URL and is truly surprised when that doesn't work because they truly, deeply thought the program would just figure out how to turn that into some URL they had in their head for the user, but never explained to the code. That's "not thinking about types". It is nonfunctional.)

As others have said, dynamic code requires you to do more thinking about types, not less, for two reasons: One, the compiler isn't doing it for you, and two, you have a lot more things to juggle in a dynamic language than in most static ones precisely because they give you more power. You shouldn't be fighting this idea, you should be embracing it; it is precisely the fact that they make you think more about types and leave more of the decisions to you that gives you the additional power in dynamic types you are enjoying.

But that additional power irreducibly comes with more responsibility. You can't claim you've obtained the power yet somehow dodged the responsibility of managing it. You are holding a lot more state in your head that has no existence in your source code than you would be in an equivalent static program. You can't claim you've got that state in your head but you're somehow not "thinking" about it.

You're thinking about types all the time. Your complaint is more than you like a programming style that involves very complicated type ideas that are difficult to express in a static language. (Or, possibly, that you haven't taken the time to learn to express in a static language. There are some static languages that work better with this style than others.) Or that you don't want the constraint of having to express them. So you stick to an environment that loads the work on to you instead in return for the power of those more complicated things you never have to lay out for the compiler. But the work is getting done somewhere. It has to be, or your program wouldn't work.

Re:Are dynamic languages going to replace static languages? ... by kitkat_new on Wednesday August 04, 2021 @11:10AM (#28061899)
@belorn:

> You can pass a LoggedInUser to a thing expecting a URL in a dynamic language if the LoggedInUser has the same methods as defined in the interface of an URL. It called ducktyping. In the same line of thought, you should even actively avoid checking if LoggedInUser is of the type URL because a different type sharing the same interface as URL should be equally accepted as URL.

You can do that in statically typed languages as well (though not in every). See C++. Rust actively decided against it, and makes it the users responsibility to say "yes I indeed want to give this type to this function, because it satisfies the trait like this".

Is a type, as defined above, required for all programming? No. Interfaces? Yes. Interfaces are also more similar to customer requirements in that they define behavior. Do the object has an absolute path method. Do it has an UUID property. Can it be used to call open on. Those questions are not type questions, and so I do not think about type when answering them.

Interfaces in TypeScript just describe sets of types, so yes you are still thinking about types (about types of types). I'd like to know why you think either one is (syntactically) required for programming (as we know ASM doesn't have either of those) Further, I'd like to know how you don't think about basic types in JS. Finally, I'd like to know why you couldn't fall back to (mostly) duck typing in statically typed langauges.

Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @09:29PM (#28068668)
> I'd like to know why you think either one is (syntactically) required for programming

Taking the concept of interface, it would be difficult to program something with objects if you did not know the methods, properties, events. Just knowing the type name without any of the knowledge about the interface of the object would make programming close to impossible. The opposite however, knowing the methods and properties but not the type, is enough information to write a program.

In one python program I wrote I created a proxy object for a third-party library. The library only supported a single process, and I needed multiprocessing. The proxy object allowed me to take every call to the object from process B to be pickled and forwarded to process A, with the return value being sent back to B. No function needed to be made aware of the proxy object, the third-party library behaved just as it was a single process program and everything just worked. The proxy object did not need to have any information about the call signatures or method names of the third-party library objects.

It would be interesting to see such proxy object being written in a statically typed language that maintain the type checks when the proxy object get used inside a third-party library. Requirements would be that the proxy object should be independent implemented without being effect by the call signatures and method names in the third-party library. It sounds a bit fun trying to get the compiler to resolve what the type and signature should exist at compile time, through that might just be implementing a dynamic-like language through macros and compiler tricks.

Re:Are dynamic languages going to replace static languages? ... by oalae5niMiel7qu on Wednesday August 11, 2021 @02:12AM (#28138633)
What you'd end up doing is copying and pasting a lot of code. You'd need to define one kind of proxy object for one type in the third-party library, and another kind for another type, and so on. Each would need to implement all the methods, with correct type signatures.

Perhaps you could parse the source code to the third-party library and generate matching proxy objects from that.

No number of compiler tricks would allow you to define a single object that can be a proxy for anything using a statically-typed language.

Re:Are dynamic languages going to replace static languages? ... by c-cube on Wednesday August 04, 2021 @05:32PM (#28066632)
Exceptional comment, thank you.
Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @10:34AM (#28061463)
You can pass a LoggedInUser to a thing expecting a URL in a dynamic language if the LoggedInUser has the same methods as defined in the interface of an URL. It called ducktyping. In the same line of thought, you should even actively avoid checking if LoggedInUser is of the type URL because a different type sharing the same interface as URL should be equally accepted as URL. Two objects with the same interface should not be treated different unless very special circumstances.

If the code only expect the interface of an URL, the type of the object being sent in is irrelevant, and thus the programmer do not need to think about the type. Instead we are thinking about interfaces.

Programming in a dynamic language do allow a programmer to not think about types, but they do need to think about interfaces. Programming in a static language require the programmer to think about types, but they also need to think about interfaces. Having types does not eliminate the obligations to think about interfaces regardless of programming style.

If we want to use TypeScript as an example, a type is a data type of either Any Type, Built-In Type, and User-Defined Type. The Type System in TypeScript is responsible for checking the data type of any value taken before it can be provided as an input to the program.

Interface in TypeScript: An Interface in TypeScript is a syntactical obligation that all entities must follow. It can only contain the declaration of the members and is responsible for defining the properties, methods, and events. In a way, it is responsible for defining a standard structure that the derived classes will have to follow.

(above taken from https://www.geeksforgeeks.org/what-is-the-difference-between...)

Is a type, as defined above, required for all programming? No. Interfaces? Yes. Interfaces are also more similar to customer requirements in that they define behavior. Do the object has an absolute path method. Do it has an UUID property. Can it be used to call open on. Those questions are not type questions, and so I do not think about type when answering them.

Re:Are dynamic languages going to replace static languages? ... by adwn on Wednesday August 04, 2021 @02:09PM (#28064259)
> Two objects with the same interface should not be treated different unless very special circumstances.

...until you accidentally pass the ClientsTable object to the delete_supplier() function, which expects a Supplier object. Unfortunately, the delete_supplier() function calls the delete() function of the passed object, which is helpfully provided by ClientsTable. Bummer. Eh, just restore it from backups, right?

Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @05:49PM (#28066842)
Unfortunately right before that an SQL function was called that wiped the database, just before calling the banking function that used an corrupt pointer to send a large sum of money to a random tax account which then happened to have a major tax debt, and as matter of tax law one can't demand money back from the government if paid to such account.
Re:Are dynamic languages going to replace static languages? ... by adwn on Thursday August 05, 2021 @02:21AM (#28070483)
You've completely missed the point: A powerful static type system helps prevent many types of logic bugs.

No, it won't prevent every conceivable bug or error, but nobody claimed it does. Automatically ruling out a large class of bugs at compile-time is still very valuable. Don't let the perfect be the enemy of the good.

Re:Are dynamic languages going to replace static languages? ... by belorn on Thursday August 05, 2021 @06:02AM (#28071703)
In almost 20 years of writing programs I have yet to write a delete function that dynamically call delete based on the object type. Having a delete_supplier() function that assumes Supplier object is a pattern that has direct security issue baked in.

The closest I would ever have gotten to the above scenario would be the time when I wrote an array of function pointers to be called in a parallel process. A bit of rather complex C code, and if I recall a bunch of void pointers.

If you intend to provide examples or bugs being caught with type checking, it would be useful if those examples actually occurred and were caught by the type checking.

Re:Are dynamic languages going to replace static languages? ... by scrollaway on Thursday August 05, 2021 @10:19AM (#28074076)
You sure seem to be thinking about types a lot for somebody who claims to not have to think about types. Which is the entire point everybody is trying to make you understand.
Re:Are dynamic languages going to replace static languages? ... by belorn on Friday August 06, 2021 @09:02PM (#28094669)
You seems to insist on that a lot, but can't seem to show it.
Re:Are dynamic languages going to replace static languages? ... by gefhfff on Wednesday August 04, 2021 @05:22AM (#28058937)
And with dynamic ts the programmer is not required to think about it? You don't think anymore if you return a number or a string or a map? I doubt it. Static TS require you to think correct (and occasionally write it down - depends on the language) before you run the code.
Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @06:53AM (#28059531)
Here is a real life example. I have a library that communicate with an API that extract information, and now I want it to also grab an additional field and extract it to a database. The goal is to figure out which functions in the code accesses the field, where the best spot is to extract the information, and what the best way to call into the database without adding too much code in places where it shouldn't be. In addition I need to keep the information synced over time.

Do I care what the different functions in the library return? No. The field could exist in everything from an XML object, a dict, a string, a byte array, or a custom object made for easy interaction. What I need to know is where in the flow I can best inject my new code, and in order to do so I need to know when and where the information can be accessed. In an optimal world I would have written a shell script, and in that case every function has a single return type which is string.

Re:Are dynamic languages going to replace static languages? ... by gefhfff on Wednesday August 04, 2021 @08:38AM (#28060283)
I can't answer your question. You may care since you may not want to break other code within the library that depends on what is returned by the function (depends how it looks like).

Otherwise I don't know why you would particularly care more about types with st than otherwise You'd just follow the same pattern as you did when extracting the other fields. E.g. if the fields to extract are listed in a list like structure, you're just going to add the extra field to the list. And in case of static typing, you'll get soonish feedback if you messed something up.

The return type thing was just an example to show that you care about return types regardless of static typing, not that you care about return types during every act of programming.

Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @08:54AM (#28060442)
> The return type thing was just an example to show that you care about return types regardless of static typing, not that you care about return types during every act of programming.

If we both agree that you do not need to care about types during every act of programming, then lets follow that thread and see where it leads. When do you need to care about types, and how big portion of a programmers time is spent on thinking about types?

My own expensive provides the answer "rarely" and "as little as possible". The few times I do care about types is when interacting with third-party functions, and in those cases I read the manual to figure out what their functions are returning and what I can expect to use. I do not however write test that verify that a function that is documented to return a string actually do return a string (or expect my compiler to do it for me). If the documentation is incorrect then I treat that as a bug, just as if it was a logic bug.

It would however be interesting to hear how much others spend time on it, and in what kind of acts of programming.

Re:Are dynamic languages going to replace static languages? ... by gefhfff on Wednesday August 04, 2021 @09:20AM (#28060689)
I think about types (almost?) every time I write a function. What type of data does the function expect, and what type of data am I supposed to transform this data to?

For instance, if I calculate the time that has elapsed between two points in time: - what does my input look like (e.g. two objects that look like XY) - in what form should I return the difference? Time in seconds (i.e. number), again an object that looks like XY ? ...

I can't imagine saying I would care about types rarely.

Another nice benefit of st langs is that you have to read manuals less often. IDEs so a way better job showing you the type of every variable (and result of an operation) as well as the options you have at your hand for a given type (including their documentation and example code). Yes I know dt languages and their tools try to catch up.

> or expect my compiler to do it for me). If the documentation is incorrect then I treat that as a bug, just as if it was a logic bug.

Well, I don't expect that with Dr languages as well, but I am glad that the compiler does this (or in DT languages at least the IDE due to type hints). I mean, it saves a lot of time (money) later on ... even if you notice it right away the first time you use the code

Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @11:03AM (#28061812)
Interesting, let me do the same example and see how my thought process differ.

I would first ask, should I write a function or maybe have this as an property of the object that has the original data. I want the intended interface to influence my design.

What methods does my input has? Does it already implement what I want or have a helper function that makes writing the transformation easier? Is there built in functions or third-party libraries that do time differences calculations.

Within python I would apply some minor assumptions about types. If something is a time it is either a string or an object with a time interface, and so I might need to cast it to a time-like object. Preferable this already occurred as close to the edge of the program as possible so in the rest of the program I don't need to put any thought about the type. If its a date, it should be a an object with a time interface. If time strings are floating around in the data flow, just as with byte strings, I should try to fix that as early and close to the edge of the program.

There seems to be a similar view about unicode. You don't want to have every function check if the input is of the type unicode. Instead what people do is when they read a byte string, they turn it into unicode as everything else assume the unicode interface.

Re:Are dynamic languages going to replace static languages? ... by gefhfff on Wednesday August 04, 2021 @12:08PM (#28062680)
Thanks for confirming
Re:Are dynamic languages going to replace static languages? ... by joelbluminator on Wednesday August 04, 2021 @09:12AM (#28060608)
This. I was wondering if it's because I'm a web dev that I rarely care/think/debug typing issues or what. I hear the stories I'm just not sure what everyone is talking about. I did have that in js a bit (the good old == vs ===) but not with Ruby.
Re:Are dynamic languages going to replace static languages? ... by scrollaway on Wednesday August 04, 2021 @06:57AM (#28059561)
If you do not care about the type, and indeed do not do anything special with it other than pass it through to somewhere (that may or may not care about it), then there are types that let you do that.

A good typed language will allow you to be more or less strict about what you accept (eg. a specific literal string, a set of strings, any string, any string like object, any object...)

Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @07:55AM (#28059923)
If there are types that allow you to not care about the type, then why have a type?

People argue that they need types to very that you do not add in programming errors, and in order to easier read what the code does. In the environment I operate in and the jobs I do, types do not achieve those things. All they do is add unnecessary information and restrictions that need to be worked around.

Shell is an interesting environment in that there really is only one type: string. There are no int, no floats, barely any arrays (rare enough that I don't ever use them). You run a program with string inputs and you may get an string output in return. The majority time writing a shell script is spent on manuals, understanding how different programs interact, and data flows. This remain mostly true for dynamic languages. For static typed languages some of the time get redirected on dealing with types, declaring types ahead, and making sure the type declarations and castings are correct.

Re:Are dynamic languages going to replace static languages? ... by lkitching on Wednesday August 04, 2021 @09:06AM (#28060557)

    If there are types that allow you to not care about the type, then why have a type?
The type represents a set of properties about the inhabiting values so if you have an opaque value you don't want others to inspect, wrapping it in such a type makes that explicit throughout the rest of the program. That information is not available if every value in your type has the same type. Presumably though you will actually attempt to do something with the contained value at some point so you must have some expectation about what it is.
Re:Are dynamic languages going to replace static languages? ... by scrollaway on Wednesday August 04, 2021 @08:13AM (#28060048)
You're making an entire argument about something you clearly haven't properly tried. It sounds like you have your own misconceptions about what static typing is and how types work. Your premise is flawed so it's difficult to have a conversation.

I would encourage you to try typescript for a while, it's very approachable and has excellent tooling.

Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @08:40AM (#28060297)
One can measure the quality of a discussion in how often people refer to the arguments, and how often they refer to the person. You're making... you have your own misconceptions... Your premise is flawed... encourage you to try...

I have worked with 10+ different languages, multiple different IDE's, some types and some dynamic, some like shell which doesn't really have the concept of types at all.

If you are encouraging me to try typescript because you think its great, then I would encourage you in return to test python in combination with system and integration tests. It makes for a very safe environment where you know your code is working.

Re:Are dynamic languages going to replace static languages? ... by scrollaway on Wednesday August 04, 2021 @11:07AM (#28061853)
I've worked with python for 17 years. I maintain that given your arguments, you haven't tried a properly set up static language.

I know how to make python safe with TDD. It doesn't even sort of compare.

Re:Are dynamic languages going to replace static languages? ... by belorn on Wednesday August 04, 2021 @01:23PM (#28063726)
You can maintain that if you like.

I don't want to speculate why you feel so attached to static languages. I worked with python in 15 years, you in 17. I have done low level embedded C code. I done web development, and shell scripts. Tried lisp, and programmed in Ada. If you have also worked with similar amount of languages and reach a different conclusion then either your work is very different from mine, or you as an other person have a different experience than mine.

When it comes to keeping simple thing being simple, static languages has never delivered for me. In embedded system I live with that aspect, but that's the nature of such environments. The primary question when working with dynamic language is: "is there already a library that does what I want, and how do I modify it to work in my use case". Instead of thinking about structure and types, I am thinking about interfaces.

I will conceit one example where a static typed language is much better than a dynamic typed, and it illustrate the environment where such language aspect shine. SQL. SQL with dynamic types would be horrible and any database which treat types some-what dynamic is a horror to work with. SQL does not make simple things simple, and database exceptions are quite harsh in every aspect. There is also few if any interfaces, so its types or nothing.

Re:Are dynamic languages going to replace static languages? ... by doomvox on Tuesday August 10, 2021 @07:14PM (#28135988)
Douglas Crockford, "Javascript: The Good Parts" (2008):

  "But it turns out that strong typing does not eliminate the need for careful testing.  And I have found in my work that the sorts of errors that strong type checking finds are not the errors I worry about."
Re:Are dynamic languages going to replace static languages? ... by dade on Wednesday August 04, 2021 @02:00AM (#28057700)
> "static" languages are incorporating ideas from dynamic languages. So the end result is a symbiosis, not opposition.

If I may ask, what ideas are static languages incorporating from dynamic languages? Could you help clarify?

Re:Are dynamic languages going to replace static languages? ... by native_samples on Wednesday August 04, 2021 @03:54AM (#28058431)
The most obvious example is pervasive type inference. It's not really dynamic, but languages with it look a lot closer to dynamic languages, and the removal of repetitive type information is one of the benefits of dynamically typed languages. It gives them the clean, simple feel that it so attractive to many programmers.

Also, over the past 20 years what you've seen is big advances in the 'semi-static' world like the JVM, where it runs statically typed languages but they have the ability to eval code, redefine their own code on the fly, reflect themselves, they're garbage collected etc. This is kind of a middle ground. It's worth remembering that when Python and Ruby were new, there weren't really any great options if you wanted lightweight syntax with garbage collection. Nowadays there is Kotlin and you can write code that looks very similar to say Ruby, but which often has the performance of entirely statically typed languages.

Re:Are dynamic languages going to replace static languages? ... by Zababa on Wednesday August 04, 2021 @04:34AM (#28058653)
> This is kind of a middle ground. It's worth remembering that when Python and Ruby were new, there weren't really any great options if you wanted lightweight syntax with garbage collection. Nowadays there is Kotlin and you can write code that looks very similar to say Ruby, but which often has the performance of entirely statically typed languages.

Lisps and MLs offered this before Ruby and Python got popular. Unless you don't consider them great options?

Re:Are dynamic languages going to replace static languages? ... by native_samples on Wednesday August 04, 2021 @05:19AM (#28058910)
Well, getting into the question of why Lisps and MLs didn't take off is maybe too big a topic for this thread, but clearly the market didn't feel they were great options and still doesn't. Clojure remains a niche language for example.

I suspect one issue is that Lisp never seemed to be well supported on Windows and never came out of the box on Linux, except perhaps for Guile, but Guile never reached any kind of critical mass despite being promoted by the GNU project. Maybe one reason is the lack of learning materials. Even today, although Guile has an initially pretty and appealing website, clicking "tutorials" reveals a complete lack of interest in growing that community - there is only one single tutorial, which is about how to embed Guile as a scripting language into a C program!

https://www.gnu.org/software/guile/learn/#tutorials

I remember learning Python in the 1990s. The learning materials were excellent. Java was also famous for extensive tutorials and learning materials (they've lost that in recent years, the modern Java docsites are just piles of specifications, but when Java was interested in growth they had it). In the end these things matter more than the exact nature of a runtime or type system.

Re:Are dynamic languages going to replace static languages? ... by Zababa on Wednesday August 04, 2021 @05:35AM (#28059027)
That's a good point. I never really understood why GNU didn't use more Lisp, as the idea of "C for when performance is needed, Lisp for the rest" sounds great, but if tutorials weren't there that explains it. I learned programming later (~2010) and I remember Python being very easy to learn and install on Windows.
Re:Are dynamic languages going to replace static languages? ... by nonameiguess on Wednesday August 04, 2021 @07:11AM (#28059634)
Some Lisps were probably passable options in the early 90s, but as the sibling comment says, the lack of documentation and tutorials makes it not all that beginner friendly, along with the dizzying array of what to even choose if you want to use "a" Lisp.

No ML was a realistic workable option back then at all. Haskell is fine now, but was barely introduced in 1993. OCaml has become a workable option almost entirely due to the gargantuan effort of Jane Street, but again, it wasn't then. Standard ML remains terrible. Library support is sparse, there is almost no community outside of academics, no consistent implementation of the standard basis, compilers are wildly different from each other. The REPLs tend to be great, but it's very difficult to get from a set of source files to a portable executable, whereas with Python and Ruby, just writing the source files already gets you that.

Re:Are dynamic languages going to replace static languages? ... by Zababa on Wednesday August 04, 2021 @07:57AM (#28059935)
That's fair for Lisp, I though having a standard made it better and the main choice was between Common Lisp and Scheme, but from what I see different people use different standards for scheme.

> OCaml has become a workable option almost entirely due to the gargantuan effort of Jane Street, but again, it wasn't then.

What do you mean by this? I'm aware of dune and opam, but people were using C and C++ without equivalents before without problems. Python's package managment and building is also not that good, even today. I don't have a strong grasp of the history of OCaml so maybe they released Core, Base and Async really early compared to batteries and Lwt? But outside of that, basic OCaml with a makefile doesn't sound worse than C/C++.

> Standard ML remains terrible. Library support is sparse, there is almost no community outside of academics, no consistent implementation of the standard basis, compilers are wildly different from each other.

That's fair, my point is more that I don't really understand why no big company ever picked it. Considering how much companies invested in their tooling (Google with Java, Go, Dart, Python, C++ ; Facebook with PHP and C++ ; etc), they could have made something great.

> it's very difficult to get from a set of source files to a portable executable, whereas with Python and Ruby, just writing the source files already gets you that.

Depends on your definition of portable executable. I've always found deploying and distributing Python and Ruby painful, at least to end users. The best in class experience here for me is Go, it's great for end users, great for servers, cross compilation works well.

Re:Are dynamic languages going to replace static languages? ... by bmitc on Wednesday August 04, 2021 @09:56AM (#28061047)
> but it's very difficult to get from a set of source files to a portable executable

That isn’t the case for F#, and I would say it’s questionable for Python for anything larger than a couple source files.

Re:Are dynamic languages going to replace static languages? ... by dbt00 on Wednesday August 04, 2021 @02:02AM (#28057709)
Go's interfaces are a great example.
Re:Are dynamic languages going to replace static languages? ... by sidlls on Wednesday August 04, 2021 @10:44AM (#28061575)
Not really. It’s a terrible approach that permits some really, truly awful patterns that the designers should have known better than to permit. But it’s not really “go is dynamic!”
Re:Are dynamic languages going to replace static languages? ... by IshKebab on Wednesday August 04, 2021 @03:52AM (#28058413)
Go interfaces aren't dynamically typed. They are statically duck typed, like C++ templates.
Re:Are dynamic languages going to replace static languages? ... by majjgepolja on Wednesday August 04, 2021 @05:30AM (#28058991)
I guess the word is structural typing.
Re:Are dynamic languages going to replace static languages? ... by gefhfff on Wednesday August 04, 2021 @05:28AM (#28058982)
Down voters may express the reason for their action?
Re:Are dynamic languages going to replace static languages? ... by wizhi on Wednesday August 04, 2021 @02:10AM (#28057753)
What makes Go's interfaces dynamic in nature?
Re:Are dynamic languages going to replace static languages? ... by zmmmmm on Wednesday August 04, 2021 @04:35AM (#28058663)
they are "duck typed" .... so an object automatically implements an interface if it has methods with the right signatures to satisfy the interface.

It's handy if you need to add interfaces onto code you don't control (say, library code) as you can avoid a whole layer of adapter types / functions that you need in true statically typed languages.

But I'm curious if its a great idea in the long run to have interfaces being "accidentally" implemented by objects. Doesn't seem like it would stand up well to refactoring or various other scenarios.

Re:Are dynamic languages going to replace static languages? ... by kaba0 on Wednesday August 04, 2021 @05:58AM (#28059171)
Than it’s the age-old war between nominal and structural typing. The latter can be really comfortable and productive, but as you note, it may be less safe (eg. just because I have a next method doesn’t mean I want to make it an iterable or something like that. It can easily break class invariants)
Re:Are dynamic languages going to replace static languages? ... by Zababa on Wednesday August 04, 2021 @10:53AM (#28061687)
Isn't this more "structurally typed" rather than "duck typed"? From what I've seen, duck typing implies dynamism, while structual typing implies static types. Go is clearly statically typed. So no, Go interfaces are not dynamically typed, they are structurally typed, which is static.
Re:Are dynamic languages going to replace static languages? ... by kgeist on Wednesday August 04, 2021 @02:19AM (#28057803)
C# has "dynamic" type. All calls on it are late-bound.
Re:Are dynamic languages going to replace static languages? ... by ComputerGuru on Wednesday August 04, 2021 @03:33AM (#28058299)
Dynamic didn’t really go anywhere, but more appropriate examples that have now pervaded the language are await in general and IDisposable for ref struct. If it has a GetAwaiter it can be awaited, with no interface. If it has a Dispose() it can be disposed with no interface.
Re:Are dynamic languages going to replace static languages? ... by mgdlbp on Wednesday August 04, 2021 @11:17AM (#28061996)
Interestingly, this sort of structural typing was already present in C# 1.0 with the foreach statement allowing anything with a GetEnumerator() method that returns something that looks like an IEnumerator.

This was discussed in 2011 in a StackOverflow question [0], including a link to a blog post by one of the language designers [1].

[0] https://stackoverflow.com/questions/6368967/duck-typing-in-t...

[1] https://web.archive.org/web/20120126033827/http://blogs.msdn...

Re:Are dynamic languages going to replace static languages? ... by UglyToad on Wednesday August 04, 2021 @08:41AM (#28060311)
As far as I understand it it went to wherever there are still poor souls writing COM Interop stuff primarily. Luckily I've never had to touch it so outside of Dapper for SQL I've never really had cause to use dynamic. I imagine there are Windows shops using it heavily though.
Re:Are dynamic languages going to replace static languages? ... by Zababa on Wednesday August 04, 2021 @04:08AM (#28058511)
> If it has a GetAwaiter it can be awaited, with no interface. If it has a Dispose() it can be disposed with no interface.

I don't know much about C# but how is this dynamic? Are those methods often added at runtime?

Re:Are dynamic languages going to replace static languages? ... by useerup on Wednesday August 04, 2021 @04:57AM (#28058783)
It's not dynamic. It is structural typing
Re:Are dynamic languages going to replace static languages? ... by eloisius on Wednesday August 04, 2021 @02:18AM (#28057796)
Rust’s traits come to mind. If it quacks like an Iterable it’s an Interable
Re:Are dynamic languages going to replace static languages? ... by setr on Wednesday August 04, 2021 @02:34AM (#28057908)
Rust traits have the opposite behavior. If it says it’s an iterable, it must quack like an iterable.

Something that quacks like an iterable cannot be used as an iterable, unless the trait is explicitly stated — unlike python, where it simply has to quack.

Re:Are dynamic languages going to replace static languages? ... by yxhuvud on Wednesday August 04, 2021 @03:37AM (#28058335)
Crystal would be a better example of a statically compiled language with duck typing.
Re:Are dynamic languages going to replace static languages? ... by NtrllyIntrstd on Wednesday August 04, 2021 @02:24AM (#28057841)
Typeclasses/traits are not duck typing. A type statically needs to implement an abstract data type (with its methods and invariants). This is more of a categorization/composition effort.
Re:Are dynamic languages going to replace static languages? ... by benrbray on Wednesday August 04, 2021 @04:57AM (#28058786)
afaik Rust traits were directly inspired by the typeclass system in Haskell, which came about as a type-safe way to do the kind of ad-hoc polymorphism that you can do with interfaces in object-oriented languages like Java. Here's [1] a good talk by SPJ:

[1] https://channel9.msdn.com/posts/MDCC-TechTalk-Classes-Jim-bu...

Re:Are dynamic languages going to replace static languages? ... by zozbot234 on Wednesday August 04, 2021 @02:23AM (#28057838)
On the contrary, the point of type classes/traits is to provide a type-based alternative to simple overloading.
Re:Are dynamic languages going to replace static languages? ... by shadowfox on Wednesday August 04, 2021 @02:24AM (#28057840)
What feature of rust traits make them "dynamic" as opposed to the traditional notion of typed interfaces? The latter had been part of static languages for quite a while.
Re:Are dynamic languages going to replace static languages? ... by eloisius on Wednesday August 04, 2021 @03:05AM (#28058111)
I'm probably way in over my head with making a good case for how this resembles dynamic languages, but what I had in mind was trait objects. You can box a struct and refer to it as a trait object (aka type erasure). Thereafter, the receiver doesn't care _what_ concrete implementation it gets, just that it implements a certain trait.
Re:Are dynamic languages going to replace static languages? ... by 4ad on Wednesday August 04, 2021 @05:06AM (#28058825)
What you describe are existential types, a feature that every statically-typed language with parametric polymorphism has, either through some explicit syntactic feature (Rust traits, Haskell type classes, ML modules), or even without, as from basic logic and the Curry–Howard correspondence you can always encode an existential using universals.

         ∃a.P(a)
    ----------------- Remove-Exist
    ∀b.(∀a. P(a)→b)→b
Some static languages had existentials even before they got parametric polymorphism (Go interfaces). This is why we could do so much in Go without generics!
Re:Are dynamic languages going to replace static languages? ... by lmm on Wednesday August 04, 2021 @03:28AM (#28058266)
Yeah that's traditional subtyping, not a dynamic language thing at all.
Re:Are dynamic languages going to replace static languages? ... by 4ad on Wednesday August 04, 2021 @05:08AM (#28058837)
Rust traits are not subtyping, Rust's type system is principal (although with subtyping you could achieve the same thing as described by the OP, e.g. in C++, C#, etc, which only have subtyping but no existentials exposed as a syntactic feature).
Re:Are dynamic languages going to replace static languages? ... by lmm on Wednesday August 04, 2021 @09:12PM (#28068546)
The only reason trait objects aren't subtyping is that impl trait is not a first class type in Rust. They behave like subtyping in this context.
Re:Are dynamic languages going to replace static languages? ... by monocasa on Wednesday August 04, 2021 @03:15AM (#28058187)
Not really traits per se, but std::any::Any is implemented by most Rust types and is pretty dynamic.
Re:Are dynamic languages going to replace static languages? ... by NtrllyIntrstd on Wednesday August 04, 2021 @02:41AM (#28057952)
Ever heard of &dyn traits?

(that's a joke)

Re:Are dynamic languages going to replace static languages? ... by 4ad on Wednesday August 04, 2021 @05:00AM (#28058797)
Rust's traits are a copy of Haskell's type classes. They are as far removed from dynamically-typed languages as you can get.
Re:Are dynamic languages going to replace static languages? ... by iovrthoughtthis on Wednesday August 04, 2021 @03:53AM (#28058424)
dialectics strikes again!