- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
time::duration::fromSecs(NULLPTR);
Admin
Great, next time I should name my variable
threeSome
when I'm actually having relationships with 59 mates at once. Sounds nothing but fun!Admin
That's a terrible variable name. A good variable name should say what the variable contains, but what it represents. That is, while the variable might contain "three seconds", it might represent a "network timeout delay" - which in that case would have been a much better name for it.
Admin
I find it's the other way about.
"Ah this won't take long to fix, about three minutes" ... and then an hour later: "... nearly there."
Admin
https://xkcd.com/612/
Admin
when estimating time to do some task allways multiply by two and take next larger time unit
Admin
Yes, but if everyone did that, we wouldn't have nearly so much material for this site.
Admin
You estimate the time required and then multiply it with Pi...
Admin
You don't know the code. What if it represents three seconds?
Admin
Let's be honest, I've seen spectacular examples of this sort of thing in the past. My absolute favourite was a byte constant named THFF (think about it, you'll get it in a minute)
Admin
Victoria's at least got a good approach. Try to get in the previous developer's head to understand what they might've been thinking, so that you can understand the problem. Then, refactor to have a more sensible solution.
Sometimes, however, the answer to "what were they thinking?" is simply, "they weren't".
Admin
s/though/thought/
(I hope my backslashes will avoid the Markdown WTFery)
Admin
This is why languages with dynamic typing are so bad, is that it breaks features in the IDE. For Java, all you have to do to rename a variable in Eclipse is right-click, Refactor, Rename.
Admin
Am I missing a joke? I fail to see what dynamic typing has to do with the IDE not being able to rename a variable.
Admin
Does Rust not have refactoring capability?
Admin
I recently encountered something like this. Except there were two cases, each started with a variable named based on the length of the time, and everything else the same.
This was from someone who had a CS BS. I think this is the sort of thing that comes from professors choosing to grade code by running it through programs. Sure, it gives an objective assessment rather than a subjective one, but it gives a very poor objective assessment. I know, as I intentionally submitted obfuscated code that still got full marks, just to see.
Admin
They should've gone with 7 seconds instead. A) 7 is a lucky number and b) there's a song called "7 seconds" which is pretty decent.
Admin
And I can't skip commenting on yet another programming language. Guys we have enough programming languages. Stop making new ones. Second, what kind of name is Rust? All kinds of nasty expressions involving the word rust come to mind. Just no.
Admin
I think it's where the program gets stored.
Admin
It did in fact take me a minute: Two Hundred Fifty-Five.
I'm curious, what language was that from? In many languages, bytes are signed, so it's not even a valid byte constant in those.
Admin
Rust is named after a fungus that is robust, distributed, and parallel.
And I generally agree with the language proliferation problem (there are too many), but Rust fills a need nothing else was filling - which is for a memory safe language which is as fast and as memory-light as C++ without being as terrible to work with. I'm pretty good at C++ (thanks Scott Meyers!) but it's an ancient, bloated, creaking, ugly pain in the ass that's only tolerated because it's fast and has deterministic memory allocation. C# is much nicer for doing GUIs, but sometimes you need the performance and for that Rust is much nicer.
Admin
Actually, I was thinking it stood for The Holy FF - that Holy Grail of magic numbers.
Admin
C# on .Net Core 3 is not that much slower, and constantly improving. For web it is one of the fastest frameworks around now.
Admin
This. For performance, C# has unsafe context. Even in managed mode, it's come a long way. Once you include the great BCL, fantastic IDE, rich ecosystem, and now cross platform support, I really see no need for any new languages. Maybe Rust (I said it again damn it) is a little faster compared to even unsafe C# (which I doubt), but those performance critical areas can be offloaded into a native DLL of some sort. Yes C++ is all those things you said, but it's good enough if all you're doing in it is high performance routines that are part of a larger managed application.
Admin
You are clearly not considering embedded applications, where managed environments (especially if GC is involved) are not an option.
Admin
I can use C# for almost everything on a desktop, but Rust stomps Mono for performance and memory use on our little embedded devices. Worse, C#/Mono garbage collection is non-deterministic, meaning you never know when the thing is going to hiccup.
It fills a niche, which is 'C++ is awful and dangerous, C# isn't cross-platform enough for GUI stuff, and virtual machines are bad for real-time'.
Admin
It's a flexible variable, as it can also be used to store 344 if required.
Admin
Perhaps you're right about the performance. I'm not doing anything with embedded devices at the moment. My question - now that they're willing to create a whole new language, why not adopt an existing language and give it a new runtime?
Admin
Surely, Victoria's problem would have been easily solved by a comment that reads "// this takes about five seconds, so let's take eight to be sure"
Admin
Funny: I got there by a different route. T (for whatever naming convention reason) Hex FF.
Addendum 2019-11-06 01:48: It's a bilingual variable name.
Admin
If you have a static-typed language like Java, C, C++, .net, you can rename member variables(1), and the IDE's renamer knows for sure that this instance of the name of the member variable actually is (or is not) the same member variable(2). In dynamic-typed languages like Python, JS, etc., the renamer can't be sure.
(1) That is, in C++ notation, I want to rename
ThisClass::m_frobbleCount
but not renameThatClass::m_frobbleCount
.(2) Apart from some flakiness about templates in C++, where a function or class template might use
T::m_frobbleCount
, and the question arises about whether the renamer should rename it, especially if the function is instantiated with T =ThisClass
in one place and with T =ThatClass
in another.Admin
Rust's GUI story isn't great either, at the moment. I've tried gtk-rs which works but looks extremely non-native outside of Linux, and rust-qt is not very usable since you can't subclass Qt widgets and add fields. AFAIK there aren't other mature platform-native or non-native but non-HTML GUI toolkits either. I heard it has usable imgui bindings, and some web-based things. https://areweguiyet.com/
Rust still has the "virtual machine" advantage over C#.
Admin
Regarding rust: There is a nice article, on why it gets some adoption [1] (Warning: Ad-heavy site...).
Basically the argument is that systems programming basically REQUIRES a language with deterministic memory management, and compared to C or C++ Rust avoids many classes of bugs by design.
No amount of testing and linting beats not needing it due to language guarantees.
[1] https://www.infoworld.com/article/3451296/why-the-rust-language-is-on-the-rise.html
Admin
This could have been a case of attempting to meet impossible customer requirements.
CUSTOMER: "Your network timeout delay must be three seconds."
ENGINEER: "...that's just not possible in this system. It has to be sixty. We'd have to refactor the whole system. Also, you wouldn't notice sixty."
CUSTOMER: "No, it has to be three."
ENGINEER: "...okay..."
Admin
It's Rust, therefore it is not dynamically typed. All they need to do is change the name of the variable in the
let
, recompile and fix the new errors.Admin
Maybe their programmer used that name because he had a Three Second Memory. Then he got replaced with someone who doesn't have the attention span of a GoldFish.
Admin
Not the one I was expecting it to be, which was https://xkcd.com/349/