(注:2016/1/21、頂いたフィードバックをもとに記事を修正いたしました。) 『 Programming in Scala (Scalaでプログラミング) 』の初版を読み始めた(でも読み終えていない)5年前からJavaの代わりにScalaを使うようになりました。最初はテストの時に使用していましたが、すぐにちょっとしたユーティリティクラスでも使用するようになり、気付いたらプロジェクト全てで使用するようになっていました。 Scalaに対する不満は多く存在しますが、この記事は違います。これは非難するものではなく、むしろ称賛するものです。 Scalaに興味ある開発者や聞いたことがあっても詳しく見たことがない人、「スムーズなプログラミングの妨げになる」と思い使用を先送りしていた人のために書きました。もちろんScalaファンに読んでもらうのも、他の人にも紹介してもらうのも大歓迎です。 この記事は3
Dear Hakkers, we—the Akka committers—are very pleased to announce Akka Streams & HTTP 2.0. This major update represents the culmination of an inspiring community push after our 1.0 release more than five months ago. The changes we made can be classified into two categories: We streamlined the API in response to user feedback—both direct and indirect—by offering a well-rounded set of combinators fo
Dependency Injectionとはコンポーネント間の依存関係をプログラムのソースコードから排除し、外部の設定ファイルなどで注入できるようにするソフトウェアパターンである ってwikipedia先生が言ってました。 Scalaにおける最適なDependency Injectionの方法を考察する 〜なぜドワンゴアカウントシステムの生産性は高いのか〜 - Qiita を読んでいろいろ考えたので、なんで今さらって感じのことを書きます。 ScalaでDIというとDIコンテナとかCake PatternとかReader Monadとかって話になっちゃうんですが、これらはいかにかっこよくDIするかの話であって、別にこういった道具やパターンを使わなくてもDIは可能という話です。 Constructor Injection 簡単な例で考えます。今ここにUserRepositoryにべったり依存し
19 November 2015 Comparing Scala’s HTTP client libraries Or why should probably use Play! WS Today we’re looking at the various Scala libraries available to perform HTTP requests. It’s a very easy problem, yet there’s a bunch of projects on Github all hoping to do better than the previous one. Let’s see how they really compare to each other. This comparison is not about low-level performance or cl
By: Heather Miller, Martin Odersky, and Philipp Haller Updated September 15th, 2013 Functional programming languages are regularly touted as an enabling force, as an increasing number of applications become concurrent and distributed. However, managing closures in a concurrent or distributed environment, or writing APIs to be used by clients in such an environment, remains considerably precarious–
Jim has got this pretty much covered in his blog post, but I'm posting a briefing here for reference. First, let's see what the Scala Specification tell us. Chapter 3 (types) tell us about Function Types (3.2.9) and Method Types (3.3.1). Chapter 4 (basic declarations) speaks of Value Declaration and Definitions (4.1), Variable Declaration and Definitions (4.2) and Functions Declarations and Defini
はじめに こんばんは! 突然ですが、 Scala における fold と foldLeft はほとんど同じものだ!と思っていませんか? また、Scala の Option#fold メソッドを使って、何か不自然に思ったことはありませんか? 先に結論を述べますと、 fold メソッドと foldLeft メソッドは異なります(もちろん foldRight とも違いますよ!)。 「ちょっとだけ挙動に差が…」的な違いではなく、根本的に違います。 たまたま、 List#fold と List#foldLeft が(例外的に)似たような定義で、かつ(例外的に)似たような挙動をするため、誤った通説(全てのfold≒foldLeft)があったりなかったりするようです。少なくとも僕は、Scala を書くようになってからある一定の期間、全ての fold と foldLeft は同じものだと考えていました。
利用方法はとても簡単で、カリー化された第一引数にアキュームレータの初期値を渡し、第二引数に関数を渡します。 List(1, 2, 3, 4).foldLeft(0) { (acc, x) => acc + x } // -> 10 "abcd".foldRight(Nil : List[Int]) { (x, acc) => x :: acc } // -> List(97, 98, 99, 100) コレクションAPIに定義されているほとんどのメソッドは、 foldLeft か foldRight を用いて実装することができます。上記の foldLeft のコード例などは、 sum (総和) 関数そのものですね。 さて、それぞれの特徴を比較すると真っ先に目につくのが、foldLeft はスタックセーフな高階関数で、foldRight はそうではない、という点だと思います。それじゃあ、 f
がくぞ @gakuzzzz 初期化子みたいな専用の言語機構をオブジェクトにもコレクションにも用意して個別に覚える必要があるのに比べて、applyが省略可能とい1個のルールのみでその辺までカバーできるシンプルなScalaが複雑だと言われるのは何故なんだぜ? 2015-09-16 12:18:33
2022-06-25 IT Development 1892 Southern Street, New York 09:00AM-07:00PM Register Target audience: Marketing, advertising and PR specialists of development companies, product and project managers responsible for developing and bringing new services and information systems to market.Entrepreneurs who create promising it services and programs.Marketing managers of companies that have considered or a
Still the newbie in Scala and I'm now looking for a way to implement the following code on it: @Override public void store(InputStream source, String destination, long size) { ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(size); final PutObjectRequest request = new PutObjectRequest( this.configuration.getBucket(), destination, source, metadata); new RetryableService(3)
2022-06-25 IT Development 1892 Southern Street, New York 09:00AM-07:00PM Register Target audience: Marketing, advertising and PR specialists of development companies, product and project managers responsible for developing and bringing new services and information systems to market.Entrepreneurs who create promising it services and programs.Marketing managers of companies that have considered or a
While there might be valid cases where such method overloadings could become ambiguous, why does the compiler disallow code which is neither ambiguous at compile time nor at run time? Example: // This fails: def foo(a: String)(b: Int = 42) = a + b def foo(a: Int) (b: Int = 42) = a + b // This fails, too. Even if there is no position in the argument list, // where the types are the same. def foo(a:
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く