4
Nevoic
7y

Why do you (if you do) prefer dynamic languages? I.E Python, Ruby, JS over Kotlin, Swift, and Haskell? (I know why people don't like Java, I purposefully omitted that).

Comments
  • 0
    Tool for the job, i use python for small backends and java for big or distributed ones.
  • 0
    @Charon92 I've heard this argument before, but this is what you described in Kotlin:

    val doc = Jsoup.connect("http://article.com").get()

    val elements = doc.select("#title-article")

    val titles = elements.map { it.attr("title") }

    I've done similar things in Python, and it's not any longer in (good) statically typed languages.

    I know Python is shorter than Java, and that's why I omitted Java from this, newer statically typed languages are just as concise.
  • 0
    I don't believe conciseness to be an advantage of dynamically typed languages. I actually find them to be more verbose at times because when you need safe type annotations, it's like a whole thing to check the type and verify it without throwing a runtime error.

    In statically typed languages, you're always safe (implicitly), and you can explicitly define type annotations for better documentation and compile-time safety.
  • 1
    @Charon92 there are a lot of reasons.
    1. The safety that comes in having a compiler. Even with type inference, code can look literally *identical* (compare Ruby vs Crystal) but one (Crystal) verifies that the calls you make actually work, and the other (Ruby) waits until you're running your app to throw an error (meaning a lot of errors that would be caught by the compiler instead get caught by the consumer. That's not good)

    2. The self-documentation in statically typed methods. They have compile checked return types (even if there is no return type explicitly declared) and well defined parameters) I've spent literally minutes following call stacks of code to figure out what type something is in a dynamic language.
  • 0
    I.E is a user an Elastic search user, an AR user, a mongodb user, etc. You don't know until someone uses it (so if it's just being passed through methods you can't know until someone calls it, and even then it's defined by a small interface and might be used by something else that requires another method)
  • 0
    The inherent concept of not having well defined types and trusting the developers to not do something crazy is just not something that's ever worked out for me in my professional career.

    I've been in a situation where a method took an object, user, and so when unit testing, I mocked a user and passed it in.
    It failed because of some nested call stack thing. I was like okay, this must not be a User, it must be some other kind of user we have.

    So I went into debugging on our server (had to literally start up a server to get a working version of this running) and put binding.pry in and checked the type.

    It returned User.

    It turns out we had another kind of user, but we masked the type and had it return user because we thought it would always work.

    It didn't always work.

    It's 30 minute long tangents like that, that can be fixed by one word, that absolutely destroy dynamic languages for me.
  • 0
    @Charon92 Kotlin is definitely my favorite. Kotlin has a 1:1 relationship with Java (all Java and Kotlin code turns into the same code at the JVM).

    Meaning you can use all the resources available to Java developers, and use a modern language like Kotlin.

    Swift is very similar, just for iOS development.

    Haskell is a totally other world. Functional. I suggest you check it out, I'm still learning functional programming, but it has it's advantages.
  • 0
    @Charon92 a better version of C would just be Rust or C++ (I'd suggest the former).

    But more specifically what do you want to do? You can do scientific/math oriented things in newer statically typed OOP languages.
  • 0
    I used to prefer dynamically typed languages, but I've been using C++ for a while now and it's amazing...

    The only thing that I find frustrating is the non-auto casting of the same type to a different length (such as uint8_t to uint16_t)
  • 0
    @Charon92 the way I see these kinds of things is that the default go-to should be a nice statically typed language (for the reasons I stated above). It's definitely capable of doing the things you want to.

    That being said, I would consider the following in potential favor of something like Python or R:
    1. Libraries/frameworks that support your domain.
    2. Communities that specialize in your domain in said language forums.

    Pretty much if you can find really nice frameworks that accomplish a lot of the work that you want to get done, in Python or R and not Kotlin or C# or C++, then feel free to use said framework in said language.
  • 0
    @Charon92 no problem! There are some nice web frameworks out there for Kotlin/Java and obviously .NET stuff for C#, so you should have some luck there.
    Wish you all the best!
  • 0
Add Comment