News for hackers. Stuff that matters.

tethis

Re:How slow is Python really? Or how fast is your language? on Wednesday April 30, 2014 @09:05PM (#7677560)
If you look at those benchmarks, for the same db queries on the same db backend, throughput and latency can differ by an order of magnitude. We're talking the difference between 200 or 2000 requests per second, or 50ms vs 500ms latency. That's not a rounding error.
Re:Bitcoin Price Pressure on Wednesday April 30, 2014 @04:06PM (#7676042)
But to succeed as a currency, it needs to encourage people to spend.
Re:“Mostly functional” programming does not work on Wednesday April 30, 2014 @03:52PM (#7675927)
I am indeed referring to for-comprehensions. Any time you have nested flatMap/maps you can replace it with a for, since that's all a for-comprehension really is...

  computation1.flatMap { result1 =>
    computation2.flatMap { result2 =>
      computation3.map { result3 =>
        result2 + result3
      }
    }
  }
Becomes...

  val foobar = for {
    result1 <- computation1
    result2 <- computation2(result1)
    result3 <- computation3(result2)
  } yield {
    result2 + result3
  }
Or, since I'm using the async Postgres module which returns Futures, to make them run in parallel you need to create the futures beforehand. I often have something like this...

  val fProject = Project.findById(projectId)
  val fTask = Task.findById(taskId)

  for {
    projectOption <- fProject

    taskOption <- fTask

    students <- projectOption match {
      case Some(project) => Student.findByProject(projectId)
      case None => Future.successful(IndexedSeq[Student]())
    }

    result <- (projectOption, taskOption) match {
      case (Some(project), Some(task)) => { 
        /* do something with project, task and students */ 
      }
      case (None, _) => Future.successful(NotFound(s"Project $projectId not found"))
      case (_, None) => Future.successful(NotFound(s"Task $taskId not found"))
    }
  }
  yield result
By creating the futures first, they both run in parallel and their results are 'collected' by the for comprehension. In the first example, the computations necessarily run in sequence.

I'm using Play framework, for me, these for comprehensions are usually found in my controllers and the final result is an HTTP result.

Passing along failure can still be tricky but I find this much more organized than nesting callbacks.

Re:Bitcoin Price Pressure on Wednesday April 30, 2014 @03:47PM (#7675881)
But if the currency is deflationary with a coin limit, over the long term the only way more people can enter the market / make use the currency is for, as an example, $1 USD to be represented by smaller and smaller subdivisions of BTC. This necessarily increases the value of 1 BTC.

Why is there ever any incentive to do anything with BTC besides hoarding?

Re:How slow is Python really? Or how fast is your language? on Wednesday April 30, 2014 @03:29PM (#7675754)
The point of these benchmarks is that, given the same database and the same queries, languages have different performance profiles.

If I build an application in Java and Python, with the same database backend, running the exact same set of SQL queries, the Java application should perform better.

Re:Firefox 29 on Tuesday April 29, 2014 @02:21PM (#7668961)
The address bar works as both now, it seems that the search bar is left there so that it doesn't startle all the neophobes even more.
Re:“Mostly functional” programming does not work on Sunday April 27, 2014 @09:48AM (#7655024)
And it's important to note with Scala, a big part of its complexity comes from the practical philosophy of its creators: purity is sacrificed in order to actually make it work on the JVM the way we want it to.

I used to work with Java on the server-side, but I'm programming almost entirely in Scala now (I'm at a small shop where I was lucky enough to convince the boss to let me give it a go on a project last year) and I've got to say that it's completely changed the way I think about and solve problems. I learned Haskell in university and I'm trying to learn more, but I don't see it ever being accepted in our office.

The Scala syntax does (especially when working with async programming / Futures) suffer from problems, like the nested callback problem that Javascript also has, but there is an elegant solution in the language... you just have to know how to use it. But on the other hand, it doesn't look like a completely foreign language to Java developers and it's not too hard to get our new hires productive with it.

Re:DEC64: Decimal Floating Point on Saturday March 08, 2014 @07:58PM (#7367032)
Providing additional information about the author is a logical fallacy now?

Also, see: http://www.logicalfallacies.info/relevance/fallacists/

Re:Apple Explains How Secure iMessage Is on Thursday February 27, 2014 @10:25PM (#7317062)
And it would also only be for a specific user, rather than the dragnet surveillance (biggest fishing trip in history) that the NSA, et al, are conducting.
Re:Losing graciously on Friday February 14, 2014 @06:03PM (#7241661)
Are they preventing you from installing GNOME2 on your desktop?
Re:Silk Road 2 Hacked, All Bitcoins Stolen on Thursday February 13, 2014 @06:39PM (#7235549)
Yeah, right, they "got hacked".
CKEditor 4 also supports inline editing like this.
Re:A letter from Paper (FiftyThree) to Paper (Facebook) on Monday February 03, 2014 @06:55PM (#7174472)
Sweet jesus I cannot read that font.
Re:CoffeeScript 1.7.0 on Tuesday January 28, 2014 @07:33PM (#7140918)
It's also included by default in Play Framework.

I used it for a while, on a large project, and eventually came to hate it. I try to write as clean code as ppossible but still found the resulting mess of words, commas and arrows floating around at differing indentation levels to be much harder to read.

To me, even though javascripts syntax can be annoying, it's parentheses provide a certain amount of structure to the code.

Re:CoffeeScript 1.7.0 on Tuesday January 28, 2014 @07:26PM (#7140877)
Ooh, is there a story behind this one?
Re:Which programming language has the best package manager? on Thursday January 23, 2014 @07:48PM (#7112649)
I've been pleasantly surprised using SBT... it's been doing the job for me for a year now and I haven't had any problems.
Re:Graph of Programming Language Influences on Thursday January 23, 2014 @07:45PM (#7112635)
I know I like to talk about Haskell, even if it's too dense for me to grasp at a level where I could put it into production without jumping off a bridge.
Re:Confession From a Go Programmer on Thursday January 23, 2014 @07:39PM (#7112605)
This isn't really a "confession"... just someone gushing over a programming language in a terrible looking font.
Re:W3Schools Hider: Hide W3Schools results from Google searches on Thursday January 23, 2014 @06:03PM (#7112072)
Not if you have to type that out every single time...
Re:Debunking Princeton on Thursday January 23, 2014 @05:58PM (#7112038)
Google Trends predicts own demise?
Re:Django vs. Flask for a long-term project on Thursday January 23, 2014 @02:38AM (#7107312)
There certainly are ORMs available with Play!

I'm using one called Activate (http://activate-framework.org/) in a few of my latest projects and it's really simplified things. There's also Squeryl, ReactiveMongo, Slick...

Re:How the Drug War Disappeared the Jury Trial on Thursday January 16, 2014 @10:33PM (#7074113)
We just had a ruling a couple months ago, up here in Canada, that a 3-year mandatory minimum sentence involve possession of a loaded firearm was unconstitutional as it is considered "cruel and unusual punishment".

Is such a challenge possible in the USA?

Re:PSD to HTML is Dead on Tuesday January 14, 2014 @11:25PM (#7061672)
Let me know when you find that grave, because I'll join you after eating a huge bowl of chilli.
Re:Node OS on Tuesday January 14, 2014 @11:24PM (#7061667)
My thoughts exactly!