Reserved Words of Programming languages

28 November 2016

blog_post_image

Amount of reserved words per programming language:

As You can see Golang has the minimal amount of reserved words.

C++ keywords: 92 words

alignas (since C++11)    dynamic_cast           reinterpret_cast
alignof (since C++11)    else                   requires (concepts TS)
and                      enum                   return
and_eq                   explicit               short
asm                      export(1)              signed
atomic_cancel (TM TS)    extern(1)              sizeof(1)
atomic_commit (TM TS)    false                  static
atomic_noexcept (TM TS)  float                  static_assert (since C++11)
auto(1)                  for                    static_cast
bitand                   friend                 struct(1)
bitor                    goto                   switch
bool                     if                     synchronized (TM TS)
break                    import (modules TS)    template
case                     inline(1)              this
catch                    int                    thread_local (since C++11)
char                     long                   throw
char16_t (since C++11)   module (modules TS)    true
char32_t (since C++11)   mutable(1)             try
class(1)                 namespace              typedef
compl                    new                    typeid
concept (concepts TS)    noexcept (since C++11) typename
const                    not                    union
constexpr (since C++11)  not_eq                 unsigned
const_cast               nullptr (since C++11)  using(1)
continue                 operator               virtual
decltype (since C++11)   or                     void
default(1)               or_eq                  volatile
delete(1)                private                wchar_t
do                       protected              while
double                   public                 xor
                         register(2)            xor_eq

C keywords

C89: 32 words

auto         goto         
break        if           
case         int          
char         long         
const        register     
continue     return       
default      short        
do           signed       
double       sizeof       
else         static       
enum         struct       
extern       switch       
float        typedef      
for          union        

C99: C89 + 5 words

_Bool
_Complex
_Imaginary
inline
restrict

C11: C99 + 5 words

_Alignas        _Noreturn
_Alignof        _Static_assert
_Atomic         _Thread_local
_Generic        _Noreturn

Python 2: 31 words

and       del       from      not       while
as        elif      global    or        with
assert    else      if        pass      yield
break     except    import    print
class     exec      in        raise
continue  finally   is        return
def       for       lambda    try

Python 3: 33 words

False      class      finally    is         return
None       continue   for        lambda     try
True       def        from       nonlocal   while
and        del        global     not        with
as         elif       if         or         yield
assert     else       import     pass
break      except     in         raise

Ruby: 41 words

__ENCODING__
__FILE__  and    def       end     in      or      self   unless
__LINE__  begin  defined?  ensure  module  redo    super  until
BEGIN     break  do        false   next    rescue  then   when
END       case   else      for     nil     retry   true   while
alias     class  elsif     if      not     return  undef  yield

Golang: 25 words

break        default      func         interface    select
case         defer        go           map          struct
chan         else         goto         package      switch
const        fallthrough  if           range        type
continue     for          import       return       var

Java: 53 words

abstract    continue   for         new          switch
assert***   default    goto*       package      synchronized
boolean     do         if          private      this
break       double     implements  protected    throw
byte        else       import      public       throws
case        enum****   instanceof  return       transient
catch       extends    int         short        try
char        final      interface   static       void
class       finally    long        strictfp**   volatile
const*      float      native      super        while
false       true       null

*       not used
**      added in 1.2
***     added in 1.4
****    added in 5.0

Scala : 50 words

abstract    case        catch       class       def
do          else        extends     false       final
finally     for         forSome     if          implicit
import      lazy        macro       match       new
null        object      override    package     private
protected   return      sealed      super       this
throw       trait       try         true        type
val         var         while       with        yield
_    :    =    =>    <-    <:    <%     >:    #    @

Scala’s special symbols (_ : = => <- <: <% >: # @) can be excluded and in this case Scala might have only 40 reserverd words.

Who left Ruby Community?

27 November 2016

blog_post_image

I’ve been listening The Ruby Rogues podcast for several years. Despite the fact the I’m not a Ruby developer ;-). I’m Ruby user if You will.

So, there was one very interesting episode “#283 - Is Ruby Dying?”.
I’m in Java community and it’s very common to hear that “Java is Dying” ;-). But, it’s very uncommon to hear such statement in Ruby-related podcast.

The most interesting part is:

Charles: Yeah, it’s really interesting too. This goes back, you talking about people coming in,
it comes back at least for me to the people who say that the Ruby community is shrinking.
They see prominent members of the community leaving but at the same time they’re typically doing Ruby and something else.
If they’re going and picking up JavaScript, they’re picking up a front-end framework or something
and occasionally they’ll move off to express or something instead of Rails.

But yeah, is the Ruby community really shrinking? Well, the ticket for Rails Conf and Ruby Conf as far as I can tell are getting harder and harder to get. The conference really isn’t getting bigger or smaller, it’s harder and harder to get because more and more people want to go.

And, I’ve decided to find out who are from prominent members of the community leaving:

Name Info Ruby Community Alt/New Community
Yehuda Katz github, site Merb, Ruby on Rails, Bundler, Thor Rust
Steve Klabnik github, site Ruby on Rails Rust
José Valim github Ruby on Rails Elixir
Dave Thomas github, blog wrote the 1st English Ruby Book in 2000 Elixir
Matt Aimonetti github, site Merb, MacRuby Golang
Mark Bates github, site Ruby Conf Speacker, Screencast Golang
Blake Mizerany github Sinatra Golang
Ron Evans github KidsRuby Ruby, Golang
Katrina Owen github, site Ruby Conf Speacker Golang, Ruby
Bryan Liles github Ruby Conf Speacker Golang
Chad Fowler github, site Ruby Conf orginizer, Ruby Books writer Ruby, Scala, Clojure
David Chelimsky github RSpec Ruby, Clojure
Chris McCord github Ruby on Rails Elixir

It’s very interesting aspect of any community.

Please comment/correct me if this table has incorrect info.

Gradle, Groovy, Kotlin. FTW?

15 June 2016

gradle

You’ve probably heard about "Kotlin-based approach to writing Gradle build scripts". A lot of noise was produced based on this announcement and Cédric Champeau tried to explain the real state of Groovy, Gradle and their future relationship.

Just to avoid different speculation about "Gradle is written in Groovy" and now "it will be re-written in Kotlin" here are some numbers:

  • Let’s check the Gradle repo language statistic provided by GitHub

gradle github
  • Gradle root folder has several very important sub-folders:

    • buildSrc - It’s related to Gradle build process

    • config - nothing interesting: condenarc and checkstyle configs

    • design-docs - markdown documentation

    • gradle - Gradle scripts

    • subprojects - Gradle sources. It’s our goal to analyze this folder and understand the language statistics

  • subprojects contains several interesting sub-folders:

    • src/main - actual "gradle" source code

    • src/test, src/integTest and src/testFixtures test source code.

  • Now, count the language stats by cloc tool:

    • src/main:

$ cloc-1.66.exe  --match-d="src/main/" --found=oicloc2.log .
    6052 text files.
Wrote oicloc2.log
    5975 unique files.
    1881 files ignored.

https://github.com/AlDanial/cloc v 1.66  T=19.50 s (298.2 files/s, 23192.5 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Java                          5466          56689         128109         238097
Groovy                         278           3100           5179          14336
JavaScript                       3            160            272           4528
XML                             15              8              0            669
CSS                              6             64             38            354
XSLT                             1             24             31            140
C++                              7              7              0             51
C                                6             22             22             50
Scala                           15             12             39             50
C/C++ Header                     6              9              4             33
HTML                             3              9             17             24
Objective C++                    2              7              0             18
Assembly                         2              1              0             17
JSP                              3              0              0             14
IDL                              1              2              0             14
Objective C                      1              3              0              7
-------------------------------------------------------------------------------
SUM:                          5815          60117         133711         258402
-------------------------------------------------------------------------------

Based on this raw analysis we have 93% Java files and 4.7% Groovy files.

  • Let’s add test ( src/test, src/integTest and src/testFixtures) folders to our statistics:

$ cloc-1.66.exe  --match-d="src/(test|integTest|testFixtures)/" --found=oicloc3.log .
    3867 text files.
Wrote oicloc3.log
    3775 unique files.
    2657 files ignored.

https://github.com/AlDanial/cloc v 1.66  T=15.24 s (243.1 files/s, 29213.4 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
Groovy                        3043          65654          47398         291716
Java                           536           5830           7278          23568
XML                             57             19             36           1845
Maven                           22             57             20            571
HTML                            10             18             10            430
Scala                           24             48            122            162
JavaScript                       5             14             13            105
CSS                              1             19              0             91
DTD                              1             54            164             33
XSLT                             2              6              0             20
CoffeeScript                     1              7              8             13
YAML                             1              0              0              7
JSP                              1              0              0              6
SQL                              1              2              1              2
C                                1              0              0              1
-------------------------------------------------------------------------------
SUM:                          3706          71728          55050         318570
-------------------------------------------------------------------------------

As You can see we have 14.5% Java files and 82% Groovy files.

Summary

Gradle is Java-based project and it uses Groovy for testing and as a DSL implementation tool, nothing more. The noise around "Groovy vs Kotlin" for DSL implementation inside Gradle sounds strange. Gradle Inc. has just made pragmatic decision. That’s it.

Java Day - Kiev, 2015 - Report

08 November 2015

blog_post_image

November 6-7, 2015 I visited Java Day Kyiv conference. This report is for myself just to keep track talks I’ve attended.

Day 1

Day 2

References


Older posts are available in the archive.