|
https://perl6advent.wordpress.com/2017/12/01/the-grinch-of-perl-6-a-practical-guide-to-ruining-christmas/
|
# ? Dec 1, 2017 20:12 |
|
|
# ? May 25, 2024 14:05 |
|
Dylan16807 posted:https://perl6advent.wordpress.com/2017/12/01/the-grinch-of-perl-6-a-practical-guide-to-ruining-christmas/ lmao oh god
|
# ? Dec 1, 2017 21:03 |
|
Dylan16807 posted:https://perl6advent.wordpress.com/2017/12/01/the-grinch-of-perl-6-a-practical-guide-to-ruining-christmas/ This mostly looks like any language that lets you modify internals, combined with "Perl 6 looks kind of strange".
|
# ? Dec 1, 2017 21:17 |
|
Dylan16807 posted:https://perl6advent.wordpress.com/2017/12/01/the-grinch-of-perl-6-a-practical-guide-to-ruining-christmas/ Nope.
|
# ? Dec 1, 2017 21:32 |
|
Coffee Mugshot posted:I mean, the idea is reasonable. Coffee Mugshot posted:I assume you would write a huge standard library for your language in Rust and then just have your compilation frontend generate some intermediate code that calls those library functions after you take all the expressions in your languages and massage them into Rust code. The generated code would probably be very little in comparison to the size of the existing Rust stdlib that people can actually read and write and use nice tools for. Debugging Rust code would probably be a lot easier than debugging LLVM IR's SSA code in terms of the tooling in place. And well, Rust generates LLVM IR anyways. It seems like it'd be nice not to reimplement the borrow checking logic in your language if you take advantage of an intermediary target that becomes LLVM IR anyways. You're not getting the Rust feature set for "free," you're getting an extra layer potential of bugs. By the time you're down at LLVM, getting a reasonable error to bubble back up to the original un-mangled source is just exhausting levels of hand waving.
|
# ? Dec 1, 2017 22:34 |
|
I imagine in a finalized rust is LLVM world, you would let rust compile to assembly on the target platform instead of using LLVM as an intermediary. Of course, such an enterprise would be an immense undertaking.
|
# ? Dec 2, 2017 00:25 |
|
Dylan16807 posted:https://perl6advent.wordpress.com/2017/12/01/the-grinch-of-perl-6-a-practical-guide-to-ruining-christmas/
|
# ? Dec 2, 2017 00:26 |
|
JawnV6 posted:It really isn't. This is basically how we did C++ in University. There was some C++ to C transpiler that than compiled C with the HPUX 6.X C toolchain. Debugging compiler or worse run time errors were an exercise in frustration.
|
# ? Dec 2, 2017 01:45 |
|
JawnV6 posted:It really isn't. I also don't think you get the Rust feature set for free, it's a trade-off. Source mapping and error propagation are always frustrating to get right when writing a transpiler, which is a good enough reason to target gimple and LLVM IR. At the same time, debugging LLVM IR and gimple is largely frustrating in and of itself and could benefit from better tools. Are better tools worth investing in if the resulting toolchain is fragile?
|
# ? Dec 2, 2017 06:01 |
|
I figured the target is more 'I am doing research on compiler/language design and am implementing something for a paper", not "I am writing production code" So most of your work and bugs would be in compiler you're writing of in the input code you're feeding it. Debugging your compiler emitting bad Rust is probably easier than debugging it emitting bad LLVM or C and all you're really trying to show is that some basic concept is interesting/feasible.
|
# ? Dec 2, 2017 06:50 |
|
Foxfire_ posted:Debugging your compiler emitting bad Rust is probably easier than debugging it emitting bad LLVM what makes you think so? the llvm intermediate representation was explicitly designed for compilers to emit, while the rust programming language was not
|
# ? Dec 2, 2017 07:03 |
|
DELETE CASCADE posted:what makes you think so? the llvm intermediate representation was explicitly designed for compilers to emit, while the rust programming language was not Well, I think the value of LLVM IR is the ease of adding or taking advantage of optimization transformations if you can generate reasonable code like https://llvm.org/docs/LangRef.html#type-system mentions. I don't know, it depends on this theoretical language you're implementing a compiler for, I suppose. I think it's non-trivial to map non-C like languages to LLVM's type system and wouldn't mind stealing some of the work of another similar language frontend that's close enough to my language. That's all I'm saying when I claimed it was not unreasonable to desire something like this. Is Rust the language for it? Probably not like that article says.
|
# ? Dec 2, 2017 08:40 |
|
Using an intermediate representation that enforces strong formation rules can be invaluable in a compiler. However, it is really difficult to generate source code that is structured even vaguely idiomatically unless your source language is basically a minor superset of the target language. Rust trades extremely heavily on the scope structure of the source, so it's very hard for me to imagine what language could be usefully transformed into Rust code.
|
# ? Dec 2, 2017 10:10 |
|
iospace posted:BITWISE OPERATIONS MOTHER FUCKER, DO YOU KNOW THEM "Can your API just send me an array of booleans instead of an int?" "Don't you have to initialize the bit before you can shift to it?" "Are you sure a MySQL BLOB can store enough quest flags?" I exaggerate, but still... Ranzear fucked around with this message at 22:55 on Dec 3, 2017 |
# ? Dec 3, 2017 22:50 |
|
Hughlander posted:This is basically how we did C++ in University. There was some C++ to C transpiler that than compiled C with the HPUX 6.X C toolchain. Debugging compiler or worse run time errors were an exercise in frustration. Cfront, the original C++ compiler, compiled to C yeah. They don't do that any more for a reason.
|
# ? Dec 3, 2017 23:08 |
|
Student code is cheating but stillC++ code:
C++ code:
C++ code:
|
# ? Dec 4, 2017 11:10 |
|
Wouldn't a compiler that emits valid Rust have to pretty much re-implement enough of the borrow checker to basically be the Rust compiler with a different lexer?
|
# ? Dec 4, 2017 18:40 |
|
Xarn posted:Student code is cheating but still Just gotta take it one line at a time... just watching a debugger do each baby step until they can't verbally justify to you why one of them took place... Trying to just look at the whole code and explain to them the issue has no hope. It does take forever to walk them through it by hand and can be a real slog when a dozen students are lined up. At my school, running the office hours room for intro to programming is often compared to being a triage doctor in a war zone.
|
# ? Dec 5, 2017 02:04 |
|
"Rule RequireUpperBoundDeps failed with message:" followed by like 10 pages of dependency trees Kill me now.
|
# ? Dec 5, 2017 23:47 |
|
C# code:
(It's pretty tame but it's all I got recently, since quite a lot of my work has been greenfield. Aka, generating horrors.)
|
# ? Dec 6, 2017 03:56 |
Xik posted:
ah, go#
|
|
# ? Dec 6, 2017 04:04 |
My linter slows my computer the gently caress down because I have it constantly re-analyzing my code, but I honestly don't mind because it's kept me from making stuff like that a non-trivial number of times. I'm still embarrassed that an if(date.compareTo(otherDate) == 0) made it into a PR
|
|
# ? Dec 6, 2017 04:23 |
|
ChickenWing posted:I'm still embarrassed that an if(date.compareTo(otherDate) == 0) made it into a PR what’s wrong with it?
|
# ? Dec 6, 2017 06:37 |
|
Shinku ABOOKEN posted:what’s wrong with it?
|
# ? Dec 6, 2017 06:46 |
|
Xik posted:
Trying to figure out why this would be necessary. Side effect of evaluating result != null possibly??? Other than that, no reason not to just return someServiceCall().
|
# ? Dec 6, 2017 14:33 |
|
Pollyanna posted:Trying to figure out why this would be necessary. Side effect of evaluating result != null possibly??? This is the coding horrors thread, not the "this looks weird but is necessary" thread.
|
# ? Dec 6, 2017 14:40 |
My money's on 'writing without thinking' rather than some weird-but-necessary magic. Not quite as hilariously pointless as "if (thing == true) return true else return false", but very close. hailthefish fucked around with this message at 14:46 on Dec 6, 2017 |
|
# ? Dec 6, 2017 14:44 |
|
"I need a place to put a breakpoint to inspect result in the rare case it's not NULL."
|
# ? Dec 6, 2017 15:10 |
|
Hughlander posted:"I need a place to put a breakpoint to inspect result in the rare case it's not NULL." "You can't see the debugging code I deleted from this function"
|
# ? Dec 6, 2017 15:12 |
|
I spent the last 15 days cleaning up the code of our biggest application. In total: - Over 500 variable names where straight up changed to be readable (IE: a -> accounts) - All of the variables were standardized for capitalization, as they were all loving random, to begin with. (IE: Some variables began with a capital, some not, some were camel case, some not, some were descriptive, some were a combination of descriptive and shorthand, etc etc) - The previous dev had all of the class names start with a _ and then had a typedef pointing to the class without a _, thus hiding if the function argument was a pointer or not. Example: C++ code:
- There were almost no function pointers. Instead, the previous developer decided to have 6 listeners all in their own separate threads that the various classes talked to. I removed all but one of them in favor of function pointers without any ill effects. - Previously there was just two folders: src and inc. Now there are multiple folders. - I added 6 new cpp/h files in an attempt to break up a single file that was over 3,000 lines long. - Namespaces are a now a thing. - The one class that was using a namespace was extending std. - I removed all of the "using namespace std" lines everywhere. - The last thread had a usleep(100) in it. Changing that to a msleep(250) had no ill effects and made processor usage go from 20% to 0% at idle. - A SUPERCLASS DEPENDED ON A SUBCLASS OF ITSELF. When I saw that I drat near had an aneurysm. The sheer amount of stupidity in this code was staggering. That list is just a few of the big ones I remember. The merge request was over 5,000 lines of code changed.
|
# ? Dec 6, 2017 15:27 |
|
boo_radley posted:"You can't see the debugging code I deleted from this function" I’m not saying it’s good, but I have written code like that for Android NDK code and I may even have left it in place at one point or another. Anything past -O0 will do the right thing anyway. But yes it’s a horror to see in production code and to me means that people don’t diff what they’re checking in.
|
# ? Dec 6, 2017 15:35 |
|
hailthefish posted:Not quite as hilariously pointless as "if (thing == true) return true else return false", but very close. These get posted every once in a while in this thread and I'm like 95% sure it's people who learned to program using Perl, since ca. Perl 5 and Perl Best Practices that was a common idiom to guarantee you returned a boolean value and not something else. e: along with return (var? || false) The Phlegmatist fucked around with this message at 15:52 on Dec 6, 2017 |
# ? Dec 6, 2017 15:46 |
|
ratbert90 posted:- A SUPERCLASS DEPENDED ON A SUBCLASS OF ITSELF. When I saw that I drat near had an aneurysm. How does this work in C++? Is this some shenanigans with forward-declared classes that just end up not causing a linker/compiler error by chance (because of no data members?)? Athas fucked around with this message at 22:59 on Dec 6, 2017 |
# ? Dec 6, 2017 15:58 |
|
Athas posted:How does this work in C++? Is this some shenanigans with forward-declared classes that just end up not causing a linker/compiler error by change (because of no data members?)? Pretty much!
|
# ? Dec 6, 2017 16:00 |
|
ratbert90 posted:The sheer amount of stupidity in this code was staggering. That list is just a few of the big ones I remember. The merge request was over 5,000 lines of code changed. But all the tests passed, right, so you know nothing broke, right?
|
# ? Dec 6, 2017 16:27 |
Factor Mystic posted:But all the tests passed, right, so you know nothing broke, right? in before "what tests?"
|
|
# ? Dec 6, 2017 16:55 |
|
Key to making a large change like that -- disable the tests with 1 line somewhere in the middle.
|
# ? Dec 6, 2017 16:58 |
|
boo_radley posted:"You can't see the debugging code I deleted from this function" This kind of thing is why I always review my changes before sending out for review. Preferably with a night's sleep in between authoring and reviewing, too.
|
# ? Dec 6, 2017 17:25 |
|
ChickenWing posted:in before "what tests?" More like upper management going: "Test? We have always done it without unit tests."
|
# ? Dec 6, 2017 17:56 |
|
|
# ? May 25, 2024 14:05 |
|
boo_radley posted:"You can't see the debugging code I deleted from this function" This is going to be it, or something similar. Or there was logic just before return result; or there was logic just before return null; which was removed some time back. It's much easier to accidentally refactor into that state than it is to write it out directly.
|
# ? Dec 6, 2017 19:31 |