24

Code snippets without dependencies ❤️

Comments
  • 0
    Implies that either
    The snippet is tiny
    The problem happens to involve only very lightly composed types
    The STL for the particular language happens to define the types the snippet relies on
    The snippet has type definitions embedded which the user is expected to move into the correct structure such that they're easily searchable
    The snippet is unsafe
  • 1
    @lbfalvy nah that really just implies carelessness
  • 1
    @lbfalvy The snippet was made in PHP
  • 0
    @lbfalvy you are clearly traumatized by C/C++ 😄
  • 0
    @Lensflare No, I prefer safe languages. Languages that allow you to pass a string into a function that was written with the expectation of an integer aren't safe. Languages that don't even have the tools to deallocate memory in a safe way aren't safe. C++ is safe but it has shit like the 0/3/5 rule to demonstrate that it's not even close to convenient, and the headers which are supposed to be the public interface of a source file (which is a brilliant idea by the way) have to include private members for low level implementation reasons, thereby uprooting the whole wonderful model of implementation hiding.
  • 1
    @lbfalvy I know and I hate unsafe shit like JS, too. But there are languages out there that are safe AND a joy to use (Swift, Kotlin). You don’t have to sacrifice anything to get the same safety and strictness as C++ has. You get even more safety and more performance at the same time.
    And you also get an awesome standard lib so that code snippets can be self contained and concise.

    I’m telling you because you are apparently struggling with the flaws of C++ but you like the strengths of it.
  • 1
    @Lensflare I've heard Swift is a platform language but Kotlin has been on my to-learn list for a really long time. I'm currently mainly using Typescript.
  • 1
    @lbfalvy Swift is mainly used for Apple platforms but it’s also available for Linux and Windows.
    If you are used to typescript, you should feel right at home with Swift and Kotlin.

    Just a little comparison: Both are very similar.

    Kotlin is garbage collected (due to JVM) where Swift has Automatic Reference Counting. Which makes Swift as fast and deterministic as C++ in terms of memory management, but a lot safer because it’s done by the compiler that doesn’t make mistakes like humans do.

    Kotlin doesn’t have value types (again due to JVM). Swift not only does have value types, but it’s also using them very extensively in the standard lib. Like all standard types and collections are value types. You don’t need to worry about performance though, because of Copy On Write semantics.

    Kotlin has absolutely awesome class initialization syntax which Swift is lacking.
  • 0
    @Lensflare Kotlin also has KotlinNative that doesn't run on JVM and can even compile for iOS although Apple might not officially approve publishing of such binaries because... Apple
  • 0
    @LordPeeve ok but the fact that Kotlin needs to be compatible with JVM prevents it from having value types, unfortunately. Not 100% sure about that, though.
Add Comment