MEAP Edition Manning Early Access Program Nim in Action Version 1

Size: px
Start display at page:

Download "MEAP Edition Manning Early Access Program Nim in Action Version 1"

Transcription

1

2 MEAP Edition Manning Early Access Program Nim in Action Version 1 Copyright 2016 Manning Publications For more information on this and other Manning titles go to

3 Welcome Thank you for purchasing the MEAP of Nim in Action. This is the first ever book about Nim and I am very excited to share the knowledge contained in it with you. This book assumes that you are fluent in at least one other programming language. When I began writing it, I made a conscious decision to focus the intended audience on software developers, computer science students, hobbyist programmers, and the like. As an example, this book will often show you features of the Nim programming language and then compare those features to that of other programming languages. To illustrate the difference better, fundamentals of programming in general will not be covered, whereas fundamentals of programming in Nim specifically will. My journey with Nim began in 2010, when I stumbled upon it as I was searching for a compiled replacement for Python. Since then I have been a core part of Nim s development, over the years I have written many of the modules in Nim s standard library as well as tools such as the Nimble package manager, which is now a major part of Nim s ecosystem. This has given me a wealth of experiences and knowledge about Nim which I hope to share with you in this book. Nim in Action is divided into three parts. Part 1 will teach you the basics of Nim, it consists of two chapters, both of which I encourage you to read even if you are already familiar with Nim. Part 2 of the book is more practical and consists of 5 chapters which will lead you through the development of some impressive and hopefully fun to write software including a chat application. Part 3 consists of 3 chapters covering advanced topics like metaprogramming. The MEAP starts with the first three chapters of the book. Chapter 1 explains what Nim is; its uses, strengths and weaknesses. Chapter 2 first gives instructions on how to set up Nim and related tools; it then goes on to describe many aspects of Nim s syntax, some of the most useful built-in types, the semantics of control flow statements, and much more. Chapter 3 puts many of the concepts which you will have learned in Chapter 2 into practice, by guiding you through the development of a simple chat application. As you develop the chat application, you will learn how to retrieve input from the user, how to parse and generate JSON, and how to transfer data over the network. It is my hope that you will enjoy learning Nim with the aid of this book. I encourage you to visit the Author Online forum, where you will have the opportunity to leave any comments, suggestions, and questions you have about Nim in Action. I will truly appreciate you taking the time to do so, as any comments are extremely valuable in the development process. Thanks again and I hope you enjoy Nim in Action. Dominik Picheta

4 brief contents PART 1: THE BASICS OF NIM 1 Why Nim? 2 Getting started PART 2: NIM IN PRACTICE 3 Writing a chat application 4 Standard library 5 Package management and other tools 6 Concurrency 7 Building a Twitter clone PART 3: ADVANCED CONCEPTS 8 Interfacing with other languages 9 Metaprogramming 10 Direct hardware control

5 1 1 Why Nim? In this chapter Why should you learn Nim? Comparison to other programming languages Use cases Strengths and weaknesses In the past century, technology has been evolving at a very fast rate. The last 70 years in particular saw computer hardware steadily improving together with programming languages. Programming languages have a long history of evolution, very few programming languages that were around in the 50s are around now. Thousands are created every year, some only used by but a handful of people, others becoming adopted by millions of programmers around the world to become mainstream. When the first computer was invented, the primary method of programming was writing machine code specific to your computer s CPU. Machine code is still used today, but it is not written by programmers; in most cases it is generated by compilers because writing large and complex pieces of software using machine code would be an extremely time consuming and draining experience. The first programming languages were designed and implemented to make software development easier and less error prone; to this day, programming languages try to strike the perfect balance between ensuring that programmers make the least mistakes possible and that programmers are as efficient at writing software as possible. Each new programming language builds upon older programming languages, adding tiny innovations along the way or combining features from multiple programming languages to create a new and better programming language. Nim is still a relatively new programming language. In fact, you are holding one of the very first books on it. The language is still not fully complete, but core aspects like its

6 2 syntax, the semantics of procedures, methods, iterators, generics, templates, and more are all set in stone. Despite this, there has been a significant interest in Nim from the programming community. This chapter includes answers to questions that you may ask before learning Nim, such as why you would want to use Nim. I will outline some of the common practical uses of Nim, compare it to other programming languages and discuss some of Nim s strengths and weaknesses. In Chapter 2 I will begin teaching you Nim, including how to set up and use the compiler, and the basics that you need to know to begin writing software in Nim. 1.1 What is Nim? Nim is a general-purpose programming language designed to be efficient, expressive and elegant. These 3 goals are of course difficult to achieve at the same time, so the designers of Nim have given each of them different priorities. Efficiency being the most important and elegance being the least important. The development of Nim began in Andreas Rumpf developed Nim on his own for the next 3 years before releasing the source code and starting to develop Nim publicly in It wasn t long before the project gained support and many contributions from the open source community. Nowadays the development of Nim is still lead by Andreas Rumpf, with many volunteers around the world contributing code via pull requests on Github. 1 Footnote 1mCurrent open Nim pull requests, TIP Contributing to Nim The Nim compiler, standard library and related tools are all open source. The project is available on Github, and everyone is encouraged to contribute. Use cases for Nim Nim was designed to be a general purpose programming language from its inception. As such, it was designed with a wide range of features to make it usable for just about any software project. This design makes it a good candidate for writing software in a wide variety of application domains ranging from web applications to kernels. Nim does indeed support practically any application domain. But this does not mean that it is the right choice for everything. Certain aspects of Nim make it more suitable for some categories of applications than others. This does not mean that these applications cannot be written using Nim; it just means that Nim may not support the code styles that are well suited for writing those kinds of applications. One detail of how Nim compiles your application makes it a language that is particularly well suited to systems programming. You will find that the Nim compiler

7 3 compiles Nim source code into C code first. C is a pretty old but well supported systems programming language; because of this, Nim allows more direct and easier access to the physical hardware of the machine. As such, Nim is very well suited to writing operating systems, compilers, device drivers, embedded system software, and more. Despite the fact that Nim is still a new programming language, there are already many examples of such projects. For example, a very simple operating system called NimKernel is available on Github here: NOTE How does Nim compile source code. The full details of Nim s unusual compilation model and it s benefits are described in a later section title How does it work?. Applications written in Nim are very fast. Nim as a whole values efficiency the most and provides features which make optimizing code easy. This goes hand in hand with Nim s soft real-time garbage collector. Which allows you to specify the amount of time that it should spend collecting memory. This is important for games development where an ordinary garbage collector may slow down the rendering of frames on the screen, if it takes up too much time collecting memory. It is also useful in real-time systems which need to run in very strict time frames. Applications which perform input/output operations such as reading files or sending data over a network are well supported by Nim. Web applications for example can be written easily using a number of web frameworks like Jester. Nim s script-like syntax together with the powerful asynchronous input/output support makes rapid development of these applications easy. Footnote 2mhttps://github.com/dom96/jester Nim is particularly well suited to writing command-line applications because it does not require any runtime dependencies (unlike Java with the JVM or Python with the Python interpreter). Applications can be compiled to be standalone without any dependencies easily and distributed across many machines without any issues. One example of such an application that has been written in Nim is Nimble; it is a package manager for Nim and allows users to install packages containing Nim libraries and applications. Those are just some examples of the use cases that Nim can be used for. There are of course many more. Nim is still in development and has not yet reached a stable version. Because of this some of its features may not yet be finished. This can make Nim less suited for certain applications. For example, Nim includes a JavaScript backend that allows you to write JavaScript applications for your web pages in Nim. This backend works but does not yet support all of the features of JavaScript that are needed to write good client-side web applications. This will improve with time. 2

8 4 You should now know a little bit about what Nim is, its history and some of the applications that it s suitable for. The next sub-sections demonstrate some of Nim s features and talk about how Nim works Core features In many ways Nim is very innovative. Many of Nim s features can t be found in any other programming language. If you enjoy learning new programming languages, especially those with interesting and unique features, then this is the language for you. In this section we will look at some of the core features of Nim. In particular the features which make Nim stand out from other programming languages. Metaprogramming The most practical as well as in some sense unique feature of Nim is its extensive metaprogramming support. Metaprogramming was by no means a Nim invention, but there is no other programming language with metaprogramming that is so extensive and at the same time easy to pick up as Nim s. If you re familiar with Lisp then you might have some experience with metaprogramming already. Metaprogramming in Nim is special because languages with good metaprogramming features typically belong to the Lisp family of languages. If you are already familiar with the likes of Java or Python then you will find it easier to start using Nim than Lisp. You will also find it more natural to learn how to use Nim s metaprogramming features rather than Lisp s. Metaprogramming is generally an advanced topic. It is a very powerful feature which you will be introduced to in Chapter 9 of this book in greater detail. One of the main benefits that metaprogramming brings is the ability to remove boilerplate code. Metaprogramming also allows the creation of domain specific languages, which can be used to include mini-languages inside Nim source code. For example: html: body: p: "Hello World" The mini-language above specifies a bit of HTML code. In this case: <html>, <body> and <p>hello World</p> will be returned by the code above. Metaprogramming in Nim allows you to define such languages and mix them freely together with your ordinary Nim code. Such languages have many use cases, for example the one above can be used to create HTML templates for your web apps. Style insensitivity Another interesting and likely unique feature of Nim is style insensitivity. One of the hardest things a programmer has to do is to come up with names for all sorts of identifiers like variables, functions and modules. In many programming languages these

9 5 names cannot contain whitespace, so programmers were forced to adopt another way of separating multiple words in a single name. As is often the case, multiple differing methods were devised. The most popular being snake_case and camelcase which are still debated to this day. Nim allows you to use snake_case even if the identifier has been defined using camelcase, and vice versa. This allows you to write code in your preferred style even if the library which you are utilizing uses a different style for its identifiers. Listing 1.1 Style insensitivity import strutils echo("hello".to_upper()) echo("world".toupper()) The strutils module defines a procedure called toupper We can call it using snake_case or, as it was originally defined using camelcase. This works because Nim considers the identifiers to_upper and toupper to be equal. It does not bother with case, or the underscores when comparing identifiers. Powerful type system One of the many characteristics which differentiate programming language from one another is their type system. The main purpose of a type system is to reduce the possibilities for bugs in your programs. Other benefits which a good type system provides are the possibility of certain compiler optimisations, better documentation of code and more. There are many different categories used to classify a programming language s type system. The main categories are the static and dynamic type systems. In most cases a programming language is not on the extreme end of either of those type systems, it incorporates ideas from both. This is done because both require certain trade-offs. While static typing finds more errors at compile-time, it also decreases the speed at which programs can be written. Dynamic typing is the exact opposite. Nim leans towards static typing. But unlike some statically typed programming languages it also incorporates many features which make development fast. Type inference is a good example of that, types can be figured out by the compiler without the need for you to write the types out yourself, unless you choose to write them out of course. Because of that your program is still bug free and your development speed is not hindered. Nim also incorporates some dynamic type-checking features such as runtime type information which allows for dynamic dispatch of functions. One way that a type system will ensure that your program is free of bugs is by

10 6 verifying memory safety. Some programming languages like C are not memory safe, because they allow programs to access memory which has not been assigned for their use. Other programming languages are memory safe, at the expense of allowing programs to access low-level details of memory, which in some cases is necessary. Nim combines both, it is memory safe as long as you don t use any of the unsafe types such as ptr in your program, at the same time the ptr type is necessary when interfacing with C libraries and supporting these unsafe features makes Nim a powerful systems programming language. Lastly, one of the most important features of Nim s type system is the ability to utilize generic programming. Generics in Nim allow for a great deal of code reuse without sacrificing type safety. One of the things they allow is to specify that a single function can accept multiple different types. You may for example have a shownumber procedure which displays both integers and floats on the screen. proc shownumber(num: int float) = echo(num) shownumber(3.14) shownumber(42) In the listing above the shownumber procedure accepts either an int type or a float type. The operator is used to specify that both int and float can be passed to the procedure. This listing is a very simple demonstration of Nim s generics, you will learn a lot more about Nim s type system as well as generics in the next chapter. Compilation I have mentioned in the previous section that the Nim compiler compiles source code into C first, and then feeds that source code into a C compiler. You will learn a lot more about how this works in detail in the How does it work? section, but right now let me talk about some of the many practical advantages that this compilation model has. The C programming language is very well established as a systems programming language and has been in use for over 40 years. C is one of the most portable programming languages, with multiple implementations for Windows, Linux, Mac OS X, x86, amd64, arm and many other more obscure operating systems and platforms. C compilers support everything from a super computer to a micro-controller, they are also very mature and implement many powerful optimizations which makes C very efficient. Nim takes advantage of these aspects of C, including its portability, widespread use and efficiency. One specific benefit of compiling to C is that unlike programming languages which run on the JVM, such as Java, Scala or Clojure, and interpreted programming languages such as Python, Ruby and Perl. Nim software can run without any dependencies. This makes distribution of your applications very easy. One situation where this is a huge

11 7 advantage is when deploying web applications to multiple web servers, the lack of dependencies means that you can simply upload your web application s binary executable and run it without needing to install any additional dependencies on the server. This also makes Nim very well suited to embedded systems where resources such as memory and disk space are limited. Compilation to C also makes it very simple to use existing C and C++ libraries. This is done by first wrapping those libraries, wrapping can be done manually or with a tool called c2nim which generates these wrappers automatically. NOTE c2nim The c2nim tool cannot translate every single piece of C/C++ code out there, in some cases you may need to manually edit parts of the code. Look for more information in Chapter 8. There are very many libraries written in C and C++, many of which are very popular. You can use all of these libraries very easily from Nim. This works both ways, so you can also write libraries which can then be used from C and other programming languages. The Nim compiler can also compile Nim source code into Objective C and JavaScript. Objective C is the language mainly used for ios software development. By compiling to Objective C, you have the ability to write ios applications natively in Nim. This also includes Android applications which can be written using Java or C. Nim doesn't currently compile to Java, but it does compile to C. By doing so, Nim can also be used to create Android applications. JavaScript is the client-side language used by billions of websites, it is sometimes called the "assembly language of the web" because it is the only programming language that is supported by all the major web browsers. By compiling Nim to JavaScript you can write client-side applications for web browsers in Nim. Memory management C and C++ both require you to manually manage memory, carefully ensuring that what you allocate is deallocated once it is no longer needed. Nim on the other hand manages memory for you using a garbage collector. Garbage collectors are considered by many to be inadequate for certain application domains like embedded systems and games. For this reason, Nim supports a number of different garbage collectors with different applications in mind. The default garbage collector is real-time so it allows you to specify the amount of time it should spend on collecting memory. It is well suited for real-time systems and games, because it will not pause your applications for unknown periods of time. The garbage collector can also be removed completely, giving you the ability to manage memory yourself.

12 8 TIP Garbage collectors Switching between garbage collectors is easy, you just need to specify the --gc:<thegc> flag during compilation and replace <thegc> with one of either markandsweep, boehm, or none. There is a lot more to Nim, not just the unique and innovative features but also the unique composition of features from existing programming languages which makes Nim as a whole very unique indeed. Now let me tell you exactly how Nim works How does it work? One of the things that makes Nim unique is its implementation. Every programming language has an implementation in the form of an application, which either interprets the source code, or compiles the source code into an executable. These implementations are called an interpreter and compiler respectively. While some languages may have multiple implementations, Nim s only implementation is a compiler. The compiler compiles Nim source code by first translating the code to another programming language called C, then passing that C source code to a C compiler which then compiles it into a binary executable. The executable is a file containing instructions which indicate the specific tasks that the computer should perform, these instructions include ones specified in the original Nim source code. Let s say that you have written a calculator program, in the compilation process the executable is the program itself, it is what you execute in order to run your calculator and start feeding it calculations you wish it to perform. Figure 1.1 shows how a piece of Nim code is compiled. Figure 1.1 How Nim compiles source code Most programming languages have compilers which do not have this extra step, they themselves compile the source code into a binary executable. Some programming language implementations don t even compile code at all. Figure 1.2 shows how different programming languages transform source code into something which can perform tasks as programmed by the source code.

13 9 Figure 1.2 How the Nim compilation process compares to other programming languages As you can see the Nim compilation process joins into C s compilation process, in order to compile the C source code that was generated as part of the Nim compilation process. This does mean that the Nim compiler depends on an external C compiler such as GCC or clang. But despite this, compilation is still very fast. The result of the compilation is an executable. It can be started in order to execute the instructions contained in the initial source code. These instructions result in a number of actions being performed, one of these actions may be the download of a file from the internet or the addition of two inputs. Compiled programming languages such as Nim, C, Go, D, and Rust produce an executable which is native to the operating system on which the compiler is running on. Compiling a Nim application on Windows will result in an executable which can only be run on Windows. Similarly compiling it on Mac OS X will result in one which can only be run on Mac OS X. The CPU architecture also comes into this, compilation on ARM will result in an executable which is only compatible with ARM CPUs. This is how things work by default, it is possible to instruct the compiler to compile executable for a different operating system and CPU combination through a process known as cross-compilation. This problem is one of the major reasons why the JVM was created. You may have heard the phrase "write once, run anywhere". This is a slogan created by Sun Microsystems to illustrate the cross-platform benefits of the Java programming language. A Java application only needs to be compiled once, the result of this compilation is a JAR file which holds all of the compiled Java classes. The JAR file can then be executed

14 10 by the Java Virtual Machine in order to execute the programmed actions. This JAR file can be executed by the Java Virtual Machine on any platform and architecture. The JAR file is a platform and architecture agnostic executable. The downside to this is that the Java Virtual Machine must be installed on the user s system in order to run these JAR files. Adding another dependency is not ideal, the JVM is very big and may not be suitable for certain use cases, it also adds another piece of software which may contain bugs and security issues. Python is similar to this. It also utilizes a virtual machine to execute code. But in Python s case the virtual machine is used to optimize the execution of Python s code, it is mostly just an implementation detail. In basic terms, Python code is interpreted through a Python interpreter. The Python interpreter parses the code, determines what actions that code is describing and immediately executes those actions. There is no compilation step like with Java, C or Nim. But the disadvantages are the same, in order to execute a Python application the system needs to have a Python interpreter installed. In addition to this, any breaking changes to the Python language mean that applications which have been written in it may stop executing. This happened when Python 3 was released, and there are still libraries written for Python 2 which do not work with the Python 3 interpreter. 3 Footnote 3mhttp://py3readiness.org/ Similar to the "write once, run anywhere" slogan, other programming languages adopted the "write once, compile anywhere" philosophy which describes the fact that the programming language is only cross-platform at the source code level. In other words, you do not need to write platform specific code. This applies to languages such as C++, Pascal and Ada. But these languages still require platform specific code when dealing with more specialised features of the operating system, such as creating new threads or downloading the contents of a web page. Nim goes a step further, its standard library abstracts away the differences between operating systems and allows you to utilize a lot of the features that modern operating systems offer today. This should give you a good idea of the way in which Nim source code is transformed into a working application and how this process is different to the one used in other programming language s. The next section will evaluate positive and some negative aspects about Nim. 1.2 Nim s benefits and shortcomings I think that while it is important to understand the reasons why you might want to use a language, it is also just as important to learn about the reasons why that language may not be correct for your particular use case. In the spirit of that, this section will first compare Nim to a number of other programming languages. I will use a variety of characteristics and factors that are

15 11 typically used in such comparisons. After that you will learn about some of the areas where Nim might still need to catch up with other languages, it is after all a very new programming language Benefits There are many programming languages out there. As you read this book you may wonder how Nim compares to the programming languages that you are familiar with. There are many ways to compare programming languages, multiple factors that can be considered including their speed, expressiveness, development speed, readability, language s ecosystem and more. I will talk about some of these here. Nim is efficient The speed of a programming language is one characteristic that is often used to compare multiple programming languages. One of Nim s goals is efficiency, so it should be no surprise that it is a very efficient programming language. In the previous section I told you that when Nim source code is compiled it is first translated to the C programming language. This suggests that the performance of Nim is very similar to C, and that is in fact true. Nim can be used as a replacement for C because it fully compiles to C source code which makes it fully C compatible. Nim has similar performance, results in software which is more reliable than software written in C, features an improved type system, supports generics and advanced metaprogramming. Metaprogramming in Nim is unique, it does not use a preprocessor but is instead a part of the main compilation process. Those are just some of the reasons why you may want to choose Nim for your next project instead of C. In general you can expect to find many modern features in Nim which you are not going to find in C. Table 1.1 shows the results of a small benchmark. Nim matches C s speed and is significantly faster than Python. 4 Footnote 4mhttp://hookrace.net/blog/what-is-special-about-nim/#good-performance Table 1.1mTime taken to calculate which numbers of the first 100 million are prime Programming language C 2.6 Time (seconds) Nim 2.6 Python 35.1 In this benchmark the runtime of the Nim application matches the speed of the C one and is significantly faster than the one implemented in Python. Micro benchmarks such as this one are often unreliable, but they are one of the only ways of getting an idea as to

16 12 the speed of a programming language. Nim s performance matches that of C which is already one of the most efficient programming languages out there. Nim is readable Nim is a very expressive language, much like Python from which it borrows some syntax, including the wonderful indentation delimited scope. Nim code is not cluttered by the curly brackets and semicolons of C-like programming languages such as JavaScript and C++, nor does it require the do and end keywords that are present in languages such as Ruby. This makes Nim very easy to write but also, more importantly, easy to read. Good code readability goes a long way, it makes debugging easier leading to less time spent debugging which means you can spend more time writing beautiful Nim code and as a result cut down on your development time. Take a look at the following examples and don t worry if you don t understand them yet. The examples implement a function that calculates the Fibonacci sequence which is defined as the following: 0, 1, 1, 2, 3, 5, 8,. This sequence begins with 0 and 1, and the next numbers in the sequence are the sum of the previous two numbers. The examples in Listing 1.2 and Listing 1.3 calculate this sequence and display it to the user. Listing 1.2 Iterating through the Fibonacci sequence in Nim proc fibonacci(n: int64) = ## Displays the first ``n`` amount of numbers in the fibonacci sequence. var first = 0 var second = 1 echo first echo second for i in 0.. <n: swap first, second second += first echo second fibonacci(1_000_000) Listing 1.3 Iterating through the Fibonacci sequence in Java public class Fibonacci { /* * Displays the first ``n`` amount of numbers in the * fibonacci sequence. */ public static void fibonacci(int n) { long first = 0; long second = 1; System.out.println(first); System.out.println(second);

17 13 for(int i = n; i > 0; i--) { long temp = first; first = second; second = temp; } } second += first; System.out.println(second); } public static void main(string[] args) { fibonacci( ); } Despite the simplicity of this algorithm, the amount of noise in the Nim code is considerably lower than in the Java code. The Nim code is a lot more readable and compact, whereas the Java code is full of boilerplate. In Nim, all of the code that is in the global scope is executed as if it was in a main method which eliminates the need to specify that method. Nim stands on its own Writing applications in Nim has another major added benefit: the lack of dependencies. When writing applications in Python, distributing them can be a time consuming and error prone experience. In most cases the source code is distributed to the user and it is assumed that the user has the correct version of the Python interpreter installed. Alternatively the interpreter can be bundled with the source code. In both cases the Python interpreter is a big dependency which makes distribution of your application more difficult. Distributing Nim applications can be much easier in comparison, you simply compile your source code and distribute the binaries. One example of the difficulty associated with distributing Python applications is the recent introduction of Python 3, which has caused many issues for software which was originally written for Python 2 due to the fact that Python 3 is not backward compatible with Python 2. If something like this occurred with a compiled programming language then the binaries would at least still continue to work. Many programming languages suffer from these problems. In particular, languages which are interpreted including Ruby, Python, PHP, as well as languages which run on the Java Virtual Machine: Clojure, Scala, Java and more. Nim can be used as a replacement for all of these programming languages as a more efficient, less dependent, and just as or more expressive language. Replacing Python is especially easy because its syntax is so similar to Nim s. Nim is flexible Software may be written in different styles. The different styles and capabilities of programming languages are defined by their supported programming paradigms. A

18 14 programming paradigm is the fundamental style of writing software. A paradigm you may be familiar with is OOP (Object Oriented Programming), this paradigm is often taught as part of Computer Science courses at university. It allows programmers to model real world objects and their relationships using code. Nim is a multi-paradigm programming language, this means that it supports multiple programming paradigms. Unlike some of the popular programming languages, Nim does not focus on the OOP paradigm. It is mainly a procedural programming language, with varying support for OOP, functional, declarative, concurrent programming and more programming styles. That is not to say that OOP is not well supported by Nim. OOP as a programming style is simply not forced upon you. Common OOP features which are supported include inheritance, polymorphism, and dynamic dispatch. There is one big difference between the OOP paradigm and the procedural paradigm. In the OOP paradigm, methods and attributes are bound to objects, and the methods operate on their own data structure. In the procedural paradigm, procedures are standalone entities which operate on data structures. This may be hard for you to visualise, so I will show you some code examples to illustrate it better. TIP Subroutine terminology In the above paragraph I mentioned the terms methods and procedures, these are simply another name for subroutines or functions. A method is the term used in the context of OOP, a procedure in the context of procedural programming, and a function in the context of functional programming. The following code listings show the same application. The first is written in Python using the OOP style described above. The second is written in Nim using the procedural style described above. Listing 1.4 Barking dog modelled using OOP in Python class Dog: def bark(self): print("woof!") dog = Dog() dog.bark() The bark method is associated with the Dog class by being defined within it. The bark method can be directly invoked on the dog object by accessing the method via the dot.

19 15 Listing 1.5 Barking dog modelled using procedural programming in Nim type Dog = object proc bark(self: Dog) = echo("woof!") var dog = Dog() dog.bark() The bark method is not directly associated with the Dog type by being defined within it. This method could also easily be defined outside this module. The bark method can still be directly invoked on the dog object, despite the fact that the procedure is not associated with the Dog type as it is associated in the Python version. In the Python code, the method bark is placed under the class definition. In the Nim code, the method bark (called a procedure in Nim) is not bound to the Dog type in the same way as it is in the Python code, it is independent of the definition of the Dog type. Instead its first argument specifies the type it is associated with. Something similar could also be implemented in Python but it would not allow us to call the bark method in the same manner, we would be forced to call it like so: bark(dog). Explicitly passing the dog variable to the method as its first argument. The reason this is not the case with Nim is because Nim has been designed to rewrite dog.bark() to bark(dog), allowing you to call methods using the traditional OOP style without having to explicitly bind them to a class. This ability is referred to as Uniform Function Call Syntax and has multiple advantages. It allows you to create new procedures on existing objects externally and allows procedure calls to be chained. TIP Classes in Nim Defining classes and methods in Nim in a manner similar to Python is also possible. The community has created numerous macros which emulate the syntax. 5 Footnote 5mhttps://nim-by-example.github.io/oop_macro/ Another paradigm that Nim has support for is the functional programming paradigm. While the OOP paradigm has been popular for many years now, the functional paradigm in comparison is not as popular, but in recent years it has seen a surge in popularity.

20 16 Functional programming is a style of programming which primarily avoids the changing of state and the use of mutable data. It introduces the use of certain features such as first-class functions, anonymous functions and closures which are all supported by Nim. Let s take a look at an example to show the differences between programming in a procedural style and a functional one. The following code listings show code which separates people s names into a first and last name. The first code listing shows it in a functional style and second in a procedural style. Listing 1.6 Iterating over a sequence using functional programming in Nim import sequtils, future, strutils var list Picheta", "Andreas Rumpf", "Desmond Hume"] list.map( (x: string) -> (string, string) => (x.split[0], x.split[1]) ).echo Import the sequtils, future and strutils module. These modules define the map,, and split procedures respectively. Define new list variable containing a list of names. The map procedure is used to iterate over the list. The map procedure takes a closure which specifies how to modify each item in the list. The modified list is then displayed on the screen. Listing 1.7 Iterating over a sequence using a procedural style in Nim import strutils var list Picheta", "Andreas Rumpf", "Desmond Hume"] for name in list: echo((name.split[0], name.split[1])) Import the strutils module which defines the split procedure. A for loop is used to iterate over each item in the list. The code inside the for loop is executed during each iteration, in this case each name is split into two and displayed as a tuple. The functional version uses the map procedure to iterate over the variable list, which contains a list of names. Whereas the procedural version uses a for loop. Both versions split the name into a first name and a last name. They then display the result in a tuple. There is a lot of new terms being thrown at you here, don t worry if you are not familiar with them as you will be introduced to them in the next chapter. The output of the code listings will look something this:

21 17 (Field0: Dominik, Field1: Picheta) (Field0: Andreas, Field1: Rumpf) (Field0: Desmond, Field1: Hume) Nim is incredibly flexible and allows you to write software in many different styles. This was just a small taste of some of the most popular paradigms supported by Nim, and how they compare to Nim s main paradigm. More obscure paradigms are also supported, and support for more can be introduced easily by using macros. Nim catches errors ahead of time Nim is a statically typed programming language and as such it provides a certain level of type safety that dynamically typed programming languages do not provide. Throughout this chapter I have been vaguely comparing Python to Nim. While Nim does take a lot of inspiration from Python. They do differ in one important way: Python is dynamically typed. Despite the fact that Nim is statically typed it does feel very dynamic as it supports type inference and generics. You will learn what this means in the second chapter, but think of it as a way to retain the high development speed that dynamically typed programming languages allow, while also providing extra type safety at compile-time. In addition to Nim being statically typed, it also implements an exception tracking mechanism that is entirely opt-in. Exception tracking allows you to ensure that a procedure will not raise any exceptions or will only raise exceptions from a pre-defined list. This prevents unexpected crashes by ensuring that you handle exceptions. Summary This section compared Nim to some other programming languages based on characteristics such as efficiency, dependencies of the resulting software, flexibility of the language and the language s ability to catch errors before the software is deployed. Based on these characteristics alone, Nim is a very good candidate for replacing some of the most popular programming languages out there including Python, Java, C and more. For reference, here is a table showing a list of programming languages and some of the features that they do and do not support.

22 18 Table 1.2mCommon programming language features Programming language Static typing Generics Modules GC Syntax Metaprogramming Execution Nim Yes Yes Yes Yes, multiple Python-like Yes Compiled binary C Yes No No No C No Compiled binary C++ Yes Yes No No C-like No Compiled binary Go Yes No Yes Yes C-like No Compiled binary Rust Yes Yes Yes No C-like Limited (A) Compiled binary Java Yes Yes Yes Yes C-like No Executed via Java Virtual Machine Python No N/A Yes Yes Python Limited (B) Executed via Python interpreter Lua No N/A Yes Yes Modula-like (C) Yes via Metalua Executed via Lua interpreter or Lua JIT compiler (A) - Rust has some support for declarative macros through its macro_rules! directive, no built-in procedural macros that allow you to transform the AST except for compiler plugins, and no CTFE (Compile Time Function Execution) (B) - In Python you modify the behaviour of functions by using decorators, this is done at runtime and does not allow you to modify the AST directly. (C) - Uses do and end keywords to delimit scope Areas where Nim still needs to improve Nothing in this world is perfect, programming languages are no exception. There is no perfect programming language that can solve each problem in the most reliable and quickest manner. Each programming language has its strengths and weaknesses. Nim is no exception. This chapter has so far been focusing almost solely on Nim s strengths. There is a lot of good things about Nim that I have not mentioned in this chapter, and you will discover what those things are throughout this book. But it would be unfair for me to only talk about Nim s strengths. Nim is still a relatively young programming language, so there are of course areas where the language can still improve. Nim is still young and immature

23 19 All programming languages go through a period of immaturity. Some of Nim s more advanced and new features are still unstable. Using them can result in buggy behavior in the compiler like for example crashes. In reality crashes don t happen very often, also the unstable features of the language are opt-in which means that you can t accidentally use them. Nim has a package manager called Nimble, and while other programming languages may have thousands of packages available, Nim only has about 300. This means that in some situations you may need to write libraries for certain tasks. This situation is of course improving, with new packages being created by the Nim community every day. By the end of chapter 5 you will be able to create your own packages. Nim s user base and community is still quite small Nim has very few users in comparison to the mainstream programming languages such as Python or Java. The result is that unfortunately there is very few jobs that ask for knowledge of Nim. Finding a company that uses Nim in production is rare, but when it does happen the demand for good Nim programmers tends to make the salaries quite high. On the other hand, one of the most special things about Nim is that its development is very open. Nim s creator, Andreas Rumpf, and many other Nim developers (including me) discuss Nim s future development plans on Github and on IRC openly. Anyone is free to challenge these plans and because the community is still quite small it is very easy to do so. IRC is also a great place for newcomers to ask questions about Nim and to meet fellow Nim programmers! TIP IRC Take a look at the Getting Help appendix to learn how to connect to IRC! Having said all of this, these problems are temporary. Nim has a bright future ahead of it, and you can help shape it. This book will teach you how! 1.3 Summary This chapter should have given you a good understanding of what Nim is, how it works on a basic level and whether it is the right programming language for you. Some of the things we covered: Nim is still a very new programming language, it has not yet reached version 1.0. Nim has been designed to be efficient, expressive and elegant (in that order). Nim is an open source project that is developed entirely by the Nim community of volunteers. Nim was created by Andreas Rumpf in Nim is general purpose and can be used to develop anything from web applications to kernels.

24 20 Nim is a compiled programming language which compiles to C and takes advantage of C s speed and portability. Nim supports multiple programming paradigms including OOP, procedural programming and functional programming. Nim has multiple innovative features which make it appealing to enhusiasts, including style insensitivity and metaprogramming. Nim is still very new which makes it a bit immature and it s user base is still quite small. The next chapter will teach you the basics of Nim, including how to set up the Nim compiler and the foundations of Nim that you need to be familiar with in order to begin writing software in Nim.

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014 CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages Nicki Dell Spring 2014 What is a Programming Language? A set of symbols and associated tools that translate (if necessary) collections

More information

C# and Other Languages

C# and Other Languages C# and Other Languages Rob Miles Department of Computer Science Why do we have lots of Programming Languages? Different developer audiences Different application areas/target platforms Graphics, AI, List

More information

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives Introduction to Programming and Algorithms Module 1 CS 146 Sam Houston State University Dr. Tim McGuire Module Objectives To understand: the necessity of programming, differences between hardware and software,

More information

1/20/2016 INTRODUCTION

1/20/2016 INTRODUCTION INTRODUCTION 1 Programming languages have common concepts that are seen in all languages This course will discuss and illustrate these common concepts: Syntax Names Types Semantics Memory Management We

More information

Evolution of the Major Programming Languages

Evolution of the Major Programming Languages 142 Evolution of the Major Programming Languages Object Oriented Programming: Smalltalk Object-Oriented: It s fundamental characteristics are: Data abstraction, Inheritance and Dynamic Binding. The essence

More information

General Introduction

General Introduction Managed Runtime Technology: General Introduction Xiao-Feng Li (xiaofeng.li@gmail.com) 2012-10-10 Agenda Virtual machines Managed runtime systems EE and MM (JIT and GC) Summary 10/10/2012 Managed Runtime

More information

Building Applications Using Micro Focus COBOL

Building Applications Using Micro Focus COBOL Building Applications Using Micro Focus COBOL Abstract If you look through the Micro Focus COBOL documentation, you will see many different executable file types referenced: int, gnt, exe, dll and others.

More information

Chapter 1. Dr. Chris Irwin Davis Email: cid021000@utdallas.edu Phone: (972) 883-3574 Office: ECSS 4.705. CS-4337 Organization of Programming Languages

Chapter 1. Dr. Chris Irwin Davis Email: cid021000@utdallas.edu Phone: (972) 883-3574 Office: ECSS 4.705. CS-4337 Organization of Programming Languages Chapter 1 CS-4337 Organization of Programming Languages Dr. Chris Irwin Davis Email: cid021000@utdallas.edu Phone: (972) 883-3574 Office: ECSS 4.705 Chapter 1 Topics Reasons for Studying Concepts of Programming

More information

The Decaffeinated Robot

The Decaffeinated Robot Developing on without Java Texas Linux Fest 2 April 2011 Overview for Why? architecture Decaffeinating for Why? architecture Decaffeinating for Why choose? Why? architecture Decaffeinating for Why choose?

More information

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages ICOM 4036 Programming Languages Preliminaries Dr. Amirhossein Chinaei Dept. of Electrical & Computer Engineering UPRM Spring 2010 Language Evaluation Criteria Readability: the ease with which programs

More information

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming

Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming Characteristics of Java (Optional) Y. Daniel Liang Supplement for Introduction to Java Programming Java has become enormously popular. Java s rapid rise and wide acceptance can be traced to its design

More information

1. Overview of the Java Language

1. Overview of the Java Language 1. Overview of the Java Language What Is the Java Technology? Java technology is: A programming language A development environment An application environment A deployment environment It is similar in syntax

More information

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq

qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq qwertyuiopasdfghjklzxcvbnmqwerty uiopasdfghjklzxcvbnmqwertyuiopasd fghjklzxcvbnmqwertyuiopasdfghjklzx cvbnmqwertyuiopasdfghjklzxcvbnmq Introduction to Programming using Java wertyuiopasdfghjklzxcvbnmqwertyui

More information

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1 The Java Series Java Essentials I What is Java? Basic Language Constructs Slide 1 What is Java? A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose

More information

CSC230 Getting Starting in C. Tyler Bletsch

CSC230 Getting Starting in C. Tyler Bletsch CSC230 Getting Starting in C Tyler Bletsch What is C? The language of UNIX Procedural language (no classes) Low-level access to memory Easy to map to machine language Not much run-time stuff needed Surprisingly

More information

Programming Languages

Programming Languages Programming Languages Qing Yi Course web site: www.cs.utsa.edu/~qingyi/cs3723 cs3723 1 A little about myself Qing Yi Ph.D. Rice University, USA. Assistant Professor, Department of Computer Science Office:

More information

An Easier Way for Cross-Platform Data Acquisition Application Development

An Easier Way for Cross-Platform Data Acquisition Application Development An Easier Way for Cross-Platform Data Acquisition Application Development For industrial automation and measurement system developers, software technology continues making rapid progress. Software engineers

More information

Jonathan Worthington Scarborough Linux User Group

Jonathan Worthington Scarborough Linux User Group Jonathan Worthington Scarborough Linux User Group Introduction What does a Virtual Machine do? Hides away the details of the hardware platform and operating system. Defines a common set of instructions.

More information

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz 2007 03 16

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz 2007 03 16 Advanced compiler construction Michel Schinz 2007 03 16 General course information Teacher & assistant Course goals Teacher: Michel Schinz Michel.Schinz@epfl.ch Assistant: Iulian Dragos INR 321, 368 64

More information

CS 40 Computing for the Web

CS 40 Computing for the Web CS 40 Computing for the Web Art Lee January 20, 2015 Announcements Course web on Sakai Homework assignments submit them on Sakai Email me the survey: See the Announcements page on the course web for instructions

More information

Lecture 1 Introduction to Android

Lecture 1 Introduction to Android These slides are by Dr. Jaerock Kwon at. The original URL is http://kettering.jrkwon.com/sites/default/files/2011-2/ce-491/lecture/alecture-01.pdf so please use that instead of pointing to this local copy

More information

From Faust to Web Audio: Compiling Faust to JavaScript using Emscripten

From Faust to Web Audio: Compiling Faust to JavaScript using Emscripten From Faust to Web Audio: Compiling Faust to JavaScript using Emscripten Myles Borins Center For Computer Research in Music and Acoustics Stanford University Stanford, California United States, mborins@ccrma.stanford.edu

More information

Fundamentals of Java Programming

Fundamentals of Java Programming Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors

More information

CSC 551: Web Programming. Spring 2004

CSC 551: Web Programming. Spring 2004 CSC 551: Web Programming Spring 2004 Java Overview Design goals & features platform independence, portable, secure, simple, object-oriented, Programming models applications vs. applets vs. servlets intro

More information

CSCI 3136 Principles of Programming Languages

CSCI 3136 Principles of Programming Languages CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University Winter 2013 CSCI 3136 Principles of Programming Languages Faculty of Computer Science Dalhousie University

More information

Enterprise Mobile Application Development: Native or Hybrid?

Enterprise Mobile Application Development: Native or Hybrid? Enterprise Mobile Application Development: Native or Hybrid? Enterprise Mobile Application Development: Native or Hybrid? SevenTablets 855-285-2322 Contact@SevenTablets.com http://www.seventablets.com

More information

What is a programming language?

What is a programming language? Overview Introduction Motivation Why study programming languages? Some key concepts What is a programming language? Artificial language" Computers" Programs" Syntax" Semantics" What is a programming language?...there

More information

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters Interpreters and virtual machines Michel Schinz 2007 03 23 Interpreters Interpreters Why interpreters? An interpreter is a program that executes another program, represented as some kind of data-structure.

More information

CSE 130 Programming Language Principles & Paradigms

CSE 130 Programming Language Principles & Paradigms CSE 130 Programming Language Principles & Paradigms Thomas A. Powell tpowell@pint.com Housekeeping Syllabus review Direct class page link http://www.pint.com/classes/cse130 Updated syllabus, notes, homework

More information

The C Programming Language course syllabus associate level

The C Programming Language course syllabus associate level TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming

More information

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio. Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Names, Bindings, and Scopes A name is a symbolic identifier used

More information

6.170 Tutorial 3 - Ruby Basics

6.170 Tutorial 3 - Ruby Basics 6.170 Tutorial 3 - Ruby Basics Prerequisites 1. Have Ruby installed on your computer a. If you use Mac/Linux, Ruby should already be preinstalled on your machine. b. If you have a Windows Machine, you

More information

Chapter 13 Computer Programs and Programming Languages. Discovering Computers 2012. Your Interactive Guide to the Digital World

Chapter 13 Computer Programs and Programming Languages. Discovering Computers 2012. Your Interactive Guide to the Digital World Chapter 13 Computer Programs and Programming Languages Discovering Computers 2012 Your Interactive Guide to the Digital World Objectives Overview Differentiate between machine and assembly languages Identify

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

More information

The Learn-Verified Full Stack Web Development Program

The Learn-Verified Full Stack Web Development Program The Learn-Verified Full Stack Web Development Program Overview This online program will prepare you for a career in web development by providing you with the baseline skills and experience necessary to

More information

Java Coding Practices for Improved Application Performance

Java Coding Practices for Improved Application Performance 1 Java Coding Practices for Improved Application Performance Lloyd Hagemo Senior Director Application Infrastructure Management Group Candle Corporation In the beginning, Java became the language of the

More information

CS3813 Performance Monitoring Project

CS3813 Performance Monitoring Project CS3813 Performance Monitoring Project Owen Kaser October 8, 2014 1 Introduction In this project, you should spend approximately 20 hours to experiment with Intel performance monitoring facilities, and

More information

Lesson 06: Basics of Software Development (W02D2

Lesson 06: Basics of Software Development (W02D2 Lesson 06: Basics of Software Development (W02D2) Balboa High School Michael Ferraro Lesson 06: Basics of Software Development (W02D2 Do Now 1. What is the main reason why flash

More information

Rakudo Perl 6 on the JVM. Jonathan Worthington

Rakudo Perl 6 on the JVM. Jonathan Worthington Rakudo Perl 6 on the JVM Jonathan Worthington About Rakudo Most complete and most actively developed Perl 6 implementation Compiler + built-ins 66 monthly releases to date 10-20 code contributors per release

More information

CSCI E 98: Managed Environments for the Execution of Programs

CSCI E 98: Managed Environments for the Execution of Programs CSCI E 98: Managed Environments for the Execution of Programs Draft Syllabus Instructor Phil McGachey, PhD Class Time: Mondays beginning Sept. 8, 5:30-7:30 pm Location: 1 Story Street, Room 304. Office

More information

Parrot in a Nutshell. Dan Sugalski dan@sidhe.org. Parrot in a nutshell 1

Parrot in a Nutshell. Dan Sugalski dan@sidhe.org. Parrot in a nutshell 1 Parrot in a Nutshell Dan Sugalski dan@sidhe.org Parrot in a nutshell 1 What is Parrot The interpreter for perl 6 A multi-language virtual machine An April Fools joke gotten out of hand Parrot in a nutshell

More information

Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named

More information

Java Application Developer Certificate Program Competencies

Java Application Developer Certificate Program Competencies Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle

More information

EMSCRIPTEN - COMPILING LLVM BITCODE TO JAVASCRIPT (?!)

EMSCRIPTEN - COMPILING LLVM BITCODE TO JAVASCRIPT (?!) EMSCRIPTEN - COMPILING LLVM BITCODE TO JAVASCRIPT (?!) ALON ZAKAI (MOZILLA) @kripken JavaScript..? At the LLVM developer's conference..? Everything compiles into LLVM bitcode The web is everywhere, and

More information

Python, C++ and SWIG

Python, C++ and SWIG Robin Dunn Software Craftsman O Reilly Open Source Convention July 21 25, 2008 Slides available at http://wxpython.org/oscon2008/ Python & C++ Comparisons Each is a general purpose programming language,

More information

Java in Education. Choosing appropriate tool for creating multimedia is the first step in multimedia design

Java in Education. Choosing appropriate tool for creating multimedia is the first step in multimedia design Java in Education Introduction Choosing appropriate tool for creating multimedia is the first step in multimedia design and production. Various tools that are used by educators, designers and programmers

More information

Hypercosm. Studio. www.hypercosm.com

Hypercosm. Studio. www.hypercosm.com Hypercosm Studio www.hypercosm.com Hypercosm Studio Guide 3 Revision: November 2005 Copyright 2005 Hypercosm LLC All rights reserved. Hypercosm, OMAR, Hypercosm 3D Player, and Hypercosm Studio are trademarks

More information

Programming Languages

Programming Languages Programming Languages Programming languages bridge the gap between people and machines; for that matter, they also bridge the gap among people who would like to share algorithms in a way that immediately

More information

Garbage Collection in the Java HotSpot Virtual Machine

Garbage Collection in the Java HotSpot Virtual Machine http://www.devx.com Printed from http://www.devx.com/java/article/21977/1954 Garbage Collection in the Java HotSpot Virtual Machine Gain a better understanding of how garbage collection in the Java HotSpot

More information

Language Based Virtual Machines... or why speed matters. by Lars Bak, Google Inc

Language Based Virtual Machines... or why speed matters. by Lars Bak, Google Inc Language Based Virtual Machines... or why speed matters by Lars Bak, Google Inc Agenda Motivation for virtual machines HotSpot V8 Dart What I ve learned Background 25+ years optimizing implementations

More information

Python Programming: An Introduction to Computer Science

Python Programming: An Introduction to Computer Science Python Programming: An Introduction to Computer Science Chapter 1 Computers and Programs 1 The Universal Machine n A computer -- a machine that stores and manipulates information under the control of a

More information

White Paper: 5GL RAD Development

White Paper: 5GL RAD Development White Paper: 5GL RAD Development After 2.5 hours of training, subjects reduced their development time by 60-90% A Study By: 326 Market Street Harrisburg, PA 17101 Luis Paris, Ph.D. Associate Professor

More information

Mobile Application Development Android

Mobile Application Development Android Mobile Application Development Android MTAT.03.262 Satish Srirama satish.srirama@ut.ee Goal Give you an idea of how to start developing Android applications Introduce major Android application concepts

More information

Java (12 Weeks) Introduction to Java Programming Language

Java (12 Weeks) Introduction to Java Programming Language Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short

More information

Introduction to Software Paradigms & Procedural Programming Paradigm

Introduction to Software Paradigms & Procedural Programming Paradigm Introduction & Procedural Programming Sample Courseware Introduction to Software Paradigms & Procedural Programming Paradigm This Lesson introduces main terminology to be used in the whole course. Thus,

More information

Web Development Frameworks

Web Development Frameworks COMS E6125 Web-enHanced Information Management (WHIM) Web Development Frameworks Swapneel Sheth swapneel@cs.columbia.edu @swapneel Spring 2012 1 Topic 1 History and Background of Web Application Development

More information

Online Recruitment System 1. INTRODUCTION

Online Recruitment System 1. INTRODUCTION 1. INTRODUCTION This project Online Recruitment System is an online website in which jobseekers can register themselves online and apply for job and attend the exam. Online Recruitment System provides

More information

Chapter 13: Program Development and Programming Languages

Chapter 13: Program Development and Programming Languages Understanding Computers Today and Tomorrow 12 th Edition Chapter 13: Program Development and Programming Languages Learning Objectives Understand the differences between structured programming, object-oriented

More information

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture

Last Class: OS and Computer Architecture. Last Class: OS and Computer Architecture Last Class: OS and Computer Architecture System bus Network card CPU, memory, I/O devices, network card, system bus Lecture 3, page 1 Last Class: OS and Computer Architecture OS Service Protection Interrupts

More information

The programming language C. sws1 1

The programming language C. sws1 1 The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

More information

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE

INTRODUCTION TO JAVA PROGRAMMING LANGUAGE INTRODUCTION TO JAVA PROGRAMMING LANGUAGE Today Java programming language is one of the most popular programming language which is used in critical applications like stock market trading system on BSE,

More information

Mark Bennett. Search and the Virtual Machine

Mark Bennett. Search and the Virtual Machine Mark Bennett Search and the Virtual Machine Agenda Intro / Business Drivers What to do with Search + Virtual What Makes Search Fast (or Slow!) Virtual Platforms Test Results Trends / Wrap Up / Q & A Business

More information

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program CS 2112 Lecture 27 Interpreters, compilers, and the Java Virtual Machine 1 May 2012 Lecturer: Andrew Myers 1 Interpreters vs. compilers There are two strategies for obtaining runnable code from a program

More information

Chapter 12 Programming Concepts and Languages

Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages Paradigm Publishing, Inc. 12-1 Presentation Overview Programming Concepts Problem-Solving Techniques The Evolution

More information

RED HAT SOFTWARE COLLECTIONS BRIDGING DEVELOPMENT AGILITY AND PRODUCTION STABILITY

RED HAT SOFTWARE COLLECTIONS BRIDGING DEVELOPMENT AGILITY AND PRODUCTION STABILITY RED HAT S BRIDGING DEVELOPMENT AGILITY AND PRODUCTION STABILITY TECHNOLOGY BRIEF INTRODUCTION BENEFITS Choose the right runtimes for your project with access to the latest stable versions. Preserve application

More information

Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111

Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages. Corky Cartwright Swarat Chaudhuri November 30, 20111 Comp 411 Principles of Programming Languages Lecture 34 Semantics of OO Languages Corky Cartwright Swarat Chaudhuri November 30, 20111 Overview I In OO languages, data values (except for designated non-oo

More information

Introduction to Python

Introduction to Python WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

More information

White Paper. Java versus Ruby Frameworks in Practice STATE OF THE ART SOFTWARE DEVELOPMENT 1

White Paper. Java versus Ruby Frameworks in Practice STATE OF THE ART SOFTWARE DEVELOPMENT 1 White Paper Java versus Ruby Frameworks in Practice STATE OF THE ART SOFTWARE DEVELOPMENT 1 INTRODUCTION...3 FRAMEWORKS AND LANGUAGES...3 SECURITY AND UPGRADES...4 Major Upgrades...4 Minor Upgrades...5

More information

9/11/15. What is Programming? CSCI 209: Software Development. Discussion: What Is Good Software? Characteristics of Good Software?

9/11/15. What is Programming? CSCI 209: Software Development. Discussion: What Is Good Software? Characteristics of Good Software? What is Programming? CSCI 209: Software Development Sara Sprenkle sprenkles@wlu.edu "If you don't think carefully, you might think that programming is just typing statements in a programming language."

More information

MASTERTAG DEVELOPER GUIDE

MASTERTAG DEVELOPER GUIDE MASTERTAG DEVELOPER GUIDE TABLE OF CONTENTS 1 Introduction... 4 1.1 What is the zanox MasterTag?... 4 1.2 What is the zanox page type?... 4 2 Create a MasterTag application in the zanox Application Store...

More information

VOC Documentation. Release 0.1. Russell Keith-Magee

VOC Documentation. Release 0.1. Russell Keith-Magee VOC Documentation Release 0.1 Russell Keith-Magee February 07, 2016 Contents 1 About VOC 3 1.1 The VOC Developer and User community................................ 3 1.2 Frequently Asked Questions.......................................

More information

A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming

A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming A Python Tour: Just a Brief Introduction CS 303e: Elements of Computers and Programming "The only way to learn a new programming language is by writing programs in it." -- B. Kernighan and D. Ritchie "Computers

More information

Introduction to Python

Introduction to Python 1 Daniel Lucio March 2016 Creator of Python https://en.wikipedia.org/wiki/guido_van_rossum 2 Python Timeline Implementation Started v1.0 v1.6 v2.1 v2.3 v2.5 v3.0 v3.1 v3.2 v3.4 1980 1991 1997 2004 2010

More information

Kotlin for Android Developers

Kotlin for Android Developers Kotlin for Android Developers Learn Kotlin in an easy way while developing an Android App Antonio Leiva This book is for sale at http://leanpub.com/kotlin-for-android-developers This version was published

More information

Content. Development Tools 2(63)

Content. Development Tools 2(63) Development Tools Content Project management and build, Maven Version control, Git Code coverage, JaCoCo Profiling, NetBeans Static Analyzer, NetBeans Continuous integration, Hudson Development Tools 2(63)

More information

Fall 2012 Q530. Programming for Cognitive Science

Fall 2012 Q530. Programming for Cognitive Science Fall 2012 Q530 Programming for Cognitive Science Aimed at little or no programming experience. Improve your confidence and skills at: Writing code. Reading code. Understand the abilities and limitations

More information

Habanero Extreme Scale Software Research Project

Habanero Extreme Scale Software Research Project Habanero Extreme Scale Software Research Project Comp215: Evolution of Java Zoran Budimlić (Rice University) The Beginnings Sun Microsystems 1990 - Create a language for delivering programs on small electronic

More information

Developing Embedded Software in Java Part 1: Technology and Architecture

Developing Embedded Software in Java Part 1: Technology and Architecture Developing Embedded Software in Java Part 1: Technology and Architecture by Michael Barr Embedded Systems Conference Europe The Netherlands November 16-18, 1999 Course #300 Sun s introduction of the Java

More information

Java CPD (I) Frans Coenen Department of Computer Science

Java CPD (I) Frans Coenen Department of Computer Science Java CPD (I) Frans Coenen Department of Computer Science Content Session 1, 12:45-14:30 (First Java Programme, Inheritance, Arithmetic) Session 2, 14:45-16:45 (Input and Programme Constructs) Materials

More information

YouTrack MPS case study

YouTrack MPS case study YouTrack MPS case study A case study of JetBrains YouTrack use of MPS Valeria Adrianova, Maxim Mazin, Václav Pech What is YouTrack YouTrack is an innovative, web-based, keyboard-centric issue and project

More information

To Java SE 8, and Beyond (Plan B)

To Java SE 8, and Beyond (Plan B) 11-12-13 To Java SE 8, and Beyond (Plan B) Francisco Morero Peyrona EMEA Java Community Leader 8 9...2012 2020? Priorities for the Java Platforms Grow Developer Base Grow Adoption

More information

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert

Fachbereich Informatik und Elektrotechnik SunSPOT. Ubiquitous Computing. Ubiquitous Computing, Helmut Dispert Ubiquitous Computing Ubiquitous Computing The Sensor Network System Sun SPOT: The Sun Small Programmable Object Technology Technology-Based Wireless Sensor Networks a Java Platform for Developing Applications

More information

CS 51 Intro to CS. Art Lee. September 2, 2014

CS 51 Intro to CS. Art Lee. September 2, 2014 CS 51 Intro to CS Art Lee September 2, 2014 Announcements Course web page at: http://www.cmc.edu/pages/faculty/alee/cs51/ Homework/Lab assignment submission on Sakai: https://sakai.claremont.edu/portal/site/cx_mtg_79055

More information

With a single download, the ADT Bundle includes everything you need to begin developing apps:

With a single download, the ADT Bundle includes everything you need to begin developing apps: Get the Android SDK The Android SDK provides you the API libraries and developer tools necessary to build, test, and debug apps for Android. The ADT bundle includes the essential Android SDK components

More information

Informatica e Sistemi in Tempo Reale

Informatica e Sistemi in Tempo Reale Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)

More information

Efficiency of Web Based SAX XML Distributed Processing

Efficiency of Web Based SAX XML Distributed Processing Efficiency of Web Based SAX XML Distributed Processing R. Eggen Computer and Information Sciences Department University of North Florida Jacksonville, FL, USA A. Basic Computer and Information Sciences

More information

Cloud Computing. Up until now

Cloud Computing. Up until now Cloud Computing Lecture 11 Virtualization 2011-2012 Up until now Introduction. Definition of Cloud Computing Grid Computing Content Distribution Networks Map Reduce Cycle-Sharing 1 Process Virtual Machines

More information

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011 1 Goals of the Lecture Present an introduction to Objective-C 2.0 Coverage of the language will be INCOMPLETE

More information

Effective Java Programming. efficient software development

Effective Java Programming. efficient software development Effective Java Programming efficient software development Structure efficient software development what is efficiency? development process profiling during development what determines the performance of

More information

VMware Virtualization and Software Development

VMware Virtualization and Software Development VMware Virtualization and Software Development 1 VMware Virtualization and Software Development Mark Cloutier Undergraduate Student, Applied Math and Computer Science Keywords: Virtualization, VMware,

More information

CSE 307: Principles of Programming Languages

CSE 307: Principles of Programming Languages Course Organization Introduction CSE 307: Principles of Programming Languages Spring 2015 R. Sekar Course Organization Introduction 1 / 34 Topics 1. Course Organization Info and Support Course Description

More information

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

More information

White Paper. Java Security. What You Need to Know, and How to Protect Yourself. 800.266.7798 www.inductiveautomation.com

White Paper. Java Security. What You Need to Know, and How to Protect Yourself. 800.266.7798 www.inductiveautomation.com White Paper Java Security What You Need to Know, and How to Protect Yourself Java Security: What You Need to Know, and How to Protect Yourself Ignition HMI, SCADA and MES software by Inductive Automation

More information

Developing multi-platform mobile applications: doing it right. Mihail Ivanchev

Developing multi-platform mobile applications: doing it right. Mihail Ivanchev Developing multi-platform mobile applications: doing it right Mihail Ivanchev Outline Significance of multi-platform support Recommend application architecture Web-based application frameworks Game development

More information

Serving dynamic webpages in less than a millisecond

Serving dynamic webpages in less than a millisecond Serving dynamic webpages in less than a millisecond John Fremlin 2008 November 8 Contents This talk is about a web-application framework I built. Introduction Benchmarking framework overhead High performance

More information

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution

CSE 452: Programming Languages. Acknowledgements. Contents. Java and its Evolution CSE 452: Programming Languages Java and its Evolution Acknowledgements Rajkumar Buyya 2 Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java

More information

Course MS10975A Introduction to Programming. Length: 5 Days

Course MS10975A Introduction to Programming. Length: 5 Days 3 Riverchase Office Plaza Hoover, Alabama 35244 Phone: 205.989.4944 Fax: 855.317.2187 E-Mail: rwhitney@discoveritt.com Web: www.discoveritt.com Course MS10975A Introduction to Programming Length: 5 Days

More information

10 STEPS TO YOUR FIRST QNX PROGRAM. QUICKSTART GUIDE Second Edition

10 STEPS TO YOUR FIRST QNX PROGRAM. QUICKSTART GUIDE Second Edition 10 STEPS TO YOUR FIRST QNX PROGRAM QUICKSTART GUIDE Second Edition QNX QUICKSTART GUIDE A guide to help you install and configure the QNX Momentics tools and the QNX Neutrino operating system, so you can

More information

How to Choose Right Mobile Development Platform BROWSER, HYBRID, OR NATIVE

How to Choose Right Mobile Development Platform BROWSER, HYBRID, OR NATIVE How to Choose Right Mobile Development Platform BROWSER, HYBRID, OR NATIVE Solutions Introduction: Enterprises around the globe are mobilizing mission-critical services. Businesses get streamlined due

More information