Wha is a Call Site in Programming?

A call site is the location, the line of code where a specific function is called by passing to it its arguments and receiving its return value.


Kotlin JavaScript “Hello, World!” Project

 This GitHub repository provides you with detailed instructions and an out-of-the-box working sample project to get started with Kotlin and its JavaScript transpilation capability.


Comparison: Rust vs Go

"They are not meant to be competing languages. They fill different needs, designed with different approaches and excels at different things.
If you want to write low-level stuff, something that needs every tiny bit of performance, working directly with the hardware or graphics, and you want to handle the memory. Basically something that you'd use C/C++ to write, something like kernel, driver, graphics library, a big library that exposes a C interface for other languages to call, a game that couldn't work well if there are GC pauses, or something like what Mozilla is building: Servo, a new browser engine. Then go with Rust, just choose Rust, or plain C/C++ for that. I've made the mistake of "fanboyingly" choosing Go for this kind of task and it hurts, it's really stupid and inappropriate, even though Go can definitely do some, it's awkward.
On the other hand, if you want to do something like writing a tool, a server, a web application, a network application or an application to process, send/receive something or whatever that is called high-level. Things that previously people have to use such slow and unsafe scripting languages like Python, Ruby or PHP to write. You don't care about GC, you don't care about memory management, lifetimes and all that stuff, and you shouldn't care because Go is a compiled language which is more than fast enough to do ten times the work. You just want something simple, fast, compiles instantly and makes your code the easiest to read, to understand, to cooperate and to maintain. Choose Go, for the love of god choose Go because it's awesome for the job.
One more thing I want to say: I've made of mistake of being such a fanboy, choosing that language I love for unsuitable tasks. And that's the worst thing. There's no perfect language, there is no best language. The best language is "choosing the right tool for the job"."


Short Definition: Pessimistic Locking vs Optimistic Locking

In Pessimistic Locking a lock is always applied to a modifiable resource once it is accessed in an — even potentially — modifiable transaction. A lock prevents other requests from modifying the resource as the current transaction proceeds. This is necessary to prevent other requests from modifying a resource whereas the current transaction assumes a certain state that is not given anymore as the resource has already been modified by a faster processing operation. This is the core problem that can also be addressed in a different way. In Optimistic Locking, no lock is applied. Instead once a resource is accessed, its state is temporary saved. After the transaction has modified the resource and is about to commit the modified resource to persistent storage, the resource is read again from persistent storage and compared to the temporary saved state from the beginning of the transaction. If the retrieved state differs from the previously temporary saved state of the resource, then the resource has been modified by another operation in the meantime. In this case the current transaction needs to rollback.  

What is better? Depends… but usually you should choose Optimistic Locking as it’s better in multi-user resp. concurrency driven environments. 


Escape @Value Spring Annotation in Kotlin

If you are using Spring annotations like 
in your Kotlin code, you might get compile-time errors like these

Error:Kotlin: [Internal Error] org.jetbrains.jet.utils.KotlinFrontEndException: Exception while analyzing expression at (16,14) in /Users/alex/my/project/loxal/rest-kit/src/main/kotlin/net/loxal/soa/restkit/client/RepositoryClient.kt:
Error:Kotlin: Compiler terminated with exit code: 2

because the ${blub} notation is also used by Kotlin for expression and literal resolution. So just add a backslash like
and everything is going to be alright. 


Client-side Facebook Access Token Retrieval

Save this HTML5 app as facebook-accessToken.html:
<!DOCTYPE html>

<div id="fb-root"></div>
<div class="facebook">Log in with Facebook</div>
<script src="//code.jquery.com/jquery-2.1.0.min.js"></script>
    $(document).ready(function () {
        (function (d, s, id) {
            var js, fjs = d.getElementsByTagName(s)[0];
            if (d.getElementById(id)) return;
            js = d.createElement(s);
            js.id = id;
            js.src = "//connect.facebook.net/en_US/sdk.js";
            fjs.parentNode.insertBefore(js, fjs);

        (document, 'script', 'facebook-jssdk'));
        window.fbAsyncInit = function () {
                        appId: 'App ID, e.g. 2496324382648314, ' +
                        'can be retrieved from ' +
                        'https://developers.facebook.com, under Apps',
                        cookie: false,
                        xfbml: true,
                        version: 'v2.1'                    }

            $('.facebook').on('click', function () {
                FB.login(function (response) {
                    if (response.authResponse) {
                        FB.api('/me', function (response) {


Start a web server on port 80 in the directory where you saved this HTML5 app, executing:
sudo python -m SimpleHTTPServer 80
The web browser console should print something like this:
[Log] CAAUsh234342IUSSDASDsGZAicW7WqmcJreEOzenjJ5kBvuMSDKLJASD224QNHcQ5vM1LPlQBjqWONoSc4zKlUtnnjGfVLNwDuLjZBASD24234CgZAYjiPqTl2p6xVM0hWTh86utuJ99PLXywHg9ZCrMjU6d52DQTnOfXgq0OdzxS (facebook-accessToken.html, line 30) 
[Log] Object (facebook-accessToken.html, line 31) 
[Log] Alexander Orlov (facebook-accessToken.html, line 34)
when you access it using e.g. Cmd + Opt + I in Safari.