Hacker News new | ask | show | jobs
by alpaca128 1966 days ago
> it's much easier to understand what's happening (=debug) in a dynamic language.

I would argue the opposite. It's easier to understand what's happening when you know at a glance what datatypes are involved, whether they're used by value or reference and how each case is handled. When I last worked with Python it was rather time consuming to fix bugs that crashed a script at some point after 10 minutes of processing, caused by code that would have thrown a clear compiler error in some languages and would have been fixed in seconds.

And when I look at e.g. a Rust function signature I immediately see what kind of data is used as arguments and what's passed back in the result. Meanwhile in JavaScript you just need to forget a symbol in a check and suddenly it won't know the difference between "false", "null" and "undefined".

You are right about integrating third-party systems, but I still prefer the approach where possible issues are discovered as early as possible.

2 comments

You are bringing in Rust's amazing type system but that assumes that you understand how the 3rd party system behaves. Otherwise your types will be very loose (i.e. String ? could be anything in there) not gaining anything compared to Javascript/Ruby/Python.

If I know how the external system will behave then yes Rust is better, obviously. However I was talking on the case of figuring out, as the article says. Sometimes you are not even there, you integrate with an external (legacy? undocumented? buggy?) system and you need to understand what's going on. In these cases a dynamic language is so much more productive than Rust and any Rust-like language.

> whether they're used by value or reference

Or even better, if both is the same. That's the reason why, as much as I like Rust, I would never use it for a project where performance is not critical.

> Or even better, if both is the same.

That makes it just less transparent. You still have to be careful and know the difference or one day you unintentionally create a shallow copy of an object and now you've got a bug the runtime won't warn about. Yes, Rust is more complicated and harder to get into in those areas, but in return it's not as ambiguous. I know that calling `clone()` will always do just that, no edge cases, and even if I were wrong the compiler would immediately tell me because of a type mismatch.

Realistically I don't think any of the two approaches is significantly faster. But I know what I find more consistent and less frustrating to debug.

You are talking from the perspective of Rust. And you are right that in Rust, it cannot/should not be the same!

However, if you forget about Rust specifics, then things look different. E.g. by simply having the constraint of complete immutability, there is no reason to differ between an object identity and its deep content anymore - it will just be always the same. Of course that means no mutation and hence reduced performance for certain things, which is why Rust doesn't do it.

Rust is absolutely amazing and made me a much better programmer. But programmer ergonomics don't seem like a focus of their team currently.

I can only hope for Rust 202X edition that can introduce new syntax / deprecate another and make certain things clearer (even if that means explicit with a little writing here and there). Lifetimes and traits in particular need a lot of upfront investment to grok intuitively, and the fact that some core aspects of the language are implied can later hit your assumptions really hard and confuse you for a while. At least that's happened to me, maybe I am just dumb and mediocre though.

> But programmer ergonomics don't seem like a focus of their team currently.

Actually, maybe my post gave a wrong vibe. I like Rust and I think the team put a lot of effort into programmer ergonomics.

It's just that the language is focused on performance a lot and compete with C++. And so they sometimes make tradeoffs in favor of performance instead of expressiveness or simplicity.

That is understandable - but 95% of the projects I(!) have worked on don't need this - I can just give it a GB more RAM and a bit more CPU and write software quicker because I don't have to care about certain details.

> At least that's happened to me, maybe I am just dumb and mediocre though.

The fact that you used Rust probably puts you in the upper 10% - rough gestimation. I'm not telling you which 10% though. :P

> It's just that the language is focused on performance a lot and compete with C++. And so they sometimes make tradeoffs in favor of performance instead of expressiveness or simplicity.

Yep, exactly my feeling. When I get back to writing Elixir at my $day_job I am just blown away how I can achieve most of the same results (for 100X less performance of course) in like 20x less coding lines... :( Not a direct comparison with a dynamic language is possible of course, but I too wish the Rust team starts sacrificing something for a bit more expresiveness and code conciseness.

> That is understandable - but 95% of the projects I(!) have worked on don't need this - I can just give it a GB more RAM and a bit more CPU and write software quicker because I don't have to care about certain details.

Both what you describe and hand-crafted and ruthlessly tested C/C++ code that's maximally efficient have their place. But I definitely don't belong the the "machine efficiency at all costs" tribe and I get worried at any potential signal that Rust is headed in that direction. Which it might not be. We'll see.

> The fact that you used Rust probably puts you in the upper 10% - rough gestimation. I'm not telling you which 10% though. :P

<Saruman voice> YOU HAVE NO POWER HERE!

...I mean, I am myself's worst critic. It took me a while to get comfortable with Rust and even if that means I am a below-average programmer, I don't care. I am taking my time and I can objectively measure that I am getting better with time there.

I still do agree that Rust does require time and persistence however. That is irrevocably true. Here's to hoping the team will make it consume a bit less characters (and thus typing) and improve the compiler and the tooling further. I am rooting for them with all my heart.

> I get worried at any potential signal that Rust is headed in that direction. Which it might not be.

I think they do - but that's good! We need a language like Rust to write operation systems, databases, proxys, webservers, hey maybe even browsers. All the things that are widely used and need to be high performant and secure.

Maybe you are using Rust, but you actually really want a different language, one that doesn't focus so much on low level / performance?

Haskell or Scala or F# come to my mind. I'm listing statically typed languages, because I assume you like those (otherwise, why Rust and not sticking to Elixir).

> Maybe you are using Rust, but you actually really want a different language, one that doesn't focus so much on low level / performance?

That is very possible. But utilizing my experience and intuition, very rarely have I seen such meticulous and relentless pursuit for efficiency and a compiler that will kill most of your bugs after it successfully compiles your program like Rust. Maybe Haskell and OCaml are it as well but they have plethora of problems that Rust doesn't have. Maybe Nim and Zig? Only heard good things about those but never tried them.

> Haskell or Scala or F# come to my mind. I'm listing statically typed languages, because I assume you like those (otherwise, why Rust and not sticking to Elixir).

Personal / professional development. I started with C/C++ and Java 19 years ago and moved to dynamic languages at least 12 years ago and I felt that I want to have such a powerful language like Rust in my toolbelt again.