-
Notifications
You must be signed in to change notification settings - Fork 9
Choosing a Language
William Wood edited this page Jul 15, 2019
·
14 revisions
Since JISA
can be used in a multitude of different languages, it can be quite hard to pick which one to use!
This page will hopefully serve to help you decide out of the three main "target" languages:
- Java
- Kotlin
- Python
Out of the three target languages, Kotlin
and Python
appear quite similar, with some minor (but key) differences. On the other hand, Java
stands out as the more traditional C/C++ style language.
Here's a quite preview of what a simple "Hello World!" application looks like in each:
Java
public class Main {
public static void main(String[] args) {
System.out.println("Hello World!");
int myVariable = 15;
System.out.printf("My number is %d\n", myVariable);
}
}
Kotlin
fun main() {
println("Hello World!")
var myVariable = 15
println("My number is $myVariable")
}
Python
print("Hello World!")
myVariable = 15
print("My number is %d" % myVariable)
As a general overview:
- If you are used to traditional languages like C/C++, then you will want to use Java
- If you are looking to extend the
JISA
library itself you MUST use Java (for my sanity if nothing else). - If you are used to more modern-style languages (like Python), you want Kotlin.
- You probably only want Python if you're already very used to it since it's more of a pain to set-up for using
JISA
than Kotlin (and comes with a raft of draw-backs compared to Kotlin despite being very similar). - Stay away from Python if you're writing a large program. It works well for quick "hack-it-together" type scripts or as an interactive environment, but not for large projects. For big projects use Java or Kotlin.
- If I catch you writing a
JISA
program in MATLAB... let's just say make sure that doesn't happen.
Attribute | Pros | Cons |
---|---|---|
Verbose | Makes it easier to follow the logic of a program | Makes your code longer to write |
Statically Typed | Makes it easy to spot where a variable is first declared and what type it is, also faster to run | Extra words to write and think about |
Traditional Syntax | Tried and tested, very standard and similar to other languages, robust | Can look scary since it looks like C++ |
Input/Output Streams | Gives more precise control over terminal input and output | Slightly more complex to use |
Strong Object Orientation | Forces you into good practices, leads to well organised code | Can seem a bit much for simpler programs |
Compiled | Runs fast | Code needs to be compiled when changed |
Attribute | Pros | Cons |
---|---|---|
Concise | Makes it quicker to write programs | Can make it harder to follow the logic of your code |
Static Inferred Typing | Fast to run, still easy to spot declarations but removes need to remember type names | Harder to tell which variable is of what type |
Simplified Traditional Syntax | Very standard and similar to other tried and tested languages but more human readable than most | None really, unless you are conditioned to expect Python syntax |
Input/Output Methods | Far simpler to use terminal input/output than in Java | Less control and precision |
Fair Object Orientation | Forces you into good practices, leads to well organised code but doesn't require your main method to be inside a class | None really |
Compiled or Interpreted | Your choice, you can compile to run fast or write Kotlin scripts that run in an interpreter | None really, you can choose whetever best suits your needs |
Attribute | Pros | Cons |
---|---|---|
Concise | Makes it quicker to write programs | Can make it harder to follow the logic of your code |
Dynamically Typed | No need to explicitly declare variables | Hard to see where variables are first declared, what type they are and gives rist to scoping issues |
Reinvented Syntax | Designed to be human readable, commonly used in scientific community | Completely different from almost all other languages, sacrifices functionality, can become messy easily |
Input/Output Methods | Far simpler to use terminal input/output than in Java | Less control and precision |
Weak Object Orientation | Lets you do it your way(tm) | Missing some very useful OO features, often leads to huge messes of code without proper discipline |
Interpreted | No compilation needed, allows straight-forward interactive shell usage | Slow and memory-hungry execution, up to roughly 30x slower than the likes of Java and C++ |
- Getting Started
- Object Orientation
- Choosing a Language
- Using JISA in Java
- Using JISA in Python
- Using JISA in Kotlin
- Exceptions
- Functions as Objects
- Instrument Basics
- SMUs
- Thermometers (and old TCs)
- PID and Temperature Controllers
- Lock-Ins
- Power Supplies
- Pre-Amplifiers
- Writing New Drivers