1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

rustとscalaとkotilnの勉強 hello world をcargo sbt gradle で

Last updated at Posted at 2018-06-09

Rustから

Rustはcargoを使う

プロジェクトを作成

cargo new hello_cargo --bin

hello_cargoディレクトリができるのでcd

cargo.tomlに色々書けるらしいがとりあえずは放置
ビルト

cargo build

リリースビルドするときは —-releaseで

cargo build —-release

runでビルドして実行

cargo run

checkでコンパイラのチェックだけする

cargo check

sbtとgradleはググったサイトを丸パクリ。
意味はよくわかってない。そのうちわかるといいな。

scalaといえばsbt
hello_sbt用にプロジェクトをつくる

sbt new sbt/scala-seed.g8

プロジェクト名を聞かれるのでhello_sbtと入力
hello_sbtディレクトリができるのでcd
~/src/main/scalaにhello.scalaを書く

sbtをたたいてrun

[xxx/ ~/study/scala/projects/hello_sbt/hello_sbt/ #docker-scala#]% sbt
Getting org.scala-sbt sbt 1.1.1  (this may take some time)...
:: retrieving :: org.scala-sbt#boot-app
        confs: [default]
        75 artifacts copied, 0 already retrieved (27501kB/231ms)
[info] Loading project definition from /home/xxx/study/scala/projects/hello_sbt/hello_sbt/project
[info] Loading settings from build.sbt ...
[info] Set current project to Hello (in build file:/home/xxx/study/scala/projects/hello_sbt/hello_sbt/)
[info] sbt server started at local:///home/xxx/.sbt/1.0/server/8c79b53261d7cc7d0f28/sock
sbt:Hello> run
[info] Running Hello 
こんにちは世界
[success] Total time: 1 s, completed 2018/06/09 1:43:51
sbt:Hello> exit

kotlinはgradle
ますはプロジェクトをつくる

mkdir hello_gradle
cd hello_gradle
gradle init

build.gradleを以下に書き換え

plugins {
	    id "org.jetbrains.kotlin.jvm" version "1.1.3-2"
}

apply plugin: 'application'

mainClassName = 'HelloKt'

repositories {
	    jcenter()
}

dependencies {
	    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8"
}

/src/main/kotlinにHello.ktをつくる

fun main(args:Array<String>){
	println("こんにちは世界")
}

ビルド

./gradlew build

実行

./gradlew run
1
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?