9 ms·
D for the Win
- lclarkmichalek 12y agoI know this is an inevitable comment on any article that calls any software slow, but: "~500 requests/sec" using ten servers? Python may be slow, but I would be very suprised if it can't do 50req/second.
- falcolas 12y agoThis doesn't pass the smell test for me either. I'm running a Python Django server with a primarily write load on an EC2 small instance, and easily exceeding 50 requests per second, with very low load on the box.
- eps 12y agoIt all depends on what a request is. The req/sec metric alone makes no sense.
- tomwilde 12y agoAs I read it that's one AWS server of unknown size serving ~500rps of an application of unknown complexity. Tripled when using PyPy (whatever that is). Maybe a very small instance serving something fairly complex?
- bkeroack 12y agoYeah, I read it as 500 rps per instance, which is not unreasonable for AWS.
- valarauca1 12y agoHow complex? In one second a modern processor can do ~1 billion operations (ish, some are faster, some are slower, sometimes multiple are done in the same clock tick). Even if its slow, core2 architecture. This means they have the time for about ~200 million instructions per request (Ignoring internal disk I/O, or network I/O). That amount of work is insane! :.:.: I want to say their doing something fundamentally wrong. And it has nothing to do with their language.
- tachyonbeam 12y agoThe i7 can dispatch 4 instructions per cycle. In practice, I find it can realistically execute about 2 per cycle. So at 2GHz, that's closer to 4 billion instructions per second, or ~800M instructions per request as per your calculation. The slowness of their system can probably be blamed on slow database access, or some kind of initialization cost they're paying for every request (i.e.: calling into a binary like in the old CGI days, initializing the Python VM every time).
- valarauca1 12y agoLike I said something fundamentally wrong. With their approach. Un-Indexed databases, databases far away from front end servers (in terms of network topography), or weird VM things with python. Something is bad, and if changing languages solved their problems, they are just sweeping an issue under the rug. It'll hit them in the face later, and harder. Be it developer knowledge, or architectural choices. It'll surface again, they'll (hopefully) be large, and the problem will sting harder too.
- tomwilde 12y agoUnless you're a mathematician or theoretical physicist the gross of your CPU time will be spent waiting for IO. Reading from disk, writing to the network, synchronizing, etc. They're probably just aggregating 2 or 3 APIs, maybe hitting a database and then adding it all together. That description can apply to almost any and all web applications and is inherently IO-bound.
- copx 12y ago>Unless you're a mathematician or theoretical physicist [...] ..or Dwarf Fortress player ;)
- valarauca1 12y agoOooh thank you for reminding me. I recently upgraded to a i7-4790k I've been meaning to jump back into DF now that I should have much better single threaded performance. I honestly haven't played since 2008 on my parents home pentium3.
- loxs 12y agoYep, I could readily point to my Erlang application that can serve thousands of requests per second, doing real work. While simultaneously handling 10k+ websocket connections. All that on a single machine (16G RAM, 8 cores). Does that mean that Erlang is the best? Of course not! It only means that Erlang was specifically designed for this sole use case, which only happens to encompass the whole "web" thingie. It would be an overkill to use Erlang for single-threaded software that requires number crunching speed or for any kind of system scripting. Comparing Erlang to D or Python is stupid. As is (IMHO) using any of the latter for massively parallel servers.
- cjslep 12y ago> go (Google must be joking if they actually consider it for system programming) I am curious what led the author to be dismissive of Go in such a strongly negative manner. Lack of generics? Disagree with certain language design choices? Too many cuddly caricatures of gophers?
- Ironballs 12y agoGo hasn't been intended for "systems programming" for quite a while. It is a general purpose language.
- tomwilde 12y agoThose properties are not mutually exclusive.
- seabee 12y agoC++ is the counterexample in nearly all such cases, for better or worse!
- rakoo 12y agoThe important distinction here is that go creators never set "system programming" as a goal, contrary to what OP implied in the blog post. Now, whether go turns out to be good at that task is another story
- andralex 12y agoGo has been announced as a systems programming language: https://www.youtube.com/watch?v=rKnDgT73v8s https://www.youtube.com/watch?v=rKnDgT73v8s. After some backlash the slogan has been changed quietly.
- jacques_chester 12y agoNevertheless, many of the design decisions make sense in that context. For example: the difference in initialisation of simple data types vs slices and maps. For an application programmer these are weird inconsistencies. But they make sense in the domain. Or the way error handling works. Very tedious to have to do-check, do-check, and not be able to have automatic upwards delegation. But in system programming it's about robustness, not ease of development. A database server can't just restart if it has a file or memory problem. There needs to be a solution and it needs to be immediately next to the problem.
- deleted 12y ago[deleted]
- charlieflowers 12y ago"The strange alias _curr this is a lovely feature of D known as subtyping. It basically means that any property that doesn't exist at the struct's scope will we forwarded to _curr, e.g., when I write myCtx.foo and myCtx has no member named foo, the code is rewritten as myCtx._curr.foo." That's a great feature. I don't see many languages investing enough focus into this kind of "delegation wiring."
- 4ad 12y agoGo has something similar, but it's implicit with type embedding, you don't have to explicitly alias anything; also the Plan 9 C dialect has it too (and was used extensively in the Go runtime until recently). One nice idiom in Plan 9 is to be able to call Lock on various structures that embed a lock.
- p0nce 12y agoCan you give a code example in Go?
- cjslep 12y agoQuick example on the playground, if this is what you were asking about: http://play.golang.org/p/zShJKp0t3n http://play.golang.org/p/zShJKp0t3n
- eco 12y agoSo subtyping automatically happens for all members of a struct? I'm not sure I like that but I guess I'd have to see how well it works in practice.
- 4ad 12y agoNo, it only happens if you embed the type, a.i. the member is anonymous. http://golang.org/doc/effective_go.html#embedding http://golang.org/doc/effective_go.html#embedding http://golang.org/ref/spec#Struct_types http://golang.org/ref/spec#Struct_types Note that there's also interface embedding which is a different thing.
- ckaygusu 12y agoThis article is full of D hype and so so so far away from reality. Alright, some basics; Everything that has to access persistent information frequently is bound by disk/network/whatever IO, and web programming is no different. The reason why languages such as Python and Ruby are very viable options for this task is they are quite a lot abstracted away from bare metal to hasten the development process. The wait for IO is quite long compared to logic execution, so even though we are executing more instructions to get the same job done, the resulting overhead isn't very significant. CPU-Bound computations are most definitely will execute faster in statically compiled languages such as C/C++, D, golang relative to interpreted languages but in the context of web programming this is not the case. Even though; if rendering HTML is such a big pain in the ass that it is slowing you down a lot you can always use a library that is implemented in a language that's fast, say C, and use its wrappings in your scripting language of choice. I am not sure about to what extent this is supported in other languages but I know you can do this in Python, heck you can do this in golang, even though it is a relatively new language [1]. I wonder how the author will move to C10M world by optimizing the wrong thing. [1] http://gopy.qur.me/extensions/ http://gopy.qur.me/extensions/
- a8da6b0c91d 12y agoPeople endlessly parroting the "IO bound" line never post numbers. As far as I've seen it's just not true. Things like web apps are routinely bottle-necked by execution speed, not disk or network.
- marcosdumay 12y agoWell, my experience is that web apps are most often bottlenecked by the database speed, because almost any other problem can be solved with money (and not even much of it). I've seen databases bottleneck on lots of different resources, even some virtual ones (unexpected serializing). But I'm very suspicious of people claiming that one must write webapps in low level languages "because speed". (And yes, I know there exist problems out there where this is true, the same way that there exist people out there that've won the lottery.)
- skizm 12y agoPython a D have totally different use cases. Just because you can do something with Python doesn't mean you should.
- pjmlp 12y agoTell that to all those guys writing desktop utilities in Python slow as molasses. Every time I get some GNU/Linux GUI utility running very very slow and check the code, it is Python under the hood.
- klibertp 12y agoOn the other hand, every time I start a program and have to wait tens and hundreds of seconds for it to finally fully load, it's invariable written in C, C++ or Java... Now I could start bashing Java and the others, but I hope I don't need to and that you already realized that your comment is a bit unfair.
- anon4 12y agoPlease, it's really unfair to single out Linux GUI tools. Basic system utilities are also written in python, like yum, which masks its slowness by doing network access on each invocation and makes you think that's why it's so slow.
- pjmlp 12y agoI singled out GUIs, because it seems to be so pervasive nowadays, as if the coders couldn't do better.
- gldsmth 12y agoAnd yum has always been much slower than apt-get.
- danieldk 12y ago...and it it used to be far worse. In the old days it was spending most of its time parsing metadata, until the C metadata parser introduced, and later sqlite databases were added to repositories as an alternative for the XML metadata. I even backported the C metadata parser to CentOS 3 and 4, because it was a whole different experience altogether: http://lists.centos.org/pipermail/centos-devel/2007-May/001732.html http://lists.centos.org/pipermail/centos-devel/2007-May/0017...
- kolev 12y agoI definitely agree that D is better from many and all the hype of the day gos to Go, not D. I really have issues with the Go syntax though - it's really not intuitive, some things are just made different just for the sake of being different, syntax is all over the place. I think Rust is way more elegant, unfortunately, it doesn't get as much hype as it deserves compared to Go.
- cnbuff410 12y agoWhat makes Go's syntax that unintuitive to you? Go's syntax is really easy to most programmers who is willing to learn. It's probably just 1 days work to pick it up. It's very similar to Swift's syntax in many aspects, and I don't hear anyone complaining Swift's syntax is not intuitive and just for the sake of being different. Perhaps instead of just claiming you can give us some examples on "syntax is all over the place" part?
- fleitz 12y agoI think the reason swift gets away with it is because it borrows enough from a language you already know that the rest feels like an addition. (eg. Python + that, C# plus this, OCaml + brackets, c++ plus ARC, ObjC minus square brackets) Also, swift has an API that's familiar to ObjC devs which means it's just changing brackets. It's pretty easy to port a ObjC program to swift line by line.
- kolev 12y agoWorking with something familiar is always a good thing. Having something intuitive is a great pleasure for your soul - you memorize generic principles, not specific constructs. I like in rust that they really put abbreviation all across the board consistently. If they use "fn" as a keyword, also system lib is abbreviated similarly "to the max". I don't have to remember is it "string" or "str" - Rust consistency saves time and makes it obvious.
- klibertp 12y ago> syntax is really easy to most programmers who is willing to learn This is exactly how this sentence should look like, no need for any language at the beginning. While syntax does matter (and I only recently arrived at this conclusion) its "intuitiveness" or "similarity" is utterly unimportant. You either are a "real programmer" and have no problem picking up different syntaxes and semantics, or you're not. That's all there is to it.
- saosebastiao 12y agoWhy did Walter choose to not open source the compiler from the beginning? I would be willing to bet that it would hold the position that Ruby/Python currently hold if he had made that choice. The ability to apt-get/yum to install a language on a cheap linux server would have done wonders for its adoption, especially in the middle of the rise of linux and the web.
- tdees40 12y agoI feel like D's lack of adoption was mostly due to issues around the way things transpired, specifically the closed-source compiler and of course the big mess with the standard library. Otherwise it was well-placed and well-timed, just ill-executed.
- andralex 12y agoI think it's a good point. I can't speak for Walter, but I can say I've fostered openness ever since joining D development and we're both glad things are now in the right place.
- eco 12y agoPerhaps that would have helped with adoption. I'm not all that convinced that would have really tipped the scales. It's been 5 years since it was open sourced and there have been over a hundred contributors but it's still only fairly recently gotten to the point where development is more about mundane bug fixes instead of implementing huge, unfinished parts of the language and blocker bugs that make the language hard to use. Open sourcing sooner would have given it a head start but even then, I don't think D would have been ready for heavy use in the middle of the rise of linux and the web. Here's what Walter said at the time when asked why it took so long: I've been intending to for a while, it took a while for me to clean it up, check all the licenses, and get it into a presentable form. Essentially, it's pretty obvious that the world has changed, and closed source is no longer acceptable for a mainstream product that people will be relying on. Open source is the future, and it's past time for dmd to join the party!
- WalterBright 12y agoThe D front end is not only open sourced now, it is Boost licensed, which is the most open of the open source licenses. Over in the D community we're very proud of our use of the Boost license.
- smegel 12y ago> The code must compile If the code compiles, it must run without error?
- Abscissa 12y agoIf it compiles, it must run without several entire classes of errors.
- beagle3 12y agoI have a lot of respect for Walter and for D. But having not enough time to try everything, I'm leaning towards doing a project in Nimrod[0] when I have the time. D people who have some knowledge of Nimrod (or Nimrod people who have good knowledge of D) - where do you think D outdoes Nimrod? D is more mature, with a larger community, and a recognized brand - granted, and these are NOT trivial things -- in practice, they usually matter more than any specific feature. Yet, my question in this case IS about language/environment features. As far as I can tell, all the examples in the article can be done at least as easily/tersely/nicely, if not more so, in Nimrod. [0] http://nimrod-lang.org/ http://nimrod-lang.org/
- CyberShadow 12y agoI don't know much Nimrod, but here's an article I wrote about a D package I also wrote, in which a number of D features have come together in an especially pleasing way: http://blog.thecybershadow.net/2014/03/21/functional-image-processing-in-d/ http://blog.thecybershadow.net/2014/03/21/functional-image-p... I'd be interested to know if the same expressiveness is possible in other languages without sacrificing speed.