6 ms·
Systems Programming at Twitter
- halayli 14y agoThis is more about Scala than systems programming.
- codewright 14y agoFor that matter, it's an incredibly anachronistic and inaccurate usage of systems programming. People generally reserve systems programming to problems that in order to be solved require something closer to gluing toothpicks than spraying memory.
- rudasn 14y agoOn topic then, this is the first time I see Scala syntax and was somewhat pleasantly surprised (the only languages I really know are JavaScript and Python). On slide http://monkey.org/~marius/talks/twittersystems/#16 http://monkey.org/~marius/talks/twittersystems/#16: case class Stock(ticker: String, price: Double) { def <(other: Stock) = price < other.price } val goog = Stock("GOOG", 675.15) val aapl = Stock("AAPL", 604.00) aapl < goog == true goog < aapl == false Correct me if I'm wrong but it seems to me that the class Stock gets a method called "<". So appl.< google (or the other way around) would also work. The previous slide also shows this, but the Stock example is makes it even clearer that "Scala is a pure object oriented language: every value is an object." appl and goog are objects, of type Stock, and < is an object, a method of Stock. I wonder if this kind of method would work def ==(other: Stock) = price != other.price and what would happen if it was like this def ==(other: Stock) = self != other (where self would be a reference to the Stock instance, ala python, or this in javascript) and it was invoked like this appl == goog and return true
- alexdias 14y agoYes, it would work. "==" is a method like any other, and you're overriding it. You should download the Scala IDE and play with a feature called the "Worksheet". See here: https://github.com/scala-ide/scala-worksheet/wiki/Getting-Started https://github.com/scala-ide/scala-worksheet/wiki/Getting-St...
- rudasn 14y agoCool thanks. Isn't this ability a bit dangerous or worrisome? It means that for every Scala package you use you need to review the code. It does make a good prank though :)
- Bjartr 14y agoIt's certainly possible to get out of hand with operator overloading, especially if you try. Take this implementation of "analog literals" in C++ http://www.eelis.net/C++/analogliterals.xhtml http://www.eelis.net/C++/analogliterals.xhtml
- weego 14y agoThere is a library called Dispatch that has/had this problem entirely, the author decided to use symbols instead of natural language method names and left it fairly undocumented, so you had to spend time reading the source to have any idea what was going on. To the point where a kindly soul decided to write a periodic table (http://www.flotsam.nl/dispatch-periodic-table.html http://www.flotsam.nl/dispatch-periodic-table.html) to help people with its use. I wouldn't say it was particularly dangerous, but it is a massive pain to deal with (it also means you can google for any help with a particular method).
- cheald 14y agoFor what it's worth, this is how Ruby operates, as well - "a + b" is really "a.+(b)". In practice, it doesn't end up being very dangerous. Maybe it's just a community thing (the potential for abuse is certainly there), but it means that you get some really nice, natural-feeling code when you do need to use those overrides.
- smegel 14y agoYawn. Headline should have been "Scala tutorial".
- codewright 14y agoDo the dispatches from engineering-land from Twitter strike anyone else as: "Please learn Scala, we can't hire people that already know Scala. Please? Learn Scala." The last presentation of any substance I saw re: Twitter Engineering was their cute BitTorrent based deployment stack.
- DanielRibeiro 14y agoIf you take slides 52[1] to 63[2], you can see the emphasis put into run-time diagnosis. Which is really important for largely distributed systems. Google wrote a little about it when they introduced their global run-time performance tracing tool called Dapper[3] in "Dapper, a Large-Scale Distributed Systems Tracing Infrastructure"[4]" Modern Internet services are often implemented as complex, large-scale distributed systems. These applications are constructed from collections of software modules that may be developed by different teams, perhaps in different programming languages, and could span many thousands of machines across multiple physical facili- ties. Tools that aid in understanding system behavior and reasoning about performance issues are invaluable in such an environment. [1] http://monkey.org/~marius/talks/twittersystems/#52 http://monkey.org/~marius/talks/twittersystems/#52 [2] http://monkey.org/~marius/talks/twittersystems/#63 http://monkey.org/~marius/talks/twittersystems/#63 [3] http://highscalability.com/blog/2010/4/27/paper-dapper-googles-large-scale-distributed-systems-tracing.html http://highscalability.com/blog/2010/4/27/paper-dapper-googl... [4] http://research.google.com/pubs/pub36356.html http://research.google.com/pubs/pub36356.html
- zxypoo 14y agoTwitter open sourced Zipkin, their distributed tracing system based on the Dapper paper: http://twitter.github.com/zipkin/ http://twitter.github.com/zipkin/
- abhijat 14y agoIt appears to have an error on slide 23, where the flatMap should return 1, -1 at the beginning rather than 1, -2? I don't know enough Scala to say with certainty but that seems to be an error: Seq(1,2,3,4) flatMap { x => Seq(x, -x) } == Seq(1,-2,2,-2,3,-3,4,-4)
- domlebo70 14y agoYeah you're right.
- duncans 14y agoOff-topic somewhat, but I appreciate the way the slides used `location.replace('#'+n)` so my browser history wasn't littered with slide navigations, hence the back button brought me back here (but slides are still bookmarkable).
- tzury 14y agoWell, aapl < goog == true Should be false, at least by real market values. ;-)
- deleted 14y ago[deleted]
- shin_lao 14y agoScala is interesting but as others have pointed out, I think it gives a disservice to the presentation to call it "Systems programming at Twitter" . To me it shows two things: * The author doesn't know what system programming is; * Future, promises and generally speaking asynchronous operations are I/O management 101. It doesn't paint your company in a good light to exhibit these techniques as "how we do things". Am I too pedantic?
- frou_dh 14y agoBikeshedding what constitutes Systems Programming has been done to death in Go-related discussions.
- pretoriusB 14y ago>The author doesn't know what system programming is No, it's that systems programming is not what it was. The term now also applies to large scale server side systems, not just drivers and lower level work. See also how Go was presented as a "systems language" for these same uses. >Future, promises and generally speaking asynchronous operations are I/O management 101. It doesn't paint your company in a good light to exhibit these techniques as "how we do things". I/O 101? You'd be surprised. Take a look around the industry, and even HN posts, and you'll find out this is far far from the truth.
- jeremiep 14y agoI couldn't agree more, if this is I/O 101 then most network programmers I've met weren't even aware this course existed! Heck, back when I was in CS I had one teacher who was saying "use Java applets for web forms, its more secure since you can't right click to view the source to see the field names in order to forge a request". Somehow most of his students ended up on government contracts..
- mariusaeriksen 14y agoHello from the author. Indeed the vernacular has changed, and “systems programming” refers also to the distributed systems server software. Composable futures and promises are still fairly new in use; I would wager our systems are some of the largest using the techniques described therein. While this talk focused on composable IO and services, there is much more to it. Finagle (https://github.com/twitter/finagle https://github.com/twitter/finagle) is where the rubber meets the road. Its interfaces are described in these terms and it makes great use of their power. Also, as with any talk, it is difficult to convey the message using only the slides.
- duaneb 14y agoWhatever presentation software is used appears to be nigh unusable on the iPad.
- pionar 14y agoOT, but it took me way too long to figure out how to make the slides advance. I'm an idiot :)
- fkaminski 14y agoI agree this is more about scala than system programming.. I was very happy back then when scala shows up.. but with time i think computer languages should just get out of your way.. be simple as possible.. nowadays im more a Dennis Ritchie/Ken Thompson fan.. they had make simple tools with C and Unix, that just worked.. This is also the Go language school of thought.. Languages must get out of our way, get things done in the simplest way possible.. Functional language people , are more passionate about proving some theoretical points like using immutability all way down.. even if this will blow out your memory resources, or make your code longer.. i think language designers need to be more pratical, and i like when the simplicity way of thought like the one seen in Go comes around the table, to make discussion a little bit more interesting.. We nee more simplicity, work less, so we can be more with our children or family.. and spending less time on our computer.
- jebblue 14y agoI can't get my head around stuff like a function is a value (I can what it's doing, it's the syntax that boggles me) : val f: Int => Int = { x => x*2 } f(123) == 246
- mrcrassic 14y agoIf you do more functional programming, it will become second-hand to you.
- ChrisArchitect 14y agoerr http://news.ycombinator.com/item?id=4732958 http://news.ycombinator.com/item?id=4732958
- mattdw 14y agoWhen all you have is a flatMap, everything looks like a nested list ;). (The author seems to be shoe-horning a lot of different concepts into flatMap via traits. I count several different Monads in there.)
- sanderjd 14y agoIt is possible that you're making the same mistake you accuse the author of making. "You have a hammer and are seeing everything as a nail, but I have a screwdriver and all those things are actually screws."