| ▲ | mabster 5 days ago |
| With dynamically typed languages I feel it's better to wait until you've tried to maintain the code for a while before you consider the languages effectiveness. I had to maintain a very large Lua codebase that has been active for several years. One big problem with Lua was how it will happily take more or less parameters to functions and continue to execute compared to something like Python where it is an error to pass the wrong parameters. This meant when we update a function signature we would often incorrectly update call sites, etc. I can't remember the specifics but we had a few issues with tables being both dictionaries and lists. IIRC, if you delete a list index and there are later list indices, they will turn into dictionary keys. We had a few bugs to do with not traversing the entire array portion of a Lua table because of this. I also implemented a few classic algorithms, e.g. bisect in Lua and you have to be very careful with 1-based indices. You also have to be very careful when interfacing between C and Lua. I prefer 0-based indices and [start, stop) style ranges for everything nowadays. I much prefer statically typed code during maintenance. But dynamically typed languages like Python or Typescript where you can bolt on types, later if you wish, are not too bad. Also using named parameters as much as possible is great for maintenance. |
|
| ▲ | aomix 4 days ago | parent | next [-] |
| I saw someone describe python as “stressful” for this reason and I couldn’t agree more. It’s difficult to have confidence in any change I make or review. I need to sit down and manually exercise codepaths because I don’t get the guarantees I crave from the language or tooling. While with the small amount of Rust code I’ve written lately I could yolo changes into production with no stress. |
| |
| ▲ | pnathan 4 days ago | parent | next [-] | | Agreed. I had to work in a larger Python codebase after spending a few years with Go and Rust and the drop in logical confidence around the language was remarkable. I have, roughly, sworn off dynamic languages at this point. Although I have dreams of implementing a firm typed system over Common Lisp. | | |
| ▲ | shermantanktop 4 days ago | parent | next [-] | | Same, though my trauma was Ruby. Those Rubyists who were apparently born with the language spec in their heads can do amazing things, but I am a mere mortal who needs to be told I wrote bad code right when I wrote it, not told at 2am on a production server. | | |
| ▲ | stinkbutt 4 days ago | parent [-] | | do you not test your code? | | |
| ▲ | pavel_lishin 4 days ago | parent [-] | | In a large enough code base, there is no "your code". There is the code you wrote today, there is the code you wrote two years ago, there's all the code people are writing around you. I change a function's arguments, I'm _pretty_ sure I caught every place it's called (spoiler alert: I didn't, because someone calls functions dynamically based on their names with call_user_func_array, maybe), and I ran the test suite - everything works, and I've fixed what doesn't. Except some of that old code written 8 years ago didn't have good tests, or didn't have any tests at all, or didn't cover the specific code path. And now it's 2am on the production server. Now, you could tell me - Pavel, you're an engineer, you should be sufficiently dedicated to your craft to verify that the tests are testing those paths, you should find all those instances where that function is called (a few dozen times across the codebase), and check that those tests exist and are good. And you're not wrong! I should be doing cleanup in the codebase as I go, washing those dishes while I wait for pasta to boil or whatever... ... but now I've given myself two more actual engineer-weeks of work for a change that just needed to add a flag to a function to make sure only premium users get emails when something happens. My manager will be thrilled to hear it. Do you think I'll get a raise? |
|
| |
| ▲ | felipeccastro 4 days ago | parent | prev | next [-] | | I’m assuming that Python code base didn’t have thorough type hints. What if it had? Would Go still feel safer? I know these aren’t checked in runtime, but Python type system seems more thorough than Go’s, so shouldn’t a Python code base fully typed be even safer than Go? If so, why not? (I know Python type checks aren’t mandatory, but for this question assume that the type checker is running in CI) | | |
| ▲ | pnathan 6 hours ago | parent | next [-] | | Since Python type checking is functionally optional, it implies that somewhere, somehow, someone has opted out, or has used a type checker that differs subtly but unpleasantly from the one you're using. Python's type checker systems are fundamentally a _linter_ more than something like Java or C...or Rust. It's not about feeling. It's about the theorems you can make about the codebase. With Python the answer actually is ¯\_(ツ)_/¯. | |
| ▲ | Mawr 4 days ago | parent | prev | next [-] | | You're hand-waving the insane amount of effort that would be required to type every bit of Python code that gets executed. You get that by default in statically typed languages. Even then, you're reliant on the correctness of a 3rd party tool vs a 1st party compiler. It's never going to be as good of an experience. | |
| ▲ | misiek08 4 days ago | parent | prev [-] | | You mean compiler vs client reporting issues? Never safer. | | |
| ▲ | felipeccastro 4 days ago | parent [-] | | Yes, but in practice, is the difference significant enough to matter? I’m genuinely looking to see if I’m missing anything when favoring Python type system over Go’s. | | |
| ▲ | pansa2 4 days ago | parent | next [-] | | One difference is that Python's type system is unsound. You can write code that passes `mypy --strict` but still contains functions that, for example, claim to return an `int` but actually return a `list` [0]. AFAIK it's not possible to circumvent Go's type system in such a way. [0] https://news.ycombinator.com/item?id=43508152 | | |
| ▲ | kbolino 3 days ago | parent [-] | | The biggest limitation of Go's static type system vs. Python's type hints system that I can think of would be the lack of union types, with nullability a close second (and it's just a specialized application of union types in Python). An interface in Go can be anything under the hood, though you at least know that, whatever its concrete type, it does implement the methods exactly as defined. You can definitely circumvent Go's type system with unsafe operations (with FFI also recognized as inherently unsafe) but that's a clear boundary that you know you're crossing (albeit not quite as clear as e.g. in Rust). |
| |
| ▲ | pdimitar 3 days ago | parent | prev [-] | | It matters the most in practice, actually. Much less production all-hands-on-deck situations. The fact that there still exist people to whom this is not painfully obvious is despairing me. |
|
|
| |
| ▲ | -__---____-ZXyw 4 days ago | parent | prev | next [-] | | Firm like: https://coalton-lang.github.io/20211010-introducing-coalton/
?
| | |
| ▲ | pnathan 6 hours ago | parent [-] | | I need to spend some quality time with Coalton. I don't think it's _quite_ what I want, but its in the same key. |
| |
| ▲ | 4 days ago | parent | prev [-] | | [deleted] |
| |
| ▲ | jlarocco 4 days ago | parent | prev | next [-] | | > I need to sit down and manually exercise codepaths Isn't that exactly what unit tests are for? | | |
| ▲ | pansa2 4 days ago | parent | next [-] | | Yeah, that's a common argument for dynamic typing. You're writing tests anyway (right?), and those will catch type errors and many other kinds of error. Why bother with a separate level of checking just for type errors? I personally believe it's a valid argument (others will disagree). IMO the main benefit of static types isn't for correctness (nor performance) - it's to force programmers to write a minimal level of documentation, and to support IDE features such as autocomplete and red underlines. Hence the popularity of Python type hints and TypeScript, which provide these features but don't fully prove correctness nor provide any performance benefit. | | | |
| ▲ | mkehrt 4 days ago | parent | prev | next [-] | | Fortunately my compiler writes a large number of unit tests for me, that run at compile time! I call it the "typechecker". | |
| ▲ | airstrike 4 days ago | parent | prev [-] | | Except now you're writing and maintaining twice the amount of code instead of relying on the compiler and/or type checker to help you catch those errors | | |
| ▲ | jlarocco 4 days ago | parent [-] | | Sorry, but I don't agree that static typing is a replacement for unit tests. I can see static languages having fewer unit tests, but it's not going to eliminate them. | | |
| ▲ | alternatex 4 days ago | parent | next [-] | | Static typing is a replacement for unit tests aimed to catch type bugs. Also, no one has 100% code coverage so might as we get some guarantees for granted. I understand that statically typed code doesn't mean bug-less code, but I always find it odd that dynamic language enthusiasts feel like they need to stretch the benefits. Dynamic languages are great for many things. Strictness is not one of them and that's fine. | | |
| ▲ | esafak 4 days ago | parent [-] | | It's obviously not a replacement. You can get the types right but the values wrong due to faulty logic. | | |
| ▲ | MrJohz 4 days ago | parent [-] | | Sure, but only some of the unit tests are about values. Others, at least in my experience, are any handing various aspects of the implied types of values, and those can largely be removed. Moreover, a good type system can also force the values to be right by enforcing certain invariants directly in the type system. For example, let's say I have a function `deleteProjectAs(user, project)` that deletes a project, but it only works if the user is an admin, otherwise it throws an error. I can write a bunch of tests that validate that this function checks that the user is an admin in all sorts of different cases, but with a type system I can write something like `deleteProjectAsUser(user: Admin, project: Project)`, and this guarantees at the type level that no non-Admin user can delete a project. The point here is not that types can replace all tests, but that well-designed types can get rid of a lot of them. | | |
| ▲ | esafak 4 days ago | parent [-] | | I agree. My post was unnecessary; I did not realize the response was talking specifically about type bugs. |
|
|
| |
| ▲ | pdimitar 3 days ago | parent | prev [-] | | You're tearing down a straw man. Your parent poster did not say it eliminates tests. He said static typing mean less tests. He didn't say static typing is a replacement for tests either. Why are you doing double misrepresentation? More honest discussion tactics, please. |
|
|
| |
| ▲ | je42 4 days ago | parent | prev | next [-] | | When using dynamic languages, either minimize code dependencies / function calls and complexity or ensure high test coverage. | |
| ▲ | d0mine 4 days ago | parent | prev | next [-] | | Do you believe that Rust's type system is as flexible, powerful, and easy to maintain as unit tests in Python? | | |
| ▲ | MrJohz 4 days ago | parent | next [-] | | One of the big advantages of Rust's type system is that, if you decide you want to change something (add a parameter, give a type a lifetime, rewrite an entire module), you can just do that, and then follow the errors until they're all gone. Often, once the types have been fixed again, the result will work first time when you try and run it. In this regard, Rust (and other languages where lots of data invariants can be encoded in the type system) is very flexible and easy to maintain indeed, because you can easily make changes, even in very old or poorly-maintained code, without having to worry about the consequences. Moreover, rather than writing all the unit tests yourself, it's as if the compiler is writing the unit tests for you. In fairness, you can't encode everything in the type system, so you still need unit tests in top of that, but in my experience you can get away with far fewer. In general, I would say that Rust's type system, when combined with unit tests, is far more flexible, powerful, and easy to maintain than dynamic Python with only unit tests. | |
| ▲ | 12_throw_away 4 days ago | parent | prev | next [-] | | I write and test a lot of both rust and python, so I can say quite confidently: 1. Of course a type system is not as "flexible" as arbitrary test code. 2. Compiler-enforced type safety is many orders of magnitude easier to maintain than the equivalent unit tests 3. Defining rigorously enforced invariants with a type system is far, far more powerful than hoping you remembered to test all the important cases. | | |
| ▲ | d0mine 3 days ago | parent [-] | | Your 2-3 points remind me of the quote by Ludwig Wittgenstein: “The limits of my language means the limits of my world.” Of course if you limit yourself only to problems that can be effectively solved by type system, then it may work. It is like limiting yourself only to those text processing tasks where regexs work. Yes, some text processing tasks may be much more effectively solved using a regex. But it is obvious that at some point in a more general case grep can’t replace python. It may be less apparent for compiler vs. python case but the general logic is the same. | | |
| ▲ | 12_throw_away 3 days ago | parent | next [-] | | So you asked a question, didn't like the answer, and decided to just start insulting people instead? | | |
| ▲ | d0mine 2 days ago | parent [-] | | No disrespect intended. I’m making purely technical point. |
| |
| ▲ | pdimitar 3 days ago | parent | prev [-] | | Nobody is "limiting" themselves to anything. That's not a counterargument you're making. We all deploy to production, dude. Strong static typing (Rust), even only dynamic strong typing + pattern matching (Elixir), are leagues better than Python. Literal 3x - 7x less code and less production errors both in Elixir and Rust, over the course of 5 years. You're the one limiting yourself. Expand your horizons. |
|
| |
| ▲ | airstrike 4 days ago | parent | prev [-] | | No, it's more flexible, more powerful, and easier to maintain than unit tests in Python. |
| |
| ▲ | bormaj 4 days ago | parent | prev [-] | | If using python with type annotations, linters like ruff and mypy do a great job at identifying issues. It's no substitute for tests and nor will it give you the same guarantees that rust will at compile time. But I think it improves the base quality of the code. | | |
| ▲ | mabster 4 days ago | parent [-] | | The thing I find annoying with MyPt is trying to tell it I'm doing variable shadowing. E.g. X is a list of strings
Translate X to a list of indices
Translate X back to a list of strings. In that paragraph the input and output types are the same, but not complains about the second line. I always have to introduce a variable with a new name. | | |
| ▲ | bormaj 4 days ago | parent [-] | | Yeah I see what you mean, you can always disable specific features, but I think that's a habit mypy tries to enforce. They consider redefining a variable bad practice. Even in rust you have to be explicit about doing the same thing with an extra "let" statement. | | |
| ▲ | mabster 4 days ago | parent [-] | | Yeah that's fair enough, and I've lived with it because of how good MyPy is. But I always end with weird variable names like uuids_as_list as a result! |
|
|
|
|
|
| ▲ | kgeist 4 days ago | parent | prev | next [-] |
| >This meant when we update a function signature we would often incorrectly update call sites, etc. The same thing happened with our huge legacy PHP monolith, which was written before type hints were a thing. Developers were reluctant to refactor large chunks of code when the time came, because it was just too easy to introduce bugs - you couldn’t be confident about anything without manually digging through tons of code. So, when business requirements changed, they’d just bolt on some hacks to avoid touching the existing, tested code, and call it a day. It became a self-reinforcing loop: fear of refactoring → more hacks to avoid refactoring → more brittle code → even more fear of refactoring. Eventually, they added type hints and a linter to analyze them, but by that point you start to wonder - why are we even using a dynamic language and fighting its quirks? |
| |
| ▲ | shermantanktop 4 days ago | parent | next [-] | | This is something I watch out for: teams which fear their own code and operate defensively, typically with cargo-cult practices that accumulate even though they themselves aren’t well understood. | |
| ▲ | mabster 4 days ago | parent | prev | next [-] | | When I started, the culture was already engineered to prevent this reluctance. You would hear "the code is fragile, it's going to break. Noone will shout at you for that." This was great. But I would prefer to just not have to "run in eggshells" haha! | |
| ▲ | z3t4 4 days ago | parent | prev [-] | | It can be solved with static analysis and type inference. Inference can be tricky though, as you have to backtrack and figure out what type of values functions return etc, so type hints/annotations make the job easier for the IDE/tooling developer, but they are not necessary! |
|
|
| ▲ | arp242 5 days ago | parent | prev | next [-] |
| > With dynamically typed languages I feel it's better to wait until you've tried to maintain the code for a while before you consider the languages effectiveness. True for any language really. There's an entire category of blog posts: "I used language X for 2 weeks and here's my hot take". Okay, great. But what do you really know? For every language I've used for a serious amount of time I've changed opinion over time. Some things that seemed like neat ideas at the start turned out to be not so neat ideas down the line. Or things I considered pointless or even stupid at the start turned out to be very useful once I better understood the nuances and/or got used to working with it. And of course it's double hard to judge will come back to haunt you a year down the line. Even as an experienced programmer I find it hard to properly judge any of that from just a few weeks. |
| |
| ▲ | mabster 5 days ago | parent | next [-] | | To extend on this: There was always this implied impression that the original developers were hot because they got stuff up and running really quickly and that all the newer developers were lukewarm because they weren't getting stuff happening quickly at all, all as a result of the original language choice! | |
| ▲ | szundi 5 days ago | parent | prev [-] | | This is what makes Java underrated these years. Some annoying stuff pays off over a decade several times. You can make insane complexity with ease. | | |
| ▲ | ecshafer 4 days ago | parent | next [-] | | Java is a great language, and the JVM a great platform. I think that the thing which makes Java underrated isn't the language, but rather Java Developers. There are tons of great Java developers, but they are probably great developers in any language. But Java being the language of choice at so many enterprises results in a large number of very low skilled and inadequate Java programmers, who would be bad developers in any language, but specialize in Java. | | |
| ▲ | kmbfjr 4 days ago | parent [-] | | The JVM is awful. In 2025, it still arm wrestles with the OS on which it runs for memory management and still completely loses its shit should the OS decide to send any portion of its precious memory allocation to swap. The language, is beautiful. | | |
| |
| ▲ | mabster 4 days ago | parent | prev [-] | | I have mixed feelings about Java. It's a solid feature set, and I really love how InterruptedException was always a thing, so you can generally terminate a thread and it works (a lot of languages don't do this right). I love checked exceptions. But the spooky action at a distance type annotation hell, needing builders everywhere because of lack of named parameters, poorly conceived generics, nullability not being first class, lambdas being incompatible with checked exceptions, etc. are a pain. |
|
|
|
| ▲ | packetlost 4 days ago | parent | prev | next [-] |
| One of my coworkers described Python (specifically in reference to a niche framework, but I think it applies generally) as "a bucket of play-doh filled with broken glass" |
| |
|
| ▲ | jhatemyjob 4 days ago | parent | prev | next [-] |
| I understand your frustrations since you are forced to work within a codebase that is shared with other developers with varying levels of experience. Lua was from the get-go never supposed to be a standalone language, it is more of a complimentary language and if you fail to respect that then it becomes unwieldy, quick. It is extremely easy to shoot yourself in the foot with the language and once bad design decisions creep in it is hurts a LOT. However once you get enough experience with the language you manage stay within the "happy path" (which is EXTREMELY difficult when you are on a team with salaried software engineers with different and often misaligned incentives) it is actually one of the best languages available. One of the things I suspect your team is doing wrong is you are using the PUC Lua C API instead of the LuaJIT FFI. That is one of those things which just completely destroys the "happy path". The PUC Lua C api is effectively a deprecated feature at this point. A few years ago you could have made the argument that the PUC Lua C API is more portable than LuaJIT which is absolutely true. But q66's (from Chimera Linux fame) cffi-lua project nullifies that argument since you can now use the luajit-style FFI in PUC Lua, which works on every platform that libffi supports. Again I understand your frustrations with the language since you are working within a fundamentally adversarial environment. Perverse incentives can easily destroy any good patterns you can establish since the language is so flexible. I implore you to explore the language outside of your day job. |
| |
| ▲ | mabster 4 days ago | parent [-] | | We were using Luajit with our own extensions with our own binding mechanisms that included automatic translation of indices. And we had A LOT of bindings. There was some "fun" there. Luajit C functions uses space indentation that becomes tabs every 8 spaces, i.e. mixed tabs and spaces. And his custom assembler for the assembly portions. I personally spent a lot of time "refactoring code to generate less garbage" as we had purposeful garbage collection in our idle time. One of the advantages with Lua was that everyone could code in it. I.e. for our games all the artists, sound engineers and producers were developing Lua which was super productive. But the function signature one in particular - that would have saved me a lot of stress on release nights! | | |
| ▲ | jhatemyjob 3 days ago | parent [-] | | Oh wow you were editing the source of LuaJIT? That sounds like a nightmare. I'm pretty sure Mike Pall is the only person who understands that codebase lol. To be honest I am trying to move away from LuaJIT, now that q66's cffi-lua project exists I don't have a reason to use LuaJIT from a dev productivity perspective. For speed, sure. But for my use-case regular Lua is fast enough and the added features in 5.4 over 5.1 are really nice. Plus having the option to easily edit the Lua source code if I want gives me a lot of comfort, since the codebase is way simpler than LuaJIT's. I have removed LuaJIT from everything I use other than OpenResty. If I could, I would remove it from OpenResty but that is a huge undertaking Yeah the garbage collector is one of the things in Lua I really don't like - in Lua 5.4 Roberto added the <close> thing and generational GC but I'm not sure how well these work in practice. I guess I'm lucky enough in that I have never hit the upper limit where a GC cycle totally kills performance and if that ever happens I have the option of rewriting that code in C |
|
|
|
| ▲ | TinkersW 4 days ago | parent | prev | next [-] |
| Yeah I had a pretty high opinion of Lua when I first used it, then I came back to code I'd written years earlier, and the lack of types just made it a nightmare. It really could use a fully statically typed layer that compiles down to Lua, and also fixes some of the stupid stuff such as 1 based indexing and lack of increment ops etc. |
| |
|
| ▲ | TJSomething 4 days ago | parent | prev | next [-] |
| I think that much of game development is unlike a lot of other kinds of programming, where there's often more ad hoc game mechanic prototyping than maintenance. This is where dynamic programming excels. But of course, that consideration needs to be balanced against others. |
| |
|
| ▲ | drysine 4 days ago | parent | prev | next [-] |
| >when interfacing between C and Lua Except for the indexing mismatch, I've found calling Lua from C and vise-verse very easy. |
|
| ▲ | kristopolous 5 days ago | parent | prev | next [-] |
| you might like this one: https://github.com/ast-grep/ast-grep ... it sounds like you'd get some mileage out of it. |
|
| ▲ | teamonkey 4 days ago | parent | prev | next [-] |
| They mention Luau near the end, and my opinion is that Luau is a significant improvement. Mainly because of the optional typing, but the other features too are each small but impactful quality of life improvements. |
|
| ▲ | nine_k 5 days ago | parent | prev [-] |
| > dynamically typed languages like Python or Typescript You likely mean JavaScript. Typescript is very much statically typed, unless you allow everything to be `any` and `unknown`. Typescript is mentioned in TFA as a desired (but not available) option, because of the great static typechecking support. |
| |
| ▲ | mabster 5 days ago | parent | next [-] | | I guess I mean both. In that you can take something dynamically typed and add type definitions to make it more typed over time. JavaScript would not be what I'm talking about without the existence of Typescript. | |
| ▲ | LoganDark 5 days ago | parent | prev [-] | | TypeScript is sort of "dynamically typed but statically verified". | | |
| ▲ | nine_k 5 days ago | parent [-] | | Much like C++ then — the machine code to which it translates lacks types! A TS compiler will reject an ill-typed program. You of course can just strip the type syntax and get a valid (though buggy) JavaScript code. | | |
| ▲ | LoganDark 5 days ago | parent [-] | | > Much like C++ then — the machine code to which it translates lacks types! Ehh, not exactly. Most C++ compilers won't output machine code for inputs they don't understand. Though of course, you could simply translate some C++ code yourself into machine code and then say C++ is just like TypeScript in that way. "If you turn C++ into machine code, the machine code lacks types!" "If you turn TypeScript into JavaScript, the JavaScript lacks types!" The main difference is the C++ compiler won't generate machine code for you if the code you provided it doesn't compile, but the TypeScript compiler essentially treats types as a lint (unless extended by compiler plugins such as `typescript-is`, which I greatly enjoyed back in the day). Also, CHERI begs to differ. And even other than that, machine code isn't dynamically typed because it's not typed at all. Usually, everything is data (usually even the machine code itself, except on Harvard architectures), aside from any architecture-specific memory protections (and other protections), if applicable. I could probably go on about this for days. > A TS compiler will reject an ill-typed program. You of course can just strip the type syntax and get a valid (though buggy) JavaScript code. Can't Deno execute TypeScript directly? Last I checked, it didn't do typechecking itself because [the size and complexity of tsc]. For what that's worth, cling also exists, so try tricking that into executing compiler errors. I don't think it would. | | |
| ▲ | nine_k 5 days ago | parent | next [-] | | > TypeScript compiler essentially treats types as a lint Sorry, I think you've been swindled. The Typescript compiler is made by Miscrosoft and is called tsc. It very much heeds the type annotations, and very much rejects ill-typed programs. An LSP based on it does the same in an editor. Also tsc supports refinement types via flow control analysis and a bunch of other static correctness checks. Deno, bun, swc are not true compilers like tsc, they don't do much correctness checking at all. They discard al the type info, and then operate on pure JS (modules conversion, minification, etc). | | |
| ▲ | debugnik 4 days ago | parent | next [-] | | > and very much rejects ill-typed programs No it doesn't. Even on the strictest settings, Typescript is unsound in trivial ways, which I hit every time I use it in anger (e.g. undefined in unassigned variables). And Microsoft libraries seem perfectly ok with asserting their type errors away without any validation, specially for JSON values. I had a similar experience with Python until I found Pydantic. I haven't had a chance to try Elixir's new type system (is it ready yet?), but at least their strong-arrow model would ensure that runtime checks for dynamically-typed values are done eventually. | | |
| ▲ | nine_k 4 days ago | parent | next [-] | | This is sadly so; TS's type system is unsound. But so is C#'s, in ways much more egregious that in TS. Despite that, both languages are very usable in practice, and their static checks prevent a very wide range of problems common in languages without a static type system. If you need bulletproof soundness and JS as the runtime, you have Purescript %) | | |
| ▲ | debugnik 4 days ago | parent [-] | | > in ways much more egregious that in TS Which ways you say? As far as I know: both TS and C# can carry hidden nulls; both made the mistake of covariant arrays, but C# actually type checks accesses at runtime; and the other unsound case I know of in C# involves a runtime type check as well. Meanwhile, TS (and Python) allow fully unchecked casts into the wrong type. > both languages are very usable in practice Agreed, but I still consider TS too unsound in trivial cases for the claim I replied to, despite its expressive power. I think this industry is lacking severely when it comes to basic software correctness. |
| |
| ▲ | pdimitar 2 days ago | parent | prev [-] | | > I haven't had a chance to try Elixir's new type system (is it ready yet?) Sadly no, and it will likely not be fully ready for years still. It's not a funded work and only a few people are working on it (AFAICT) and the core team understandably wants gradual movement and no incompatibilities. Elixir made me rediscover love for programming and gave me productivity I never dreamed of. But after using it for 9 years, the lack of static typing really started getting on my nerves. There are only so many times you can do manual exhaustive pattern-matching on the hot paths that yell errors in production before you start feeling envious of Rust and Haskell. |
| |
| ▲ | ZephyrBlu 4 days ago | parent | prev | next [-] | | You can lie to TypeScript extremely easily in a way that you can't do in strongly typed languages. | | |
| ▲ | colejohnson66 4 days ago | parent [-] | | Even in a strongly typed language like Java or C#, nothing stops `(string)(object)42`. It all compiles and fails at runtime, like TypeScript. No matter what language you’re in, the second you use a cast, you’re asserting to the compiler that you know more than it. |
| |
| ▲ | nurettin 4 days ago | parent | prev [-] | | I think they are confused by the tslint project, which is different than tsc and is not supported by Microsoft | | |
| |
| ▲ | mabster 5 days ago | parent | prev | next [-] | | I would argue that machine code is typed, but this will be up to interpretation. I.e. you can add two 32 but floating point numbers or two 16 bit integers or store an 8 bit value. It's just doesn't require you to purposefully type pun in some circumstances (e.g. where floating point and integer registers are shared). | | |
| ▲ | jerf 4 days ago | parent [-] | | A "typed" machine code would imply that you can say "Add these two 32-bit floating points" and the CPU will say "No, I can't, those are 4 8-bit unsigned integers". I don't believe the CPU will ever say that, so it is not typed by any sensible measure. Best you can do is that there may be some registers that can only be used by floating point units and others that can only be used by ints, but even that is really just hardware limitations for performance and not any sort of type assertion; the CPU will happily bit-slam them back and forth without anything like an "exception". |
| |
| ▲ | weinzierl 5 days ago | parent | prev [-] | | "And even other than that, machine code isn't dynamically typed because it's not typed at all." Well, we have bytes, words, doublewords and quadwords on the machine level. They are usually referred to as data types in the processor manuals. | | |
| ▲ | nine_k 4 days ago | parent [-] | | I'd say that instructions are typed, but data are not. You can use an integer arithmetic, bit manipulation, floating point arithmetic, or vector SSE instruction on the very same data in the very same register, and it will just work without any complaints for most bit patterns. A CPU of course does analyze the code, but only the short segment currently in the pipeline, and not for any high-level semantics, just for data dependencies and very local jumps. |
|
|
|
|
|