code logs -> 2011 -> Mon, 21 Mar 2011< code.20110320.log - code.20110322.log >
--- Log opened Mon Mar 21 00:00:07 2011
00:18 You're now known as TheWatcher[T-2]
00:21 You're now known as TheWatcher[zZzZ]
00:23 cpux [chatzilla@510B1D.8D602E.9FE2BE.9FAE21] has joined #code
00:55
< Tarinaky>
I feel dirty for this hackish function :/
00:56
< Tarinaky>
It involves a static std::map of std::maps of std::maps of... In order to cache graphics so they're drawn once on demand and can be reused again and again.
00:57
< Tarinaky>
(I'm using pointers to constants as keys, so comparisons are hopefully relatively cheap)
01:01
< Tarinaky>
It works though. So it can't be so evil I guess.
01:04
<@ToxicFrog>
...why are they nested so deeply?
01:04
< Tarinaky>
Because there;s f
01:05
< Tarinaky>
Stupid laptop keyboard.
01:05
< Tarinaky>
There's four parameters for drawing the glyphs.
01:05
< Tarinaky>
So there's a map for each parameter.
01:07
<@ToxicFrog>
Does C++ not have a Tuple4 type or something?
01:07
< Tarinaky>
Three of the parameters are pointers, which means they're already word-length (unless I misunderstand something). So generating a compound probably wouldn't be any more efficient.
01:07
<@ToxicFrog>
I'm thinking readability here, not efficiency.
01:08 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [[NS] Quit: Z?]
01:08
< celticminstrel>
(unrelated) Parse a comma-separated string of integers and get a list: map(int,map(str.strip,val.split(',')))
01:08
<@ToxicFrog>
That said, this is basically implying the creation of up to three maps per glyph
01:08
< celticminstrel>
Nice and concise. :)
01:08
<@ToxicFrog>
celticminstrel: python?
01:08
< celticminstrel>
Yup.
01:09
< Tarinaky>
ToxicFrog: A forground colour and a background colour.
01:09
<@ToxicFrog>
Tarinaky: ?
01:09 Phox [Tertius_Vul@EB02D1.0F3E21.BE1EAF.350E2F] has quit [NickServ (GHOST command used by Neophox)]
01:09
<@ToxicFrog>
I though you said there were four parameters?
01:09
<@Derakon>
CM: you should be able to just do map(int, val.split(','))
01:09
< Tarinaky>
The other one is for the font used because 'in for a penny in for a pound'.
01:09 Phox [Tertius_Vul@EB02D1.0F3E21.BE1EAF.350E2F] has joined #code
01:09
< celticminstrel>
I thought standard C++ containers didn't nest well in standard C++ containers.
01:09
<@Derakon>
Python excises whitespace from around strings automatically when you cast the string to an int.
01:09
< Tarinaky>
celticminstrel: You thought wrong. It's just ugly as sin.
01:10
< celticminstrel>
Derakon: Eh. Still concise.
01:10
< celticminstrel>
Tarinaky: I can imagine.
01:11
< celticminstrel>
By the way: for tuples in C++, I'd suggest just making a struct.
01:11
< Tarinaky>
Of course, that'd require (in this context) making every permutation of glyph, colours and such a constant.
01:12
< Tarinaky>
Which'd make memory use baloon as well as being a drain on Programmer time.
01:13
<@ToxicFrog>
What?
01:13
<@ToxicFrog>
Why?
01:13
<@ToxicFrog>
What is the fully expanded type of the maps you're using?
01:14
< Tarinaky>
Because two structs with the same value don't have the same address in memory and performing comparisons on structs is a Bad Thing(tm)
01:14
< Tarinaky>
(As well as requiring you to work out what the hell it even means for two structs to be less than or greater than each other)
01:15
<@ToxicFrog>
I may be understimating how much work maps are in C++ :/ I'm used to them being effortless language builtins these days.
01:15
<@ToxicFrog>
Still- what is the type?
01:16
< Tarinaky>
http://pastebin.com/z5U52XuV
01:17
<@ToxicFrog>
Aah.
01:17 * ToxicFrog does thirty seconds of research, learns that tuples are apparently a Boost thing, not a builtin thing
01:19
< celticminstrel>
Tarinaky: Write an operator== for the struct.
01:19
< celticminstrel>
And if you need it, an operator<
01:19
< celticminstrel>
And that's correct ToxicFrog.
01:21
< Tarinaky>
celticminstrel: Maybe if I revisit it or do it in future. At the moment it just works though.
01:29
<@Namegduf>
std::pair exists, however
01:37
<@ToxicFrog>
Yeah, but then we end up with a std::map<std::pair<std::pair<TTF_Font *, int>, std::pair<const SDL_Color *, const SDL_Color *>>, SDL_Surface *>
01:37
<@ToxicFrog>
Which is, well, hardly an improvement
01:37
<@ToxicFrog>
C++ ;.;
01:38
< Tarinaky>
C++ <3
01:47
<@Namegduf>
I suspect it's an improvement to doing four map lookups instead of one.
01:48
<@Namegduf>
And constructing three pairs is probably cheaper than constructing three maps.
01:48
<@Namegduf>
But yes, it isn't pretty either.
01:48
<@ToxicFrog>
Yeah, but it's still - yes.
01:49
<@ToxicFrog>
C++ is a language for masochists with an OO fetish who nonetheless are not turned on by Java~
01:49
<@Namegduf>
Haha.
01:49
<@Kazriko>
Or who work on hardware where Java won't work...
01:50
<@Namegduf>
C++ is for when you want more features than C (whichever features they are, C++ will probably have them) but need it to run as fast as C.
01:51
<@Namegduf>
Of course, that presents no arguments for *why* you want more features, but I'm assured that it's very helpful in some usecases.
01:51 * Namegduf isn't sure he buys it. Use of pure virtual classes to emulate interfaces is not *too* evil, though.
01:51
<@ToxicFrog>
C++ is for when you want more features than C, need C speed, somehow can't use D, Java, or anything else that compiles to machine code or has a fast JIT, and don't mind your code being incredibly fucking ugly.
01:51
<@ToxicFrog>
IME, this is a situation so rare as to be nonexistent.
01:51
<@Kazriko>
Yep, none of that stuff works when you're locked into proprietary hardware.
01:52
<@Namegduf>
Java doesn't run as fast as C.
01:52
<@Kazriko>
like 33mhz arms with a wonky OS.
01:52
<@ToxicFrog>
Java starts up slower than C, and uses more memory, but the modern JIT will hit C speeds reliably.
01:52
<@Namegduf>
It hypothetically can if you write it in an unidiomatic way and ignore startup time, the GC, and memory.
01:52
<@ToxicFrog>
The GC means it's probably not suitable for realtime use unless you take manual control of it, though.
01:52
<@Namegduf>
Memory usage tends to matter more than CPU usage gaps, though, with Java.
01:53
<@ToxicFrog>
But if you're doing realtime stuff you probably aren't using C++ anyways.
01:53
<@Kazriko>
Eh, aside from the OS being incapable of realtime stuff, C++ is actually not terrible if you enforce some rules on yourself.
01:53
<@Namegduf>
As for D... D has multiple versions, none of which are both complete and having all the features
01:53
<@Namegduf>
I hear it only recently got x86_64 working...
01:54
<@ToxicFrog>
Yeah, but once you're done enforcing those rules, why not use C and have way fewer issues to deal with?
01:54
<@Kazriko>
I hate manually managing virtual function call tables.
01:54
<@Namegduf>
It might actually work in a given use case but they need to actually finish it properly before it's a valid option.
01:54
<@Namegduf>
And *then* they can start work on getting it supported and used.
01:55
< Tarinaky>
Back. C++'s Tuples are called std::vectors :p
01:55 * Tarinaky ducks.
01:55
<@ToxicFrog>
Well, yes
01:55
<@Namegduf>
Can you use those?
01:55
<@ToxicFrog>
Nonetheless, my underlying point is that if you're doing realtime work, you're probably better off with C, and if you aren't, you're better off in a HLL.
01:56
<@Namegduf>
Games development seems to be a common home for C++
01:56
< Tarinaky>
Yeah.
01:56
<@Kazriko>
C would be inordinately difficult to do what I'm doing in.
01:56 * Tarinaky is writting a game, so C++ isn't a silly choice.
01:57
<@Namegduf>
Is it because your operations are hard to in C, or because your design is hard to do in C?
01:57
< celticminstrel>
Tarinaky: Those aren't tuples; they're dynamic arrays. The difference being that tuples are heterogenous and arrays are homogenous.
01:57
<@Kazriko>
I've actually ported a very limited, fixed version of my program to C...
01:57
<@Kazriko>
but it's too static and inflexible.
01:57
< celticminstrel>
As for Java, it can get pretty ugly too in some cases.
01:58
<@Namegduf>
Java *is* ugly
01:58
<@Namegduf>
It's a language deissgned to limit the damage terrible coders can do, and let lots of bad ones produce working code.
01:58
< celticminstrel>
XD
01:58
<@Kazriko>
Useful for enterprise, since most of what they have are bad coders.
01:58
<@Namegduf>
Yes.
01:59
<@Namegduf>
Not ideal for anyone whose goal is better than working code, and it's terrible at helping good coders produce good programs. Not "fun" to work in.
02:00
< Tarinaky>
Also, I see a lot of C++ jobs advertised.
02:00
< Tarinaky>
At least, more so than for any other one languae.
02:00
< Tarinaky>
*language
02:00
<@Kazriko>
C++ isn't fun to work in, but with copious unit tests it's highly functional for making very flexible and configurable control systems. :)
02:01
<@ToxicFrog>
Control systems as in...?
02:01
< Tarinaky>
I'm working in C++ 'for fun'. >.>
02:01
<@Kazriko>
Oil and gas automation?
02:01
< Tarinaky>
C++ is Fun.
02:02
<@ToxicFrog>
Tarinaky: you see a lot of PHP jobs advertised as well. This has more to do with the huge install base of legacy PHP code than with PHP being a good language.
02:02
<@ToxicFrog>
Kazriko: why couldn't you use a HLL for that?
02:02
<@Namegduf>
C++ is a horrific language but so long as you stay in the C subset for as long as possible and use additional features as sparingly as possible you're okay.
02:02
<@Kazriko>
As I said before...
02:02
< Tarinaky>
ToxicFrog: Probably. Still, worth learning.
02:02
<@Kazriko>
33mhz Arm chip running a wonky OS that doesn't have any other compilers or interpretors.
02:02
< Tarinaky>
Namegduf: Really?
02:03
<@Kazriko>
It's C or C++, nothing else.
02:03
<@ToxicFrog>
Ok, so C++ is useful if you're operating under artificial constraints that preclude the use of other languages~
02:03
<@Namegduf>
Tarinaky: It has a lot of very arcane mechanics and rules and a Turing complete template system
02:04
< Tarinaky>
Namegduf: And the Turing complete template system is bad because?
02:04
<@ToxicFrog>
Tarinaky: C++'s biggest flaw (arguably; it has a lot of big flaws. At least most compilers mostly support most of the language these days...) it is that it is too big and too complicated to really understand without years of study and experience.
02:04
<@Namegduf>
Because you now have two programming languages?
02:04
<@Kazriko>
I wouldn't be using C++ if I had a choice in the matter, Python would be much more fun, and more capable for this task if it were supported.
02:04
<@Namegduf>
C++ is a huge, huge language
02:04
<@ToxicFrog>
Anyone who tells you they understand C++ is either lying or tragically mistaken; there's always some new edge case lurking around the corner, and you'll probably hit it next month.
02:04
< Tarinaky>
ToxicFrog: You can use that as an advantage whenever you need to wave your e-peen in people's faces though.
02:05
<@Kazriko>
I code primarily in C, but use C++ to handle the virtual functions and inheritance...
02:05
< celticminstrel>
I won't say I fully understand C++, but I think I have a fairly good understanding of it.
02:06
< Tarinaky>
I'm a lot better at C++ now than I was when I started.
02:06
<@ToxicFrog>
Tarinaky: not really, because if they're someone worth impressing their reaction will be "yeah, right"
02:06
< Tarinaky>
ToxicFrog: You never impress people by waving your e-peen. It's just to make yourself feel good.
02:09
< Tarinaky>
Also, as far as Linux dev goes - all the other HL C-likes are proprietary.
02:09
< Tarinaky>
C#/Mono is a full version behind Windows, Objective C is Apple, Java is Sun...
02:11
<@Kazriko>
I've been using C++ for 14 years, and I still don't know it all the way through.
02:15
<@Kazriko>
Also, there's that whole Oracle problem with Java.
02:16
<@ToxicFrog>
...why does it have to be a C-like?
02:16
<@ToxicFrog>
Use Scala, or Python, or Lua, or Scheme, or Erlang, or or or
02:17
<@ToxicFrog>
(also, you may have missed the memo, there are free-as-in-freedom JVM implementations these days)
02:17
<@Kazriko>
And they're being sued by Oracle...
02:17
<@Kazriko>
Even if one particular implementation isn't being sued yet, doesn't mean it won't be in the future.
02:18
< Tarinaky>
Mono and the free JVM implementations only exist as long as their corporate masters suffer them to.
02:19
<@ToxicFrog>
What, no, you're crazy
02:19
<@Namegduf>
Mono is supposed to exist.
02:20
<@Namegduf>
It's there so MS can meet the "portability" checkmark while providing a superior experience on Windows, thus bolstering it as a platform more than would be the case if there was no Mono.
02:20
<@Kazriko>
For as long as it fits with their corporate vision.
02:20
<@Kazriko>
They've done that before. IE for other platforms is another example.
02:20
<@ToxicFrog>
And you still haven't answered my question
02:21
<@Kazriko>
which?
02:21
< Tarinaky>
I've had issues with Python.
02:22
<@ToxicFrog>
"Why does it have to be C-like"
02:22
< Tarinaky>
C-likes are more familiar to me.
02:22
<@ToxicFrog>
Specifically, it went "why use C++" -> "because all of the other high-level C-likes are proprietary, which causes issues for linux compatibility"
02:23
<@Namegduf>
Java is less C-like than Python
02:23
<@ToxicFrog>
Which is (a) wrong full stop, (b) wrong in the implication that C or C++ are high-level languages, and (c) confusing in the implication that only C-like languages are worthy of consideration
02:23
<@Namegduf>
I mean, it emulates the appearance but in terms of style of programming, it's much more weird.
02:24
< celticminstrel>
Tarinaky: JavaScript. :P
02:24
< celticminstrel>
It's like Python, but C-like.
02:24
< Tarinaky>
Okay. This conversation's too silly.
02:24
< celticminstrel>
Though possibly a tad less friendly, and without Python's extensive library.
02:24 * Tarinaky goes to do something else.
02:24
< celticminstrel>
XD
02:25
<@Kazriko>
C/C++ are lower level than Pascal. heh
02:25
<@ToxicFrog>
celticminstrel: well, it depends on whether you mean "C-like semantics" or "C-like syntax"; it has the latter (sorta), not the former.
02:25
<@ToxicFrog>
But in any case, why does that matter?
02:26
< celticminstrel>
True. And it doesn't, really.
02:27
<@Kazriko>
You know, I imagine Javascript for writing games may increase in the near future.
02:27
<@Kazriko>
WebGL, you know.
02:27
<@Kazriko>
Have you tried the new google maps with google earth support? You can drop straight into a webgl version of google earth right on the web page.
02:28 Attilla [Some.Dude@37647E.0E7447.22C7B1.567421] has quit [Ping timeout: 121 seconds]
02:31
< celticminstrel>
Ah yes, and HTML5.
02:39
<@Kazriko>
The google earth webgl is faster than google maps with satellite on my computer
02:41
<@Namegduf>
Kazriko: Link?
02:41
<@Kazriko>
maps.google.com, then there's a dropdown to select mode, earth mode should be in the list if you have a good enough browser installed.
02:41
<@Kazriko>
I use the latest chrome for it.
02:42
<@Kazriko>
the chrome on my linux box doesn't support it though.
02:42
<@Namegduf>
I have the latest Chrome, and it supports WebGL in experiments, but it doesn't appear. Linux, yeah.
02:43
<@Kazriko>
It's working on my windows box here and at work, but not on the linux one yet.
02:44
<@Kazriko>
Hmm. I wonder if it actually is webgl...
02:46
<@Kazriko>
Maybe they're being sneaky and just embedding google earth as a plugin...
02:48 * Kazriko uninstalls google earth to try it...
02:51
<@Kazriko>
Ugh. yep, it's a plugin. *grumble*
04:25 Kindamoody is now known as Kindamoody[zZz]
05:07 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
05:27 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [[NS] Quit: If the world didn't suck, we'd all fall off.]
05:31 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has quit [[NS] Quit: And lo! The computer falls into a deep sleep, to awake again some other day!]
05:45 Derakon is now known as Derakon[AFK]
06:13 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has joined #code
08:35 AnnoDomini [annodomini@D553D1.41311B.78E477.38AFDE] has joined #code
08:35 mode/#code [+o AnnoDomini] by Reiver
08:42 You're now known as TheWatcher
09:02 Kindamoody[zZz] is now known as Kindamoody
09:57 gnolaptop [lenin@Nightstar-1f37a239.eduroam.liu.se] has joined #code
10:02 AnnoDomini [annodomini@D553D1.41311B.78E477.38AFDE] has quit [[NS] Quit: leaving]
10:47 AnnoDomini [annodomini@F67919.F326B3.98D923.BDA7B6] has joined #code
10:47 mode/#code [+o AnnoDomini] by Reiver
10:50 gnolaptop [lenin@Nightstar-1f37a239.eduroam.liu.se] has quit [[NS] Quit: Blergh]
11:08 Kindamoody is now known as Kindamoody|lunch
11:26 Attilla [Some.Dude@Nightstar-92c9199f.cable.virginmedia.com] has joined #code
11:26 mode/#code [+o Attilla] by Reiver
11:27 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
11:44 Kindamoody|lunch is now known as Kindamoody
11:54 Kindamoody is now known as Kindamoody|out
12:16 AnnoDomini [annodomini@F67919.F326B3.98D923.BDA7B6] has quit [[NS] Quit: leaving]
12:19 celticminstrel [celticminstre@Nightstar-f8b608eb.cable.rogers.com] has joined #code
13:11 SmithKurosaki [smith@DCDEB4.F95CFD.2EEAA4.B1AE3D] has joined #code
14:42 SmithKurosaki [smith@DCDEB4.F95CFD.2EEAA4.B1AE3D] has quit [Ping timeout: 121 seconds]
14:43
< simon_>
q
14:48
<@VornicusVashicus>
r?
14:49
<@TheWatcher>
d, the q for austrialians.
15:08 Reiv [orthianz@3CF3A5.E1CD01.36D449.95F5A5] has quit [Connection reset by peer]
15:08 Reiv [orthianz@3CF3A5.E1CD01.36D449.95F5A5] has joined #code
15:40 Syloqs-AFH [Syloq@NetworkAdministrator.Nightstar.Net] has quit [Ping timeout: 121 seconds]
16:51 SmithKurosaki [smith@Nightstar-7820a96a.dsl.teksavvy.com] has joined #code
16:58 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has quit [Ping timeout: 121 seconds]
17:14 Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has joined #code
17:38
< Tarinaky>
TheWatcher: Don't be silly. They flip the bits upside down when they cross the equator.
17:50
< simon_>
Tarinaky, is that what they call median-endian?
18:01 * gnolam slips another byte on the barbie.
20:32 Kindamoody|out is now known as Kindamoody
20:53
< Tarinaky>
Is it wrong that I don't understand how to do test cases?
20:53 * Tarinaky facepalms.
20:55
<@ToxicFrog>
In what sense?
20:55
<@ToxicFrog>
You don't understand what they are, how to design them, how to implement them, how to use them, why they're useful, other?
20:55
< Tarinaky>
How to design, implement and use them.
20:55
< Tarinaky>
I understand what they are and why they're useful.
21:01
<@ToxicFrog>
Well, broadly speaking, it goes like so:
21:02
<@ToxicFrog>
- identify a behaviour in your software you want to test for. For example, in my vstruct library, one such behaviour is that unpack("b1", x"01") should return true.
21:02
<@ToxicFrog>
- write a function to test that behaviour.
21:06
< Tarinaky>
Most of what I write seem to be games or variants thereof. So it seems a little... difficult...
21:11
<@ToxicFrog>
Sorry, lengthy absences because I'm TAing a lab
21:11
<@ToxicFrog>
- write a function to test that behaviour.
21:11
<@ToxicFrog>
function test_boolean_true() return unpack("b1", x"01") == true end
21:11
<@Namegduf>
TDD has a nice stance on it.
21:11 Kindamoody is now known as Kindamoody|chore
21:12 Kindamoody|chore is now known as Kindamoody|chores
21:12
<@ToxicFrog>
- add the function to the test list
21:12
<@Namegduf>
Your tests should define what your stuff needs to do to work.
21:12
<@ToxicFrog>
And then, to actually *test*, you iterate the test list and if any of them fail, yell.
21:12
<@Namegduf>
Or to meet its specificatin, rather.
21:12
<@Namegduf>
*ion
21:12
<@ToxicFrog>
TDD is a variation on this where you write the test first; you specify the behaviour, write a test, run the test (which fails), and then implement the code.
21:13
< Tarinaky>
Aye, I've seen that.
21:13
<@ToxicFrog>
(it stands for Test Driven Development, incidentally, and is the approach I'm using to add more robust error handling to vstruct)
21:13
< Tarinaky>
I'm not sure how one goes about writing test cases for a graphical game though. Most of the functions frequently don't return anything - instead messing around with either an internal state or some kind of black box library.
21:14
<@Namegduf>
I'm not a fan of writing it first rather than simultaneously, because I often think of ways to make things neater while writing stuff.
21:14
<@Namegduf>
But in terms of "what to test", it informs well.
21:14
<@ToxicFrog>
Then - barring a redesign - your test case should do that, then interrogate the internal state to make sure it's correct.
21:14
< Tarinaky>
Redesign is not a bad idea.
21:14
<@Namegduf>
There are things which are hard to unit test.
21:14
<@Namegduf>
Graphical output is one of them.
21:15
< Tarinaky>
I got more or less where I wanted to with the C++ program so I can go back and try something new now.
21:15
<@ToxicFrog>
And yeah, there are things that are bastards to unit test, including graphical user interfaces, graphics and sound output, and networking.
21:16
<@ToxicFrog>
I can't really give a lot of advice on unit testing because the only project I have actually developed comprehensive tests for is vstruct, which is a mostly-referentially-transparent library for (de)serialization and is thus dead easy to test.
21:16
< Tarinaky>
So I guess I should concentrate on testing the things that are easy to test?
21:17
< Tarinaky>
And just accepting the things I can't?
21:17
<@McMartin>
One of the "advantages" of test-driven development is that it leads you towards designs that are easy to test~
21:17
<@McMartin>
So, for network stuff, for instance, you have a mostly-referentially-transparent library that you unit test locally and then a pet machine that feeds stock replies for automated systemic tests.
21:18
<@McMartin>
GUI, sound, general user experience stuff cannot be unit tested sensibly, I don't think. The unit test is "watch a user interact with it".
21:21
<@jerith>
Which is why your GUI layer should be as thin as possible.
21:21
< Tarinaky>
Thin?
21:22
<@jerith>
Should to as much as possible.
21:22
<@jerith>
Erm.
21:22
<@jerith>
As little as possible.
21:24
< Tarinaky>
Stupid question. How do you find out what python version ipython is using?
21:24
<@jerith>
Clicking on a button should call a testable function, not do a bunch of stuff in the handler.
21:24
< Tarinaky>
And is it possible to put it into python 2.7 'mode'.
21:24
<@jerith>
lantea:~ jerith$ ipython
21:24
<@jerith>
Python 2.5.4 (r254:67916, Jun 24 2010, 21:47:25)
21:26
< Tarinaky>
Ahah.
21:26
< Tarinaky>
I'm a little concerned that there's no way to control the interpretter version.
21:26
< Tarinaky>
Since, you know... porting from 2.7 to 3 is nontrivial.
21:27
<@jerith>
Quite.
21:27
< Tarinaky>
Am I missing something obvious in the manual?
21:27 * jerith has worked on two nontrivial porting problems.
21:27
<@jerith>
*projects
21:29
<@jerith>
What are you porting?
21:30
< Tarinaky>
I'm not.
21:31
< Tarinaky>
I want to start a python2.7 project because I've had terrible luck using pygame in 3.
21:31
< Tarinaky>
ipython is, currently, using python2.7 - but I'm worried that there's no easy way to specify that explicitly if ipython updates to 3.
21:31
<@jerith>
python3 isn't really ready for primetime.
21:32
< Tarinaky>
My distro has python3 as the 'default' python now.
21:32
< Tarinaky>
There's a python2 package though so it's all good.
21:32
<@jerith>
That's... broken.
21:33
<@jerith>
Python 3's executable is supposed to be "python3", not "python".
21:34
< Tarinaky>
/usr/bin/python is a symlink.
21:34
< Tarinaky>
lrwxrwxrwx 1 root root 7 Feb 21 01:54 /usr/bin/python -> python3
21:34
<@jerith>
Gentoo?
21:34
< Tarinaky>
Arch.
21:35
<@jerith>
Ah.
21:35
< Tarinaky>
It's like Gentoo except source based.
21:35
< Tarinaky>
Err Binary based.
21:35
<@jerith>
Set fire to it.
21:35
< Tarinaky>
Lol.
21:35
< Tarinaky>
Meh. It's good habit to explicitly state python2 in your shebangs.
21:35
<@jerith>
Seriously.
21:35
< Tarinaky>
I don't see what the issue is with having python point to python3.
21:36
<@jerith>
If your distro specifically goes against a language's stated recommendation...
21:36
<@jerith>
Tarinaky: Python 3 breaks backwards comapt.
21:36
<@jerith>
*compat
21:37
< Tarinaky>
Anyway.
21:38
< celticminstrel>
There is no python2 on my computer. Only python2.7, python2.6, python2.5, python2.4, python3. And on some platforms, the dots are omitted. So specifying python2 in your shebangs is itself nontrivial.
21:38
<@jerith>
By making it default, you're breaking anything that doesn't explicitly specify the version.
21:39 Derakon[AFK] [Derakon@8E7DA3.11EB2E.8356BF.B82ACB] has quit [Ping timeout: 121 seconds]
21:39
< celticminstrel>
My default is 2.7.
21:40
< celticminstrel>
Tarinaky, you should probably change where that symlink points. :/
21:40
< Tarinaky>
celticminstrel: That'll break too much.
21:40
< celticminstrel>
Why, do you have stuff that requires Python 3 without specifying the version?
21:41
< Tarinaky>
celticminstrel: I have both python2.7 and 2.
21:41
< Tarinaky>
celticminstrel: Anything installed through my distro's package manager will assume that python points to python3.
21:42
< Tarinaky>
The package manager itself will complain loudly if you molest the files it manages too much.
21:42
< Tarinaky>
Or else overwrite them.
21:42
< celticminstrel>
What do you mean by python 2?
21:43
< Tarinaky>
python2 points to python2.7
21:43
< celticminstrel>
Ah.
21:43
< Tarinaky>
But just 2.x
21:50 RichardBarrell_d [droid@F67919.628980.16FC78.24AEE3] has joined #code
21:59
<@ToxicFrog>
Tarinaky: isn't this managed by the alternatives mechanism?
21:59
<@ToxicFrog>
You should be able to use update-alternatives to redirect python to python2 or python2.7; if doing this causes other things to break, those packages should probably be reported as broken.
22:01
< Tarinaky>
I have no idea what the alternarives mechanism is.
22:01 * Tarinaky would rather just leave it be.
22:02
< RichardBarrell_d>
Often a sound choice.
22:03
< RichardBarrell_d>
How are the people of #code? There is so rarely banter in here that I see.
22:04
<@jerith>
We tend to banter more technically.
22:04 Stalker [Z@26ECB6.A4B64C.298B52.D80DA0] has quit [Ping timeout: 121 seconds]
22:06 * gnolam hands RichardBarrell a Bantha.
22:06
< gnolam>
Close enough.
22:06
< RichardBarrell_d>
Well within epsilon, gnolam.
22:07
< RichardBarrell_d>
True, jerith. You still teaching undergrads in .za?
22:08
<@jerith>
Not for half a decade.
22:08
<@jerith>
Now I'm being curmudgeonly at junior devs.
22:08
< RichardBarrell_d>
Huh. Apparently all my memories are kinda old.
22:08
<@jerith>
Like me. :-)
22:09
< RichardBarrell_d>
Hee. Same thing, almost. :)
22:09 * TheWatcher lends jerith his cane
22:10
<@jerith>
Thanks, TW, but I have my own.
22:12 * Tarinaky hmms... Trying to figure out why vim seems to want to indent his python files with 8 spaces rather than 4.
22:12
<@jerith>
:%s et sw=4 sw=4
22:12
<@jerith>
Um.
22:12
<@TheWatcher>
<insert vim v emacs here>
22:12
<@jerith>
How did that happen?
22:13
<@jerith>
:set et sw=4 sw=4
22:14
< Tarinaky>
I'm using a filetype plugin.
22:17
< Tarinaky>
jerith: Thanks for the Vim magic.
22:18
< RichardBarrell_d>
Don't you need to set ts too?
22:18 * jerith takes a small bow.
22:19
<@jerith>
Oh, right. Yes.
22:19
<@jerith>
I set sw twice there.
22:21
< RichardBarrell_d>
Was wondering, though it has been a little while since I used vim except for within M-x ansi-term
22:26
< Tarinaky>
Derp. How do I make an interactive python reload a module that's changed?
22:26 * TheWatcher passes Tarinaky a butterfly, suggests he use that.
22:26
<@jerith>
reload(module)
22:27
< Tarinaky>
Thanks.
22:27
< gnolam>
Arghl. Still no requirements specification.
22:27
<@TheWatcher>
(I find it hilarious that M-x butterfly actually works)
22:27
< Tarinaky>
Sorry I'm asking stupid/newbie questions.
22:30
<@jerith>
Tarinaky: You're fixing your ignorance. This is admirable.
22:31
< Tarinaky>
How annoying. When I create an object but don't assign it to anything the interpretter doesn't destruct it.
22:32 * Tarinaky wasn't expecting that behavior.
22:32
< Tarinaky>
Isn't that going to be a potential memory leak problem in interactive mode (since I'm not returning)? Or am I missing something?
22:32
<@McMartin>
Huh, that's interesting
22:33
<@McMartin>
Oh, um
22:33
<@McMartin>
Python doesn't have precise destructors, I don't think
22:33
<@jerith>
Tarinaky: Destruct?
22:33
< Tarinaky>
Well, it has a __del__ method.
22:33
< Tarinaky>
Which iirc is meant to be called when it leaves scope...
22:33
<@jerith>
You can't really trust __del__().
22:33
<@jerith>
What are you trying to do?
22:34
< Tarinaky>
When I create an object it initialises pygame. When I destroy that object is deinitialises pygame.
22:34
< RichardBarrell_d>
Python does have reliable destructors in CPython.
22:35
< RichardBarrell_d>
In the absence of cycles, that is. Just because it refcounts.
22:35
< Tarinaky>
Oh. I'm using ipython if that matters.
22:36
<@jerith>
Perhaps pygame keeps a refernce to globals or something?
22:36
< RichardBarrell_d>
Do not rely on it though because it is not supposed to be a guaranteed part of the language spec.
22:36
<@jerith>
RichardBarrell_d: The reason I said you can't trust it is because cycles can sometimes sneak in without you noticing.
22:37
<@McMartin>
Doesn't Python also do mark-and-sweep?
22:37
<@jerith>
Especially if you're doing something complicated enough to require a destructor.
22:37
< RichardBarrell_d>
"Spec", heh. But yeah, different Python implementations will colllect at different times.
22:37
<@McMartin>
Er, CPython
22:37
<@jerith>
McMartin: No, just refcount.
22:37
< RichardBarrell_d>
Especially Jython or IronPython.
22:37
<@jerith>
Although it'll break weakrefs.
22:38
< Tarinaky>
Fortunately it'll let me reach in and call __del__ on a new instance so I can get away with it for now >.>
22:38
< RichardBarrell_d>
McM: it has a mark-sweep GC that is supposed to be just for colllecting cycles.
22:39 * jerith tries out this "sleep" thing he's been hearing so much about.
22:39
< RichardBarrell_d>
Best practice is to always define an explicit .close() method for any object that represents any resource that is not just RAM.
22:40
<@TheWatcher>
Night jerith
22:40
< RichardBarrell_d>
Sleep well.
22:40
< Tarinaky>
Well, the issue I have is if I keep creating these objects is ipython going to memory leak.
22:41
< RichardBarrell_d>
Space leak.
22:41
<@TheWatcher>
which sounds vaguely akin to an interstellar allium
22:42
< RichardBarrell_d>
A memory leak is where you dail to free. A space leak is where you hold references to things that you shiuld have dropped.
22:43
< RichardBarrell_d>
Space leaks are usually easier to debug because you can just traverse the object graph and find where the unneeded references aee.
22:43
< gnolam>
TheWatcher: http://sodemotivational.com/wp-content/uploads/2010/12/so-demotivational-posters -wikileeks.jpg
22:43
< Tarinaky>
Is that not just as bad?
22:44
< Tarinaky>
I mean. To me the end user.
22:44
<@TheWatcher>
gnolam: pft
22:44
< gnolam>
Speaking of space, my preferred cluster topology is now "k-dimensional hypercube". Just so you can get to use the phrase "k-dimensional hypercube".
22:44
< Tarinaky>
Since I have no interest in writing a patch for an interpretter in a language I'm, by all counts, a newb in :p
22:45
<@TheWatcher>
um
22:45
< RichardBarrell_d>
Tarinaky no, you want the one which is easier to debug and hence fix. Either represents a bug in your progeam. :)
22:46
< RichardBarrell_d>
*program
22:47
<@TheWatcher>
I note that just because the 'terp isn't freeing your unreferences objects /now/, it doesn't mean it won't do it later. In general, in any system that does GC for you, you can't really guarantee when it'll free anything you've allocated, except that it'll happen before the terp shuts down.
22:47
< gnolam>
... so apparently, the Chinese sign for "mouth" looks just like the "character not found" box.
22:47
< gnolam>
All this time, I thought my font was lacking a character. :P
22:48
<@TheWatcher>
*unreferenced
22:49
<@TheWatcher>
And, frankly, if you're doing anything in your destructor, you're doing it wrong.
22:49
<@TheWatcher>
(unless you really know what you're doing)
22:53
< celticminstrel>
Well, Python does let you manually delete objects, unlike Java... though that's probably not reliable either.
22:53
< RichardBarrell_d>
*unless you are writing C++, where destructors are executed in a precisely determined order.
22:53
< celticminstrel>
I think Python also has a "collect now" function in one of its modules.
22:53
< Tarinaky>
The documentation for delete says it just decrements the reference counter.
22:53
< celticminstrel>
Exactly.
22:54
< celticminstrel>
Thus not reliable.
22:54
< RichardBarrell_d>
That only deletes tge referebces to them, AIUI.
22:54
< RichardBarrell_d>
*references, the
22:56
< Tarinaky>
I've just spent the past week practicing my C++ >.> Fair to say it's just the transition from one mindset to another.
22:57
< celticminstrel>
Like me finding myself writing a copy constructor in Java.
23:00 * Tarinaky sniggers.
23:01
< celticminstrel>
?
23:09
< Tarinaky>
Copy constructors in Java...
23:09
< Tarinaky>
I was under the impression Java didn't need copy constructors.
23:10
<@McMartin>
Not in the way C++ does
23:10
< Tarinaky>
Hence why it was funny. >.>
23:10
<@McMartin>
There are reasons to want them on occasion.
23:10
<@McMartin>
Mainly for making deep copies so that you can simulate passing mutable objects by value
23:12 Stalker [Z@3A600C.A966FF.5BF32D.8E7ABA] has joined #code
23:14
< celticminstrel>
Well, in this case it probably wasn't necessary.
23:31 * Tarinaky facepalms.
23:32
< Tarinaky>
So my python plugin appears to want every word of a docstring to be on a new line.
23:32
< Tarinaky>
For reasons completely unknown to me.
23:33
< Tarinaky>
Ah. Nothing to do with docstrings.
23:35 RichardBarrell_d [droid@F67919.628980.16FC78.24AEE3] has quit [[NS] Quit: Auf wiedersehen.]
23:37
< Tarinaky>
It appears to be adding setlocal et sw=4 tw=4 that messed it up.
23:46 gnolam [lenin@Nightstar-38637aa0.priv.bahnhof.se] has quit [[NS] Quit: Z?]
23:46
< Tarinaky>
Okay. So now we're at the problem I had last time with python.
23:47
< Tarinaky>
I need a reference to a single object more or less throughout the entire code-base.
23:48
< Tarinaky>
What is the correct python-y way of achieving this, aside from passing a handle to this object as an argument to everything.
--- Log closed Tue Mar 22 00:00:08 2011
code logs -> 2011 -> Mon, 21 Mar 2011< code.20110320.log - code.20110322.log >