|
For anyone else learning rust, this code review of ripgrep is really fantastic: http://blog.mbrt.it/2016-12-01-ripgrep-code-review/
|
# ? Dec 10, 2016 16:46 |
|
|
# ? May 22, 2024 13:09 |
|
There's also the underhanded c++ contest which is cute
|
# ? Dec 10, 2016 21:22 |
Bloody posted:There's also the underhanded c++ contest which is cute Wait really? I had only ever seen underhanded C (which owns).
|
|
# ? Dec 11, 2016 01:44 |
|
I used a named break in Java this week at work.
|
# ? Dec 11, 2016 02:06 |
|
what is the current hipster reference to learn python with or does it even matter
|
# ? Dec 11, 2016 02:19 |
|
Dongslayer. posted:what is the current hipster reference to learn python with or does it even matter there's one but you've probably never heard of it
|
# ? Dec 11, 2016 02:21 |
|
MALE SHOEGAZE posted:there's one but you've probably never heard of it
|
# ? Dec 11, 2016 02:22 |
|
MALE SHOEGAZE posted:there's one but you've probably never heard of it
|
# ? Dec 11, 2016 02:31 |
|
Dongslayer. posted:what is the current hipster reference to learn python with or does it even matter googling for poo poo has worked pretty well for me tbh python irritates me. i've been learning it, and despite idiotic things like semantic whitespace, overall it started feeling like a nice perl replacement. was even finding that despite all the ludicrous compactness tricks in perl, i was using fewer lines of code in python, and it was like 1000x more readable. then [needle drop] i port a simple perl script that reads files and regexes each line and discover that python only manages about 1/10th the throughput how do they do that. i refuse to believe perl's implementation is anything other than a garbage fire to match the externally visible plang i've been using for years, so how hard can it be to match its performance
|
# ? Dec 11, 2016 05:03 |
|
perl is generally extremely good at string processing and specifically has a fantastic regexp implementation iirc perl's implementation is overall quite good, especially for something that hasn't had the same effort put into it as javascript. javascript regexp implementations are also generally superior, btw
|
# ? Dec 11, 2016 05:10 |
|
try compiling the regex objects, it used to help a lot with the performance and use the ASCII flag if you're not dealing with unicode
|
# ? Dec 11, 2016 05:46 |
CPColin posted:I used a named break in Java this week at work. Was it to break out all the way out of a loop/switch statement inside another loop? It feels so dirty. "I'll take Refactoring for 600."
|
|
# ? Dec 11, 2016 06:10 |
|
python 3 used utf-32 encoding instead of utf-8 so everything is going to be unnecessarily slower edit: apparently it's a lot more complicated than that with later versions of python 3 http://stackoverflow.com/a/9079985 comedyblissoption fucked around with this message at 06:34 on Dec 11, 2016 |
# ? Dec 11, 2016 06:25 |
|
Skim Milk posted:Was it to break out all the way out of a loop/switch statement inside another loop? It feels so dirty. That's the one! It's actually a named continue, now that I look at it again. Wouldn't have had to do it, if Java had for-else.
|
# ? Dec 11, 2016 06:48 |
|
CPColin posted:That's the one! It's actually a named continue, now that I look at it again. Wouldn't have had to do it, if Java had for-else. isn't that the thing they had to remove from some other language because almost nobody understood what that hosed up construct actually does
|
# ? Dec 11, 2016 06:57 |
|
Possibly. It could use a better keyword than "else," certainly. Maybe for-didn'tbreak?
|
# ? Dec 11, 2016 07:03 |
|
what we really need is a more thorough set of constructs for working with loops:code:
of course, we're reusing existing keywords for maximum backwards compatibility (and confusion)
|
# ? Dec 11, 2016 07:20 |
|
rjmccall posted:perl is generally extremely good at string processing and specifically has a fantastic regexp implementation huh. well count me surprised (not at js, though) Symbolic Butt posted:try compiling the regex objects, it used to help a lot with the performance comedyblissoption posted:python 3 used utf-32 encoding instead of utf-8 so everything is going to be unnecessarily slower will look into these things. annoying if it turns out you have to jump through extra hoops to get on the performance path
|
# ? Dec 11, 2016 09:42 |
|
python is also just really slow overall. for some reason people go to the effort of writing C extensions to do things fast in it
|
# ? Dec 11, 2016 10:20 |
|
redleader posted:what we really need is a more thorough set of constructs for working with loops: why are you using a for loop anyway? just map a function across your collection
|
# ? Dec 11, 2016 16:13 |
|
Sapozhnik posted:isn't that the thing they had to remove from some other language because almost nobody understood what that hosed up construct actually does there was a proposal to add it to c++ which was withdrawn when it was pointed out that despite citing python as the inspiration for it, it was proposing the opposite of what python has
|
# ? Dec 11, 2016 20:01 |
|
leper khan posted:why are you using a for loop anyway? just map a function across your collection no. that makes it too easy to reason about the code. by reusing a bunch of keywords, we can significantly increase the difficulty of comprehension - especially if we introduce some subtle and surprising semantics here
|
# ? Dec 11, 2016 21:50 |
|
leper khan posted:why are you using a for loop anyway? just map a function across your collection My for loop had side effects!
|
# ? Dec 11, 2016 22:21 |
|
once while browsing old issues of CACM (i don;t remember why) i happened on this really weird article in a 1970s/early 1980s issue, which i don't think was an april issue, where the author had rolled while loops, until loops, and i think a couple of other control structures into one, and there was really nothing to the article except "look, I could do this!" and for some reason CACM published it
|
# ? Dec 11, 2016 22:28 |
|
(and that author's name was larry wall)
|
# ? Dec 11, 2016 22:30 |
Gazpacho posted:once while browsing old issues of CACM (i don;t remember why) i happened on this really weird article in a 1970s/early 1980s issue, which i don't think was an april issue, where the author had rolled while loops, until loops, and i think a couple of other control structures into one, and there was really nothing to the article except "look, I could do this!" and for some reason CACM published it personally i just use if and goto for better performance and more fine-grained control. it's very expressive
|
|
# ? Dec 11, 2016 23:44 |
|
Symbolic Butt posted:try compiling the regex objects, it used to help a lot with the performance i think the python regex compiler cache globally. could be wrong though.
|
# ? Dec 12, 2016 09:36 |
|
crazysim posted:i think the python regex compiler cache globally. could be wrong though. Its supposed to, but there is still speed-up from compilation .
|
# ? Dec 12, 2016 13:24 |
|
i didn't realize that java had a named break, that's pretty neat. that's basically the only situation where i use gotos.
|
# ? Dec 12, 2016 16:41 |
|
HappyHippo posted:i didn't realize that java had a named break, that's pretty neat. that's basically the only situation where i use gotos. rust has it too i used it the other day when looping through events in my game loop. user pressed Q? exit out of the main loop e: now though I just moved it out into its own function and return early instead of breaking early.
|
# ? Dec 12, 2016 19:15 |
|
Xarn posted:Its supposed to, but there is still speed-up from compilation . that's not so surprising if the cache just does a hash lookup on the regex string, which is going to have a hit if it's in a tight inner loop that won't be there for the compiled object.
|
# ? Dec 12, 2016 19:39 |
|
Soricidus posted:that's not so surprising if the cache just does a hash lookup on the regex string, which is going to have a hit if it's in a tight inner loop that won't be there for the compiled object. It also helps pin things in the caches that might otherwise fall out from use of libraries which also use regular expressions.
|
# ? Dec 12, 2016 21:41 |
|
back to our homemade variant! well, we started in the completely wrong way, apparently. we want feature parity with std::variant (minus the boring parts), and an std::variant that can only contain literal types is, in turn a literal type. a literal, or constexpr type is a type that acts like a literal (like say, a number literal or a string literal), and can be used wherever literals can, like array sizes, template parameters, static_assert and so on. of course, a literal type is subject to a ton of constraints, that essentially boil down to "predictable compilation times" and "no runtime environment". the former is obvious (you don't want the whole program to run at compile time, although you'd hardly call c++ compilation times "predictable") and the latter is necessary: the runtime environment (and by extension, constexpr code) the compiler runs in is neither safe to use (unless compiler writers start listening to reason, i.e. me, and run the compile-time code in a proper process that I can debug) nor necessarily matches the runtime environment expected by the program. one of the things that can't be done in literals is aliasing, i.e. taking an area of memory of one type and treating it as a different type: the whole concept of "area of memory" is runtime environment nonsense that the compiler won't entertain remember how I decided to base my variant around aligned_union? aligned_union is a generic type that acts like an untyped, uninitialized union that can contain any of a list of types: it's large enough and memory-aligned enough to be safely cast to any of the specified types, and so it may sound perfect as the basis of variant. unlike real unions, though, aligned_union requires type casts, and type casts imply aliasing, and aliasing is inaccessible in literal expressions. real unions work perfectly in literal expressions, but they are lists of named fields, and as we've seen at the beginning of this Learning Experience, one very important thing template code can't do is define names. what templates can do perfectly well, however, is list manipulation through recursion. if, in an ideal world, we'd pass a template a list of types and names, and get it to generate a union like this: C++ code:
C++ code:
C++ code:
C++ code:
C++ code:
you may wonder, can a union contain types with non-trivial constructors and destructors? and how, exactly, does the compiler know which field of the union is the active one? these are really good questions! in fact, before c++11, unions could only contain trivial types. the limitations were greatly relaxed, specifically to allow tagged unions. the full ruleset is not important right now, but two important rules are: if any of the fields of the union have a non-trivial default constructor, the union has no default constructor; same goes for the destructor. the default constructor is not terribly important: all our variant class needs from this base component is a generic constructor that takes an index to the field to be constructed, and a list of arguments to be passed to the constructor of the field. something like this: C++ code:
|
# ? Dec 13, 2016 00:43 |
|
hackbunny posted:the start of a variant hole you will never escape from it would be easier to implement the union end case with a single item C++ code:
|
# ? Dec 13, 2016 02:18 |
|
GLSL is a wonderful language of simple, predictable features with many, many high quality cross-platform compilers and C++ code:
|
# ? Dec 13, 2016 02:36 |
|
is that from the folks fuzzing it? e: here's one of their articles
|
# ? Dec 13, 2016 02:41 |
|
JawnV6 posted:is that from the folks fuzzing it? no, it's something I ran into just moments ago on desktop. i'm running on opengl 4.40 compatibility profile and whichever NVidia's driver windows update has installed (21.21.13.6909, published 2016-08-01 looks like it) I think I might have an infinite value that somehow survives being coerced into a Boolean and ...time to go to bed thanks for the article, i'll have to dig into it
|
# ? Dec 13, 2016 03:28 |
|
Slurps Mad Rips posted:
joke's on you! it's already done and I'm doing a postmortem. last week I had five days off and I used them well Slurps Mad Rips posted:it would be easier to implement the union end case with a single item I do this in my actual for real implementation, but for my posts I rewrite the code from memory. this way I can often understand the code better than when I wrote it, and sometimes have new ideas Slurps Mad Rips posted:also std::variant just landed in libc++, and there's some cool stuff in there i wouldn't have thought of do tell, by now I may even understand
|
# ? Dec 13, 2016 10:49 |
|
hackbunny posted:we'll need two storage types: one for trivially-destructible types only, that can be used in a literal expression, and one that may contain non-trivially-destructible types, for everywhere else. next time we'll see how to make it... well, no, I'm not going to sugarcoat it, we can't make it painless. it will be the tip of an iceberg of suck, but the payoff will be worth it (if you're the kind of person who cares about making complex classes constexpr-compliant! which I apparently am) This is C++ telling you to stop trying to constexpresize the variant, please listen to it. (I have had to deal with something similar, albeit with lot less recursive templates, and I am still not sure it was worth it)
|
# ? Dec 13, 2016 15:13 |
|
|
# ? May 22, 2024 13:09 |
|
Xarn posted:This is C++ telling you to stop trying to constexpresize the variant, please listen to it. too late! I already have lines like these: C++ code:
|
# ? Dec 13, 2016 15:35 |