Re: TDD is BS?
On Wed, 26 Jun 2013 13:58:18 -0700 H. S. Teoh hst...@quickfur.ath.cx wrote: Actually, my first introduction to programming was the interactive tutorial disks that came with the Apple IIc. I sometimes find it kind of depressing that instruction isn't even *that* far along anymore, let alone any further advanced. Yeah, no kidding! In the Good Ole Days (gosh I'm old :-P Heh. I admit I have little right to be talking about getting old, but one thing I have learned: Hearing things I still think of as normal be referred to by people as retro or ancient or before their time certainly doesn't help one feel young ;) I've even seen N64/PS1 stuff called retro! That just seems so wrong - they supported *true 3D*! I don't think I'll ever get used to anything from 1990-2005 being old (90's==old? That just ain't right!), and I sympathize with anyone who feels that way about the 80's. You know there are *adults* now who never lived through any part of the 80's? Again, that just doesn't seem right! I can't legitimately say I'm getting old yet, but it sure as hell feels like it! the Apple PCs used to come with *full listings of the ROM code*, schematic diagrams of PC internals, and voltage/amperage levels and pin diagrams along with suggestions of how to hook it up to homemade electronics. A far cry from today's blackboxed lawyer-guarded device rentals. Sigh. Yea. I had heard somewhere that at one point electronic devices often came with their own schematics, and the demise of that was part of what put Stallman down the path leading to the FSF. (Although I can kinda understand why the Core i7, etc, don't come with printed schematics - would there even be enough paper in the world? ;) ) Luckily, there's at least a good fight being put up against orwell-computing, even if it is an uphill battle. The thing I find most encouraging thing (although this is software-side) is gog.com - there's a good article on it here: http://www.forbes.com/sites/erikkain/2013/05/30/good-old-games-gog-com-and-the-drm-free-revolution/ There's also some encouraging things happening on the game hardware front: The old guard of the Nintendo/MS/Sony ivory towers will soon have some extra competition from the Nvidia's Shield, and Valve's SteamBox. Not really *entirely* open systems, granted, as neither of them compare to, for example gog.com. And they're certainly not going to kill anything from Nintendo/MS/Sony anytime soon (maybe even never, if I'm being pessimistic). But nonetheless, Shield and SteamBox are a huge increase in openness for primarily gaming devices - a category of devices which have barely seen a shred of openness since the 2600 (and that was open only because Atari hadn't anticipated anything like Activision happening).
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/21/2013 4:10 AM, Paulo Pinto wrote: Except not everyone has the authorization to place their work code in such public places nor the availability or desire to code after work, just to please job interviewers. True, but your odds of being 'discovered' go up enormously if you make such an effort to make yourself findable with a professional online persona. It reminds me of some music superstars who started out singing at shopping malls, dive bars, weddings, anyplace they could get anyone to listen. They'd do this grind for a couple years until someone discovered them. The Beatles is one of those that comes to mind who did this. Anyhow, I recommend that anyone who wants to promote their 'brand' and increase their prospects do: 1. get a domain name that is yourname.com and put on it your resume, links to significant things you've done, etc. 2. use your own name as your handle when posting professionally 3. submit presentation proposals about your work to conferences 4. blog or otherwise write articles about your work or some neat tech thing you figured out 5. get a twitter account github account in your own name - even if you don't use it, reserve it for when you do want to etc. Essentially, you want to own your online persona. Read any of Donald Trump's books on how he operates, it's the same thing. Gene Simmons is another one who excels at promoting himself.
Re: TDD is BS?
On Sat, 22 Jun 2013 06:27:34 +0200 QAston qas...@gmail.com wrote: On Thursday, 20 June 2013 at 12:16:54 UTC, deadalnix wrote: Which lead to TITMOD, test in the middle of dev. You should write a book on that, it'd be a total paradigm shift for the non-yet-believers of TITMOD. The coolest acronym in programming history, ever :)
Re: TDD is BS?
On Thu, 20 Jun 2013 00:15:50 +0200 Szymon Gatner noem...@gmail.com wrote: On Wednesday, 19 June 2013 at 21:59:21 UTC, Jonathan M Davis wrote: I _do_ agree with writing the tests fora function as soon as the function is done, in which case, you're likely going to have to do more work on the function, since it'll probably fail the test, and you'll probably improve the tests some more at that point as well. But I completely disagree with writing the test before the code, which is one of the key features of TDD as its always been explained to me. It forces you to think about parameters it should take and value(s) it should return first. TBH, I've never found a lot of value in that. What I find write tests first does is force you to *guess* about params and return values. In my experience, implementation automatically roots out the necessary set of ins and outs. API change cost is way higher than fixing a bug inside a function or a class I very much disagree with that, unless you're talking about write implementation, use it everywhere, do a big public release, and *then* write unittests, which is a bad thing to do anyway. Fixing a bug can often be non-trivial, but changing an API right after, or while, you're implementing it is always trivial (although it's less trivial if you've already written a lot of tests that rely on it). also you will often realize that what you initially though was necessary turns out not to be after all. Like I said above, I find that writing the implementation does a far better job of that then making guesses about what will/won't be necessary before implementing.
Re: TDD is BS?
On Fri, 21 Jun 2013 16:03:57 -0700 H. S. Teoh hst...@quickfur.ath.cx wrote: On Fri, Jun 21, 2013 at 06:12:57PM -0400, Nick Sabalausky wrote: - Many of the professors are terrible programmers themselves. For example, I had one who openly admitted the only language he knew was C, and yet at one point it became painfully obvious that he had almost no comprehension of null-terminated strings. That's the beef I have with over-emphasis on CS theory. There's nothing wrong with theory in and of itself -- in fact it's foundational and very much indispensible -- but when you become so detached from reality that you think in terms of pure idealizations -- when you can *only* think in terms of pure idealizations -- that you can't even write a single line of real code without some external help, then something has clearly gone very, very wrong. Yea. I'm convinced that the theory and the practical are both critically important. Either one is only minimally useful without the other. - Many of the teachers don't even teach, they just collect the thousands of dollars in tuition and give you a book recommendation (really more of a demand than a recommendation). That's because the incentives are all wrong. Professors aren't paid to teach; they're paid to produce research. Publish or perish, so goes the saying in those circles. To them, teaching is an additional burden imposed upon them that they'd rather get over with ASAP and get back to their research, whatever it takes. Turn away the students showing up at your office hours. Bore them to death in class so they wouldn't know *what* to ask even if they wanted to. Read from a photocopy of the textbook word-for-word to pass lecture time with zero effort (I've actually been in a class where this was done). Anything, to get it over with and get back to the work that pays. That's a good point. Although it doesn't help that (from what I've seen) the students are given basically no indication ever that the profs are there for anything other than teaching. As far as the school ever indicates to the students, it's a school rather than an RD lab. And that's a natural conclusion for the student to make when they're forking out $100k for an alleged education. Some of my best teachers in university were part-time lecturers, one of whom won several teaching awards and accolades for 3 years straight. I don't know if there's even one faculty member that ever got *one* teaching award. You know, I honestly noticed the same thing. I always thought it was...interesting...in college that the best teachers I had were almost exclusively the part-timers, and vice versa. (On the contrary, a certain faculty member was so arrogant of his tenurehood that he'd show up on evaluation day and tell students to their face that they can write whatever they want and it wouldn't affect him in the least, 'cos his tenure meant he can never be fired. And of course, he consistently gets rock-bottom reviews from students, and incoming students are consistently warned by said students to avoid his courses at all costs.) Tenure is a concept I've *always* despised. May as well just hand out Royalty status to people. It ends up the pretty much the same way. Now, I'm a strong believer in being self-taught and learning from books, but all I need for that is a library card, not a $100k debt and four years of elitist attitudes from people who clearly don't know what they're doing anyway. Heh. Nearly all of my programming skills are self-taught (well, and learned from experience now that I have some number of years in the industry), but I'm no reader either. I was doing online learning long before the 'Net became cool, Actually, my first introduction to programming was the interactive tutorial disks that came with the Apple IIc. I sometimes find it kind of depressing that instruction isn't even *that* far along anymore, let alone any further advanced. and every now and then I still browse around learning new algorithms and stuff, while everybody else is clicking their lives away on FB and twitter (no offense, Andrei, but I do think FB is an evil waste of time, at least when it comes to the way most people use it). My biggest issues with FB/Twit are that: A. They degenerate the internet into proprietary walled-gardens (it's internet w/ orwellian training wheels, or a Dvorak put it: It's New AOL) B. They've managed to turn every product and advertisement, ever, into their *own* advertisement with the f and t plastered everywhere you look. I even have a granola bar sitting here with FB's and Twit's advertising plastered on the wrapper, for fuck's sake. I wouldn't mind the twitfaces so much if I were able to opt-out of their constant bombardment from every fucking facet of society. But yea, the fact that, for the most part, they ultimately amount to LiveJournal anyway (itself an abomination of pointless self-indulgent
Re: TDD is BS?
On Wed, 26 Jun 2013 16:24:27 -0400 Nick Sabalausky seewebsitetocontac...@semitwist.com wrote: On Fri, 21 Jun 2013 16:03:57 -0700 H. S. Teoh hst...@quickfur.ath.cx wrote: and every now and then I still browse around learning new algorithms and stuff, while everybody else is clicking their lives away on FB and twitter (no offense, Andrei, but I do think FB is an evil waste of time, at least when it comes to the way most people use it). My biggest issues with FB/Twit are that: A. They degenerate the internet into proprietary walled-gardens (it's internet w/ orwellian training wheels, or a Dvorak put it: It's New AOL) B. They've managed to turn every product and advertisement, ever, into their *own* advertisement with the f and t plastered everywhere you look. I even have a granola bar sitting here with FB's and Twit's advertising plastered on the wrapper, for fuck's sake. I wouldn't mind the twitfaces so much if I were able to opt-out of their constant bombardment from every fucking facet of society. But yea, the fact that, for the most part, they ultimately amount to LiveJournal anyway (itself an abomination of pointless self-indulgent minutia and drivel) doesn't help matters. Again though, like you said, nothing against Andrei. I completely understand the difference between a person and their employer. Hell, I used to work for a [car] insurance company!
Re: TDD is BS?
On Wed, Jun 26, 2013 at 04:24:27PM -0400, Nick Sabalausky wrote: On Fri, 21 Jun 2013 16:03:57 -0700 H. S. Teoh hst...@quickfur.ath.cx wrote: On Fri, Jun 21, 2013 at 06:12:57PM -0400, Nick Sabalausky wrote: [...] Now, I'm a strong believer in being self-taught and learning from books, but all I need for that is a library card, not a $100k debt and four years of elitist attitudes from people who clearly don't know what they're doing anyway. Heh. Nearly all of my programming skills are self-taught (well, and learned from experience now that I have some number of years in the industry), but I'm no reader either. I was doing online learning long before the 'Net became cool, Actually, my first introduction to programming was the interactive tutorial disks that came with the Apple IIc. I sometimes find it kind of depressing that instruction isn't even *that* far along anymore, let alone any further advanced. Yeah, no kidding! In the Good Ole Days (gosh I'm old :-P) the Apple PCs used to come with *full listings of the ROM code*, schematic diagrams of PC internals, and voltage/amperage levels and pin diagrams along with suggestions of how to hook it up to homemade electronics. A far cry from today's blackboxed lawyer-guarded device rentals. Sigh. T -- Political correctness: socially-sanctioned hypocrisy.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 18:24:05 UTC, Andrei Alexandrescu wrote: On 6/23/13 11:04 AM, Dicebot wrote: On Sunday, 23 June 2013 at 17:54:01 UTC, Andrei Alexandrescu wrote: On 6/23/13 10:34 AM, Adam D. Ruppe wrote: We should do what php does, it was very successful. I assume it's a dynamic library. And what reason behind this other than millions of lemmings can't be wrong? This approach is disaster when it comes to high load. Would separate processes work better under high load? Educate me. Andrei It is not about process vs dynamic library, it is about basic threaded architecture used in Apache. Every single network server that I know that cares about performance uses some sort of event model and avoids any context switches at all possible costs. It does not matter where request processing code is, only how it fits in bigger picture. Actually, server software with most impressive performance I have seen so far was implemented as single barebone process with all network stack and event library embedded. Slightly similar idea was propsoed here - http://highscalability.com/blog/2013/5/13/the-secret-to-10-million-concurrent-connections-the-kernel-i.html (found via reddit)
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 18:42:12 UTC, Adam D. Ruppe wrote: On Sunday, 23 June 2013 at 18:02:04 UTC, Dicebot wrote: I can see reasons for wanting to keep it behind reverse proxy like nginx, but Apache? Generally, I don't trust random http servers connected to the open internet for correctness, stability, security, and logging. Especially not my code, There's a lot of the http protocol I never implemented, and putting apache, nginx, IIS, whatever, I'm just using Apache here because Andrei mentioned it, out in front will filter some of that out before it gets to my app. Yes, that is why I have said that understand reasoning to use somthing like nginx or lighttpd - it is better to work behind something that has proper implementation of HTTP protocol and focus on application needs. I am using nginx for this on my own and perfectly satisfied with it. But using Apache is just throwing away most part of performance achived by your backend, for nothing. And creating security issues in case your app is run via Apache module is it typically runs from http user in such scenarios and using app-specific UNIX access policies becomes much harder.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Monday, 24 June 2013 at 02:39:30 UTC, Andrei Alexandrescu wrote: On 6/23/13 11:51 AM, Adam D. Ruppe wrote: I think it is just an accident of history that mod_php ever got used. Classic cgi implementations were still slow enough (especially with an interpreted language) that people wanted to try something else, but the other world of options hadn't taken root yet either (I think mod_php even slightly predates fastcgi's introduction), and continues to exist just out of inertia. OK so what's the way to go now? One process per request? Seems heavy to me seeing as most requests last very little. Andrei One process/thread per CPU core + async I/O. FastCGI as simple alternative (it is similar to CGI but does not respawn process after processing request).
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Monday, 24 June 2013 at 09:07:54 UTC, Dicebot wrote: Actually, server software with most impressive performance I have seen so far was implemented as single barebone process with all network stack and event library embedded. Slightly similar idea was propsoed here - http://highscalability.com/blog/2013/5/13/the-secret-to-10-million-concurrent-connections-the-kernel-i.html (found via reddit) BTW, this article is full of bullshit and hand wavy stuff. I wanted to write a article destroying it, but I then decided that I had other thing to do than loose my time :D
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Monday, 24 June 2013 at 09:22:58 UTC, deadalnix wrote: BTW, this article is full of bullshit and hand wavy stuff. I wanted to write a article destroying it, but I then decided that I had other thing to do than loose my time :D Yeah, it has plenty of bullshit but core idea is the same as one in project I have been engaged in and I can't write article about latter because of NDA, so using this an alternative available in the internet ;)
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Monday, 24 June 2013 at 02:39:30 UTC, Andrei Alexandrescu wrote: so what's the way to go now? One process per request? Seems heavy to me seeing as most requests last very little. Performance wise, I've found heard very good things about async i/o (like vibe.d) and had very good experience with a process pool (on linux anyway, cgi.d's fastcgi and new embedded_httpd_processes do this, the latter hitting 6,000 requests per second for hello world on my machine!). The process pool forks ahead of time, then they take connections as they become available. Basically it puts the concurrency in the kernel's hands, which does a good job. The zip I linked to yesterday does a simple one thread per connection, multiple requests per connection model. Doesn't scale very well, but works well and with simplicity on light loads.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/21/13 4:02 PM, Walter Bright wrote: On 6/21/2013 3:35 PM, Andrei Alexandrescu wrote: On 6/21/13 3:22 PM, Adam D. Ruppe wrote: Just for laughs I just slapped together a strstr Post it and I'll destroy it. Can I play, too? Mine from the Digital Mars C library. Haven't looked at it since 2001. == /*_ strstr.c */ /* Copyright (C) 1985-2001 by Digital Mars */ /* All Rights Reserved */ /* www.digitalmars.com */ /* Written by Walter Bright */ #include stdio.h #include ctype.h #include stddef.h #include string.h #include stdlib.h #if 0 /* Smaller but slower under many circumstances. */ char *strstr(const char *s1,const char *s2) { size_t len2; size_t len1; char c2 = *s2; len1 = strlen(s1); len2 = strlen(s2); if (!len2) return (char *) s1; while (len2 = len1) { if (c2 == *s1) if (memcmp(s2,s1,len2) == 0) return (char *) s1; s1++; len1--; } return NULL; } #else I won't comment on the B-M implementation. This brute force implementation has the problem of calling strlen on both strings upfront, which is arguably unnecessary. Although it doesn't affect complexity, it is an inefficiency hard to recover from. (The tradeoff is that memcmp will help with that.) Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/22/13 12:28 PM, Adam D. Ruppe wrote: On Saturday, 22 June 2013 at 16:38:31 UTC, Andrei Alexandrescu wrote: Huh, even the shortest impl I can think of is about the same length: inout(char)* mystrstr(inout(char)* haystack, const(char*) needle) { assert(haystack !is null); if(needle is null) return haystack; while(*haystack) { auto h = haystack; const(char)* n = needle; while(*n == *h *n *h) { h++; n++; } if(*n == 0) return haystack; haystack++; } return null; } I like this a lot better because it is more straightforward. Still buggy. The empty string must be a prefix of any string including the empty string. I describe the canonical implementation of substring brute for string search as far as I see it http://www.serversidemagazine.com/news/10-questions-with-facebook-research-engineer-andrei-alexandrescu/. Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 16:07:05 UTC, Andrei Alexandrescu wrote: Still buggy. The empty string must be a prefix of any string including the empty string. Huh. Well, that makes sense. Just change while to do while and you've got that. Probably compiles to exactly the same code as your implementation in the link at that point. But this probably told you more about my methods than getting it right the first time would have: I'll just slap something together that's good enough for the test case(s) fed to it and then change it if new stuff arises where it fails. One of the nice things about software is you generally don't have to get it right the first time since it is so easy to change. This is TDD-lite isn't it! lol http://www.serversidemagazine.com/news/10-questions-with-facebook-research-engineer-andrei-alexandrescu/. I definitely remember reading that when you posted it a while ago because I have code that does that ?d writeln(hello, world); ? laying around. http://arsdnet.net/dcode/dhp.d It works by just reading the file and translating everything outside the ?d? into a giant writeln(string literal), pasting in the D code, then compile+running it, inserting a bunch of imports so it works. dom.d now supports those kinds of tags, it could probably be even nicer, especially with a D lexer so it doesn't think ? is the same as ?. But as I'm sure I said then, this is a bad idea anyway since mixing code and html data leads to ugliness, whether the code is php or D.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/23/13 9:21 AM, Adam D. Ruppe wrote: http://arsdnet.net/dcode/dhp.d It works by just reading the file and translating everything outside the ?d? into a giant writeln(string literal), pasting in the D code, then compile+running it, inserting a bunch of imports so it works. dom.d now supports those kinds of tags, it could probably be even nicer, especially with a D lexer so it doesn't think ? is the same as ?. But as I'm sure I said then, this is a bad idea anyway since mixing code and html data leads to ugliness, whether the code is php or D. Nice! (BTW: foreach(ln; stdin.byLine) { string line = ln.idup ~ \n; is simpler written as foreach(ln; stdin.byLine(KeepTerminator.yes)) { string line = ln.idup; .) Would be awesome if an Apache extension would make it trivial to write Web pages in D. Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 16:28:56 UTC, Andrei Alexandrescu wrote: foreach(ln; stdin.byLine(KeepTerminator.yes)) { Yeah. Would be awesome if an Apache extension would make it trivial to write Web pages in D. Just use cgi or fastcgi, both are really easy to configure on apache (often needing nothing more than copying your executable into /cgi-bin/, or adding three lines to ,htaccess), and being separate processes, if you crash them it is no big deal. No need to do set up a reverse proxy or get your system administrator to load strange new Apache modules. Or if you are just playing, you can skip apache altogether and use a D http server, like my cgi.d and vibe.d both offer (vibe.d's scales way better but mine is simpler). But I kinda want to play with this now with shared libraries just for something to do so maybe I will.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/23/13 10:34 AM, Adam D. Ruppe wrote: Just use cgi or fastcgi, both are really easy to configure on apache (often needing nothing more than copying your executable into /cgi-bin/, or adding three lines to ,htaccess), and being separate processes, if you crash them it is no big deal. No need to do set up a reverse proxy or get your system administrator to load strange new Apache modules. We should do what php does, it was very successful. I assume it's a dynamic library. Or if you are just playing, you can skip apache altogether and use a D http server, like my cgi.d and vibe.d both offer (vibe.d's scales way better but mine is simpler). But I kinda want to play with this now with shared libraries just for something to do so maybe I will. Awesome! The more I think of it the more I get to the conclusion I should migrate my own website (www.erdani.com) to a 100% D toolchain. Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 17:34:52 UTC, Adam D. Ruppe wrote: Would be awesome if an Apache extension would make it trivial to write Web pages in D. Just use cgi or fastcgi, both are really easy to configure on apache (often needing nothing more than copying your executable into /cgi-bin/, or adding three lines to ,htaccess), and being separate processes, if you crash them it is no big deal. No need to do set up a reverse proxy or get your system administrator to load strange new Apache modules. Or if you are just playing, you can skip apache altogether and use a D http server, like my cgi.d and vibe.d both offer (vibe.d's scales way better but mine is simpler). Actually vibe.d embedded HTTP outperforms Apache. With high concurrency - a lot. I can see reasons for wanting to keep it behind reverse proxy like nginx, but Apache? I dream of the day this freaking monstrosity dies together with web app infrastructure it has developed. Please, don't help it survive with D module support. :(
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 17:54:01 UTC, Andrei Alexandrescu wrote: On 6/23/13 10:34 AM, Adam D. Ruppe wrote: We should do what php does, it was very successful. I assume it's a dynamic library. And what reason behind this other than millions of lemmings can't be wrong? This approach is disaster when it comes to high load.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/23/13 11:04 AM, Dicebot wrote: On Sunday, 23 June 2013 at 17:54:01 UTC, Andrei Alexandrescu wrote: On 6/23/13 10:34 AM, Adam D. Ruppe wrote: We should do what php does, it was very successful. I assume it's a dynamic library. And what reason behind this other than millions of lemmings can't be wrong? This approach is disaster when it comes to high load. Would separate processes work better under high load? Educate me. Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 18:02:04 UTC, Dicebot wrote: I can see reasons for wanting to keep it behind reverse proxy like nginx, but Apache? Generally, I don't trust random http servers connected to the open internet for correctness, stability, security, and logging. Especially not my code, There's a lot of the http protocol I never implemented, and putting apache, nginx, IIS, whatever, I'm just using Apache here because Andrei mentioned it, out in front will filter some of that out before it gets to my app. And who knows what kinds of hidden bugs my code has, so having a tested and reliable server out there to revive my process if it dies is nice too.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 18:24:05 UTC, Andrei Alexandrescu wrote: Would separate processes work better under high load? Educate me. One nice thing is you can spread separate processes across several machines. Another advantage of *cgi|embedded_httpd is that it is portable to other web servers too, you can just drop it into a shop that uses nginx or Microsoft IIS and expect it to work, whereas an Apache module is generally apache only. I think it is just an accident of history that mod_php ever got used. Classic cgi implementations were still slow enough (especially with an interpreted language) that people wanted to try something else, but the other world of options hadn't taken root yet either (I think mod_php even slightly predates fastcgi's introduction), and continues to exist just out of inertia.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
BTW I should mention, I wasn't actually trying to do an Apache module. I wanted to do a D server that watches the files for changes, then recompiles them as needed and reloads the resulting file as a shared lib. I could just run the compiled executable too, cgi style, but here I was more interested in playing with shared libraries than just getting it to work.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 17:54:01 UTC, Andrei Alexandrescu wrote: I assume it's a dynamic library. PHP can work as fastcgi too. But I kinda want to play with this now with shared libraries just for something to do so maybe I will. Awesome! Eh, not so much. I started playing and got a thing saying Runtime.loadLibrary is not yet implemented on posix... so went to do it myself and got random segfaults, relating to the garbage collector (and yes, I tried Runtime.initialize). I've never done a shared library plugin before so I could be doing something wrong, but it seems to me that druntime said it wasn't implemented yet for a reason, must still have some work to do there. Oh well, maybe I'll try again next release.
Re: TDD is BS?
Am 20.06.2013 11:26, schrieb Jacob Carlborg: On 2013-06-20 00:13, Paulo Pinto wrote: The issue is not to test third party libraries, far from it. The problem is that you cannot mock them, specially if you rely a lot on non virtual methods or pure function calls. Or on framework code that calls your code back, after certain events happened in the system. I would only mock an external service that needs to be available online. I don't mock third party code. That would be insane. There's no limit. Should I mock the standard library? No, but if your code calls something that ends up calling again other part of your code, you might need to mock it somehow. Specially if it is a library that does some IO (network, disk) in the process and is full of static methods. -- Paulo
Re: TDD is BS?
On 2013-06-23 21:50, Paulo Pinto wrote: No, but if your code calls something that ends up calling again other part of your code, you might need to mock it somehow. I'm using same approach there. If I'm testing method a and it also calls method b. I assume method b works and I don't mock it. Then I make sure to have a test for method b as well. A given test only tests one method. Specially if it is a library that does some IO (network, disk) in the process and is full of static methods. Especially network IO is a good idea to mock. -- /Jacob Carlborg
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Sunday, 23 June 2013 at 17:54:01 UTC, Andrei Alexandrescu wrote: Awesome! I realized initializing the runtime might have been a mistake when loading the .so and moreover I was using the wrong calling convention. Fixed that and now the shared library thing works. On Linux at least, I hardcoded .so so don't try it anywhere else. Here's some code: http://arsdnet.net/dcode/dhp.zip unzip it, hit make. dhp2.d is the main file here, it also uses some helper libraries you can see in the arsd folder. Then run ./dhp2 in another window or something. It is a long running process that serves http. Head over to your browser and surf to http://localhost:8085/ It will take a couple seconds to load the first time, because it needs to compile the code. Subsequent loads will pull it from a cache and be faster. Anyway it will show you some stuff and a link. These pull from the files in the zip called index.dhp and dhpt.dhp. index is just html, no D code, although it will compile it since this server compiles everything. dhpt.dhp actually includes some D: pHello, % cgi.write(cgi.request(name, user)); %, happy to see you./p Note: you access that by going to localhost:8085/dhpt, NOT /dhpt.dhp. It strips out dots from the url as a way of sanitizing the filename so keep it simple. It uses ASP style % % tags instead of ?d ? because my dom.d already understands them. (BTW this parses the .dhp files to be well-formed xml, so if you mismatch tags, it will throw. It might be fun to put the DOM node in scope to inspect too). There's a Cgi cgi in scope in the function it builds here. Use it to do communication instead of writeln() etc., as seen in this example. Here's where the shared library magic comes in: feel free to edit one of those .dhp files, or create your own, and go back to it in the browser. It will recompile and present it to you without having to restart the server. That's kinda cool. The downside is if you segfault in here it will take the whole server down so don't do that. If you fail compiling though, it will actually read dmd's output and translate the filename and line number to match the .dhp file input, instead of the .d file dmd actually sees. So it feels less like a filthy hack then. Feel free to look at index.d and dhpt.d in that same folder after you browse to them to see what the generated code looks like. S yeah. I'll probably never use this, dom templates rok so much more than anything asp/php style, but if you wanna play, feel free and let me know if you want more features or see bugs. Probably won't be too hard to fix up now that it is started.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/23/13 11:51 AM, Adam D. Ruppe wrote: I think it is just an accident of history that mod_php ever got used. Classic cgi implementations were still slow enough (especially with an interpreted language) that people wanted to try something else, but the other world of options hadn't taken root yet either (I think mod_php even slightly predates fastcgi's introduction), and continues to exist just out of inertia. OK so what's the way to go now? One process per request? Seems heavy to me seeing as most requests last very little. Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Monday, 24 June 2013 at 02:39:30 UTC, Andrei Alexandrescu wrote: On 6/23/13 11:51 AM, Adam D. Ruppe wrote: I think it is just an accident of history that mod_php ever got used. Classic cgi implementations were still slow enough (especially with an interpreted language) that people wanted to try something else, but the other world of options hadn't taken root yet either (I think mod_php even slightly predates fastcgi's introduction), and continues to exist just out of inertia. OK so what's the way to go now? One process per request? Seems heavy to me seeing as most requests last very little. That is what apache used to do when mod_php was introduced anyway. This whole conversation has gone out of control :D mod_php was a way to reduce the communication overhead and avoid 2 process per request in the first place (instead of one). It become plain obvious that no silver bullet exists here. The solution seems to be a mix of fibers/threads and processes where number of each depends on your workload and the actual hardware it is running on. Most high performance and high scalability system are converging toward one flavor of that pattern.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Friday, 21 June 2013 at 21:33:43 UTC, Andrei Alexandrescu wrote: If there's any need to reach for documentation, the interviewer has failed. When interviewing we (at Facebook) ask problems that are likely to appear in a normal day's work, but for which the typical libraries don't help. (E.g. many libraries don't can't help with implementing unstable remove (see std.algorithm).) Amongst other thing, I did a merge sort and a quicksort in my FB interviews. It is fair to assume they can be found as libraries. But overall the process is really accurate to assert what a dev can do. Most question were technically challenging, but weren't tricks or overly complicated and useless. For the anecdote, my quicksort was buggy, but my interviewer convinced me it wasn't - when later check (after the interview) demonstrated is indeed was. Also it's fair to ask about implementing a stdlib function itself if the interview concerns some systems-level work; e.g. brute-force strstr() is fair game and I think any engineer should be able to lift it off the ground quickly (to my dismay, only a fraction can). Paradoxically use of stdlib functions may actually hurt; I've seen people who e.g. call strlen() in a loop in order to implement strstr()! When i was doing interview, I used to ask people to program a function that sort an array of integer. No constraint of performance or anything, the good old 5 lines bubble sort would have been accepted. Most can't.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 2013-06-21 23:33, Andrei Alexandrescu wrote: If there's any need to reach for documentation, the interviewer has failed. When interviewing we (at Facebook) ask problems that are likely to appear in a normal day's work, but for which the typical libraries don't help. (E.g. many libraries don't can't help with implementing unstable remove (see std.algorithm).) Also it's fair to ask about implementing a stdlib function itself if the interview concerns some systems-level work; e.g. brute-force strstr() is fair game and I think any engineer should be able to lift it off the ground quickly (to my dismay, only a fraction can). Paradoxically use of stdlib functions may actually hurt; I've seen people who e.g. call strlen() in a loop in order to implement strstr()! Yes, if they tell you that from the beginning. Instead they said: solve it anyway you like, then they started to add restrictions. -- /Jacob Carlborg
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 2013-06-22 01:58, H. S. Teoh wrote: And where's the unittest block? ;-) (OK OK, I know this wasn't written in D. But I had to ask. :-P) DMC does support contracts, as an extension. That is, in and out contracts. I don't know about unit test blocks. -- /Jacob Carlborg
Re: TDD is BS?
On 2013-06-22 00:12, Nick Sabalausky wrote: - The nasty little details like pointer/memory problems, linker errors, etc that real people have to deal with are neatly glossed over and sidestepped. They never teach you about that. - There was one CS101 teacher (I had to tutor her unfortunate students) who constantly bragged about being from a real-world software company...but she was a Java-addict (circa v1.2-v1.4) who kept trying to teach OO *before* basic flow-of-execution. Consequently, none of her unfortunate students had the slightest clue what was going on. - Many of the professors are terrible programmers themselves. For example, I had one who openly admitted the only language he knew was C, and yet at one point it became painfully obvious that he had almost no comprehension of null-terminated strings. What annoys me is that sometimes they teach flat out lies to the students. I watch a couple of videos from a course from Standford, I think it was algorithms and data structures or similar. The teacher introduce the Map data structure by showing an interface for it and how it works. She tells the student that you cannot have any other type for the keys than strings. I think she even says it's impossible. I can understand that they don't want to make it too complicated when it's introduced for the first time. But she at least could have said something like, for now, lets imagine only string types are possible. -- /Jacob Carlborg
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/22/13, Walter Bright newshou...@digitalmars.com wrote: Can I play, too? Mine from the Digital Mars C library. Haven't looked at it #if 0 /* Smaller but slower under many circumstances. */ char *strstr(const char *s1,const char *s2) { size_t len2; size_t len1; char c2 = *s2; len1 = strlen(s1); len2 = strlen(s2); if (!len2) return (char *) s1; while (len2 = len1) { if (c2 == *s1) if (memcmp(s2,s1,len2) == 0) return (char *) s1; s1++; len1--; } return NULL; } Some things i've noticed about this implementation: - c2 is assigned by pointer dereference, but then strlen is called on s2 and you may get an early exit, meaning c2 was not needed at this point. I'd move c2 below the strlen call. - The memcp doesn't have to compare len2 amount of chars if you've already compared the first character, it can call memcmp(s2+1, s1+1, len2-1). Although I'm not sure whether it's faster to do it this way (maybe it is, if those variables are actually registers..). And notes about both implementations: - You're casting a const char * to a char * in the return, you should instead provide an overload of strstr taking char* and returning char*. - You seem to have missed the most basic and most important check. You didn't attempt to compare the memory address of both pointers against each other before doing any other work. If they both point to the same memory, the strings are guaranteed to be equal.
Re: TDD is BS?
On 2013-06-21 21:11, Walter Bright wrote: I've been around long enough to have seen an endless parade of magic new techniques du jour, most of which purport to remove the necessity of thought about your programming problem. One needs to be opened minded and be able to try new things. But there is one technique that stands head and shoulders above the others in improving code quality, sometimes dramatically so. That's unit testing coupled with a coverage analyzer. I can imagine that these techniques have been new at some point in time as well. It's possible that a new technique comes a long that help you as much as these techniques do. -- /Jacob Carlborg
Re: TDD is BS?
On 2013-06-22 00:12, Nick Sabalausky wrote: - There was one CS101 teacher (I had to tutor her unfortunate students) who constantly bragged about being from a real-world software company...but she was a Java-addict (circa v1.2-v1.4) who kept trying to teach OO *before* basic flow-of-execution. Consequently, none of her unfortunate students had the slightest clue what was going on. We learned OO before any programming. First we had a course about analyze and design of object oriented systems, or something like that. They thought the basic concepts of OO, UML diagrams and other stuff. After that course we learned programming and the practical side of OO, that is Java. - Many of the teachers don't even teach, they just collect the thousands of dollars in tuition and give you a book recommendation (really more of a demand than a recommendation). Now, I'm a strong believer in being self-taught and learning from books, but all I need for that is a library card, not a $100k debt and four years of elitist attitudes from people who clearly don't know what they're doing anyway. During my years at the university I bought three books. One of the was really good, the rest wasn't worth it. -- /Jacob Carlborg
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/22/13, Adam D. Ruppe destructiona...@gmail.com wrote: On Saturday, 22 June 2013 at 11:01:53 UTC, Andrej Mitrovic wrote: - You're casting a const char * to a char * in the return, you should instead provide an overload of strstr taking char* and returning char*. I'm pretty sure the C standard says to do it with the const arg but mutable return. http://en.cppreference.com/w/c/string/byte/strstr Ah, I momentarily forgot C doesn't have overloading, which is probably where Walter's function was implemented in. In C++ there are overloads of this function: http://www.cplusplus.com/reference/cstring/strstr/
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
Adam D. Ruppe wrote: On Friday, 21 June 2013 at 22:35:55 UTC, Andrei Alexandrescu wrote: Post it and I'll destroy it. inout(char)* mystrstr(inout(char)* haystack, const(char*) needle) { assert(haystack !is null); if(needle is null) return haystack; const(char)* where = needle; inout(char)* gotit; while(*haystack) { if(*haystack == *where) { if(gotit is null) gotit = haystack; // store where the match started where++; haystack++; if(*where == 0) return gotit; } else { // if we were in the middle of a match, we'll want to // check the current character again so only advance if // we're at the beginning if(gotit is null) haystack++; else { // partial match, but not complete so no good // start over, including the current *haystack where = needle; gotit = null; } } } return null; } I haven't tried running it, but this looks to me like it won't find ababc in abababc... Jerome -- mailto:jeber...@free.fr http://jeberger.free.fr Jabber: jeber...@jabber.fr signature.asc Description: OpenPGP digital signature
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Saturday, 22 June 2013 at 13:55:26 UTC, Jérôme M. Berger wrote: I haven't tried running it, but this looks to me like it won't find ababc in abababc... You're right. I should have went backwards all the way, not just in the one case. This passes all the tests: inout(char)* mystrstr(inout(char)* haystack, const(char*) needle) { assert(haystack !is null); if(needle is null) return haystack; const(char)* where = needle; inout(char)* gotit; while(*haystack) { if(*haystack == *where) { if(gotit is null) gotit = haystack; where++; if(*where == 0) return gotit; } else { haystack -= where - needle; where = needle; gotit = null; } haystack++; } return null; }
Re: TDD is BS?
On Friday, 21 June 2013 at 16:49:26 UTC, H. S. Teoh wrote: On Fri, Jun 21, 2013 at 05:48:25PM +0200, Jacob Carlborg wrote: On 2013-06-21 16:56, H. S. Teoh wrote: +1, me too! I can say that 85-90% of what I do at work today, I learned from my personal coding projects, not from the CS courses I took in university. (That's why I like to joke about CS grads knowing more about uncomputable problems than computable ones...) It feels like there's something wrong with the world here :) [...] Only something wrong? ;-) To be fair, though, I can understand why university programs are that way: their goal is to produce more researchers and professors who may join the faculty and produce more research. So they focus more on the theoretical aspects of computer science in order to produce such candidates, whereas focusing on more practical aspects is something for technical colleges whose goal is to produce industry workers. Unfortunately, in North America at least, the technical colleges lean more toward stuff like how to use MS Word, how to organize your company data in MS SQL, rather than _real_ programming, and universities that actually *teach* real programming are more interested in finding solutions to uncomputable problems than teaching students how to solve computable ones, so there's a gap in the area of producing qualified industry coders who can write functional software. There *are* pockets of competent programming education here and there, of course, but this is the impression I get from the general situation. T Yay, a uni bashing thread. I'm a student and I like it, so here's some subjective opinion. I don't know how it's in USA, but where i live we have 2 possibilities of getting CS education at uni level: a course at pure university and a course at something we call university of technology. Basically the former focuses much more on academic problems, the latter grants you with engineer title with all that implies - you learn how computers work from electrical level up to the high abstractions of disciplines like AI or image processing. I've been interested in programming long before I went to the university of technology. I went there to expand my knowledge on the topic. It worked out great for me, because unlike in our highschool I didn't have to learn stuff unrelated to my interests. I've learned a lot and met some very skillful people. Many of them bash unis just like you guys, yet they still gained many skills there - but that's typical - I've heard a lot of whining during my entire education. I want to point out that having a CS course alone doesn't make you a good coder. First - because CS is not only about coding, that's a wide discipline. Second - your attitude is what really matters. Noone's going to make you a (very)good C programmer in 90h course - you just get enough to grasp important concepts to be able to easily expand on your own in areas you like. If you don't like CS, yet you finish the course, you've lost X years of life for getting a sheet of paper and some opportunity to get a job which you probably won't like or won't be good at. Third - unis are really not about producing enterprise workers, you don't need much knowledge to write apps which throw around data between crud app and db. Instead they give you ability to use common scientific methodology, a complete overview of CS, means to study (or even push forward) the discipline you're interested in and most important, they teach how stupid everyone (especially you - that's a painfull lesson) really is. I'm not saying that you can't get all of this on your own, yet it's easier that way. I was a self taught programmer, but I feel that my knowledge is more complete now (and some of the knowledge is very important for a systems programmer). It's obviously the same other way around - you can pass all the exams and get nothing from that. It's up to you what you're going to do with free time. Important note: public unis are free in my country, I probably wouldn't study otherwise.
Re: TDD is BS?
On 6/22/13 3:18 AM, Jacob Carlborg wrote: I watch a couple of videos from a course from Standford, I think it was algorithms and data structures or similar. The teacher introduce the Map data structure by showing an interface for it and how it works. She tells the student that you cannot have any other type for the keys than strings. I'm very surprised to hear that, Stanford is a good university. You'd certainly need good evidence to make us believe that :o). Andrei
Re: TDD is BS?
On 6/22/13 5:54 AM, Jacob Carlborg wrote: On 2013-06-21 21:11, Walter Bright wrote: I've been around long enough to have seen an endless parade of magic new techniques du jour, most of which purport to remove the necessity of thought about your programming problem. One needs to be opened minded and be able to try new things. But there is one technique that stands head and shoulders above the others in improving code quality, sometimes dramatically so. That's unit testing coupled with a coverage analyzer. I can imagine that these techniques have been new at some point in time as well. It's possible that a new technique comes a long that help you as much as these techniques do. Was new in 1962: http://www.dtic.mil/dtic/tr/fulltext/u2/282767.pdf. Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/22/13 7:10 AM, Adam D. Ruppe wrote: On Saturday, 22 June 2013 at 13:55:26 UTC, Jérôme M. Berger wrote: I haven't tried running it, but this looks to me like it won't find ababc in abababc... You're right. I should have went backwards all the way, not just in the one case. This passes all the tests: It's still buggy. Overly complicated, too - at 21 lines, it's about twice as large as the canonical implementation. Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/22/2013 4:01 AM, Andrej Mitrovic wrote: On 6/22/13, Walter Bright newshou...@digitalmars.com wrote: Can I play, too? Mine from the Digital Mars C library. Haven't looked at it #if 0 /* Smaller but slower under many circumstances. */ char *strstr(const char *s1,const char *s2) { size_t len2; size_t len1; char c2 = *s2; len1 = strlen(s1); len2 = strlen(s2); if (!len2) return (char *) s1; while (len2 = len1) { if (c2 == *s1) if (memcmp(s2,s1,len2) == 0) return (char *) s1; s1++; len1--; } return NULL; } Some things i've noticed about this implementation: It's wrapped in #if 0 ... #endif ? :-) - c2 is assigned by pointer dereference, but then strlen is called on s2 and you may get an early exit, meaning c2 was not needed at this point. I'd move c2 below the strlen call. Yup. - The memcp doesn't have to compare len2 amount of chars if you've already compared the first character, it can call memcmp(s2+1, s1+1, len2-1). Although I'm not sure whether it's faster to do it this way (maybe it is, if those variables are actually registers..). Yup. And notes about both implementations: - You're casting a const char * to a char * in the return, you should instead provide an overload of strstr taking char* and returning char*. The function bodies would be identical - why have two of them? - You seem to have missed the most basic and most important check. You didn't attempt to compare the memory address of both pointers against each other before doing any other work. If they both point to the same memory, the strings are guaranteed to be equal. Most important? I've never even run across this case.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Friday, 21 June 2013 at 21:33:43 UTC, Andrei Alexandrescu wrote: Also it's fair to ask about implementing a stdlib function itself if the interview concerns some systems-level work; e.g. brute-force strstr() is fair game and I think any engineer should be able to lift it off the ground quickly (to my dismay, only a fraction can). Paradoxically use of stdlib functions may actually hurt; I've seen people who e.g. call strlen() in a loop in order to implement strstr()! I think it's fair game whatever kind of work you are doing. The tests aren't so much about the algorithm, but showing that the candidate thinks about edge cases, interfaces, possible failure cases etc. These are things you need to think about even if your job is just to essentially glue libraries together. Simple tasks like strstr just provide a nice small task that test these things.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/22/13, Walter Bright newshou...@digitalmars.com wrote: It's wrapped in #if 0 ... #endif ? :-) Hehe. I should totally use that as an argument in a future interview. I'll wrap all my coding-answers in '#if 0', and if they're wrong I'll just say oh, but this code doesn't *actually* exist!. :p The function bodies would be identical - why have two of them? Yeah nevermind, it's C, I was thinking about C++. Then again D would blow them both out the water since it has inout. Most important? I've never even run across this case. Ok, maybe not that important. It's likely a rare case. Btw, does anyone know if the typical memcmp implementation tries to compare the pointers' addresses first to see if they match?
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Saturday, 22 June 2013 at 16:38:31 UTC, Andrei Alexandrescu wrote: It's still buggy. What's the test case? I also forgot the empty string, blargh. Let's scrap it. Overly complicated, too - at 21 lines, it's about twice as large as the canonical implementation. Huh, even the shortest impl I can think of is about the same length: inout(char)* mystrstr(inout(char)* haystack, const(char*) needle) { assert(haystack !is null); if(needle is null) return haystack; while(*haystack) { auto h = haystack; const(char)* n = needle; while(*n == *h *n *h) { h++; n++; } if(*n == 0) return haystack; haystack++; } return null; } I like this a lot better because it is more straightforward. My first draft was trying to avoid looking at the same character twice, but obviously that didn't work so fixing that ended up doing the same thing as this anyway. I guess better to KISS than be embarrassingly wrong, eh? You could do it in about ten lines like this: inout(char)* mystrstr(inout(char)* haystack, const(char*) needle) { while(*haystack) { auto h = haystack; const(char)* n = needle; while(*n == *h *n *h) h++, n++; // LOL COMMA OPERATOR if(*n == 0) return haystack; haystack++; } return null; } But I really like the null check. Yes, I know the hardware does it, but it is a pain in the butt to fire up a debugger when a null hits you in the middle of something. The nice assertion failure message is so much faster to handle.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/22/2013 12:12 PM, Andrej Mitrovic wrote: Most important? I've never even run across this case. Ok, maybe not that important. It's likely a rare case. Btw, does anyone know if the typical memcmp implementation tries to compare the pointers' addresses first to see if they match? I don't know about typical, but I've never seen one that did.
Re: TDD is BS?
On 2013-06-22 18:27, Andrei Alexandrescu wrote: I'm very surprised to hear that, Stanford is a good university. You'd certainly need good evidence to make us believe that :o). I was surprised when I watch the video. But here it is: https://itunes.apple.com/se/podcast/6.-programming-abstractions/id384232917?i=85092416mt=2 Around 14:50 in the video. She actually didn't say it was impossible. -- /Jacob Carlborg
Re: TDD is BS?
On 2013-06-22 17:24, QAston wrote: I'm not saying that you can't get all of this on your own, yet it's easier that way. I was a self taught programmer, but I feel that my knowledge is more complete now (and some of the knowledge is very important for a systems programmer). It's obviously the same other way around - you can pass all the exams and get nothing from that. It's up to you what you're going to do with free time. Important note: public unis are free in my country, I probably wouldn't study otherwise. I would say if you want to learn about programming, read these newsgroup. I have learned more when reading these newsgroup then I ever could at the university. So I just want to say, thank you all. -- /Jacob Carlborg
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/21/13, H. S. Teoh hst...@quickfur.ath.cx wrote: In spite of it all, though, we still sometimes end up hiring people who, 6 months down the road, write code that makes you scratch your head going huh?! that genius coder we hired wrote *this* junk?!. Seems like nowadays it's not too far-fetched to ask for a github/bitbucket/etc username and see the work they've done, the way they write code, contribute, etc. It should give a better feel than any interview.
Re: TDD is BS?
On 2013-06-21 00:18, Nick Sabalausky wrote: Right. It's like creating a Vacuum Cleaner or a car or a kitchen appliance by designing the case, housing and controls first, and then trying to design working internals to fit that mold. Form needs to follow function. Ever heard of Apple :) -- /Jacob Carlborg
Re: TDD is BS?
On 2013-06-21 00:37, Nick Sabalausky wrote: I'm not saying that it's necessarily bad to write a function's tests before the function itself, I just don't see what it really matters to code the tests first. The important thing is that the tests get written, ideally before you move on to something else. If you have the discipline to write the tests before the function, then you have the discipline to write the tests after the function. I agree. But the point is also, as other has mentioned, that you should look from the client's point of view when designing your API. So if you write the test firs you're writing the client code first. The you think about how the API should look like from the client's point of view. If the implementation cannot work or fit in that API you have to change the API. -- /Jacob Carlborg
Re: TDD is BS?
On 2013-06-21 05:32, Nick Sabalausky wrote: [Snip] Bottom line is, schools are absolute garbage, and academic achievement is *at best* completely meaningless. I couldn't agree more with your post. The problem though is that most hiring process uses the HR department, as you mentioned in an other post, and they only look at the degree. I only took a degree to have something to show for these HR departments, most of what I learned I learned on my own time. -- /Jacob Carlborg
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 2013-06-21 08:33, Andrej Mitrovic wrote: Seems like nowadays it's not too far-fetched to ask for a github/bitbucket/etc username and see the work they've done, the way they write code, contribute, etc. It should give a better feel than any interview. I agree. Most interviews I have been on lately is due to my github project. -- /Jacob Carlborg
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 2013-06-21 07:57, H. S. Teoh wrote: we got to ask HR to first administer a technical test before any interviews are arranged; test results are reviewed before deciding to interview the candidate I done tests like that, they all suck. This is how it usually works: You get a problem to solve. They say: solve it anyway you want, using any language you want. You solve it farily quickly and straight forward. Then they say, you are not allowed to use that function. Basically they're saying it's cheating. Then you remove that function and change the implementation accordingly. Then they say, you are not allowed to use that other function. You change the code accordingly and this dance continues. Then you're thinking to yourself, Am I supposed to reimplement the standard library?. I would say, most times, it's almost irresponsible to _not_ use the standard library. A bunch of people, a lot smarter than I, have had a good 20 years or so to perfect and fine tune the standard library. Not a chance in hell that I'm going to beat that, on an interview, with code written on a whiteboard. A side note. You're of curse not allowed to look at any documentation at all and you're not allowed to use a text editor. You write the code on a whiteboard, yes a _whiteboard_. That's just so stupid. That's not how programming works in the real world. Why the hell do they think IDE's have built in, easy to read/find, documentation. -- /Jacob Carlborg
Re: TDD is BS?
On 2013-06-20 22:22, Walter Bright wrote: Well, it was your example :-) You got me there :) That's how you're supposed to write TDD according most strong believers. But I do some researcher about TDD and similar techniques, use my common sense, pick some pieces from here and there and use what I think works. But I also do think that it can be a good idea to at least once or twice exactly follow these religious believers and see how it works. Then make my own decisions based on that. -- /Jacob Carlborg
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/21/13, Andrej Mitrovic andrej.mitrov...@gmail.com wrote: On 6/21/13, Jacob Carlborg d...@me.com wrote: I agree. Most interviews I have been on lately is due to my github project. Oh? That's cool. Which [rpkect? Looks like I rot13'ed by accident, I meant which project?
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/21/13, Jacob Carlborg d...@me.com wrote: I agree. Most interviews I have been on lately is due to my github project. Oh? That's cool. Which [rpkect?
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Friday, 21 June 2013 at 06:34:09 UTC, Andrej Mitrovic wrote: On 6/21/13, H. S. Teoh hst...@quickfur.ath.cx wrote: In spite of it all, though, we still sometimes end up hiring people who, 6 months down the road, write code that makes you scratch your head going huh?! that genius coder we hired wrote *this* junk?!. Seems like nowadays it's not too far-fetched to ask for a github/bitbucket/etc username and see the work they've done, the way they write code, contribute, etc. It should give a better feel than any interview. Except not everyone has the authorization to place their work code in such public places nor the availability or desire to code after work, just to please job interviewers. -- Paulo
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Friday, 21 June 2013 at 05:59:00 UTC, H. S. Teoh wrote: In spite of it all, though, we still sometimes end up hiring people who, 6 months down the road, write code that makes you scratch your head going huh?! that genius coder we hired wrote *this* junk?!. But maybe some hiring managers are less discerning than others. *shrug* In my (admittedly U.S.-centric) experience: if you're getting people who know how to use external libraries, what a debugger is, more than one programming language (or, indeed, any language other than Java), and any form of source control at all, I'm afraid you're hitting among the cream of the crop as far as CS baccalaureates go. And if you want them to admin a box at the same time, good luck with that. You're often better off with a passionate dropout if you're interested in hiring someone to write code. My hypothesis is this happens because the curricula are heavily skewed toward theoretical aspects of computer science. (In my view, the exemplar for this was OSU before they axed the mandatory RESOLVE/C++ series.) Cheers, Wyatt
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 2013-06-21 12:20, Andrej Mitrovic wrote: Oh? That's cool. Which [rpkect? I don't know if it was a particular project but at least one company was interested in several projects, DStep (convert C/Objective-C headers to D modules), Jazz (D frontend) and Orbit (D package manager). https://github.com/jacob-carlborg/dstep https://github.com/jacob-carlborg/jazz https://github.com/jacob-carlborg/orbit -- /Jacob Carlborg
Re: TDD is BS?
On Wednesday, 19 June 2013 at 11:01:05 UTC, Szymon Gatner wrote: This is not strictly D related but I am very curious about D's community opinion on the points made by non other than Jim Coplien here: http://www.tele-task.de/archive/video/flash/16130/ D is the only language (that I am aware of) that has first class unit testing support. What do you think? Do we really just mentally masturbate? I finally had time to see the conf. I have to say that I started with a bad opinion of it :D But it is simply poorly marketed, the content is actually very interesting. And I'd say it is mostly about OOP rather than TDD. And I agree with most of it, while learning some other stuff.
Re: TDD is BS?
On Fri, Jun 21, 2013 at 11:31:22AM +0200, Jacob Carlborg wrote: On 2013-06-21 05:32, Nick Sabalausky wrote: [Snip] Bottom line is, schools are absolute garbage, and academic achievement is *at best* completely meaningless. I couldn't agree more with your post. The problem though is that most hiring process uses the HR department, as you mentioned in an other post, and they only look at the degree. I only took a degree to have something to show for these HR departments, most of what I learned I learned on my own time. [...] +1, me too! I can say that 85-90% of what I do at work today, I learned from my personal coding projects, not from the CS courses I took in university. (That's why I like to joke about CS grads knowing more about uncomputable problems than computable ones...) Having said that, though, I *did* find that going through university helped train my mind to think logically and rigorously, even if most of the course content was not actually useful in real-life. T -- Valentine's Day: an occasion for florists to reach into the wallets of nominal lovers in dire need of being reminded to profess their hypothetical love for their long-forgotten.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Fri, Jun 21, 2013 at 11:59:12AM +0200, Jacob Carlborg wrote: On 2013-06-21 07:57, H. S. Teoh wrote: we got to ask HR to first administer a technical test before any interviews are arranged; test results are reviewed before deciding to interview the candidate I done tests like that, they all suck. This is how it usually works: You get a problem to solve. They say: solve it anyway you want, using any language you want. Heh, at my job, we're looking for skill in specific languages, so candidates are explicitly asked to write C code. And this is done not in an interview setting (which puts too much pressure on the candidate -- can *you* write code in front of interviewers without panicking at least a bit?), but in a classroom setting. Though, granted, when *I* had to go through the procedure, it felt like I was taking my CS final exams all over again. Not exactly a pleasant experience. :-P You solve it farily quickly and straight forward. Then they say, you are not allowed to use that function. Basically they're saying it's cheating. Then you remove that function and change the implementation accordingly. Then they say, you are not allowed to use that other function. You change the code accordingly and this dance continues. Then you're thinking to yourself, Am I supposed to reimplement the standard library?. That's the sign of a poorly-chosen test question. The kind of question I like to use doesn't focus on nitpicky details like that, but on actual algorithms or domain-specific knowledge, like showing that the candidate understands bit operations, pointer arithmetic, and stuff like that. On that note, it's rather shocking how few candidates know how to use malloc() and free() correctly... That's not to say the tests my employer gives have only good questions, though; there are some that basically do what you describe: please re-implement strstr(), please concatenate strings without using strcat(), and the like. When I was involved in hiring, I usually ignore these questions when evaluating the candidate, or cut them a lot of slack. But I do have a slightly evil streak when it comes to technical tests... once I wrote a Javascript question that requires the candidate to evaluate what a piece of code does, that involves several nested closures and variable shadowing. We hired one of the (very) few candidates who actually got that question right, and she turned out to be an excellent coder. I would say, most times, it's almost irresponsible to _not_ use the standard library. A bunch of people, a lot smarter than I, have had a good 20 years or so to perfect and fine tune the standard library. Not a chance in hell that I'm going to beat that, on an interview, with code written on a whiteboard. Well, I don't think the point of the test is to prove that you can write code that's *superior* to the standard library, but that you *can* write non-trivial functionality from ground up. A side note. You're of curse not allowed to look at any documentation at all and you're not allowed to use a text editor. You write the code on a whiteboard, yes a _whiteboard_. Well, that's a new one. :-P Our tests are administered as pen-and-paper tests. Not unlike CS final exams, unfortunately. :-/ That's just so stupid. That's not how programming works in the real world. Why the hell do they think IDE's have built in, easy to read/find, documentation. [...] Actually, we instruct HR to provide the standard C library manuals if candidates ask for it. There *are* some unfair questions that expect you to know, e.g., the exact order of arguments to select() and stuff like that, but like I said, it's not HR who evaluates the tests, but the hiring managers, so it's up to our discretion how much weight we put on questions like that. We usually disregard minor mistakes like using the wrong order of arguments to qsort(), if the intent is clear. We don't (or at least I don't) just blindly look for the highest-scoring test and hire those candidates; I usually take the time to look at the code and ask, why did they write it that way? what does that show about their coding abilities?. T -- I see that you JS got Bach.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 2013-06-21 17:14, H. S. Teoh wrote: Heh, at my job, we're looking for skill in specific languages, so candidates are explicitly asked to write C code. And this is done not in an interview setting (which puts too much pressure on the candidate -- can *you* write code in front of interviewers without panicking at least a bit?), but in a classroom setting. Though, granted, when *I* had to go through the procedure, it felt like I was taking my CS final exams all over again. Not exactly a pleasant experience. :-P I had four, one hour each, interviews in one afternoon. Afterwards my brain was basically fried. That's the sign of a poorly-chosen test question. The kind of question I like to use doesn't focus on nitpicky details like that, but on actual algorithms or domain-specific knowledge, like showing that the candidate understands bit operations, pointer arithmetic, and stuff like that. On that note, it's rather shocking how few candidates know how to use malloc() and free() correctly... I guess I managed to avoid what they actually wanted to test. That's not to say the tests my employer gives have only good questions, though; there are some that basically do what you describe: please re-implement strstr(), please concatenate strings without using strcat(), and the like. When I was involved in hiring, I usually ignore these questions when evaluating the candidate, or cut them a lot of slack. I can also understand that it not that easy to create meaningful tests like these. But I do have a slightly evil streak when it comes to technical tests... once I wrote a Javascript question that requires the candidate to evaluate what a piece of code does, that involves several nested closures and variable shadowing. We hired one of the (very) few candidates who actually got that question right, and she turned out to be an excellent coder. Hehe. Well, I don't think the point of the test is to prove that you can write code that's *superior* to the standard library, but that you *can* write non-trivial functionality from ground up. Yeah, I guess it's hard to find meaningful tests. Well, that's a new one. :-P Our tests are administered as pen-and-paper tests. Not unlike CS final exams, unfortunately. :-/ I hate pen-and-paper tests too. I remember those from the university. I understand that they don't want you to have access to a computer with access to the internet or a compiler. But come on, can I at least get a simple text editor. Half of the time I spend on erasing code because I cannot insert new code in the middle of existing code. Then also writing those annoying curly braces (the actual symbols) which I never get right. Actually, we instruct HR to provide the standard C library manuals if candidates ask for it. That's generous. There *are* some unfair questions that expect you to know, e.g., the exact order of arguments to select() and stuff like that, but like I said, it's not HR who evaluates the tests, but the hiring managers, so it's up to our discretion how much weight we put on questions like that. We usually disregard minor mistakes like using the wrong order of arguments to qsort(), if the intent is clear. We don't (or at least I don't) just blindly look for the highest-scoring test and hire those candidates; I usually take the time to look at the code and ask, why did they write it that way? what does that show about their coding abilities?. I guess we have different experiences. -- /Jacob Carlborg
Re: TDD is BS?
On 2013-06-21 16:56, H. S. Teoh wrote: +1, me too! I can say that 85-90% of what I do at work today, I learned from my personal coding projects, not from the CS courses I took in university. (That's why I like to joke about CS grads knowing more about uncomputable problems than computable ones...) It feels like there's something wrong with the world here :) -- /Jacob Carlborg
Re: TDD is BS?
On Fri, Jun 21, 2013 at 05:48:25PM +0200, Jacob Carlborg wrote: On 2013-06-21 16:56, H. S. Teoh wrote: +1, me too! I can say that 85-90% of what I do at work today, I learned from my personal coding projects, not from the CS courses I took in university. (That's why I like to joke about CS grads knowing more about uncomputable problems than computable ones...) It feels like there's something wrong with the world here :) [...] Only something wrong? ;-) To be fair, though, I can understand why university programs are that way: their goal is to produce more researchers and professors who may join the faculty and produce more research. So they focus more on the theoretical aspects of computer science in order to produce such candidates, whereas focusing on more practical aspects is something for technical colleges whose goal is to produce industry workers. Unfortunately, in North America at least, the technical colleges lean more toward stuff like how to use MS Word, how to organize your company data in MS SQL, rather than _real_ programming, and universities that actually *teach* real programming are more interested in finding solutions to uncomputable problems than teaching students how to solve computable ones, so there's a gap in the area of producing qualified industry coders who can write functional software. There *are* pockets of competent programming education here and there, of course, but this is the impression I get from the general situation. T -- If you think you are too small to make a difference, try sleeping in a closed room with a mosquito. -- Jan van Steenbergen
Re: TDD is BS?
On 6/21/2013 3:04 AM, Jacob Carlborg wrote: But I do some researcher about TDD and similar techniques, use my common sense, pick some pieces from here and there and use what I think works. I've been around long enough to have seen an endless parade of magic new techniques du jour, most of which purport to remove the necessity of thought about your programming problem. In the end they wind up contributing one or two pieces to the collective wisdom, and fade away in the rearview mirror. But there is one technique that stands head and shoulders above the others in improving code quality, sometimes dramatically so. That's unit testing coupled with a coverage analyzer. I can't even count the number of times I thought this is so simple, I couldn't have gotten it wrong, I doan need no steeenkin unit tests. But I write a couple anyway, and you can guess the rest. Whether you write the unit tests before, during, or after the module is written is irrelevant.
Re: TDD is BS?
On 6/20/2013 8:50 PM, H. S. Teoh wrote: One of my previous supervisors told me that when he gets resumés, as soon as he sees Ph.D he chucks it straight into the trash. He'd have missed out on Andrei, then.
Re: TDD is BS?
On Friday, 21 June 2013 at 19:14:18 UTC, Walter Bright wrote: On 6/20/2013 8:50 PM, H. S. Teoh wrote: One of my previous supervisors told me that when he gets resumés, as soon as he sees Ph.D he chucks it straight into the trash. He'd have missed out on Andrei, then. And a lot of other people who are driven towards new ideas. There's a fair amount of inverted snobbery about academia here. Ultimately, a PhD shows the ability to conduct original research and present it. It doesn't make you a great programmer, but then again *it never purports to*. Nor does a computer science degree. If you want a normal programming job, you need to show more real world experience than a PhD, but just throwing out people who have proved their originality and in depth understanding of a topic through a PhD is nothing short of absurd.
Re: TDD is BS?
On 6/21/2013 12:49 PM, John Colvin wrote: If you want a normal programming job, you need to show more real world experience than a PhD, but just throwing out people who have proved their originality and in depth understanding of a topic through a PhD is nothing short of absurd. You need a mix of people - young and old, newbies and old hands, academics and mechanics, detail guys and big picture guys, to have a healthy dev organization.
Re: TDD is BS?
On Fri, 21 Jun 2013 21:11:51 +0200, Walter Bright newshou...@digitalmars.com wrote: Whether you write the unit tests before, during, or after the module is written is irrelevant. I mostly agree with this, but there is one reason to write tests before implementing - you don't know the code yet. This way you don't filter out stuff that you think is unnecessary because you know the code handles it. Of course, the converse is also true - write tests after writing the code, because you then know the code and have a better idea of what the corner cases are. -- Simen
Re: TDD is BS?
On Fri, Jun 21, 2013 at 09:49:21PM +0200, John Colvin wrote: On Friday, 21 June 2013 at 19:14:18 UTC, Walter Bright wrote: On 6/20/2013 8:50 PM, H. S. Teoh wrote: One of my previous supervisors told me that when he gets resumés, as soon as he sees Ph.D he chucks it straight into the trash. He'd have missed out on Andrei, then. And a lot of other people who are driven towards new ideas. There's a fair amount of inverted snobbery about academia here. Ultimately, a PhD shows the ability to conduct original research and present it. It doesn't make you a great programmer, but then again *it never purports to*. Nor does a computer science degree. According to my ex-supervisor (and I'm not saying I agree with him), it indicates that one is opinionated enough to originate ideas, and stubborn enough to successfully defend said ideas, which can be detrimental in a team setting if the idea wasn't a good one. (And since a PhD doesn't purport to make you a great programmer, and he was looking for great programmers rather than researchers, that could be a reason for his views on the matter.) If you want a normal programming job, you need to show more real world experience than a PhD, but just throwing out people who have proved their originality and in depth understanding of a topic through a PhD is nothing short of absurd. Well, my ex-supervisor *did* have a reputation of having many interesting (i.e. extreme) ideas about many things. :) I can't say I subscribe to his views on this matter, but what I was trying to get at was the prevalent fallacious fixation on academic achievement (i.e. equating he has good grades / a degree / a PhD with he is a good programmer). Too many potential employers can't see beyond that, or are not willing / don't have the time and energy to do so, thus resulting in the situation where people are being hired because of their academic achievement, but are expected to have skills not necessarily implied by said achievement. Then when such hires consistently produce sub-par work, some people get provoked to equate PhD with poor programming skills. This situation wouldn't have developed if employers evaluated candidates based on their *skills* rather than by the credentials on paper. But in this day and age where time is never enough, it's all too convenient to dismiss a candidate because he has no academic credentials rather than to spend the time / energy to review unlikely candidates on the off-chance that perhaps they might turn out to be hidden programming prodigies. Or to blindly hire a candidate *with* said credentials because someone of high academic standing is likely to be skillful enough to do the job, rather than to spend to time / energy to check if this is actually the case. (Not to mention that all too often, the ones with hiring powers may not necessarily have the ability to discern real skills from a smooth talker.) T -- You are a very disagreeable person. NO.
Re: TDD is BS?
On Fri, Jun 21, 2013 at 01:11:44PM -0700, Walter Bright wrote: On 6/21/2013 12:49 PM, John Colvin wrote: If you want a normal programming job, you need to show more real world experience than a PhD, but just throwing out people who have proved their originality and in depth understanding of a topic through a PhD is nothing short of absurd. You need a mix of people - young and old, newbies and old hands, academics and mechanics, detail guys and big picture guys, to have a healthy dev organization. This reminds me of a HR seminar I attended once, where an example was given of a particular (real) company who only ever hired top-notch programmers. They set their standards very high, and have a review system that would basically fire anyone whose skills are sub-par. The guys in charge thought this was going to skyrocket the company into success. But what actually happened was, nobody wanted to work on mundane projects -- maintaining existing systems, keeping the servers running, doing routine chores necessary for everyday operations, etc.. There was a lot of infighting on who gets to work on the fun stuff, and the people who didn't get it began to quit one by one. Eventually, none of the mundane things were adequately taken care of, and most of the employees left 'cos they didn't get to do what they wanted, and the company collapsed. T -- Many open minds should be closed for repairs. -- K5 user
Re: TDD is BS?
On 6/21/2013 1:34 PM, H. S. Teoh wrote: But what actually happened was, nobody wanted to work on mundane projects -- maintaining existing systems, keeping the servers running, doing routine chores necessary for everyday operations, etc.. There was a lot of infighting on who gets to work on the fun stuff, and the people who didn't get it began to quit one by one. Eventually, none of the mundane things were adequately taken care of, and most of the employees left 'cos they didn't get to do what they wanted, and the company collapsed. Yup. Similar things happen if you only hire people fresh out of college. Things are find for a while, and then everyone wants to move up into management at the same time.
Re: TDD is BS?
On Fri, Jun 21, 2013 at 12:11:51PM -0700, Walter Bright wrote: On 6/21/2013 3:04 AM, Jacob Carlborg wrote: But I do some researcher about TDD and similar techniques, use my common sense, pick some pieces from here and there and use what I think works. I've been around long enough to have seen an endless parade of magic new techniques du jour, most of which purport to remove the necessity of thought about your programming problem. In the end they wind up contributing one or two pieces to the collective wisdom, and fade away in the rearview mirror. +1, words of wisdom. From high-level language to structured programming to OO to aspect-oriented programming to X-oriented Y-driven whatever that is the next bandwagon, it's all the same story repeated over and over. It's supposed to be the panacea that will make you able to ship a product just by pressing a single magic button, solve all your programming problems, and cure world hunger. Then you actually get into it, and discover that you still have to (gasp!) use your brain to get your program working. And life goes on as before. But there is one technique that stands head and shoulders above the others in improving code quality, sometimes dramatically so. That's unit testing coupled with a coverage analyzer. I can't even count the number of times I thought this is so simple, I couldn't have gotten it wrong, I doan need no steeenkin unit tests. But I write a couple anyway, and you can guess the rest. Yeah, I used to be firmly in the camp of this code is so trivial, so *blatantly* correct, that it constitutes its own proof of correctness. Until D came along and shamed me into writing unittests for said trivial code, and suddenly I found myself sinking in the flood of bugs, failing corner cases, and (gasp!) typos, that I hadn't imagined were there all along. Whether you write the unit tests before, during, or after the module is written is irrelevant. Yeah, sometimes I start with one or two tests before, usually a whole bunch in the middle, and a couple after (followed by a lot more later when bugs are inevitably found and fixed). The best part about D's built-in unittests (and I keep harping on about this) is that they're so dang convenient you'd be foolish for not writing them. They can be integrated into the very process of coding -- which has singlehandedly improved the quality of my code by leaps and bounds. T -- IBM = I'll Buy Microsoft!
Re: TDD is BS?
On Fri, 21 Jun 2013 17:48:25 +0200 Jacob Carlborg d...@me.com wrote: On 2013-06-21 16:56, H. S. Teoh wrote: +1, me too! I can say that 85-90% of what I do at work today, I learned from my personal coding projects, not from the CS courses I took in university. (That's why I like to joke about CS grads knowing more about uncomputable problems than computable ones...) It feels like there's something wrong with the world here :) There definitely is. I spent a total of somewhere around 6 years in college, but somewhere around the middle of that I made the deliberate decision to *not* get a degree of any sort. That was because I wanted no part in helping to perpetuate the incredibly widespread myths/lies about academic achievement. I've never regretted that decision. (The one decision I *did* regret was not leaving college entirely after the first year.)
Re: TDD is BS?
On Friday, 21 June 2013 at 20:25:28 UTC, H. S. Teoh wrote: On Fri, Jun 21, 2013 at 09:49:21PM +0200, John Colvin wrote: On Friday, 21 June 2013 at 19:14:18 UTC, Walter Bright wrote: On 6/20/2013 8:50 PM, H. S. Teoh wrote: One of my previous supervisors told me that when he gets resumés, as soon as he sees Ph.D he chucks it straight into the trash. He'd have missed out on Andrei, then. And a lot of other people who are driven towards new ideas. There's a fair amount of inverted snobbery about academia here. Ultimately, a PhD shows the ability to conduct original research and present it. It doesn't make you a great programmer, but then again *it never purports to*. Nor does a computer science degree. According to my ex-supervisor (and I'm not saying I agree with him), it indicates that one is opinionated enough to originate ideas, and stubborn enough to successfully defend said ideas, which can be detrimental in a team setting if the idea wasn't a good one. (And since a PhD doesn't purport to make you a great programmer, and he was looking for great programmers rather than researchers, that could be a reason for his views on the matter.) If you want a normal programming job, you need to show more real world experience than a PhD, but just throwing out people who have proved their originality and in depth understanding of a topic through a PhD is nothing short of absurd. Well, my ex-supervisor *did* have a reputation of having many interesting (i.e. extreme) ideas about many things. :) I can't say I subscribe to his views on this matter, but what I was trying to get at was the prevalent fallacious fixation on academic achievement (i.e. equating he has good grades / a degree / a PhD with he is a good programmer). Too many potential employers can't see beyond that, or are not willing / don't have the time and energy to do so, thus resulting in the situation where people are being hired because of their academic achievement, but are expected to have skills not necessarily implied by said achievement. Then when such hires consistently produce sub-par work, some people get provoked to equate PhD with poor programming skills. This situation wouldn't have developed if employers evaluated candidates based on their *skills* rather than by the credentials on paper. But in this day and age where time is never enough, it's all too convenient to dismiss a candidate because he has no academic credentials rather than to spend the time / energy to review unlikely candidates on the off-chance that perhaps they might turn out to be hidden programming prodigies. Or to blindly hire a candidate *with* said credentials because someone of high academic standing is likely to be skillful enough to do the job, rather than to spend to time / energy to check if this is actually the case. (Not to mention that all too often, the ones with hiring powers may not necessarily have the ability to discern real skills from a smooth talker.) T Agreed on all points. As an aside: what defines a good programmer is of course dependant on the task. Many academics do write effective code, quite quickly, and get a lot of quite convoluted work done by coding. E.g. I would (entirely hypothetically) happily hire a physics PhD to write high-level data-analysis routines in python, but i'd be wary of getting them to work on a high security web-app. On the flip side, I would be wary of hiring an enthusiastic college dropout to write an accurate fluid simulation, but they might easily fit the definition of good programmer for extending a web framework.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/21/13 5:59 AM, Jacob Carlborg wrote: On 2013-06-21 07:57, H. S. Teoh wrote: we got to ask HR to first administer a technical test before any interviews are arranged; test results are reviewed before deciding to interview the candidate I done tests like that, they all suck. This is how it usually works: You get a problem to solve. They say: solve it anyway you want, using any language you want. You solve it farily quickly and straight forward. Then they say, you are not allowed to use that function. Basically they're saying it's cheating. Then you remove that function and change the implementation accordingly. Then they say, you are not allowed to use that other function. You change the code accordingly and this dance continues. Then you're thinking to yourself, Am I supposed to reimplement the standard library?. I would say, most times, it's almost irresponsible to _not_ use the standard library. A bunch of people, a lot smarter than I, have had a good 20 years or so to perfect and fine tune the standard library. Not a chance in hell that I'm going to beat that, on an interview, with code written on a whiteboard. A side note. You're of curse not allowed to look at any documentation at all and you're not allowed to use a text editor. You write the code on a whiteboard, yes a _whiteboard_. That's just so stupid. That's not how programming works in the real world. Why the hell do they think IDE's have built in, easy to read/find, documentation. If there's any need to reach for documentation, the interviewer has failed. When interviewing we (at Facebook) ask problems that are likely to appear in a normal day's work, but for which the typical libraries don't help. (E.g. many libraries don't can't help with implementing unstable remove (see std.algorithm).) Also it's fair to ask about implementing a stdlib function itself if the interview concerns some systems-level work; e.g. brute-force strstr() is fair game and I think any engineer should be able to lift it off the ground quickly (to my dismay, only a fraction can). Paradoxically use of stdlib functions may actually hurt; I've seen people who e.g. call strlen() in a loop in order to implement strstr()! Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Friday, 21 June 2013 at 21:33:43 UTC, Andrei Alexandrescu wrote: brute-force strstr() is fair game and I think any engineer should be able to lift it off the ground quickly (to my dismay, only a fraction can). But, should the return value be const or not? :P I think I'd write in D just cuz of inout().
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Fri, Jun 21, 2013 at 05:33:45PM -0400, Andrei Alexandrescu wrote: [...] Also it's fair to ask about implementing a stdlib function itself if the interview concerns some systems-level work; e.g. brute-force strstr() is fair game and I think any engineer should be able to lift it off the ground quickly (to my dismay, only a fraction can). Yeah, I was rather dismayed at how many people lacked basic understanding of the programming language they purport to be skilled in. Like not understanding variable shadowing in C, or simple closures in Javascript (not the evilly-nested convolution I tested for in a different test question :-P). Paradoxically use of stdlib functions may actually hurt; I've seen people who e.g. call strlen() in a loop in order to implement strstr()! [...] My favorite example of poor strlen() usage is writing strlen()==0 in a loop condition. More typical causes of disqualification, though, are what one of my university professors affectionately called squirrelly code: code that *probably* does what it's supposed to, but does so by roundabout, non-obvious ways, running around here and there doing little things that don't really relate directly to the problem at hand (like squirrels running around hunting for their forgotten stash of nuts). Code like this typically demonstrate a lack of understanding of programming in general, or lack of understanding of the problem at hand, or inability to identify and address the salient points of said problem. Typical symptoms include declaring and using useless variables, calling printf inside a function that shouldn't be doing I/O, doing unnecessary type conversions to perform trivial computations (converting int to string and attempting to do arithmetic on the digits in the string), odd usage of loops and conditionals in unexpected places, using comments to urge the computer to do what one wishes, etc.. The software analogue of Rube Goldberg machines, if you will. :-P T -- Век живи - век учись. А дураком помрёшь.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
Just for laughs I just slapped together a strstr and it made me realize a little thing I do in D that I never did in C: assert() I use it all over the place in D, pretty much any time I make an assumption, I slap it down in an assert. But I don't I ever, not once, used any kind of assertion in C or C++. I think this is a fairly significant gain that can be attributed to it being built in to D. It is just silly not to do it when it is there.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Friday, 21 June 2013 at 22:23:01 UTC, Adam D. Ruppe wrote: being built in to D Or maybe it is because everybody else does it in the documentation and such, since #include assert.h in C isn't *that* big of a deal. idk, all I do know for sure is that I do it now and didn't before.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/21/13 2:50 PM, Adam D. Ruppe wrote: On Friday, 21 June 2013 at 21:33:43 UTC, Andrei Alexandrescu wrote: brute-force strstr() is fair game and I think any engineer should be able to lift it off the ground quickly (to my dismay, only a fraction can). But, should the return value be const or not? :P I think I'd write in D just cuz of inout(). That would be a nice touch and bring bonus points, but in most of the cases I tell the candidate to gloss over that detail. Andrei
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/21/13 3:22 PM, Adam D. Ruppe wrote: Just for laughs I just slapped together a strstr Post it and I'll destroy it. Andrei
Re: TDD is BS?
On Fri, 21 Jun 2013 09:47:46 -0700 H. S. Teoh hst...@quickfur.ath.cx wrote: universities that actually *teach* real programming are more interested in finding solutions to uncomputable problems than teaching students how to solve computable ones That doesn't match my experience (also in the US here). Granted, all my info is from ten years ago, but what I saw was mainly a bunch of what The Joel on Software guy called Java Schools http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html. The following includes what I've seen at BGSU and OSU (party schools, not that I personally attended OSU, but I did have a friend that went through OSU's RESOLVE/C++ stuff) and also JCU (a private univ that, at least around Cleveland, is highly-regarded by everyone except me). What I've seen at these places, and apparently many others from what I understand, is that while they *do* recognize the importance of creating programmers, the problems are: - The theory is minimal to make sure they get all those high-paying students through the revolving door. - Tests and exams do *not* teach people. An yet, that's where the emphasis is, instead of on instruction. - The really *big* issue: You just simply CANNOT expect people to go from beginner to competent programmer when they spend *at most* one-third of their credits, and about 3 hours a week, over a mere 4 years on actual programming material instead of irrelevant liberal arts garbage that *belongs* in high school, not a college so-called major. - The nasty little details like pointer/memory problems, linker errors, etc that real people have to deal with are neatly glossed over and sidestepped. - There was one CS101 teacher (I had to tutor her unfortunate students) who constantly bragged about being from a real-world software company...but she was a Java-addict (circa v1.2-v1.4) who kept trying to teach OO *before* basic flow-of-execution. Consequently, none of her unfortunate students had the slightest clue what was going on. - Many of the professors are terrible programmers themselves. For example, I had one who openly admitted the only language he knew was C, and yet at one point it became painfully obvious that he had almost no comprehension of null-terminated strings. - Many of the teachers don't even teach, they just collect the thousands of dollars in tuition and give you a book recommendation (really more of a demand than a recommendation). Now, I'm a strong believer in being self-taught and learning from books, but all I need for that is a library card, not a $100k debt and four years of elitist attitudes from people who clearly don't know what they're doing anyway.
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On 6/21/2013 3:35 PM, Andrei Alexandrescu wrote: On 6/21/13 3:22 PM, Adam D. Ruppe wrote: Just for laughs I just slapped together a strstr Post it and I'll destroy it. Can I play, too? Mine from the Digital Mars C library. Haven't looked at it since 2001. == /*_ strstr.c */ /* Copyright (C) 1985-2001 by Digital Mars */ /* All Rights Reserved */ /* www.digitalmars.com */ /* Written by Walter Bright */ #includestdio.h #includectype.h #includestddef.h #includestring.h #includestdlib.h #if 0 /* Smaller but slower under many circumstances. */ char *strstr(const char *s1,const char *s2) { size_t len2; size_t len1; char c2 = *s2; len1 = strlen(s1); len2 = strlen(s2); if (!len2) return (char *) s1; while (len2 = len1) { if (c2 == *s1) if (memcmp(s2,s1,len2) == 0) return (char *) s1; s1++; len1--; } return NULL; } #else #include limits.h/* defines UCHAR_MAX */ / See Algorithms Second Edition by Robert Sedgewick. Boyer-Moore string search routine. / char *strstr(const char *text, const char * pattern) { const size_t M = strlen(pattern); const unsigned long N = strlen(text); const char *p_p = pattern; const char *t_p; size_t skip[UCHAR_MAX + 1]; size_t i, j; if(M == 0) return (char *)text; if(M N) /* If pattern is longer than the text string. */ return 0; #if __INTSIZE == 4 _memintset((int *)skip, M, UCHAR_MAX + 1); #else { size_t *s_p = skip + UCHAR_MAX; do { *s_p = M; }while(s_p-- skip); } #endif p_p = pattern; do { skip[*(const unsigned char *)p_p] = M - 1 - (p_p - pattern); } while(*++p_p); p_p = pattern + M - 1; t_p = text + M - 1; while(1) { char c; c = *t_p; if(c == *p_p) { if(p_p - pattern == 0) return (char *)t_p; t_p--; p_p--; } else { size_t step = M - (p_p - pattern); if (step skip[(unsigned char)c]) step = skip[(unsigned char)c]; /* If we have run out of text to search in. */ /* Need cast for case of large strings with 16 bit size_t... */ if((unsigned long)(t_p - text) + step = N) return 0; t_p += step; p_p = pattern + M - 1; } } } #endif /* #if 0 */
Re: TDD is BS?
On Fri, Jun 21, 2013 at 06:12:57PM -0400, Nick Sabalausky wrote: On Fri, 21 Jun 2013 09:47:46 -0700 H. S. Teoh hst...@quickfur.ath.cx wrote: universities that actually *teach* real programming are more interested in finding solutions to uncomputable problems than teaching students how to solve computable ones That doesn't match my experience (also in the US here). Actually, I'm up in the Great White North, so my perception of North America may be a bit biased on the first word. :-P Granted, all my info is from ten years ago, but what I saw was mainly a bunch of what The Joel on Software guy called Java Schools http://www.joelonsoftware.com/articles/ThePerilsofJavaSchools.html. LOL... that article made me laugh. Thanks for the great read! The following includes what I've seen at BGSU and OSU (party schools, not that I personally attended OSU, but I did have a friend that went through OSU's RESOLVE/C++ stuff) and also JCU (a private univ that, at least around Cleveland, is highly-regarded by everyone except me). What I've seen at these places, and apparently many others from what I understand, is that while they *do* recognize the importance of creating programmers, the problems are: - The theory is minimal to make sure they get all those high-paying students through the revolving door. Huh. I had the opposite experience. We were pounded with so much theory from day one, and then summarily executed on our Computability Theory finals (the infamous exam that was so hard, you were allowed to bring *anything* -- any textbook, reference book, your desktop PC if you were so inclined -- and none of it would help), that I came out with a rather strong distaste for anything that mentions the word computability, lasting for quite a while before it wore off. - Tests and exams do *not* teach people. An yet, that's where the emphasis is, instead of on instruction. - The really *big* issue: You just simply CANNOT expect people to go from beginner to competent programmer when they spend *at most* one-third of their credits, and about 3 hours a week, over a mere 4 years on actual programming material instead of irrelevant liberal arts garbage that *belongs* in high school, not a college so-called major. That, I have to agree. I wanted to double-major in CS and Chemistry, but gave up on the first day in 2nd year when I looked at my course / lab / programming project schedule, and said, that's not gonna work. Without adequate time actually spent programming, it's impossible to get good at it. - The nasty little details like pointer/memory problems, linker errors, etc that real people have to deal with are neatly glossed over and sidestepped. OK, that's one of my pet peeves. Back in the day, I was taught pointers (though not linker errors -- I learnt that on my own) and recursion. Nowadays, people hear the word pointer and go e, and when you say recursion their eyes glaze over. What on earth did they do to the CS programs?! - There was one CS101 teacher (I had to tutor her unfortunate students) who constantly bragged about being from a real-world software company...but she was a Java-addict (circa v1.2-v1.4) who kept trying to teach OO *before* basic flow-of-execution. Consequently, none of her unfortunate students had the slightest clue what was going on. Ugh. Talk about putting the cart before the horse... - Many of the professors are terrible programmers themselves. For example, I had one who openly admitted the only language he knew was C, and yet at one point it became painfully obvious that he had almost no comprehension of null-terminated strings. That's the beef I have with over-emphasis on CS theory. There's nothing wrong with theory in and of itself -- in fact it's foundational and very much indispensible -- but when you become so detached from reality that you think in terms of pure idealizations -- when you can *only* think in terms of pure idealizations -- that you can't even write a single line of real code without some external help, then something has clearly gone very, very wrong. - Many of the teachers don't even teach, they just collect the thousands of dollars in tuition and give you a book recommendation (really more of a demand than a recommendation). That's because the incentives are all wrong. Professors aren't paid to teach; they're paid to produce research. Publish or perish, so goes the saying in those circles. To them, teaching is an additional burden imposed upon them that they'd rather get over with ASAP and get back to their research, whatever it takes. Turn away the students showing up at your office hours. Bore them to death in class so they wouldn't know *what* to ask even if they wanted to. Read from a photocopy of the textbook word-for-word to pass lecture time with zero effort (I've actually been in a class where this was done). Anything, to get it over with and get back
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Friday, 21 June 2013 at 22:35:55 UTC, Andrei Alexandrescu wrote: Post it and I'll destroy it. inout(char)* mystrstr(inout(char)* haystack, const(char*) needle) { assert(haystack !is null); if(needle is null) return haystack; const(char)* where = needle; inout(char)* gotit; while(*haystack) { if(*haystack == *where) { if(gotit is null) gotit = haystack; // store where the match started where++; haystack++; if(*where == 0) return gotit; } else { // if we were in the middle of a match, we'll want to // check the current character again so only advance if // we're at the beginning if(gotit is null) haystack++; else { // partial match, but not complete so no good // start over, including the current *haystack where = needle; gotit = null; } } } return null; } unittest { void test(string haystack, string needle, size_t line = __LINE__) { import core.stdc.string; import std.conv; // .ptr is fine because the test uses all string literals, which are 0 terminated automatically assert(strstr(haystack.ptr, needle.ptr) is mystrstr(haystack.ptr, needle.ptr), to!string(line)); } test(foobar, f); test(foobar, ob); test(foobar, o); test(foobar, a); test(foobar, ar); test(foobar, ea); test(bedtime bedazzled!, beda); } I've heard of Boyer-Moore but don't actually know it, so I'd have to look it up! The brute force loop is simple enough though without needing a great deal of thought, though my first run through did actually fail the unittest, since I neglected the commented section in the else{} part. So if I was doing it on a whiteboard, (or didn't immediately use foo as a test variable, with the repeated o) I might not have actually caught that!
Re: OT: CS education gone wrong (Was: Re: TDD is BS?)
On Fri, Jun 21, 2013 at 04:02:20PM -0700, Walter Bright wrote: [...] / See Algorithms Second Edition by Robert Sedgewick. Boyer-Moore string search routine. / char *strstr(const char *text, const char * pattern) { [...] } Very nice! Does it help at all to cast to uint[] and search that instead of just char[]? Or do the complications caused by non-alignment outweigh the benefits? And where's the unittest block? ;-) (OK OK, I know this wasn't written in D. But I had to ask. :-P) Also, this is a prime example of code you'll *never* arrive at just by blind application of TDD. (And there's my feeble attempt to bring this back on topic. :-P) T -- This sentence is false.
Re: TDD is BS?
On Thursday, 20 June 2013 at 12:16:54 UTC, deadalnix wrote: On Thursday, 20 June 2013 at 10:13:53 UTC, Jacob Carlborg wrote: On 2013-06-20 00:47, Nick Sabalausky wrote: - Writing a unittest first forces the API to be designed before the implementation is written. But implementation is necessary to flush out unexpected design requirements (If you think you can always come up with an appropriate design and interface before implementing, then you're just plain wrong). Sometimes the appropriate design and API is obvious. Sometimes it isn't. When it isn't, then TDD skirts dangerously close to some of the problems of Waterfall Model. Sure, TDD advocates refactoring-as-needed, but I can do that with or without TDD. Just because you have written a test doesn't mean you cannot change it. Perhaps you come up with a better API design, then change the tests. When I start something, it isn't always clear what mental model of the problem fit best the problem. I usually wait until I know I have a consistent mental model of the problem to write test. Otherwise, tests tend to get into your way to change the API( because you need to change tests as well. I start writing test when I know what kind of API make sense (it isn't always finished, but I know what it will look like overall). Which lead to TITMOD, test in the middle of dev. You should write a book on that, it'd be a total paradigm shift for the non-yet-believers of TITMOD.
Re: TDD is BS?
The only time I ever did TDD was when I had to implement a really specific set of number and date format strings for a company, because the users were used to them. It was pretty natural for that. This format string x must take number y, and yield the string result z. Write a bunch of tests for those, take a step back, implement the format strings how you think they should work, and see if the tests pass. Unless I'm doing really specific this input yields precisely this output stuff, I won't ever bother with TDD. I often end up with Test a little bit after design. I think his point in the talk about objects taking on roles might map nicely to the way ranges were implemented. A object doesn't behave as a range because it inherits an interface, it behaves that way because it has the right stuff for it. Essentially, I think he's getting close to saying statically-checked duck typing. Like all things, this is good *some of the time.*
Re: TDD is BS?
On Thursday, 20 June 2013 at 01:15:58 UTC, Chris Cain wrote: On Wednesday, 19 June 2013 at 23:44:29 UTC, Walter Bright wrote: [...] Ultimately, the goal of TDD is to have the programmer sit down and look at code from a USER'S (as in, user of the API) point of view _FIRST_. Writing a test as the first step is really just suggesting as a user, how would you find it convenient to use this thing? Just left enough context to ask the following question, I hope I did not left out too much. How does TDD then help how a user of my application will use the application UI? This is the area where I usually make TDD evangelists go speechless in conferences, as they start to present ad-hoc solutions and end up changing subject. -- Paulo
Re: TDD is BS?
On Wednesday, 19 June 2013 at 17:31:33 UTC, H. S. Teoh wrote: On Wed, Jun 19, 2013 at 04:52:22PM +0200, bearophile wrote: irritate: My feelings about TDD changed when I saw that talk explaining TDD in the context of double-entry bookkeeping in accounting Before methodologies like TDD could even begin to work, one has to *solve* the problem at hand first -- analyse the problem, explore its structure, invent an algorithm, then one can verify the correctness of one's implementation with unittests. You have to already have an idea about how things are going to work, before TDD can help you. For me, it is like this: TDD is rather similar to bookkeeping; design is similar to doing (or managing) businesses. While being (or having) a good bookkeeper will definitely help your business to perform, the reverse is not true: being the most careful accountant in the world does not mean that you will do successful businesses.
Re: TDD is BS?
On Thursday, 20 June 2013 at 05:05:29 UTC, Joakim wrote: I think their argument would be that if you're only interested in classic algorithms or the best way that is known, then you may not get much out of TDD. But if you're exploring the solution space and trying to come up with a design that emerges with use, as opposed to thinking up a complete design in your head and then simply implementing it, I think they'd say TDD is a good solution for that. Szymon mentioned uncle Bob earlier, I thought I'd see what he had to say about the design benefits of TDD. Here's an archived blog post he wrote about the benefits of TDD: http://web.archive.org/web/20120201002523/http://blog.objectmentor.com/articles/2009/10/08/tdd-triage From a design standpoint, he says you need to do all the usual up-front design, but that TDD will help you modify and iterate on your inevitably incomplete initial design quicker.
Re: TDD is BS?
On Thursday, 20 June 2013 at 07:36:41 UTC, Paulo Pinto wrote: ... Just left enough context to ask the following question, I hope I did not left out too much. How does TDD then help how a user of my application will use the application UI? This is the area where I usually make TDD evangelists go speechless in conferences, as they start to present ad-hoc solutions and end up changing subject. -- Paulo Sure. The user, in this case, isn't the user of your application. The user is the person using your API (other programmers). TDD has nothing to do with the visual design of your application and everything to do with the software engineering design. It's to help guide you to the answer to the questions how should I define the behavior of this class/how should this class be used in practice? If your question is how to use TDD for UI, the answer is that you might use TDD for defining the interface to your UI API. But defining an actual UI using TDD is usually kind of awkward and I feel it's missing the point. I'm not saying I haven't seen it done, but typically what people do to test first UI designs isn't really what TDD was meant to do, I feel. --- I guess the short answer is that TDD doesn't make sense to be used for that (IMO). Just like a knife can't be used to cook an egg. I suppose this is where the phrase there is no silver bullet should be put? :)
Re: TDD is BS?
On 2013-06-19 23:19, H. S. Teoh wrote: How do you write a test that covers enough cases for a sudoku solver? I don't know. I you're about to create a sum function and use TDD. 1. Create the test: auto result = sum(1, 2); assert(result == 3); 2. Implement: int sum (int a, int b) { return 3; } In the above case you obviously haven't enough cases in your test to assert that your implementation does what it supposed to do. This example is very simple compared to sudoku. -- /Jacob Carlborg