--- Log opened Sat Sep 03 00:00:42 2016 |
00:56 | <@celticminstrel> | ...so I have an std::array<std::bitset<n>, n>, but now I want to specify n at runtime. What to do? |
00:58 | <~Vornicus> | so you want to go from a square fixed-size bitset to a square not fixed size bitset |
00:59 | <@celticminstrel> | Essentially. |
00:59 | <~Vornicus> | I know one of those things you can pick a size right when you initialize but I don't remember what it's called. |
01:01 | <&Derakon> | Man, I've never even seen bitset before. |
01:01 | <&Derakon> | I'm guessing it's a wrapper that lets you assign names to bits in a bitmask? |
01:01 | <@celticminstrel> | I suppose I could do std::vector<boost::dynamic_bitset<>>... |
01:02 | <@celticminstrel> | Derakon: No, that would be the "int var : 1;" syntax. |
01:02 | <@celticminstrel> | Which I forgot the name of. |
01:02 | <@celticminstrel> | What bitset allows you to do is access bits with the subscript operator. |
01:02 | <@celticminstrel> | Rather than & and | and masks. |
01:03 | <&Derakon> | Is there a particular reason you need to bit-twiddle? |
01:03 | <@celticminstrel> | And ^ |
01:03 | <&Derakon> | Instead of paying the 8x cost increase of storing a boolean? |
01:03 | <@celticminstrel> | There isn't any strong reason, no. |
01:03 | <&Derakon> | Then my inclination would be to say "just use a dynamic square array of bools". |
01:03 | <@celticminstrel> | Eh. |
01:04 | <@celticminstrel> | Actually, if I did that, it would end up being based around vector<bool> though, so I did consider it. |
01:04 | <&Derakon> | Nobody ever wants the boring solution. :) |
01:04 | | * celticminstrel has a custom vector2d class for 2D dynamic arrays. |
01:05 | <@celticminstrel> | Not sure if vector<bool> has the nice stream operator though... |
01:06 | <@celticminstrel> | With the array of bitset I have the nice property that, when outputted to a file, it nicely visualizes the explored area. |
01:06 | <@celticminstrel> | WIth vector2d that'd probably be harder. |
01:11 | | Netsplit Deepthought.Nightstar.Net <-> Krikkit.Nightstar.Net quits: @PinkFreud |
01:12 | | Netsplit over, joins: @PinkFreud |
01:45 | | catadroid [catadroid@Nightstar-u0e5c2.dab.02.net] has joined #code |
01:50 | | * Vornicus directs celmin in the vague direction of catadroid. |
01:51 | <~Vornicus> | (who I have no idea if she's actually awake or not, it's like, what, 2 am over there) |
01:52 | <&jerith> | Almost 2am. |
01:52 | < ToxicFrog> | She slep. |
01:52 | <@celticminstrel> | Hm? |
01:52 | <&jerith> | (An hour behind me, and it's nearly 3am here and I wish I could be sleeping but my brain won't.) |
01:52 | | * celticminstrel actually ended up using a vector of Boost dynamic_bitset. |
01:53 | <~Vornicus> | catadroid is a C++ goddess. She spent a while earlier this year doing stdlib collections optimization for work |
01:53 | | * celticminstrel would still be interested if someone else has suggestions though. It's not like I can't change it again. |
01:53 | <&jerith> | cat is the person our other C++ experts go to for help. :-) |
01:55 | <&McMartin> | That said, your initial question is pretty straightforward |
01:56 | <&McMartin> | std::bitset is built around fixing the size of the bit set at compile time. |
01:56 | <@celticminstrel> | As is std::array |
01:56 | <&McMartin> | If you want a dynamically scaling array of bits that is still reasonably space-optimized, std::vector<bool> is a special snowflake implementation that optimizes aggressively for space. |
01:56 | <&McMartin> | It won't be as small as a true static bitset because it has to carry size and linking information. |
01:57 | <@celticminstrel> | I don't need it to dynamically scale though. |
01:57 | <&McMartin> | Well, yes you do, if N is changing at run time |
01:57 | <@celticminstrel> | More specifically, its size is set at construction and never changes thereafter. |
01:57 | <&McMartin> | That is still std::vector. |
01:58 | <@celticminstrel> | The reason I decided against vector<bool> is because I was using the bitset stream operator. |
01:58 | <@celticminstrel> | (Well, vector2d<bool> rather) |
01:58 | <&McMartin> | Then reimplement it or you're out of luck, basically; the size is part of the type and that's fundamental to its ability to be used as a value |
01:59 | <@celticminstrel> | Right, that's why I chose std::vector<boost::dynamic_bitset<>>, because the dynamic bitset mimics the interface of std::bitset. |
01:59 | <@celticminstrel> | Thus, it has the stream operator. |
02:00 | <&McMartin> | Okay |
02:00 | <&McMartin> | Yeah, that should be fine |
02:01 | <&McMartin> | But at that point, yeah, you're in "outside the standard library" |
02:01 | <&McMartin> | I haven't worked with that particular Boost library before, I can't speak to how well it works |
02:01 | <@celticminstrel> | I'm already using it somewhere. |
02:01 | <@celticminstrel> | Somewhere in BoE even. |
02:12 | <~Vornicus> | is there anyone else working on BoE, or are you it? |
02:40 | <&[R]> | https://twitter.com/FioraAeterna/status/771537601069142016 <-- am I missing anything obvious here? |
02:41 | <&[R]> | https://pbs.twimg.com/media/CrTIIUyWcAQ4xas.jpg <-- also win |
02:48 | <~Vornicus> | [R]: that also appeared in the print edition! |
02:48 | <~Vornicus> | https://twitter.com/bydanielvictor/status/771698039908163584 |
03:32 | | * Vornicus should read the Dolphin progress notes more often |
03:35 | <@celticminstrel> | Vornicus: It's basically just me. |
03:36 | <@celticminstrel> | There was one other person who contributed a little, and a few people who showed up trying to get it to build and then disappeared once they managed it (or possibly gave up before that). |
03:37 | <@celticminstrel> | Hmm, I can't forward-declare a template type alias, can I. |
03:38 | <&McMartin> | ... with using? |
03:38 | <&McMartin> | I think you ought to be able to, but I haven't tried |
03:38 | <@celticminstrel> | Okay, I'll try it then. |
03:38 | | * celticminstrel needs a custom type trait that does remove_all_extents for an array or something value_type-ish for a vector. |
03:40 | <@celticminstrel> | Gives me "Cannot template a using declaration". |
03:41 | <@celticminstrel> | Which goes away if I add the assignment. |
03:44 | <@celticminstrel> | I can't figure out a generic way to specialize this, but I guess it really only needs to work for 2D arrays anyway... |
03:44 | <@celticminstrel> | Ah, and partial specialization of using is not allowed. Guess it has to be a class. |
03:53 | <&McMartin> | Hum. |
03:53 | <&McMartin> | Are you using C++11 or C++98? |
03:54 | | * McMartin digs up some of his older code |
03:54 | <&McMartin> | This works in C++11: |
03:54 | <&McMartin> | template <typename T> class Foo; |
03:55 | <&McMartin> | template <typename T> using FooPtr = std::shared_ptr<Foo<T> >; |
03:55 | <&McMartin> | (And then you could have, say, FooPtr<int> for std::shared_ptr<Foo<int>>) |
04:04 | <@celticminstrel> | C++11 |
04:05 | <@celticminstrel> | Though, possibly slightly pre-standard, not sure. |
04:05 | <@celticminstrel> | I think the clang base version is 3.2 or something. |
04:05 | <@celticminstrel> | I can get clang 3.8 to work in XCode 4, but it doesn't play well with the indexer. |
04:06 | <@celticminstrel> | I see, so forward-declaring it as a class, interesting... I probably would not have thought of that. |
04:06 | | * celticminstrel already went with making it a struct though. Also, never really needed a forward-declaration, probably. |
04:15 | <@celticminstrel> | I should find the precise git config setting that will prevent it from highlighting in the diff tabs consisting solely of tabs (but without suppressing other types of whitespace errors, like a space being mixed in with tabs). |
04:15 | <@celticminstrel> | Seems like core.whitespace is the setting I want... |
04:16 | <@celticminstrel> | Set it to blank-at-eol maybe? And then I'd need to figure out how to undo that in one specific repo... |
04:17 | <@celticminstrel> | Though does that affect diffs? |
04:17 | <@celticminstrel> | This SO thread seems to suggest not. |
04:24 | <@celticminstrel> | No wait, disabling blank-at-eol would be too much. Warning about non-blank lines with trailing whitespace is great, but I don't want to be warned about blank lines with only whitespace... |
04:24 | <@celticminstrel> | :| |
04:30 | < ToxicFrog> | ...why not? |
04:30 | <@celticminstrel> | Because I like my indentation level to be consistent even on blank lines. |
04:30 | < ToxicFrog> | Also, changing that for one specific repo is the default. |
04:30 | < ToxicFrog> | Use --global to change it everywhere. |
04:30 | <@celticminstrel> | Right, but I want to change it for all except one repo. |
04:30 | < ToxicFrog> | Right. |
04:30 | < ToxicFrog> | So use 'git config --global ...' to change it everywhere, and then on that one repo, 'git config ...' to override that. |
04:31 | <@celticminstrel> | I guess I need to check what the default is then. |
04:32 | < ToxicFrog> | Per 'git help config', the default is blank-at-eol,space-before-tab,blank-at-eof,tabwidth=8 |
04:32 | <@celticminstrel> | I don't suppose I can define filtery things to be used here? |
04:33 | < ToxicFrog> | Like, invoke arbitrary external programs to mark whitespace errors? Not there, no. |
04:33 | < ToxicFrog> | git does have a general purpose system for doing that, but I've never used it and know very little about it -- look for filters, IIRC. |
04:34 | <@celticminstrel> | Hmm, well, I'm pretty sure I've eliminated blank-at-eol issues from BoE, and since XCode is set to automatically remove such trailing blanks, it's pretty unlikely that I'd accidentally commit them, so I'll just disable it. |
04:37 | <@celticminstrel> | Seems like this doesn't prevent git diff from highlighting it though... |
04:38 | <@celticminstrel> | o.o "The default tab width is 8. Allowed values are 1 to 63." |
05:10 | <&McMartin> | re: the earlier bit with me thinking I have a better grasp of Objective-C |
05:10 | <&McMartin> | I did a proof-of-concept PR on some code I didn't think looked right |
05:10 | <&McMartin> | No behavior changes, but it's a +92/-211 diff. |
05:10 | <&McMartin> | I'm pretty OK with that |
05:13 | <@celticminstrel> | Aha, I have to explicitly say -blank-at-eol to disable it. |
05:40 | <@celticminstrel> | Is there a way to say "This template has an instantiation for these types, but the definition is elsewhere"? |
05:41 | <@celticminstrel> | Though it seems to compile without that... |
05:41 | <@celticminstrel> | Even though the definition is not in the header. |
05:41 | <@celticminstrel> | On the other hand, it doesn't link. |
05:42 | | * celticminstrel could just move this template definition to a header, I guess. |
05:47 | | * celticminstrel will try extern template. |
05:48 | <@celticminstrel> | (Though even if it works I might still need to move the definition later if it fails on MSVC 2013.) |
05:49 | <@celticminstrel> | Nope. Guess I'll put it in a header after all. |
05:49 | <@celticminstrel> | (It does compile, but still doesn't link.) |
05:57 | <&McMartin> | You should be able to forward declare with something like |
05:57 | <&McMartin> | template <> class Foo<Bar>; |
06:08 | <@celticminstrel> | The problem is that that requires the definition to be visible. |
06:08 | <@celticminstrel> | Anyway, I resolved that problem. |
06:08 | <@celticminstrel> | Slightly annoyed now that I can't do Base* a = b ? &derived1 : &derived2; |
06:09 | | * Vornicus is pretty sure he's almost there with circle collision. |
06:12 | | catadroid` [catadroid@Nightstar-o6prjn.dab.02.net] has joined #code |
06:13 | | * Vornicus hatadroids |
06:16 | <&McMartin> | celticminstrel: Not even if you cast each branch individually? |
06:16 | | catadroid [catadroid@Nightstar-u0e5c2.dab.02.net] has quit [Ping timeout: 121 seconds] |
06:16 | | himi [sjjf@Nightstar-v37cpe.internode.on.net] has quit [Ping timeout: 121 seconds] |
06:29 | <@celticminstrel> | I guess that would work, but annoying that I need to. Makes it not worthwhile (since all I need to do is get a base class member variable). |
06:39 | | Derakon is now known as Derakon[AFK] |
06:40 | | Kindamoody[zZz] is now known as Kindamoody |
06:44 | <&McMartin> | Well, you can't do it on the outside |
06:44 | <&McMartin> | Remember that in C++ a cast will usually change the bit pattern of the pointer. |
06:58 | <@celticminstrel> | Basically I had auto& thing = b ? d1->member : d2->member and wanted to change to auto& thing = (b ? d1 : d2)->member. Oh well. |
06:58 | <&McMartin> | Yeah. The offsets computed by that ->member in the first case are gonna be different offsets, so you'd need to do the cast (and thus the pointer-bump) explicitly |
07:02 | <@celticminstrel> | Seems unlikely that they'd be different offsets when it's the only base class, but not that important. |
07:16 | | gizmore [kvirc@Nightstar-61lcur.dip0.t-ipconnect.de] has joined #code |
07:48 | <&McMartin> | If the std::is_std_layout<> macro works out to true, then they behave like C structs and this works, but if there are more than two classes in the inheritance chain with fields, it doesn't work out. :shrug: |
07:51 | | celticminstrel [celticminst@Nightstar-ehtgrr.dsl.bell.ca] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!] |
08:03 | < catadroid`> | Hello |
08:03 | | * McMartin provides catadroid with an army of robotic hats. |
08:03 | | catadroid` is now known as catadroid |
08:03 | < catadroid> | I am currently suffering brain recalibration |
08:03 | < catadroid> | It's somewhat weird |
08:03 | <&McMartin> | RECALIBRATE, RECALIBRATE |
08:04 | <~Vornicus> | ...was that word in daleks.z5 |
08:04 | < catadroid> | Also Sussman is my new programming hero |
08:04 | <&McMartin> | My Obj-C redesign excercise cut the relevant codebase in half |
08:04 | <&McMartin> | I'm feeling pretty smug |
08:04 | <&McMartin> | ... reading the Wizard Book, are we? |
08:06 | < catadroid> | I watched the lecture series on yt |
08:06 | < catadroid> | But more importantly, he did a lecture titled Legacy of Computers and I think it's the single greatest talk I've every watched and may remain so |
08:15 | | * Vornicus goes hunting through some of his old code, finds the algebra things he did some long time ago. |
08:15 | <~Vornicus> | i'd forgotten that I'd done piecewise functions |
08:16 | < catadroid> | I'll piece your wise |
08:16 | | * Vornicus gives catadroid a jigsaw puzzle of a brain |
08:16 | <&jeroud> | I want peace wise functions. |
08:16 | < catadroid> | I ALREADY HAVE ONE OF THOSE MAKE IT STOP D: |
08:17 | < catadroid> | And all the pieces have different dimensionality |
08:17 | < catadroid> | ...actually that would be really cool |
08:17 | <&jeroud> | I recently worked on a codebase called xenzen. |
08:17 | < catadroid> | I guess it's known as lego |
08:18 | <&jeroud> | That was made out of the exact opposite of peace wise functions. |
08:19 | < catadroid> | Peace Hating Programming |
08:36 | < catadroid> | I keep thinking about the essence of programming and how Lisp actually isn't |
08:36 | < catadroid> | So now I want to define what is |
08:36 | < catadroid> | Without descending into lambda calculus or machine theory |
08:37 | < catadroid> | Like, whether I can create a pithy syntax for primitives and combination in a way that can be extended to self describe in a way that Scheme almost but doesn't quite manage |
08:38 | < catadroid> | Types, incidentally, are important but not different in kind to logic programming |
08:38 | < catadroid> | They're just metadata for objects |
08:38 | < catadroid> | Haskell having different syntax to describe type types is annoying me |
08:39 | <~Vornicus> | something something programs are meant to be read by humans and only incidentally for computers to execute something something |
08:39 | < catadroid> | Actually, it's important that they be both |
08:39 | < catadroid> | I refer you to that legacy of computers talk I mentioned earlier |
08:39 | < catadroid> | It covers that |
08:39 | < catadroid> | It's basically *about* that |
08:42 | < catadroid> | If a program isn't sufficiently precise as to be executable, then the thinking is not useful, and if it is too complex as to be unreadable, then it is also not useful |
08:43 | < catadroid> | Mathematics is an approximation, designed to communicate abstractions. It is not designed to be systematically computed |
08:43 | < catadroid> | This FINALLY makes sense of the fact that I find it so hard to turn what ought to be rigorous mathematic truths into executable code |
08:43 | < catadroid> | Because whilst the thinking behind them may be rigorous, the notation actually is not |
08:44 | < catadroid> | Which then makes sense of why program code and maths look different |
09:14 | <&jerith> | catadroid: Also, mathematics in an inherently creative activity whereas computers aren't very good at creativity. |
09:16 | < catadroid> | I actually think I disagree. I think computers are great at the act of creating but bad at reasoning because they have no inherent needs |
09:16 | < catadroid> | So I think they have half of creativity |
09:16 | <&jerith> | Trying to reduce mathematics to something mechanical has broken plenty of incredibly talented people. |
09:16 | <&jerith> | See also: Incompleteness. |
09:16 | < catadroid> | Oh I don't think reducing it to that is the point |
09:17 | < catadroid> | The point is that when someone writes down equations for things like simple geometry and methods for r |
09:17 | <&jerith> | Creativity (as I see it, anyway) is a combination of inventing options and filtering those options. |
09:17 | < catadroid> | For it* |
09:17 | < catadroid> | Sure, but creativity is useless and indeed probably not even definable without a goal |
09:17 | <&jerith> | If your invention side is essentially random, your filtering has to be superb. |
09:18 | <&jerith> | (See evolution.) |
09:18 | < catadroid> | Human beings manage it |
09:18 | < catadroid> | We are excessively good at immediate goal selection for short term survival though, I suspect |
09:18 | <&jerith> | If your filtering is primitive (brute force evaluation or something) your invention has to be superb. |
09:19 | <&jerith> | catadroid: We have incredibly complex machinery in our squishy headmeat for both invention and filtering. |
09:19 | < catadroid> | Yes |
09:19 | < catadroid> | I need to get up and do something instead of talk about this I think |
09:20 | < catadroid> | I'm having trouble feeling like anything I have to say is worthwhile |
09:21 | <&jerith> | catadroid: Most of what anyone ever says isn't. |
09:21 | < catadroid> | I'm not sure that's actually true |
09:21 | <&McMartin> | That's where the filtering comes in :) |
09:21 | <&jerith> | But you're one of the people I go out of my way to have conversations with. |
09:22 | <&jerith> | So you say more worthwhile things than most people I interact with. |
09:22 | <&jerith> | (Worthwhile to me, at least.) |
09:22 | < catadroid> | Like, I have trouble reconciling the fact that Vornicus and others here refer to me as a C++ expert's expert |
09:22 | <&jerith> | I'm one of those others. :-) |
09:22 | <&jerith> | And it's a purely empirical observation. |
09:23 | <&jerith> | You might have the same kind of problem I used to have in this regard. |
09:23 | <&jerith> | I tend to compare myself to the best in the world in the areas I'm interested in. |
09:24 | < catadroid> | Oh it's a problem I've known for the longest time |
09:24 | <&jerith> | I spend a *lot* of time talking to people who are very good at what they do. |
09:24 | < catadroid> | I take all of the best characteristics of everything around me and go 'well, I'll never be her and I feel useless' |
09:24 | <&jerith> | And it turns out I'm quite good at what I do too, and I'm better than all of them at *something*. |
09:24 | < catadroid> | I think I'm at least a fairly competent C++ programmer |
09:25 | < catadroid> | I have so much trouble believing I'm anything more than that |
09:25 | <&jerith> | catadroid: Have you ever mentored junior programmers? |
09:26 | <&jerith> | Where "junior" here is more "inexperienced" than anything else. |
09:27 | | Kindamoody is now known as Kindamoody|afk |
09:27 | < catadroid> | Yes |
09:27 | <&jerith> | How do you find the experience? |
09:27 | < catadroid> | I like it |
09:28 | < catadroid> | Though I'm not sure what you are getting at |
09:28 | <~Vornicus> | arg. once again I find myself wishing for reliable typing but being unwilling/unable to actually switch to something that lets him do it. |
09:29 | <&jerith> | Vornicus: Try OCaml. :-) |
09:29 | <&jerith> | catadroid: I've found it gives me a better understanding of my own level of skill and experience. |
09:30 | <~Vornicus> | is there a game library that handles the event loop already for it |
09:30 | < catadroid> | I just want someone to tell me I'm not useless |
09:30 | <&jerith> | catadroid: You are very very very not useless. |
09:30 | <~Vornicus> | and is this game library as easy to get going as love |
09:30 | <&jerith> | Vornicus: There probably isn't, but it might be worth checking. |
09:31 | <&jerith> | catadroid: Do you ever speak at conferences? |
09:31 | < catadroid> | No |
09:31 | <~Vornicus> | 'cause selling point #1 for love was "I can get something that looks like something in about 20 minutes" |
09:31 | <&jerith> | catadroid: Try it sometime. |
09:31 | < catadroid> | I honestly don't want anyone to know I exist in case they attack me |
09:31 | <~Vornicus> | starting from "google love2d" |
09:31 | < catadroid> | To be brutally honest with you |
09:32 | <&jerith> | That's a problem I don't really have. |
09:32 | <&jerith> | I'd recommend finding a conference with a supportive community. |
09:32 | <~Vornicus> | talk in front of more than a few people? I'd rather chop my own arm off. |
09:32 | < catadroid> | See also gamergate and my own past |
09:33 | < catadroid> | I guess i probably have some interesting things to talk about |
09:33 | <&jerith> | And any advice I can give on the topic beyond that would be worse than useless, because my experiences are so different. |
09:33 | < catadroid> | I'm quite happy that people found insight in the first couple blog posts |
09:33 | <&jerith> | Instead of a conference, start at a local user group. |
09:33 | <&jerith> | Or your workplace. |
09:33 | < catadroid> | But everyone knows that girls can't code |
09:33 | <&jerith> | I don't know that. |
09:34 | | * Vornicus still wishes he could get his wife to learn to program some |
09:34 | < catadroid> | The thought that some people think that makes me scared |
09:34 | <&jerith> | I know that a lot of girls have been chased out of the industry. |
09:34 | < catadroid> | I just want who I am to be a non issue |
09:34 | < catadroid> | But I'm always going to be seen as some kind of diversity nonsense |
09:35 | < catadroid> | Why can't my primary characteristic be related to be ability? |
09:35 | < catadroid> | To my * |
09:35 | < catadroid> | I guess in here it is |
09:35 | < catadroid> | Until I start talking about it |
09:35 | <&jerith> | Not entirely. |
09:36 | <&jerith> | Communication skills are just as important in here as ability. |
09:36 | <&jerith> | So is enthusiasm. |
09:36 | <~Vornicus> | I am a vastly worse programmer than I let on |
09:36 | <&jerith> | Vornicus: Most people are. |
09:37 | <&jerith> | I'm incapable of reasoning about systems of even moderate complexity. |
09:37 | <&jerith> | Well, in the short term. |
09:37 | <&jerith> | Given enough time, I can internalise enough to get a grasp on some bigger things. |
09:38 | < catadroid> | I feel like I'm swimming furiously just to keep up with folk who are treading water |
09:38 | < catadroid> | Would you trust me to maintain a system? |
09:38 | <&jerith> | But diving into a new codebase, it's usually days before I can think about things broader than individual functions and direct interactions between them. |
09:38 | <&jerith> | catadroid: I don't trust *me* to maintain a system. |
09:38 | < catadroid> | I think that's fairly normal |
09:38 | < catadroid> | Incidentally |
09:39 | < catadroid> | Based on what I know about abstraction and learning, I strongly suspect that there is no other way to learn a system |
09:39 | < catadroid> | Not one that will let you maintain it and make good decisions about it, anyway |
09:39 | <&jerith> | I've spent two decades figuring out how to counter this major weakness in my working memory and related congnitive abilities. |
09:39 | <&jerith> | *cognitive |
09:39 | < catadroid> | I certainly don't think I do anything differently to what you described |
09:40 | < catadroid> | I don't think anyone *can* |
09:40 | <&jerith> | And that is to localise complexity aggressively and write tests for everything. |
09:40 | <&jerith> | catadroid: Sure, it's a spectrum and in general humanity's terrible at that sort of thing. |
09:40 | < catadroid> | I've also seen people assume they already know about a system and ruin it by applying their poorly based analogy |
09:40 | <&jerith> | My point is that I'm a lot worse than most. |
09:41 | <&jerith> | But I've learned how to deal with it and that makes me much more effective. |
09:41 | | * catadroid nods |
09:41 | <&jerith> | Also, I learned how to deal with it long before I even realised what my problems were and that I was actually dealing with them. |
09:41 | <&jerith> | It just felt like the right way to do things. |
09:42 | | * Vornicus is really good at figuring out the big picture in a system, but has no idea at all how to write tests. |
09:42 | <&jerith> | Vornicus: That just takes practice. |
09:42 | <&jerith> | Unfortunately, there are very few tools to make writing tests easier. |
09:43 | <@abudhabi> | Do like Paradox Interactive: Your release is your testing. :V |
09:43 | <&jerith> | abudhabi: That's demonstrably untrue. |
09:43 | <@abudhabi> | Oh? |
09:43 | <&jerith> | Their games are incredibly complex in ways that are almost impossible to test in an automated fashion. |
09:44 | <@abudhabi> | Which contradicts my statement how? |
09:44 | < catadroid> | Tests are hard |
09:44 | <&jerith> | The kind of bugs automated testing helps with are very seldom present in their games, in my experience. |
09:44 | < catadroid> | I can tell you from experience that there's basically no automated testing in games |
09:45 | <&jerith> | The kind of bugs I've seen are mostly interactions between individually complex pieces of game logic. |
09:45 | < catadroid> | And, honestly, it impedes game authors ability to actually make gameplay |
09:45 | <&jerith> | catadroid: I've written games with automated tests, and sometimes they've helped. |
09:45 | < catadroid> | Same |
09:46 | <~Vornicus> | I've got all these mathy parts. They need testing. How do I test them? I have no idea! There's floating point numbers involved! Highly inexact algorithms! |
09:46 | <&jerith> | It's one of the few areas where test-first really doesn't work. |
09:46 | <&jerith> | Vornicus: Do you have some examlpe code you'd like to test? |
09:46 | <&jerith> | Actually, that's a terrible way to start. |
09:46 | < catadroid> | It does help for deep engine parts that are very precisely defined though |
09:46 | < catadroid> | I think unit tests and types are actually the same thing |
09:46 | < catadroid> | Interestingly |
09:46 | <&jerith> | Vornicus: Do you have some code you're about to write that you'd like to test. |
09:46 | <&jerith> | ? |
09:47 | <&jerith> | catadroid: They're not, but they overlap a lot. |
09:47 | < catadroid> | They have the same kind of properties when it comes to reasoning about code |
09:47 | <~Vornicus> | jerith: I'm in the middle of porting a bunch of functions about polynomials into a Polynomial class |
09:48 | < catadroid> | I agree they have different properties, but they are often used to achieve similar goals |
09:48 | <&jerith> | catadroid: Also, I've found it useful to have some broad tests around generic game logic just to make sure I don't unintentionally change important behaviour I've decided I want. |
09:48 | < catadroid> | Oh, absolutely |
09:48 | < catadroid> | I'm not saying tests are unhelpful, at all |
09:49 | < catadroid> | I'm saying that large gameplay systems are often best tested by playing |
09:49 | <&jerith> | catadroid: A good type system can reduce the amount of test code you need to write. |
09:49 | < catadroid> | And tests very frequently become outdated before they are very useful |
09:49 | <~Vornicus> | once I have that working then I get to turn all of my oher code into using the polynomial system |
09:49 | < catadroid> | I would like to have both good static types and good tests |
09:50 | <&jerith> | Vornicus: What language is this in? |
09:50 | <~Vornicus> | Lua + love2d |
09:50 | <&jerith> | Does lua have an obvious first choice for a testing tool? |
09:51 | <&jerith> | (Java has JUnit, Python has stdlib unittest, etc.) |
09:51 | <~Vornicus> | luaunit |
09:51 | <&jerith> | (Some languages have multiple options without a clear best starting point.) |
09:51 | <&jerith> | Have you used luaunit before? |
09:51 | <~Vornicus> | couple times. |
09:52 | <&jerith> | So you know the mechanics. |
09:52 | <~Vornicus> | yeah. |
09:52 | <&jerith> | How far into the refactoring are you? |
09:53 | <&jerith> | (Refactoring is actually a great place to learn about testing because you already have a good understanding of what the code needs to do.) |
09:53 | <~Vornicus> | I've got one function left to move. |
09:54 | <&jerith> | If you're not almost finished and you want to use this as an opportunity to learn testing, I'd recommend putting what you have aside and starting again. |
09:54 | <&jerith> | Ah. |
09:54 | <&jerith> | Maybe put it aside and start again anyway. You can always get it back later if you want. |
09:55 | <~Vornicus> | neh. the next step is to rejigger all the existing physics code to use the polynomial class |
09:56 | <&jerith> | Assuming you want to do this. I have the time and enthusiasm for it at the moment, but there are plenty of other things I could do instead. :-) |
09:57 | <&jerith> | Rejiggering physics code to use the polynomial class might also be a good opportunity to learn about testing, but building the polynomial class would be better. :-) |
09:57 | <~Vornicus> | I have neither at the moment |
09:57 | <~Vornicus> | I should have been in bed an hour and a half ago |
09:57 | <&jerith> | Ah. |
09:57 | <&jerith> | I'll probably still be around when you get up if you're keen then. |
09:58 | <~Vornicus> | indeed |
09:58 | <&jerith> | Otherwise just shout if and when you want to try this and I'll see if I can make the time. |
09:58 | <~Vornicus> | I actually have not-quite-smoke level tests for polynomials that I can port directly from when I did a polynomial class for depixel~ |
10:01 | <~Vornicus> | (the only one I don't have something for is the function I still need to port.) |
10:01 | <~Vornicus> | okslep |
10:02 | | * Vornicus curls up atop catadroid's head, snoozes, learns her programmery secrets like charlemagne learned to read |
10:02 | <&jerith> | Vornicus: You'll probably really like property-based testing. |
10:03 | < catadroid> | :o |
10:03 | <&jerith> | And a quick websearch finds lua-quickcheck which doesn't have any of my first glance "this is terrible" markers. |
10:03 | < catadroid> | My mind is a weird place |
10:04 | <&jerith> | https://www.youtube.com/watch?v=zi0rHwfiX1Q is one of my favourite talks ever. |
10:05 | < catadroid> | That looks interesting |
10:05 | < catadroid> | It immediately interests me because it's from a clojure conference ^^ |
10:05 | <&jerith> | I'm pretty sure there's no clojure in it. |
10:08 | < catadroid> | I don't overly care |
10:08 | | Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds] |
10:08 | < catadroid> | I've seen a lot of good talks from that conference, not that many concern the language directly |
10:13 | | catadroid [catadroid@Nightstar-o6prjn.dab.02.net] has quit [[NS] Quit: Bye] |
10:51 | | catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has joined #code |
13:59 | | Kindamoody|afk [Kindamoody@Nightstar-0lgkcs.tbcn.telia.com] has quit [[NS] Quit: Got stuff to do, bbl] |
15:26 | | celticminstrel [celticminst@Nightstar-ehtgrr.dsl.bell.ca] has joined #code |
15:26 | | mode/#code [+o celticminstrel] by ChanServ |
15:39 | | catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has quit [[NS] Quit: Leaving] |
17:49 | | catalyst [catalyst@Nightstar-bt5k4h.81.in-addr.arpa] has joined #code |
17:56 | | Vornicus [Vorn@ServerAdministrator.Nightstar.Net] has joined #code |
17:56 | | mode/#code [+qo Vornicus Vornicus] by ChanServ |
18:08 | | Kindamoody|autojoin [Kindamoody@Nightstar-qicmpi.tbcn.telia.com] has joined #code |
18:08 | | mode/#code [+o Kindamoody|autojoin] by ChanServ |
19:02 | | Kindamoody|autojoin [Kindamoody@Nightstar-qicmpi.tbcn.telia.com] has quit [Ping timeout: 121 seconds] |
20:11 | | Derakon[AFK] is now known as Derakon |
20:37 | <@abudhabi> | Hm. So how do regexing through a file's lines for matches and removing those matched lines work in Python? |
20:38 | <@abudhabi> | This sort of thing was a command-like one-liner in Perl, I recall. |
20:38 | <@abudhabi> | *command-line |
20:40 | <&[R]> | `grep -v` does that too |
20:40 | <&McMartin> | Python, unlike Perl, does not have a "use a grep-style runloop" thing |
20:40 | <&[R]> | Do you have an example of Python doing the opposite, because I'm not understanding your intent here. |
20:40 | <&McMartin> | So you have to do a loop with readline() and then print the lines you want to keep |
20:41 | <@abudhabi> | Find matching lines, remove matching lines. If grep can do that, that is more than acceptable. |
20:51 | <@ErikMesoy> | abudhabi: http://stackoverflow.com/a/5463419 ? |
20:53 | <@celticminstrel> | for line in file_obj: works. |
20:53 | <@celticminstrel> | I guess you'd just output any lines that didn't match. |
20:54 | | gizmore [kvirc@Nightstar-61lcur.dip0.t-ipconnect.de] has quit [Ping timeout: 121 seconds] |
20:55 | | gizmore [kvirc@Nightstar-sf4plu.dip0.t-ipconnect.de] has joined #code |
21:32 | | Kindamoody [Kindamoody@Nightstar-0lgkcs.tbcn.telia.com] has joined #code |
21:32 | | mode/#code [+o Kindamoody] by ChanServ |
22:19 | <&McMartin> | If this is being fed into a shell script or used as a filter that way, as opposed to some larger computational process, grep is a better tool than python |
22:19 | <&McMartin> | But python shouldn't shell out to grep for this |
22:27 | <&Derakon> | import re; for line in open(filename, 'r'): if re.match(pattern, line): print line; |
22:28 | <&Derakon> | I think something like that will do the job. |
22:28 | <&McMartin> | Well, with the extra ! because he wants to not match |
22:28 | <&McMartin> | Also, I think you don't want match but, um, the one that's "some substring matches" |
22:39 | <&[R]> | test? |
22:39 | <@Azash> | search |
23:02 | | * Vornicus pokes vaguely around for jerith |
23:02 | <&jerith> | I am here! |
23:03 | <&jerith> | I have a chicken pie! |
23:03 | <&jerith> | I also have a dog! |
23:03 | <&jerith> | These two things must be kept apart or I shall only have one of them! |
23:03 | <~Vornicus> | RIP dog, defeated by a rogue chicken pie |
23:03 | <@Tamber> | xD |
23:03 | <&Derakon> | Vorn beat me to it. |
23:04 | <&jerith> | Yes. She isn't the most graceful dog in the world. |
23:04 | <&jerith> | It's entirely possible that the chicken pie could win. |
23:04 | <&jerith> | Not *likely*, but *possible*. |
23:13 | <~Vornicus> | do you have time + enthusiasm for testing? |
23:14 | <&jerith> | I do, for probably about an hour or so. |
23:14 | <&jerith> | Maybe a bit longer. |
23:16 | | * Vornicus starts his twitch stream in case you want to look over his shoulder on this. https://www.twitch.tv/vornotron |
23:18 | | * jerith looks at some lua. |
23:18 | < ToxicFrog> | lua \o/ |
23:19 | <&jerith> | Did you watch that John Hughes video I linked earlier, btw? |
23:19 | <~Vornicus> | I don't remember seeing one? |
23:19 | <&jerith> | It was just after you went to bed. |
23:19 | | * Vornicus checks the second sight |
23:20 | <&jerith> | Well, just after you said you were going. Before your client disconnected. |
23:20 | <&jerith> | https://www.youtube.com/watch?v=zi0rHwfiX1Q |
23:20 | <~Vornicus> | yeah, I didn't see it |
23:21 | <&jerith> | It's worth watching, but probably best to leave it until after I go to bed. :-) |
23:25 | <&jerith> | You don't sound at all like I imagined. |
23:25 | | Vorntastic [Vorn@Nightstar-uhn82m.ct.comcast.net] has joined #code |
23:26 | <&jerith> | This is the point at which you should be writing the tests, not the code. ;-) |
23:26 | <&jerith> | That's important because you want your tests to fail before the code works. |
23:27 | <&jerith> | When I'm refactoring like this, I'll often comment out most of the code for the test writing. |
23:28 | <&jerith> | Hrm. I keep losing your stream. |
23:29 | <&jerith> | Back. |
23:30 | <&jerith> | Start with a trivial case. |
23:31 | <&jerith> | The most trivial polynomial is "0". :-) |
23:32 | <&jerith> | Your first test is really to make sure that you're calling it right, etc. |
23:33 | <&jerith> | Can we see the place it's running? |
23:35 | <&jerith> | Can you make the text bigger? Your terminal is too small for the stream resolution. |
23:35 | <&jerith> | Much better. |
23:36 | <&jerith> | Thanks. :-) |
23:37 | <&jerith> | 0(x) |
23:38 | < ToxicFrog> | Coincidentally, my current lua project is heavily refactoring the map loading/generating code in ttymor, and adding tests for it |
23:38 | < ToxicFrog> | (test coverage in ttymor is awful right now) |
23:38 | < ToxicFrog> | Also using luaunit, although I've wrapped it in a shell script to make the output tastier. |
23:38 | <&jerith> | That's an example of calling a number value, not actual debugging. |
23:39 | <&jerith> | You probably want a new test function for each code path. |
23:45 | <&jerith> | Maybe use {0, 0.6, 0.4} instead? |
23:45 | <&jerith> | Having different values in there makes the test slightly clearer. |
23:46 | <&jerith> | (And also catches indexing errors and such.) |
23:48 | <&jerith> | In testAdd you might also want to check some actual result coefficients. |
23:49 | <&jerith> | (f+g)(x) == f(x)+g(x) is a great test, though. |
23:50 | <&jerith> | Except it relies on evaluation working correctly. |
23:51 | <&jerith> | I think one side of your assertion is getting a polynomial instead of a coefficient or something. |
23:51 | <&jerith> | Maybe weird precedence? |
23:52 | <&jerith> | Ah. |
23:53 | <&jerith> | Can you test polynomial equality? |
23:54 | <&jerith> | Polynomial {1, 2} == Polynomial {0.5, 0.5} + Polynomial {0.5, 1.5} for example. |
23:55 | <&jerith> | That might be useful for some test examples. |
23:55 | <&jerith> | :-) |
23:55 | <&jerith> | I think it's a usfeul thing to have. |
23:55 | <&jerith> | Also a useful thing. |
23:55 | <&jerith> | Ah, floating point. |
23:56 | <&jerith> | It'll work for some magic examples, though. |
23:56 | <&jerith> | Values that fit nicely into IEEE754. |
23:57 | <&jerith> | Would a nearlyEquals() method or something be appropriate? |
23:58 | <&jerith> | Is there a more or less standard solution for float equality in lua? |
23:58 | <&jerith> | (I think Python grew one in 3.something.) |
23:58 | <~Vornicus> | http://luaunit.readthedocs.io/en/latest/#assertAlmostEquals |
23:58 | <&jerith> | Your sound went away. Was it supposed to? |
--- Log closed Sun Sep 04 00:00:57 2016 |