/srv/irclogs.ubuntu.com/2007/02/16/#upstart.txt

=== AStorm [n=astralst@host-81-190-179-124.gorzow.mm.pl] has joined #upstart
=== Amaranth [n=travis@ubuntu/member/Amaranth] has joined #upstart
=== Md [i=md@freenode/staff/md] has joined #upstart
=== Amaranth [n=travis@ubuntu/member/Amaranth] has joined #upstart
=== Keybuk [n=scott@quest.netsplit.com] has joined #upstart
_ionSigh, doing anything in a virtual machine is simply too slow on this computer.01:44
_ionIt probably takes a minute just to finish the initramfs script. :-)01:44
_ionI guess i'll have to hack on replacement-initscripts on this computer directly.01:45
Keybukheh01:59
=== Keybuk just hacks directly
=== AStorm [n=astralst@host-81-190-179-124.gorzow.mm.pl] has joined #upstart
=== j_ack [n=rudi@p508DBB02.dip0.t-ipconnect.de] has joined #upstart
_ion(offtopic: http://johan.kiviniemi.name/blag/2007/02/16/monitorcalc/)04:19
Keybukyou really do like ruby, don't you? :p04:58
=== mbiebl [n=michael@e180072138.adsl.alicedsl.de] has joined #upstart
_ionIt's not perfect, but i haven't found any better ones yet. :-)06:07
=== AStorm [n=astralst@host-81-190-179-124.gorzow.mm.pl] has joined #upstart
Keybukwhat for though?06:25
Keybuka language can never be perfect for everything06:26
Keybukonly perfect for something06:26
Keybukwhat is ruby's task?06:26
AStormTheoretically, network programming and Perl's place06:27
AStormRuby = better Perl06:27
Keybukso ruby has regular expressions as a first class object?06:27
AStormAs a language construct, you meant? Yes.06:28
AStormAnd an object too.06:28
AStormbut then, it isn't all that useful :P06:28
Keybukwhat does a ruby program that returns all lines from a file matching a regular expression look like?06:28
AStormBeats me. I don't program in Ruby.06:28
Keybukit would surprise me if it's as good at parsing as Perl is06:28
AStormWhy not?06:29
Keybuksince Perl does that so well, at the expense of other langauge niceties06:29
AStormAnything is as good at parsing as perl.06:29
Keybukeh?06:29
AStormThough the syntax might be bulkier a bit.06:29
Keybukthe syntax is everything06:29
Keybukand the speed at which it can do it06:29
AStormNothing at all.06:29
AStormSpeed, yes, that matters.06:29
Keybukyou could write a program to extract data from files and generate a report in C...06:29
Keybuk...you just wouldn't06:29
Keybukyou would always use Perl06:29
AStormNo, because it doesn't have any good regexp library.06:30
AStormI would use Python personally.06:30
Keybukof course it does06:30
KeybukPython isn't good at this kind of thing06:30
AStormpcre you mean06:30
AStormIt is _very_ good06:30
Keybukno, it's quite bad06:30
AStormif you don't mind re.match("WHATEVER")06:30
AStormInstead of ~=06:30
Mdwhich tends to suck, yes06:30
AStormIt has splitting and other things too.06:30
Keybukwhile (<>) {06:31
Keybuk        print $1 if /[a-z] ([0-9] +)/gi;06:31
Keybuk}06:31
Keybuk-- 06:31
Keybukwhat's the Python equivalent of that?06:31
AStormfor line in stdin: ...06:31
Keybukno,06:31
Keybuknot stdin06:31
AStormfor line in stdin: x = re.match("[a-z] ([0-9+)"); if x: print x.groups(1)06:32
KeybukBZZT06:32
AStormWhat is that <> thingy?06:32
AStormSome variable?06:32
Keybukdoesn't parse filenames given on the command line in preference to stdin06:32
Keybukdoesn't print each number on the line06:32
Keybukand you've tried to bunch it up into one line, which is very bad Python06:32
AStormYep06:32
AStormIt's IRCy Python06:32
AStorm:P06:32
AStormIt would probably take 5 lines to do exact the same thing as in Perl.06:33
AStormWhich I don't know.06:33
KeybukI've reached 30 lines so far ...06:33
AStorm:P06:33
AStormWhat does that thing means actually?06:33
AStorm*mean06:33
=== Amaranth [n=travis@ubuntu/member/Amaranth] has joined #upstart
Keybukwhatever you want it to mean06:33
AStormThat <>06:34
Keybukthe point is that Perl is *VERY* good at extracting information out of files and generating data sets from it06:34
Keybukextraordinarly good06:34
AStormWell, yep.06:34
Keybuk<> is "each line for each file listed on the command line, or stdin"06:34
AStormAha.06:34
AStormThat'll be 7 lines of Python06:34
AStorm:P06:34
AStormOne for more06:34
Keybukno, it's still not 7 lines of python06:34
AStormand two imports06:34
AStormOk, 8, miscalculated.06:34
AStorm:P06:35
Keybuktwo imports?06:35
AStormYep.06:35
Keybukoh, right, re06:35
AStormHeh, one less even.06:36
AStormhttp://docs.python.org/lib/module-fileinput.html06:36
AStorm:P06:36
AStormThat's what Perl does with that <>, isn't it?06:36
Keybukyes06:37
Keybukyou still can't get anything legible06:37
AStormYou can do even better with Python 2.506:37
AStormprint x.groups(1) if x06:37
AStorms/if/when/06:38
AStormprint x.groups(1) when x06:38
AStormor even.. in older Python...06:38
Keybukstill not x.groups(1) I'm afraid06:38
AStormIt is.06:38
Keybukno06:38
KeybukPerl will print all matches in the line06:38
Keybukbecause I used /g06:38
AStormx is an instance of a matchobjects.06:38
AStormAha, one missing flag.06:39
Keybuk(python doesn't have this flag <g>)06:39
AStormre.GLOBAL06:39
KeybukAttributeError: 'module' object has no attribute 'GLOBAL'06:39
AStormOh yes it does :P06:39
AStormre.findall06:39
Keybukno06:39
AStormre.finditer06:39
Keybukright, that's not a flag06:39
Keybukimport re06:40
Keybukimport fileinput06:40
KeybukRE = re.compile(r'[a-z] ([0-9] +)', re.IGNORECASE)06:40
Keybukif __name__ == "__main__":06:40
Keybuk        for line in fileinput.input()06:40
Keybuk                for number in line.findall():06:40
Keybuk                        print number06:40
Keybukis the equivalent Python06:40
AStormYep.06:40
Keybukwhich is infintely less useful than the Perl06:40
Keybukergo. at parsing, Perl wins06:40
AStormBut you don't have to compile :P06:40
Keybukyou do bloody well have to compile06:40
Keybukthis file is 2GB!06:40
AStormNo, you don't.06:40
Keybukcompiling that regexp every time will run slow as a dog06:40
AStorm100 latest matches are buffered.06:40
AStormNO.06:40
Keybukactually06:40
Keybukheh06:40
AStormPython won't compile it every time.06:40
KeybukPython can't parse that file06:40
Keybukit ENOMEM'd :p06:40
KeybukPerl took under a second06:41
Keybukand used only a few 100K06:41
AStormBecause you used findall06:41
AStormand not finditer06:41
AStorm:P06:41
Keybukok06:41
Keybukfinditer still running06:41
wasabiHeh. And here I am, a C# user.06:41
wasabiThe bane of all of you!06:41
Keybukfinditer still running06:41
=== Keybuk kills it
KeybukPerl wins06:41
KeybukI'm not saying Python is bad, Python is very good at certain things06:42
Keybukit just does emphatically not beat Perl at being a parsing/extraction language06:42
AStormWhy? My 2GB file took actually... like 10s06:42
AStormProbably not :P06:42
Keybuk10s is well over 10 times longer than Perl06:42
AStormIt's a general purpose language, hell.06:42
Keybukthere's no such thing06:42
Keybukno language is ever general purpose06:42
AStormEh...06:43
Keybukevery single one ends up specialising in being able to do one thing well06:43
Keybukwhether deliberately or not06:43
AStormIt's a language with no special purpose in mind06:43
AStormother than being easily embedded06:43
Keybukeasily embedded => Lua06:43
Keybukso Python loses there06:43
AStormYep.06:43
AStormactually, I know why it did regexp so slow06:44
Keybukone of my major, deep-seated, proto-religious hates is people who use one language for every single task06:44
AStormObject lookups :P06:44
Keybukespecially if that language is PHP :p06:44
Keybukbut it applies to any06:44
AStormPHP is evil, yep.06:44
AStormEspecially due to unreadability :P06:44
Keybukyou do not write applications with user interfaces in Perl06:44
Keybukyou do not write data parsing and report generation apps in Python06:45
AStormOh, right, Python isn't too good at threading too.06:45
AlexExtremewell, PHP is kinda sucky. especially at GUIs06:45
AStormWell, I do. But then, anyway :P06:45
AStormBut these need a bit of special care in tight loops.06:45
AlexExtremewould you beleive that the package manager in KateOS (a linux distro) is written in PHP06:45
AlexExtremewith PHP-GTK206:45
AStormEsp. putting object lookups outside of them.06:45
AStormOMFG!06:45
Keybukyou don't write *anything* in Java, C++ or PHP06:45
AStormI'd write it in Haskell, blah :P06:46
AStormC++ is good if you have a requirement on it.06:46
KeybukAStorm: haskell is good for mathmetical or functional data sets06:46
AlexExtremeI hate C++ :)06:46
AStormOr have to write low-level code.06:46
KeybukC++ is never good06:46
KeybukC++ is useless for low-level code06:46
Keybukand terrible for object oriented code06:46
AStormNo, it isn't :P06:46
AlexExtremeJava... ugh, bloat.06:46
Keybuklow-level => C06:46
Keybukobject-oriented => C# or Python06:46
AStormC++ is good enough for low-level semi-OO code.06:46
KeybukI bet you any low-level C++ code you find is really C mangled by a C++ compiler06:46
AStormThought C can do still.06:47
AStorm*though06:47
AStormKeybuk, uh... tell that to guys liking templates :P06:47
Keybukwhy the hell would you need templates for low-level code?! :p06:47
AStormC# requires mono runtime, which is ugh.06:47
Keybukone ioport looks much like another06:47
KeybukC++ requires C++ runtime, which is ugh ugh ugh06:47
AStormThat's why :P06:47
AStormNo, it doesn't.06:48
AlexExtremeyes it does06:48
AStormIt's statically compilable.06:48
AlexExtremelibstdc++06:48
AStorm^06:48
AlexExtremewell06:48
AlexExtremeit is06:48
AlexExtremebut06:48
Keybukyou can build the mono runtime into the binary06:48
AlexExtremethat makes your application unnecessarily massive06:48
AStormKeybuk, yep? Tell me about it.06:48
AStormAlexExtreme, not that much.06:48
AStormLinkers are quite smart nowadays.06:48
wasabimono is statically compilable too heh06:48
wasabiapples to apples06:48
AStormwasabi, yes, it is06:48
AStormBut it's a large runtime :P06:49
KeybukLinkers are dump06:49
Keybukuh, dumb06:49
wasabiit's not that large...06:49
AStormNot GNU ld :P06:49
KeybukAStorm: have you *looked* at the size of libstdc++ ?! :p06:49
AStormYep. 3MB06:49
KeybukAStorm: GNU ld is dump; it does exactly what you tell it06:49
KeybukAStorm: and the size of mono? :p06:49
Keybuk(tip: it's about the same size)06:49
AStorm36MB runtime06:49
AStorm(count libs in!)06:49
wasabiIt's not a 36MB runtime heh.06:49
wasabiYou have to only count USED libs heh06:49
KeybukAStorm: no, mono libs include a lot more than libstdc++06:49
KeybukI can include glibc and gtk+, etc. into the stdc++ calculation, if you like06:50
Keybukit wouldn't win :p06:50
AStormglibc can't be06:50
AStormmono uses it too06:50
AStorm:P06:50
wasabi-rw-r--r-- 1 root root 2.4M 2007-02-07 16:57 /usr/lib/libmono.so.0.0.006:50
AStormUnless it's implemented in asm06:50
wasabiSo, basic VM is 2.4 MB.06:50
AlexExtremebbl06:50
AStormBasic VM is nothing.06:50
wasabiSo, count the classes you use.06:50
AStormwasabi, a lot more06:50
wasabiWhich I can't do for you since I don't have a program in bind.06:50
=== Keybuk wonders how big Python is
AStormall system classes06:51
wasabiNot all system classes.06:51
AStormKeybuk, exactly... 2.5MB dll06:51
wasabiIf you don't use System.Windows.Forms.dll, you don't need it.06:51
AStormwasabi, ok, most of them :P06:51
KeybukAStorm: compared to a 3MB so? :p06:51
wasabiHarldy.06:51
wasabiSystem.Web06:51
KeybukMono is smaller then06:51
wasabiSystem.Runtime.Remoting06:51
wasabiSystem.Security, System.Xml06:51
wasabiSystem.Data, System.Design06:51
AStormwasabi, ok, anyway.06:51
wasabiMono.HalfABillion06:51
AStormthe problem is the mono requirement :P06:51
Keybukwhat's wrong with Mono?06:51
wasabiWhy, again? :006:51
AStormThat's why Haskell wins :P06:52
=== Keybuk likes C# - it's a nice language
wasabihaha06:52
Keybukwith a good hereditary too06:52
AStormCompilable to straight machine code.06:52
AStormYes, C# is nice06:52
Keybukyou can compile any language straight to machine code06:52
AStormthough from .NET I prefer Nemerle.06:52
Keybukadmittedly, some of the higher-level ones like Python are damned tricky to do06:52
AStormKeybuk, to _standalone_ code (semi-standalone)06:52
AStormYep.06:52
Keybukbut it's possible06:52
AStormHaskell compiles to C--06:53
wasabiBut it's *pointless*06:53
Keybuksimply because if you couldn't express the language as machine code, you could never run the damned thing06:53
AStormor optionally to C06:53
AStormKeybuk, JIT != full static compilation06:53
Keybuka runtime is just pre-packaged machine code for language constructs, after all06:53
AStormAnd a JIT :P06:53
KeybukAStorm: I'm not talking about JIT06:53
wasabiEvery program we write relies on other services.06:53
AStormMono uses JITting a lot06:53
wasabiMono can pre-JIT.06:53
AStormwasabi, well, some do more, some less06:53
Keybukif a language can be interpreted, on the fly, then it can be compiled to machine code in advance06:53
wasabiIf you really give a shit.06:53
AStormwasabi, yep, somewhat06:54
AStormBut not NET 2.006:54
wasabiHmm. MS 2.0 can pre-JIT. Don't know about Mono.06:54
AStormKeybuk, of course.06:54
Keybukif a language cannot be compiled, then ergo, it cannot be interpreted06:54
Keybukyou could define a language that was literally impossible to compile06:54
AStormBut writing such a compiler is another matter.06:54
Keybukbut then you would also not be able to interpret it06:54
AStormHeck, you can even compile a subset of special Python06:54
AStormRPython06:55
Keybuksimply because the only way to define an un-compilable language is to design a language that requires the machine to do things that it cannot do06:55
AStormwith the use of PyPy toolchain06:55
Keybukyou can compile all of Python06:55
KeybukPython is written in C06:55
KeybukC is compiled06:55
wasabiThis argument has no goal anymore.06:55
AStormKeybuk, gah06:55
Keybukergo all Python constructs can be expressed as machine code06:55
Keybukso all the compiler need to is take the machine code constructs compiled from the C, and chain them together appropriately06:55
AStormYeah right.06:55
AStormDo that and see the app fail like hell :P06:55
wasabiC# is a valuable language. It does work so I don't have to. It makes my software easier to program. It's pretty elegant as it goes for languages.06:55
Keybukwhy would it fail?06:55
wasabiHence. YAY.06:55
AStormNotice import statement.06:56
Keybuknotice that import frequently loads C .so files06:56
AStormC# is ok for me.06:56
AStormKeybuk, some, most not :P06:56
Keybukso?06:56
AStormAnyway, please write the compiler :D06:56
AStormI'd be grateful.06:56
KeybukI don't want to write the compiler06:56
AStormThere's no compiler, because it's a "damn hard" problem06:56
Keybukif the speed that machine code provides were a requirement, I probably wouldn't write it in Python to start with06:56
Keybuknote that hard != impossible06:57
AStormYep.06:57
AStormIt's already done for restricted python06:57
Keybukactually, I shouldn't imagine it's even that hard06:57
AStorm(not too restricted)06:57
Keybukthere are one or two python constructs that would require some exotic games in machine code06:57
Keybukbut nothing too untoward06:57
AStormwasabi, still, I love some constructs of Nemerle more than C#06:57
Keybukyou'd end up with more than a few jumping-point routines06:58
wasabiYeah. I like that you can use them side by side. ;)06:58
AStormWell. RPython compiles to straight nice C :P06:58
wasabiI'm really excited by a lot of C# features.06:58
wasabiI think LINQ just totally rocks.06:59
AStormwasabi, examples, because I'm not completely sold on it06:59
wasabiLINQ: language integrated queries.06:59
wasabiFor instance:06:59
wasabiISet<string> strings = new ISet<string>(); /* add a bunch of strings to strings */06:59
KeybukPython is just a wannabe-Lisp anyway :p06:59
AStormwasabi, ahha, nice :P06:59
AStormKeybuk, indeed, OO Lisp06:59
Keybukeh?07:00
wasabiforeach (string s in (from strings as string where string.StartsWith("f")) { do stuff with s; }07:00
Keybukthere's no such thing as OO Lisp or non-OO Lisp07:00
AStormObject-oriented Lisp07:00
KeybukLisp is Lisp07:00
wasabiYou can use the syntax "from" to apply constraints to enumerations in code.07:00
AStormI was talking about Python :P07:00
AStormI still prefer Haskell syntax to Scheme one :P07:00
AStormOnly thing missing is . for accessing "members" of a class07:00
AStormIt's currently used for function composition.07:01
Keybukerr?  Lisp is even more insanely "everything is a first class object" than Python is07:01
AStormHaskell' (Prime) will resolve this problem.07:01
AStormYep, most of the time.07:01
AStormExcept (define ...)07:01
Keybukto the degree that any lisp expression can either be lisp code to evalulate that expression, or a value07:01
AStormI know. Been there, done Lisp :P07:02
Keybuk(define ...) is just def in Python07:02
AStormNope.07:02
AStormdef is defun07:03
AStormdefine is more powerful07:03
AStormNo equivalent Python construct.07:03
Keybukmaybe I'm confused there, it's been a while since I did any serious lisp07:03
wasabiOkay, lets say you have a collection of Person objects... and you wanted to find Person objects with a given age and first name:07:03
wasabivar q = from persons as p where p.Name.FirstName == "Bob" and p.Age = 123;07:03
wasabiforeach (Person p in q) { do stuff with them }07:03
AStormwasabi, nice sugar :P07:04
wasabiYup. It turns into a AST, which a ORM tool can implement.07:04
AStormNot entirely necessary anyway.07:04
wasabiOr it becomes a simple loop.07:04
wasabiEither way, your code looks clear and concise.07:04
wasabiInstead of programatic.07:05
AStormI don't know if it's entirely clear :P07:05
AStormLooks like a SQL query.07:05
wasabiYeah, it is the same idea. YOu are filtering a batch of data.07:06
wasabiBut it's completely type safe.07:06
AStormWell, I actually prefer Haskell :P07:06
wasabiAnd IDEs can do pop up completion and fun stuff on it. ;)07:06
AStormfilter (\x -> x.Name.FirstName == "Bob" and p.Age == 123) thedb07:06
AStormThat's assuming H'07:07
AStormnot H9807:07
=== j_ack [n=rudi@p508DBB02.dip0.t-ipconnect.de] has joined #upstart
wasabiHow is that implemented?07:08
wasabiCan that be translated at runtime to a SQL statement?07:08
AStormProbably :P07:08
AStormDepends on what x is07:09
AStormif x is an SQL-alike object07:09
AStormOf course, it's no syntactic sugar :P07:09
AStormit depends on the qualities of the p element07:10
AStormEsp. on its class and implementation of == and . operator07:10
wasabiAhh.07:11
wasabiSo the p class could be a class which completely changes the dynamics of the == and .07:11
AStormYes.07:11
wasabiInorder to formulate one query that can be turned into one SQL statement.07:11
AStormAnother boon is it can be used everywhere :P07:11
AStormYou get an OODB gratis.07:12
wasabiYeah.07:12
AStormAh, wrong07:12
wasabiPython has a 'yield' statement, right?07:12
AStormthis can't be done in this way07:12
wasabi?07:12
AStormp would have to be a Monad :P07:12
AStormwasabi, yes, it does07:12
wasabiMonad?07:12
wasabiI like yield. ;)07:13
wasabiOne of my favorite new C# features.07:13
AStormwasabi, yes, a wrapper around interactions with outside world07:13
AStormSignifying mostly "this is not a function"07:13
wasabihmm07:13
AStormBecause it's not :P07:13
AStormSo, it'd have to be written more like x <- (p->Something->SomethingElse); x==blah07:15
AStormbut that can be also "undone"07:15
AStormBecause it's actually a syntactic sugar for some >>= operators07:15
AStormWhich work like a pipe in Linux.07:15
AStormEtc. etc.07:16
wasabiYeah. All of the stuff in C# is delayed evaluation too.07:16
wasabiIt never actually runs until it's used.07:16
wasabivar q = from whatever; just returns an instance of some class that could potentially do the filter.07:16
AStormUnfortunately not lazy, just delayed :P07:17
wasabiCould be lazy. If it's not SQL.07:17
AStormNemerle does have some lazy eval constructs.07:17
wasabiDefault implementation is lazy... it finds the NEXT element, and stops.07:17
wasabiSQL implementation could implement that by streaming results.07:17
AStormAha. Ok.07:17
AStormBut generally, C# is strict, right? Is there a method to disable that strictness locally easily?07:18
wasabiNo. It is always strict.07:18
AStormGenerators?07:18
wasabiDon't understand the reference.07:19
wasabiExplain.07:19
AStormI think it supports them.07:20
AStormYou can iterate using .next and .previous, but the objects get accessed only then07:20
AStormnot earlier07:20
wasabiOh. Yeah. IEnumerable contains .MoveNext()07:20
wasabiyield returns implementations of IEnumerable which access a method statemachine07:21
wasabiAnd the query stuff does too07:21
AStormAha, just what I though. Like Python iterator.07:21
wasabiYeah.07:21
AStormA bit of laziness in a strict language.07:21
wasabiHmm. By strict you mean? It's still completely typesafe.07:21
wasabiWhat it generates must still be of the declared type.07:21
wasabiIEnumerable<T>07:22
wasabiBasically, using yield looks like.07:22
wasabipublic IEnumerable<string> GetString() { yield return "string1"; yield return "string2"; }07:22
wasabiforeach (string s in GetString()) { operate on s; }07:23
AStormwasabi, strict == not lazy07:23
wasabiThe foreach construct basically uses MoveNext() and Current() on the IEnumerable instance.07:23
AStormNot dynamic.07:23
AStormlazy != dynamic07:23
AStormAre there any nice operators/functions to access an Nth object of an IEnumerable?07:23
wasabiNo. It's not an IEnumerable then.07:24
wasabiIList<T> contains an indexor.07:24
wasabiIList<T> : IEnumerable<T>07:24
wasabiYou could certainly implement an IList<T> which worked on a backing IEnumerable by advancing.07:25
AStormAha, correct :P07:25
wasabiBut you would prefer not to i'd imagine.07:25
AStorm:>07:25
wasabiAs you'd lose the benefits of the delayed evaluation.07:26
AStormDepends for what. E.g. memoisation07:26
wasabiSimply calling List.Count would force teh entire thing to be evaluated.07:26
wasabipublic IEnumerable<Foo> GetFoos() { for (int i = 0; i < 5; i++) return Foo();  }  <--- generator?07:28
wasabipublic IEnumerable<Foo> GetFoos() { for (int i = 0; i < 5; i++) yield return Foo();  }  <--- generator?07:28
wasabibah. I meant "new Foo()"07:29
AStormwasabi, sure07:35
AStormBecause counting is non-lazy always07:36
AStormYou could have CountAlreadyDone07:36
wasabiSure.08:23
=== Md [i=md@freenode/staff/md] has joined #upstart
=== j_ack [n=rudi@p508DBB02.dip0.t-ipconnect.de] has joined #upstart

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!