Programming

9 thoughts
last posted July 1, 2015, 3:08 p.m.
0
get stream as: markdown or atom
0

Good news.

The Kotlin plugin will be part of IntelliJ IDEA 15.

Today, we’re excited to share with you that the EAP build we published yesterday comes with a bundled Kotlin plugin

JetBrains aims to release Kotlin 1.0 this year.

If you’re following the latest news in the Kotlin blog, you may know that its team is working hard to make it ready for the release this year.


http://blog.jetbrains.com/idea/2015/07/intellij-idea-15-eap-kotlin-love/

0

Kotlin now has sealed classes. I think they primarily resemble the concept of "tagged union"s. Rust has a similar elegant construct in form of enums.

sealed class Type () {
    class Named(val name: String): Type()
    class Nested {
        class Function(val param: Type, 
                       val result: Type): Type()
    }
    object Top: Type()
}
when (type) {
    is Named -> println(name)
    is Nested.Function -> println("$param -> $result")
    // Alternatively, we can omit is here
    is Top -> println("TOP")
}

0

Some links for the Kotlin programming language:

0

"Java is a blue collar language. It’s not PhD thesis material but a language for a job. Java feels very familiar to many different programmers because I had a very strong tendency to prefer things that had been used a lot over things that just sounded like a good idea."

I think Kotlin is a language that adopts this idea really good.


0

Some Mozilla guys released a paper about programming experience with their new programming language Rust and this Servo web layout engine.

I didn't program much in Rust, but follow a lot of their work on Github and Reddit. I have some old Rust code of a "CPU emulator" inspired by LLVM and libcpu by Michael Steil et al with deprecated sigil syntax ~ for pointers.

I really like Rust but the borrow checker is not my best friend.


0

This academic stuff is very arcane somehow. Let's go mainstream, but with a bit pattern-matching sugar:

fun fib(n: Int): Int {
    return when (n) {
        1, 2 -> 1
        else -> fib(n - 1) + fib(n - 2)
    }
}

fun main(args: Array<String>) {
    for (n in 1..10) {
        println("fib($n) = ${fib(n)}")
    }
}

Is recursion good? I don't know. Just make sure you use the iterative version in production code.

0

There is also a lot of beauty in the polymorphic defined recursive functions I first saw in Erlang:

-module(fib).
-export([fib/1]).

fib(1) -> 1;
fib(2) -> 1;
fib(N) -> fib(N - 2) + fib(N - 1).

Similarily, there is also a lot of beautyness when we consider logical programming and this substitution and unification stuff in Prolog. I first saw this, when I learned about contraint satisfaction problems.

append([], X, X).
append([X|XS], YS, [X|ZS]) :- append(XS, YS, ZS).

% ?- append([], [1, 2], [1, 2]).
% true.

% ?- append([6], [1, 2], [6, 1, 2]).
% true.

% ?- append(X, [1, 2], [6, 1, 2]).
% X = [6] ;

  • Petra Hofstedt, Armin Wolf (2007): "Einführung in die Constraint-Programmierung", Springer
0

The first time I saw variable and return types on the right side after a colon was in ActionScript. This was beautiful.

function repeatString(string:String, 
                      numTimes:uint):String 
{
    var output:String = "";
    for(var i:uint = 0; i < numTimes; i++) 
    {
        output += string;
    }
    return output;
}

Now a lot of very nice modern programming languages use this convention: TypeScript, Scala, Kotlin, Rust, Swift.

0

Jetbrains Kotlin has a new fresh background image on its project site.

What does this tower mean? Somehow this is very impressive.