This is an automated email from the ASF dual-hosted git repository.

pabloem pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git


The following commit(s) were added to refs/heads/master by this push:
     new 563fa37  [BEAM-7139] Blogpost for Kotlin Samples (#8391)
563fa37 is described below

commit 563fa3772d7a044bf0c28baf28fb77a3b58800d6
Author: Harshit Dwivedi <47669588+harshithdwiv...@users.noreply.github.com>
AuthorDate: Fri Apr 26 08:18:54 2019 +0530

    [BEAM-7139] Blogpost for Kotlin Samples (#8391)
    
    * feat : add the blogpost for kotlin samples
    
    Signed-off-by: Harshit Dwivedi <hars...@pitech.app>
    
    * fix : modify date and update authors.yml
    
    Signed-off-by: Harshit Dwivedi <hars...@pitech.app>
    
    * fix : image resolution
    
    Signed-off-by: Harshit Dwivedi <hars...@pitech.app>
    
    * add syntax highlighting
    
    * fix syntax highlighting
---
 website/src/_data/authors.yml                |   4 +
 website/src/_posts/2019-04-25-beam-kotlin.md | 114 +++++++++++++++++++++++++++
 website/src/images/blog/kotlin.png           | Bin 0 -> 14563 bytes
 3 files changed, 118 insertions(+)

diff --git a/website/src/_data/authors.yml b/website/src/_data/authors.yml
index 3ffa693..16c6f1a 100644
--- a/website/src/_data/authors.yml
+++ b/website/src/_data/authors.yml
@@ -40,6 +40,10 @@ fjp:
     name: Frances Perry
     email: fran...@apache.org
     twitter: francesjperry
+harshithdwivedi:
+    name: Harshit Dwivedi
+    email: harshithdwiv...@gmail.com
+    twitter: harshithdwivedi
 iemejia:
     name: Ismaël Mejía
     email: ieme...@apache.org
diff --git a/website/src/_posts/2019-04-25-beam-kotlin.md 
b/website/src/_posts/2019-04-25-beam-kotlin.md
new file mode 100644
index 0000000..1969deb
--- /dev/null
+++ b/website/src/_posts/2019-04-25-beam-kotlin.md
@@ -0,0 +1,114 @@
+---
+layout: post
+title:  "Apache Beam + Kotlin = ❤️"
+date:   2019-04-25 00:00:01 -0800
+excerpt_separator: <!--more-->
+categories: blog
+authors:
+        - harshithdwivedi
+
+---
+<!--
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+
+Apache Beam samples are now available in Kotlin!
+
+<!--more-->
+
+<img src="{{ "/images/blog/kotlin.png" | prepend: site.baseurl }}" 
alt="Kotlin" height="320" width="800" >
+
+If you are someone who's been working with Java in your professional career; 
there's a good chance that you've also heard of 
[Kotlin](https://kotlinlang.org/), which is an Open Sourced, statically typed 
language for JVM and is mostly being favoured by Android Developers due to the 
many myriad features which enable more concise and cleaner code than Java 
without sacrificing performance or safety.
+
+It gives us an immense pleasure to announce that we are also taking a step 
ahead in the same direction and releasing the samples for the Beam SDK in 
Kotlin alongside Java!
+ 
+ (Note : At the time of writing this post, only the WordCount samples have 
been added in Koltin with more samples underway)
+
+
+## Code Snippets
+Here are few brief snippets of code that show how the Kotlin Samples compare 
to Java 
+
+### Java
+
+```java
+ String filename = String.format(
+                    "%s-%s-of-%s%s",
+                    filenamePrefixForWindow(intervalWindow),
+                    shardNumber,
+                    numShards,
+                    outputFileHints.suggestedFilenameSuffix);
+```
+
+### Kotlin
+
+```java
+ // String templating
+ val filename = 
"$filenamePrefixForWindow(intervalWindow)-$shardNumber-of-$numShards${outputFileHints.suggestedFilenameSuffix)"
  
+```
+
+### Java 
+
+```java
+public static class FormatAsTextFn extends SimpleFunction<KV<String, Long>, 
String> {
+    @Override
+    public String apply(KV<String, Long> input) {
+        return input.getKey() + ": " + input.getValue();
+    }
+}
+```
+
+## Kotlin
+
+```java
+public class FormatAsTextFn : SimpleFunction<KV<String, Long>, String>() {
+    override fun apply(input: KV<String, Long>) = "${input.key} : 
${input.value}"  //Single line functions
+}
+```
+
+### Java
+
+```java
+if(tableRow != null){
+    formatAndInsert(tableRow);
+}
+```
+
+### Kotlin
+
+```java
+tableRow?.let{
+    formatAndInsert(it)  // No need for null checks
+}
+```
+
+### Java
+
+```java
+String tableName = "testTable";
+```
+
+### Kotlin
+
+```java
+val tableName = "testTable"  // Type inferencing
+```
+
+## Contributors Welcomed!
+
+While we're still adding more samples and streamlining the current ones, we 
would love to have your feedback on the code snippets.
+You can find them over here : 
[https://github.com/apache/beam/tree/master/examples/kotlin](https://github.com/apache/beam/tree/master/examples/kotlin)
+
+If you are using Kotlin with Apache Beam already; we would very much 
appreciate if you went ahead and help us convert the existing samples from Java 
into Koltin.
+
+Thank you, and we are looking forward to feedback from you!
diff --git a/website/src/images/blog/kotlin.png 
b/website/src/images/blog/kotlin.png
new file mode 100644
index 0000000..6b965ac
Binary files /dev/null and b/website/src/images/blog/kotlin.png differ

Reply via email to