3 ms·
Writing language code idiomatically is a bit of the deal with any language. Trying to break a languages fu to be more like a language you’re more familiar with
by fnordpiglet 3y ago
Writing language code idiomatically is a bit of the deal with any language. Trying to break a languages fu to be more like a language you’re more familiar with is common when learning a new language, but blaming the language is a rookie mistake.
- Brian_K_White 3y agoWhat kind of mistake is thinking all legitimate tasks are equally doable in all legitimate languages? Or that there is any language that has no warts at all, and so any problems are automatically "holding it wrong"?
- pclmulqdq 3y agoI think people say this about languages that are very opinionated (like Rust and Go) not realizing that many other languages are a lot more forgiving of a non-idiomatic style. There are lots of good reasons to use a non-idiomatic style, one of which is mentioned here: there is an existing codebase that doesn't fit the language's idioms. Compared to Rust, C++ and Java will let you compile and run code in a lot of different styles, and it will work (albeit without the guardrails). Being permissive on this front is a language design choice, and while it is in vogue to make your language extremely opinionated to the point where you can't write non-idiomatic code that compiles, it does limit your language's applicable scope. This is such a problem that Google is currently working on their private "Carbon" language instead of switching to Rust (outside of a few areas). The OP isn't learning Rust the way you or I learned Rust. He is learning it in the context of someone who (1) doesn't want to, and (2) is doing it within a huge legacy codebase. That is a fundamentally different experience than someone who is excited about it and gets to start with a blank slate.
- fnordpiglet 3y agoMost languages have an idiomatic way of writing them, Java certainly does, Python, ruby, etc. C++ doesn’t simply because it’s a giant mess of hodge podge. Simply being able to compile something doesn’t mean you’re using the language idiomatically, and when you innovate your style off the idiomatic path sooner or later you’ll end up in a world of hurt with everyone you turn to for help telling you you did it wrong. You’ll have trouble finding collaborators, retaining talent, etc. Eventually you’ll rewrite as an idiomatic version. The fact languages have gotten tighter over time with their idiomatic style being verified up front is, IMO, a feature not a flaw. over the 40 or so years I’ve been programming I’ve come to appreciate more and more being able to learn the idiomatic way toll free when learning the language. I think rusts limitations are more to do with immaturity than opinionation - for instance lack of async closures, async traits, compile time reflection, generators, etc, are all point in time flaws that with time will make the language much easier to make expressive and flexible implantations. Yeah I get they’re not interested in learning Rust - but again that’s not rusts fault or a flaw, or in any way supportive of less opinionated languages. It’s a rookie mistake. When you’ve only learned one or two languages learning a new one is a chore and disheartening and it’s always someone else’s fault you feel like a loser. As you mature as an engineer first it gets easier and more rewarding to learn new ways of doing things, but you also realize that feeling of being a loser is just the brain resisting and the feeling of learning.
- pclmulqdq 3y agoOften in a professional context, a non-idiomatic layer written with a lot of discipline is an effective shim between nice clean code and something "dirty." Precluding people from writing that shim just makes things harder. Sure, allowing people to do whatever they want means that code written without discipline will just be a jumbled mess, but that will be true in idiomatic code too. Also, a mature language and the associated community has to be able to deal with non-hobbyists learning and using it.
- deleted 3y ago[deleted]