hello friends! new(ish)!

Programming languages: Difference between revisions

From InstallGentoo Wiki v2
Jump to navigation Jump to search
>Thelismor
>Burgertron
m (.NET (Core).)
 
(60 intermediate revisions by 15 users not shown)
Line 1: Line 1:
[[File:Practical_Language_Comparison.jpeg|thumb]]
[[File:Practical_Language_Comparison.jpeg|thumb]]
Quick summary of programming languages.
Quick summary of programming languages.
 
{{TOCright}}
= Should I learn... =
== Should I learn... ==
There's a lot of languages out there, and most of them have a lot of overlap over common problem domains. In principle, all languages being Turing complete, there's nothing stopping you from doing any task in any language. But in practice, there may be orders of magnitude difference (we're talking 100-1000x here) in how much time it takes to do a project in a suitable language vs. an unsuitable one. Among the joys you may experience by picking the wrong language are:
There's a lot of languages out there, and most of them have a lot of overlap over common problem domains. In principle, all languages being Turing complete, there's nothing stopping you from doing any task in any language. But in practice, there may be orders of magnitude difference (we're talking 100-1000x here) in how much time it takes to do a project in a suitable language vs. an unsuitable one. Among the joys you may experience by picking the wrong language are:


Line 18: Line 18:
Ultimately, you should aspire to learn ''how to program'', not to learn any given language. To wit, all programming revolves around making the computer do things: The computer know a small set of atomic, fundamental "things" which it can already do. It is your task, as the programmer, to define how these fundamental tasks should be combined with each other to perform new tasks. Depending on how the fundamental tasks of a language are chosen, and what rules govern their combination, some tasks will be rendered easy or difficult, intuitive or unintuitive.
Ultimately, you should aspire to learn ''how to program'', not to learn any given language. To wit, all programming revolves around making the computer do things: The computer know a small set of atomic, fundamental "things" which it can already do. It is your task, as the programmer, to define how these fundamental tasks should be combined with each other to perform new tasks. Depending on how the fundamental tasks of a language are chosen, and what rules govern their combination, some tasks will be rendered easy or difficult, intuitive or unintuitive.


== Intrinsic vs. Extrinsic ==
=== Intrinsic vs. Extrinsic ===
When comparing the comparative merits of languages, we may divide them into two main groups: Extrinsic properties and intrinsic properties. Intrinsic properties are properties of the language itself, such as syntax. Extrinsic properties are everything that isn't part of the language itself: The community, the tutorials available, the libraries that have been written, how the language and its users are perceived, and so on. Basically, intrinsic properties are what you get if you were using the language in a vacuum, with nothing but a description of the syntax and a basic compiler.
When comparing the comparative merits of languages, we may divide them into two main groups: Extrinsic properties and intrinsic properties. Intrinsic properties are properties of the language itself, such as syntax. Extrinsic properties are everything that isn't part of the language itself: The community, the tutorials available, the libraries that have been written, how the language and its users are perceived, and so on. Basically, intrinsic properties are what you get if you were using the language in a vacant, with nothing but a description of the syntax and a basic compiler.


Languages do not exist in a vacuum, but ''considering'' them in a vacuum may inform the bigger decision of which language is worth your time. We therefore make the distinction between intrinsic and extrinsic aspects for the following reasons:
Languages do not exist in a vacant, but ''considering'' them in a vacant may inform the bigger decision of which language is worth your time. We therefore make the distinction between intrinsic and extrinsic aspects for the following reasons:


* Intrinsic properties are constant in time (at least until a new version of the language is released). Extrinsic properties are very much inconstant (who knows what language will be popular in a five years?).
* Intrinsic properties are constant in time (at least until a new version of the language is released). Extrinsic properties are very much inconstant (who knows what language will be popular in a five years?).
Line 28: Line 28:
Generally, your decision should be rooted in the intrinsics, since as you can see, they are the key factor and they are the ones you will be stuck with so long as you use the language. But that's not to say extrinsic factors aren't important or should be ignored (this is in fact a very big mistake).
Generally, your decision should be rooted in the intrinsics, since as you can see, they are the key factor and they are the ones you will be stuck with so long as you use the language. But that's not to say extrinsic factors aren't important or should be ignored (this is in fact a very big mistake).


== Intrinsic properties ==
=== Intrinsic properties ===
For most languages that are designed without a specific purpose in mind, intrinsics will be fairly similar. They will not be glaring flaws or radical improvements. When languages are designed with a specific purpose in mind, they tend to have more drastic changes. Usually, if a specialized language is designed from a problem domain, that problem domain is very hard to deal with using more generalist languages.
For most languages that are designed without a specific purpose in mind, intrinsics will be fairly similar. They will not be glaring flaws or radical improvements. When languages are designed with a specific purpose in mind, they tend to have more drastic changes. Usually, if a specialized language is designed from a problem domain, that problem domain is very hard to deal with using more generalist languages.


=== Syntax ===
==== Syntax ====
Syntax determines what the instruction you write in a language will look like. You should ask yourself:
Syntax determines what the instruction you write in a language will look like. You should ask yourself:


Line 40: Line 40:
* Is it legible?
* Is it legible?


==== Syntactic sugar ====
===== Syntactic sugar =====
In discussions of syntax, you will come upon this term. Syntactic sugar is basically shorthand for certain kinds of commands. Depending on what you do, syntactic sugar can make your life a lot easier by making code much more legible.
[[Syntactic sugar]] is the different shorthands a language can have, such as being able to say <code>x++</code> instead of <code>x = x + 1</code>.
 
For example, in many languages assignment to a variable is done as follows:
 
x = 1
 
This means, "let x be 1" (in many languages, <code>=</code> is not like the mathematical equals sign, but more like the <code>:=</code> sign).
 
In order to increase x by one, you would do:
 
x = 1+x
 
This means "let x be 1 plus its current value". Incrementing a number is an extremely frequent task to do in programming, and so some languages have a shorthand:
 
x += 1
 
This means "add 1 to x" (although really the compiler just interprets <code>x += y</code> as <code>x = x+y</code> in most implementations). The <code>+=</code> is syntax sugar: In most languages you can do it, but in Matlab there is no <code>+=</code> and you are forced to type <code>x = x+1</code>.
 
Of all the numbers you can increment by, 1 is by far the most common in actual programming tasks. Therefore, some languages go a step further, and allow:
 
x++
 
This means "increment x by 1". C allows this, but many languages don't. The difference may seem trivial, but it can have a large impact on legibility and clarity in a complex block of code. However, once again not all languages support the <code>++</code> operator.
 
Another example: In most languages, if you need a series of numbers such as 1, 2, 3, ... 15 or 12, 15, 18, ... 32 you must call a specialized function, such as:
 
series = range(12, 32, 3)
 
Matlab has syntactic sugar for this:
 
series = 12:3:32
 
This is very helpful when you work with arrays:
 
cols = MyArray[7:2:end]
 
will get you every second row of <code>MyArray</code> starting from the 7th (<code>end</code> is Matlab sugar for referring to the last element of an array). In other languages, not only must you call range inside the brackets (making code look busier) but you often can't even do this in one line at all - being able to select multiple elements of an array is another Matlab sugar. In languages like C, you would have to get each column separately and then combine them into a new array, which may take a little more work:
 
j = 0;
for(i=7; i<sizeof(MyArray); i += 2)
{
    cols[j] = MyArray[i];
    j++;
}
   
 
Syntactic sugar is convenient, but it is not necessarily good or bad. If you happen to often do the things your language's sugar tries to facilitate, and you like the sugar, it's good. Using the above two examples, you can probably see that Matlab has very nice sugar if you shuffle around arrays a lot, but C is a bit nicer if you work with algorithms that increment things a lot (as a novice, it is impossible to decide which one is relevant to you, but after you've programmed for a while you will quickly get a feel for it).
 
If the sugar does not help you, you can ignore it, but don't make the mistake of thinking that ignoring bad sugar will make it go away. If your language has some retarded sugar that everyone loves using for some reason, it can make reading other people's code hell. For instance, R has feature where assignment can be done in two equivalent ways:


x = 5
If you happen to often do the things your language's sugar tries to facilitate, it can make your life a lot easier.
y -> 7


Presumably the arrow is supposed to avoid the confusion with equality. Since I am used from other languages to associate <code>=</code> with inequality, <code>-></code> is unusual for me and I never use it. However, every once in a while I need to look up how to do something, and seeing a page of code full of <code>-></code>s is very jarring - I often have to first search/replace them before I can even read the code. That's not to say it's a bad feature, but clearly for me the <code>-></code> notation sugar hurts more than it helps (this is also an example of intrinsics influencing extrinsics).
If the sugar does not help you, you can of course not use it, but remember that ignoring bad sugar will not make it go away. If your language has some retarded sugar that everyone loves using for some reason, it can make reading other people's code hell (this is also an example of intrinsics influencing extrinsics).


== Paradigm (imperative vs. declarative) ==
==== Paradigm (imperative vs. declarative) ====
Humanity has thus far discovered two ways of specifying instructions for a computer.
Humanity has thus far discovered two ways of specifying instructions for a computer.


Line 102: Line 53:
* The declarative approach simply defines what each thing means, and lets the computer put the definitions together. It can be difficult to make the calculations happen in a certain order, but because no order is specified, paralleling tasks to improve performance can be very easy. For the circumference, you would give the computer the formula for circumference, the formula for approximating pi (for example 22/7), and ask it for circumference given a radius. Note how I don't say "print to the screen" - communicating with the user can also be a problem with declarative languages. In practice, the main representatives of this class are functional languages like Haskell or Lisp.
* The declarative approach simply defines what each thing means, and lets the computer put the definitions together. It can be difficult to make the calculations happen in a certain order, but because no order is specified, paralleling tasks to improve performance can be very easy. For the circumference, you would give the computer the formula for circumference, the formula for approximating pi (for example 22/7), and ask it for circumference given a radius. Note how I don't say "print to the screen" - communicating with the user can also be a problem with declarative languages. In practice, the main representatives of this class are functional languages like Haskell or Lisp.


In theory, these two styles are [https://en.wikipedia.org/wiki/Church%E2%80%93Turing_thesis exactly equivalent] in terms what programs it is possible to write in them. But in practice, they are very different, and can have a huge impact on how easy a given task is.
In theory, these two styles are [[Wikipedia:Church%E2%80%93Turing_thesis |exactly equivalent]] in terms what programs it is possible to write in them. But in practice, they are very different, and can have a huge impact on how easy a given task is.


Historically, imperative languages have dominated, and have been regarded as easier to understand. Perhaps the idea of giving someone explicit step-by-step instructions is more intuitive to the human mind than systems of functions, but regardless, most people find imperative languages easier, and interest in functional languages often correlates with mathematical aptitude. If you don't know what you're doing, you should probably start with an imperative language.
Historically, imperative languages have dominated, and have been regarded as easier to understand. Perhaps the idea of giving someone explicit step-by-step instructions is more intuitive to the human mind than systems of functions, but regardless, most people find imperative languages easier, and interest in functional languages often correlates with mathematical aptitude. If you don't know what you're doing, you should probably start with an imperative language.
Line 110: Line 61:
In many modern imperative languages, it is actually possible to write almost declarative, functional-style logic (in particular, look for "lambda expressions"). Because the language is not designed with purely functional programming in mind, this may be impractical (difficult to debug, clumsy to type out, slow and unoptimized) but in some small but important subset of problems you can actually mix the two paradigms together.
In many modern imperative languages, it is actually possible to write almost declarative, functional-style logic (in particular, look for "lambda expressions"). Because the language is not designed with purely functional programming in mind, this may be impractical (difficult to debug, clumsy to type out, slow and unoptimized) but in some small but important subset of problems you can actually mix the two paradigms together.


== Object oriented programming ==
==== Object oriented programming (OOP) ====
Since the 90s, the concept of OOP has been very popular and you will certainly hear mention of it. OOP is basically a way of organizing code in types of variables. Dominant earlier languages like C often specified a small number of basic ''types'', like integer, decimal, string, memory address and array (list of one of the previous types). Code was organized into routines, each routine could call other routines (there is often a single top-level routine called <code>main()</code> which is what gets called when you run your program).
The basic logic of OOP is:
 
* Everything is an object belonging to a class of objects
Since the basic types provided don't cover all that much, you represent complex data (for instance an email which has a sender, recipient, content, attachments, encoding, subject line, cc line, timestamp and so on) by putting each part in a separate variable. To help with this, there is something called a <code>struct</code>, which is basically a bag of variables. A struct can contain other structs (and arrays of structs), so by nesting them together you can create a lot of complicated, hierarchical variables.
* Classes have their own variables (fields) and behaviors (methods)
 
* Classes are taxonomically related to each other, and can inherit and extend each other's functionality (inheritance)
Object oriented programming takes this one step further. Let's use a classic example of a program that tracks a fleet of cars. Suppose we have decided that we must store the license no, color, speed and current destination of each car. We could have a construct like so:
 
<nowiki>sruct Car {
string license_no;
int color;
int speed;
Location destination;
}</nowiki>
 
We could then perform operations on aspects of a given car:
 
<nowiki>taxi = new Car()  
taxi.license_no = "GAY4PAY"
taxi.color = hFFCC00
taxi.speed = get_speed_from_gps_tracker(taxi.license_no)
taxi.destination = "Mr. Smith's house"
 
truck = new Car()
truck.licence_no = "45A1CF3"
truck.color = h888888
truck.speed = get_speed_from_gps_tracker(truck.license_no)
truck.destination = taxi.destination</nowiki>
 
In this case we have defined a yellow taxi and a grey truck, both of them heading to the same place, and automatically obtained the speed a function that talks to the GPS tracker on each car (the GPS identifies the cars by their plate numbers).
 
Now let's say one of the cars is coming back to the office, and we want to record this. We can just do <code>truck.destination = "Office"</code>. But suppose we will type this line many times - what if somewhere we make a typo, or do something like <code>truck.destination = "Main Office"</code>, and a different function that checks which car is at the office (by looking for the exact string "Office" and not "office" or "Main Office") gets broken? What if the name of the office changes? To avoid this, we decide to make a single function for recalling a car to the office (this is called the Don't Repeat Yourself principle). We put this at the bottom of our program, and make a few other improvements, so maybe the whole file looks like this:


<nowiki>import gps_library
With an OOP project, a significant amount of work is spent on class hierarchies defining which class has what components and what it inherits from. The actual functionality of the program is supposed to flow naturally from those. There's a lot of analyzing the problem into compartmentalized units that interact with each other.


main() {
This way of thinking is suitable for some problems. For example, when programming a GUI, it can be convenient to represent all the scrollbars, buttons, checkboxes and textfields as classes with shared behaviors. At other times, adding OOP may just make a trivial thing difficult.
taxi = new Car()
taxi.license_no = "GAY4PAY"
taxi.color = hFFCC00
taxi.speed = get_speed_from_gps_tracker(taxi.license_no)
set_location(taxi, "Mr. Smith's house")


truck = new Car()
==== Strictness ====
truck.licence_no = "45A1CF3"
There's quite a bit of variance between languages in terms of how much detail they require. Say you want to define a variable to store a number. Some languages are very pedantic, you are required to specify what kind of number, whether negative values are possible, what the max value should be, whether it's a whole number or decimal, and how many digits to store if decimal. Other languages just let you define your number and never ask questions, trying to make reasonable assumptions about all the things you left out.
truck.color = h888888
truck.speed = get_speed_from_gps_tracker(truck.license_no)
truck.destination = taxi.destination


// Some code here
High strictness can be useful in two ways. First, it gives you better control over exactly what the program is doing. This helps with optimization: If you know a variable will never store a number bigger than 255, there's no point in using a larger format and wasting memory. Second, they force you to constantly think about every detail of your code, and may help reduce bugs (but not necessarily). Examples: C, C++, Java, Haskell (functional).


// Now recall both cars to office
Low strictness is good when you just have a simple idea, and want to quickly get it working without getting hung up about the particulars. Unfortunately, some of those details you did not specify will eventually cause subtle bugs that will be a pain to fix. Examples: Python, JavaScript.
recall_to_office(taxi)
recall_to_office(truck)
}


struct Car {
Strict languages tend to be good for production-level software where reliability, close adherence to specs and high level of optimization is necessary. Non-strict languages are good for prototyping and hacking together one-shot scripts.
string license_no
int color
int speed
Location destination
}


struct Location {
=== Extrinsic properties ===
string name
====Documentation====
float lat
Always check what books, tutorials and help forums (or how many questions on StackOverflow) there are for a language. It can be the best language ever made, but not being able to quickly Google simple questions can really slow down your learning.
float lon
}


recall_to_office(Car c) {
====Libraries====
c.recall_to_office
Learning exercises aside, these days it's stupid to write a program from scratch. A lot of common functionality like file I/O, working with arrays, sorting, math functions, graphics, networking, etc have already been implemented, and hopefully packaged as libraries. You shouldn't reinvent the wheel.
}


set_location(Car c, string target) {
It can be hard to gauge the ecosystem of a language, but try Googling things like "How to do X in language Y" - do you get short, easy to read results which use well-maintained and well-documented libraries, or do you get a bunch of people writing their own unreadable hacks?
loc = new Location()


loc.name = s
Examples:
loc.lat = get_lat_from_gps(s)
loc.lon = get_lon_from_gps(s)
c.destination = target
}</nowiki>


=== Code organization and reuse ===
* For a while C# was a very good choice for making games thanks to XNA (unfortunately Microsoft stopped developing it when Windows 8 came out). XNA handles many things like keyboard/gamepad input, 2D/3D graphics, sound, game update cycles, framerate, assets and so on for you, and has nicely documented functions and plenty of good tutorials. C# by itself is a decent language, but not that great - XNA was what allowed a lot of independent [[Wikipedia:Microsoft_XNA#Partial_list_of_games_that_use_XNA |games like Terraria and Bastion]] to be made with a small team.
* Python has a few libraries that are so good that doing webscraping (BeautifulSoup, etc) or scientific computing (SciPy) in something else is just stupid at this point.


You can see how already the file is getting cluttered. In a real project, especially if you have tools generating some code for you, you can easily end up with hundreds of such subroutines strewn across files. You might notice that in this case, <code>set_location</code> really only pertains to the behavior of <code>Car</code>s - so perhaps they should go together? This is what OOP does. Instead of a struct, you have something called an <code>Class</code>, which defines a kind of <code>object</code> (object is an OOP terms similar to variable, but usually only simple data types like numbers are called variables, although in most modern OOP languages everything is considered an object). If the struct is a bag of variables, then the class is a bag of variables and functions ("methods" in OOP jargon).
====Platform====
In principle any language can run on any platform, but it's another matter entirely whether your favorite framework is available everywhere (for example even though C++ works anywhere, DirectX is Windows-only), what performance will be, and how much support is available. Some platforms are dominated by a language:


Now we can refactor the above code into:
* The basis for Android apps is Java. You can get others to run, but all the tutorials you find will be in Java.
* If you want to program for iOS, you have to use Objective-C (incidentally, a language useless for anything else).
* Webapps are usually made in Python (Django), Ruby (with Rails) or JavaScript.
* Browser games use Flash or HTML5.


<nowiki>import gps_library
====Performance====
[[File:Langspeed.png|thumb]]
main() {
I'll put this into extrinsic, because its depends a lot on implementation. Generally, anything with a VM will take a performance hit. Anything interpreted will always be slowpoke. Garbage collection, dynamic typing, all slow things down. Luckily, computers these days are so fast that performance usually doesn't matter. But in high performance applications (3D vidya, cryptography, statistical computation) you need a language suitable for systems programming. Functional languages can sometimes be much faster than imperative, because you can optimize some things very nicely in them.
taxi = new Car()
taxi.license_no = "GAY4PAY"
taxi.color = hFFCC00
taxi.speed = get_speed_from_gps_tracker(taxi.license_no)
taxi.set_destination ("Mr. Smith's house")


truck = new Car()
====Perception====
truck.licence_no = "45A1CF3"
If you want to program as a hobby, this is irrelevant, but if you want to get a job, it's worth carefully researching what is in demand where. For example, Python, C# and Java are the top 3 if you want to write trader bots on Wall Street. Java and C# are shit career choices because you'll compete with millions of third-worlders for low-paying positions.
truck.color = h888888
truck.speed = get_speed_from_gps_tracker(truck.license_no)
truck.destination = taxi.destination


// Some code here
====Community====
Some languages seem to attract more faggots than others. For example, Ruby was once infamous for its hipster fans, and most users of Rust seem more concerned with social justice than software development.


// Now recall both cars to office
=== What does /g/ use? ===
taxi.recall_to_office()
There are MANY languages, and there are constant arguments on /g/ about the best language, with no general agreed upon language. Below is a list of languages frequently voted for/against, and simple explanations as to why they are liked/hated.
truck.recall_to_office()
}


class Car {
* '''C''' - Probably the most agreed upon language on /g/. Although there are many that claim C is dated. Most of the UNIX/Linux is written (and still being written) in C. [[TempleOS]] was written in Terry's own version of C; HolyC.
string license_no
* '''C++''' - For those that like C, but think it is dated, C++ exists, and is very popular both on /g/ and in the real world.
int color
* '''Haskell/Lisp/Functional languages''' - Functional languages are very useful in changing the way you think about programming. Writing in a functional language will force you to think more about your code and design much nicer functions/algorithmns. However with that being said, functional languages do not accurately represent how the computer works, and this has its problems.
int speed
* '''Python''' - A very controversial language on /g/. Some believe that it is good language for beginners. Others believe that it is the worst programming language in every aspect. It does have many flaws and many reasons not to use it, however it is very easy for someone with little knowledge to start writing code (which may or may not be a good thing).
Location destination
* '''JavaScript/Node.js''' - Recommended by those who hate Python, for those that are new. It is still an easy language for beginners, and it has many flaws, but next to Python it looks like gold.
* '''Rust'''
set_destination(string target) {
* '''Assembly''' - Recommended by /g/ because like Gentoo, you have to be a complete autist to use it (see how to write [https://jameshfisher.com/2018/03/10/linux-assembly-hello-world/ hello world in assembly]). Probably the language with the best performance possible, as it is 1:1 with machine code instructions, however many people will be quick to point out that if you do something inefficient, then other languages may be faster as their compiler will not make the same mistakes.
    loc = new Location()


    loc.name = s
Again, each of these languages is subject to through debate about whether or not it is good or bad, and most of the time the problem you are trying to solve will usually dictate what language you should use.
    loc.get_coords_from_gps()
    destination = target
}
recall_to_office() {
set_location("Office")
}
}


class Location {
== Individual languages ==
string name
=== Ada ===
float lat
* Designed to catch as many errors as possible, as soon as possible
float lon
* Pascal-like syntax
* Excellent for embedded, systems, or realtime programming, but suitable for pretty much anything
get_coords_from_gps() {
* Programming by contract in Ada 2012
lat = get_lat_from_gps(s)
* Many advanced features like tasking, generics, and exceptions were built in to the language back in the 80s
lon = get_lon_from_gps(s)
* Good support for proving code correctness, especially in SPARK variant
}
* Verbose code
}</nowiki>
* Lacking in up-to-date tutorials and documentation for beginners
* Not used much outside of the defense and aerospace industries


At this point, you either think that organizing methods into classes makes things better, or you think it's completely insane. Ultimately, OOP is a matter of personal preference - and if the latter, then maybe it isn't for you.
=== Assembly ===
 
You might think that the slightly rearranged code is a bit tidier, but not that much better. In fact, organizing code is not the main benefit of OOP. The main benefit is code reuse. In the above example, you could put the <code>Car</code> and <code>Location</code> classes into a separate file, and distribute it to other people who want to write software that operates on car. They won't need to modify anything (assuming the current functionality is sufficient for them) and can simply plug in these classes into their own program, avoiding duplication of work you have already done.
 
On the other hand, if one day you find a better implementation of car logic, you can simply swap the two files for each other to try the new one. You won't need to rewrite your whole program to try the new car code you found. Of course, the implementation of the class you found will have to match very closely, or you will have to rewrite things anyway, but modern OOP languages have mechanisms to help people write compatible code, and there very powerful IDEs like Eclipse, Netbeans and Visual Studio that do a lot of the class-stitching work for you.
 
=== Inheritance ===
Besides structs-with-methods, the other major feature of OOP is inheritance. It's a way of defining new classes by saying "this class is just like class X, but has this extra feature".
 
<nowiki>tour_bus = new Bus()
tour_bus.passengers = 20
tour_bus.set_destination("Beach")
 
// ...
class Bus : Car {
    int passengers
}</nowiki>
 
Conveniently, if you later change the logic of class X, the change will propagate to all classes inheriting from X. This helps avoid repetition, and allows you to easily extend classes created by other people or classes from your own past projects.
 
=== Benefits ===
OOP is claimed to help with code re-use, avoid repetition and help manage complexity. But then OOP also bring complexity, so it is up for debate whether ultimately you are better off with it.
 
Be that as it may, many very large projects (both open and proprietary) today use OOP. If you want to work on these, you have no choice but to learn it. Furthermore, you may or may not find that OOP is useful even in your own projects, especially as they get more complex.
 
The basic logic of OOP is:
* Everything is an object belonging to a class
* Classes have properties (data), behaviors (methods) and taxonomical relationship to other classes (inheritance)
 
This way of thinking is suitable for some problems. For example, when programming a GUI, it can be convenient to represent all the scrollbars, buttons, checkboxes and textfields as classes with shared behaviors. In other cases, adding OOP may just make a trivial thing difficult.
 
== Pedantry ==
 
== Extrinsic properties ==
 
== Summary ==
 
= Individual languages =
== Assembly ==
* Terse, but pedantic as fuck.
* Terse, but pedantic as fuck.
** Small programs are simple to write, but larger ones become an unwieldy and complex mess in most cases.
** Small programs are simple to write, but larger ones become an unwieldy and complex mess in most cases.
Line 297: Line 145:
* Currently, Intel x86-64 ASM is the largest instruction set.
* Currently, Intel x86-64 ASM is the largest instruction set.


== BASIC ==
=== BASIC ===
* >It can do anything C can do, guise!!1
* >It can do anything C can do, guise!!1
* Lots of proprietary implementations, only a few decent FOSS ones.
* Lots of proprietary implementations, only a few decent FOSS ones.
* Still slower than C
* Still slower than C
* >muh goto
* >muh goto
* muh excel programming


== [[C]] ==
=== [[C]] ===
* Designed to be a "portable assembly language"
* Designed to be a "portable assembly language"
* Small, simple language whose parts compose well
* Small, simple language whose parts compose well
* Very small standard library
* Very small standard library
** You will need to implement most non-trival things yourself.
* Lingua franca for big libraries and APIs
* Lingua franca for big libraries and APIs
** If it has no C API, it's probably shit
** If it has no C API, it's probably shit
Line 313: Line 163:
** If some hardware doesn't have a C compiler for it, chances are it doesn't matter in the first place
** If some hardware doesn't have a C compiler for it, chances are it doesn't matter in the first place
* Lots of things are left undefined so that implementations can make the best choice possible in terms of speed
* Lots of things are left undefined so that implementations can make the best choice possible in terms of speed
* Potentially dangerous to write for the uninitiated
* Easy to make dangerous errors in code
** You manage your own resources yourself
** You manage your own resources yourself
** You perform your own safety checks if you want them
** You perform your own safety checks if you want them
Line 319: Line 169:
** Undefined behavior where anything can happen
** Undefined behavior where anything can happen
* Will force you to learn a lot about memory and lower level issues
* Will force you to learn a lot about memory and lower level issues
* Pretty much the only sane choice for systems and embedded programming
* Can also be used for applications programming
* Can also be used for applications programming


== C++ ==
=== [[C++]] ===
* Very, very large and feature-filled language
* Very, very large and feature-filled language
* Considered verbose at times
* Considered verbose at times
* C, but with OOP on top, and massive set of massive libraries
* C, but with OOP on top, and massive set of massive libraries
* Industry standard for widely used commercial software
* Considered dangerous to write in because, like C, there is no memory management
* Considered dangerous to write in because, like C, there is no memory management
** There are garbage collectors for C++
* Almost as fast as C
* Almost as fast as C
* Not very orthogonal and features frequently clash with each other
* Compiling takes ages because of archaic linking system, this is basically where the Compiling xkcd is about
* Tons of very powerful features, many ways to do the same things
** The guy whose code you're reading always picks the worst one
* Despite being called C/C++ frequently, good C++ is completely different from good C
* Despite being called C/C++ frequently, good C++ is completely different from good C
* The designer of the language had this to say about it: "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off"


== C# ==
=== C#/.NET ===
* What Java should have been
* What Java should have been
* Runs on .NET or the Mono framework (Mono framework allowing you to run it on GNU/Linux)
* Very similar to Java, but fixes a lot of Java's problems that Java is stuck with because of backwards-compatibility
* Is very similar to Java, with some extra stuff borrowed from C++ and Haskell
* Runs on .NET, <strike>which is Windows only and Mono,</strike> which is FLOSS and multiplatform.
* Dubious legal situation because parts of the language are encumbered with MS patent.
* .NET is a great library, and now [https://github.com/Microsoft/dotnet open source]
* LINQ is a very powerful way of working with collections (lists/sets/arrays) and databases (if mapped to collections)
* Visual Studio/ReSharper is very nice IDE for C#
* 3rd most popular language on StackOverflow, very active community with many experts
 
====Mono====
* Open alternative to .NET started when .NET was closed-source (Mono framework allowing you to run it on GNU/Linux)
* Implements almost all of .NET, but leaves out a lot of WinForms and WPF (GUI stuff)
* <strike>Dubious legal situation because parts of the language are encumbered with MS patent</strike>
* Purchased by Microsoft, now safely legal.


== Erlang ==
=== Erlang ===
* Makes concurrency/multithread shit a breeze.
* Makes concurrency/multithread shit a breeze.
* Uses a specialised VM that has a hard time crunching numbers, and an even harder time handling strings.
* Uses a specialised VM that has a hard time crunching numbers, and an even harder time handling strings.


== Golang ==
=== Golang ===
* Also known as Go
* Also known as Go
* Created by Rob Pike (one of the original UNIX guys) and some other engineers at Google
* Created by Rob Pike (one of the original UNIX guys) and some other engineers at Google
Line 350: Line 213:
* Uses Goroutines for concurrency, which are like lightweight threads which are then fit into threads for more efficiency. The compiler handles the threads for you.
* Uses Goroutines for concurrency, which are like lightweight threads which are then fit into threads for more efficiency. The compiler handles the threads for you.


== Haskell ==
=== Haskell ===
* Extremely expressive, offers abstraction capabilities near Lisp
* Extremely expressive, offers abstraction capabilities near Lisp
* Focuses on pure functional programming and type systems
* Focuses on pure functional programming and type systems
Line 357: Line 220:
* Can be unwieldy for inherently stateful problems
* Can be unwieldy for inherently stateful problems


== Java ==
=== [[Java]] ===
* Very portable; compiling down to bytecode, which is then executed by the JVM
* Very portable; compiling down to bytecode, which is then executed by the JVM
* Object oriented language
* The language that made OOP commonplace
* Some initial design decision have turned out to cause problems, but can't be fixed because of backward compatibility
* Very large and enterprise
* Very large and enterprise
* Huge libraries and a lot of software is written in it
* Huge libraries and a lot of software is written in it, including code from academic papers
* Very verbose APIs
* Very verbose APIs
* Receives a lot of undue criticism
* Receives a lot of undue criticism
** Used to be slow many years ago, but these days is very fast
* Can be convoluted to write in sometimes
* Can be convoluted to write in sometimes
* Both the language itself and the core libraries are very bureaucratic
* Is made fun of for the design patterns people use with it, and for the verbose naming schemes often used
* Is made fun of for the design patterns people use with it, and for the verbose naming schemes often used
** Example: <code>public abstract class AbstractSingletonProxyFactoryBean</code>


== Lisp ==
=== [[JavaScript|JavaScript/Node.js]] ===
Main article: [[Lisp]].
* Programming language of the web, most web browsers come with a native JS console
* Family of programming languages which have the most notable features of using fully parenthesized [http://en.wikipedia.org/wiki/Polish_notation prefix notation] and being [http://en.wikipedia.org/wiki/Homoiconicity homoiconic].
* Usually used hand in hand with HTML/CSS
* Good for learning how functional programming works with less explicit code typing (e.g variables are assumed as strings or integers)
* Can be used to make desktop applications (albeit slow if not optimized properly) and server-side code with [https://nodejs.org/ Node.js]
* Read JavaScript: The Good Parts by Douglas Crockford to get a better understanding of how this mess of a language can be used efficiently and with consistently
* [http://www.jslint.com/ JSLint] is an excellent way to check if your JS is shit or not
* ES6/ES7 features are ready and available to use on modern browsers with [https://babeljs.io/ Babel™]
 
=== [[Lisp]] ===
 
* Family of programming languages which have the most notable features of using fully parenthesized [[Wikipedia:Polish_notation |prefix notation]] and being [[Wikipedia:Homoiconicity |homoiconic]].
* Intially appeared in 1958.
* Intially appeared in 1958.
* Lisp is said to change the way one thinks about programming, because it exposes the [http://en.wikipedia.org/wiki/Abstract_syntax_tree abstraxt syntax tree] to the programmer for modification and extension of the language itself to fit the domain-specific needs of a particular task.
* Lisp is said to change the way one thinks about programming, because it exposes the [[Wikipedia:Abstract_syntax_tree |abstract syntax tree]] to the programmer for modification and extension of the language itself to fit the domain-specific needs of a particular task.
* No (visible) limit to abstraction
* No (visible) limit to abstraction


== [[Pascal]] ==
==== Scheme ====
* Based on Lisp with a focus on minimalism and simplicity
* Popular in many universities and featured in [https://wiki.installgentoo.com/index.php/Structure_and_Interpretation_of_Computer_Programs SICP]
* Great for programs with a basis in recursion and iteration
* Lacks portability and has little implementations
 
=== Mathematica ===
* Beautiful language with extremely high-level capabilities for math
* Amazing symbolic math capabilities (solving equations, theorem proving)
* Official documentation has tons of cool math examples
* Common with physicists, mathematicians
* Error messages are fucking godawful
* Proprietary
* Creator is an insane megalomaniac
 
=== Matlab/Octave ===
* Originally designed for working on matrices and linear algebra
* Very fast matrix functions
* Very full-featured IDE with nice visualization options and toolkits
* Commonly used for engineering, machine learning and scientific computation
* Interpreted dynamic language
* Tons of shitty code out there written by clueless grad students
* Octave is a FOSS compiler that accepts a superset of Matlab syntax, with slight differences (less bloat and much lower cost).
 
=== [[Pascal]] ===
* Very strong, safe, and featured type system
* Very strong, safe, and featured type system
* Simple syntax that prefers words over symbols, and is highly-structured
* Simple syntax that prefers words over symbols, and is highly-structured
Line 385: Line 285:
* Large number of varied modern dialects and compilers may confuse newcomers
* Large number of varied modern dialects and compilers may confuse newcomers


== Perl ==
=== Perl ===
* Write-only language
* Very tacit and unreadable syntax
* Very tacit and unreadable syntax
* Called a "swiss army chainsaw" for its versatility
* Called a "swiss army chainsaw" for its versatility
Line 393: Line 294:
* Can be OO, imperative, and even has functional elements.
* Can be OO, imperative, and even has functional elements.
* Avoids the use of reserved keywords, prefers keyboard squiggles (&, $, @, ->, etc.)
* Avoids the use of reserved keywords, prefers keyboard squiggles (&, $, @, ->, etc.)
* Falling out of fashion
* Great for code golf or obfuscation contests


== [[PHP]] ==
=== [[PHP]] ===
[[File:PHP Hammer.jpg|300px|alt=No.|link=http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/]]
PHP has an awful reputation among developers. There are far more marketable languages out there that will do everything that you would care to do in PHP. Despite the poor opinion of many, the language continues active development. There have been a lot of new features and a healthy amount of legacy code cleanup attempts in recent years.
* Optional use of strict argument and return types (PHP 7.1+)
* Choice to implement procedural, functional, or OOP design patterns
* PHP 7+ is still slow compared to Java
* Not designed to be long running
* Can be memory intensive, especially when using community frameworks
* Good documentation, and a large community of active developers
* You'll get made fun of by other developers for using it


Go is a sane alternative to PHP and webapps and seems almost the only sane one. Heck, even Python is far more sane than PHP. Don't use Node.js, it's considered [[harmful software|harmful]].
=== [[Python]] ===
 
== [[Python]] ==
* Very easy to read and simple (and fun) to write
* Very easy to read and simple (and fun) to write
* Enormous, versatile standard library (a philosphy they call "batteries included")
* Kinda slow
* Kinda slow
* Uses whitespace indentation to separate logical blocks
* Uses whitespace indentation to separate logical blocks
* Excellent for scripting
* Excellent for scripting
* Considered the antithesis of Perl
* Considered the antithesis of Perl
* Can be OO, imperative, and even has functional elements.
* OO/imperative, has some functional elements but designer has a [http://stackoverflow.com/q/1017621 weird obsession] with removing those
* Is nice to start out with and program in, but after a few years of it, you'll start to want to play with some of the stuff Python sacrifices, like pointers, and speed.
* Is nice to start out with and program in, but after a few years of it, you'll start to want to play with some of the stuff Python sacrifices, like pointers, and speed.


== [[Ruby]] ==
=== R ===
* Made for statistical computation, excels at that but not much good for anything else
* Libraries like ggplot make beautiful, top-tier plots
** R libraries are THE cutting edge of data visualization
* Rstudio is a very good environment
* Data frames are strongly typed native data types for working with tabulated data
* Very commonly used in academia, data science, analytics etc
* Fucking impossible to Google anything about it
* Most polluted and inconsistent namespace known to mankind
 
=== [[Ruby]] ===
* Focus on programmer happiness
* Focus on programmer happiness
** The creator's idea of happiness may be very different from yours
* Fully object-oriented
* Fully object-oriented
* Elegant, readable code
* Elegant, readable code
* As slow as any dynamic language will be
* As slow as any dynamic language will be
* Excellent for general-purpose programming, scripting, text processing and web dev
* Excellent for general-purpose programming, scripting, text processing and web dev
* Userbase full of hipsters and insufferable faggots
* Getting displaced by less obnoxious languages that have the same advantages (Python and JS)


== Rust ==
=== Rust ===
* Developed by Mozilla
* Developed by Mozilla
* Also known as rust-lang
* Also known as rust-lang
Line 421: Line 343:
* First stable release by the end of 2014
* First stable release by the end of 2014


== Scheme ==
* Based on Lisp with a focus on minimalism and simplicity
* Popular in many universities and featured in [https://wiki.installgentoo.com/index.php/Structure_and_Interpretation_of_Computer_Programs SICP]
* Great for programs with a basis in recursion and iteration
* Lacks portability and has little implementations


== Vala ==
=== Vala ===
* The GNOME foundation's response to C++
* The GNOME foundation's response to C++
* Compiles to C code, which can then be compiled with a normal C compiler
* Compiles to C code, which can then be compiled with a normal C compiler
Line 435: Line 352:


[[Category:Programming]]
[[Category:Programming]]
[[Category:Programming languages]]
[[Category:What does /g/ use?]]

Latest revision as of 02:46, 29 March 2022

Practical Language Comparison.jpeg

Quick summary of programming languages.

Should I learn...

There's a lot of languages out there, and most of them have a lot of overlap over common problem domains. In principle, all languages being Turing complete, there's nothing stopping you from doing any task in any language. But in practice, there may be orders of magnitude difference (we're talking 100-1000x here) in how much time it takes to do a project in a suitable language vs. an unsuitable one. Among the joys you may experience by picking the wrong language are:

  • Fighting passive aggressive syntax that pesters you with irrelevant low-level details
    • You shouldn't underestimate the importance of simple syntactical decisions and syntactic sugar. Learning a language and developing software both take a lot of commitment and hard work. If you don't enjoy your language, it will destroy your motivation, and it will become very hard to get anywhere.
  • Having reinvent the wheel because nobody bothered porting critical library X
  • Having to figure shit out on your own because all guides for topic X are written for other languages (translating example code you don't understand is so much fun!)
  • Committing hundreds or thousands of man-hours into a project, only to realize that you can no longer improve on performance or a feature set because of the design decisions your language made, and if you want to progress your only hope is to rewrite everything in another language first
  • Spending time and effort learning a language only to realize the job market for it is shit (if you have career goal as opposed to being a hobbyist)

To a novice, a summary of language features will not be much help. Even something as basic as functional vs. procedural is irrelevant if you have never programmed and don't understand well what these things mean. If you are just starting out, you have to be careful about who you listen to. There are many languages out there, and a lot of them are pretty good for solving certain sets of problems. But few are suitable for a newbie (as a newbie, you will be learning not just the language, but also general computation). The last thing you won't is to get trolled by some faggot engaging in language wars.

If you are experienced (rule of thumb: have you created useful software in and gotten paid for it in more than one language?) then the choice becomes much easier. Based on the languages you do know, you will probably already have a taste for certain features. Consider the languages you're already comfortable with - what do they do well? What would you change? The language you are considering learning will invariably be better in some ways and worse in others than those you already know. The question is do the pros give you enough to justify both the cons and the extra effort of learning a new language.

Ultimately, you should aspire to learn how to program, not to learn any given language. To wit, all programming revolves around making the computer do things: The computer know a small set of atomic, fundamental "things" which it can already do. It is your task, as the programmer, to define how these fundamental tasks should be combined with each other to perform new tasks. Depending on how the fundamental tasks of a language are chosen, and what rules govern their combination, some tasks will be rendered easy or difficult, intuitive or unintuitive.

Intrinsic vs. Extrinsic

When comparing the comparative merits of languages, we may divide them into two main groups: Extrinsic properties and intrinsic properties. Intrinsic properties are properties of the language itself, such as syntax. Extrinsic properties are everything that isn't part of the language itself: The community, the tutorials available, the libraries that have been written, how the language and its users are perceived, and so on. Basically, intrinsic properties are what you get if you were using the language in a vacant, with nothing but a description of the syntax and a basic compiler.

Languages do not exist in a vacant, but considering them in a vacant may inform the bigger decision of which language is worth your time. We therefore make the distinction between intrinsic and extrinsic aspects for the following reasons:

  • Intrinsic properties are constant in time (at least until a new version of the language is released). Extrinsic properties are very much inconstant (who knows what language will be popular in a five years?).
  • Intrinsic properties influence extrinsic properties, but not vice versa (the exception is when language designers listen to what the community wants for the subsequent version of the language).

Generally, your decision should be rooted in the intrinsics, since as you can see, they are the key factor and they are the ones you will be stuck with so long as you use the language. But that's not to say extrinsic factors aren't important or should be ignored (this is in fact a very big mistake).

Intrinsic properties

For most languages that are designed without a specific purpose in mind, intrinsics will be fairly similar. They will not be glaring flaws or radical improvements. When languages are designed with a specific purpose in mind, they tend to have more drastic changes. Usually, if a specialized language is designed from a problem domain, that problem domain is very hard to deal with using more generalist languages.

Syntax

Syntax determines what the instruction you write in a language will look like. You should ask yourself:

  • How easy is it to remember commands in this language?
  • Is it easy to comprehend the syntax?
  • Can I code with just a basic text editor, or is it impractical without a sophisticated utility program helping you by highlighting code or generating repetitive code segments?
  • Are there too many keywords?
  • Is it legible?
Syntactic sugar

Syntactic sugar is the different shorthands a language can have, such as being able to say x++ instead of x = x + 1.

If you happen to often do the things your language's sugar tries to facilitate, it can make your life a lot easier.

If the sugar does not help you, you can of course not use it, but remember that ignoring bad sugar will not make it go away. If your language has some retarded sugar that everyone loves using for some reason, it can make reading other people's code hell (this is also an example of intrinsics influencing extrinsics).

Paradigm (imperative vs. declarative)

Humanity has thus far discovered two ways of specifying instructions for a computer.

  • The imperative approach gives the computer a list of instructions. The computer executes the commands in the order given (although some of the commands themselves may involve altering the initial order). For example, to compute the circumference of a circle, you would tell the computer to first take the radius, then multiply it by two to get the diameter, then multiply that by a pre-computed approximate value of pi, then print it to the screen. There are dozens if not hundreds of imperative languages like C, C++, Java and many others.
  • The declarative approach simply defines what each thing means, and lets the computer put the definitions together. It can be difficult to make the calculations happen in a certain order, but because no order is specified, paralleling tasks to improve performance can be very easy. For the circumference, you would give the computer the formula for circumference, the formula for approximating pi (for example 22/7), and ask it for circumference given a radius. Note how I don't say "print to the screen" - communicating with the user can also be a problem with declarative languages. In practice, the main representatives of this class are functional languages like Haskell or Lisp.

In theory, these two styles are exactly equivalent in terms what programs it is possible to write in them. But in practice, they are very different, and can have a huge impact on how easy a given task is.

Historically, imperative languages have dominated, and have been regarded as easier to understand. Perhaps the idea of giving someone explicit step-by-step instructions is more intuitive to the human mind than systems of functions, but regardless, most people find imperative languages easier, and interest in functional languages often correlates with mathematical aptitude. If you don't know what you're doing, you should probably start with an imperative language.

On a deeper level, there is an interesting note about having two paradigms together: There are ways of essentially calling modules written in a functional style from an imperative program, and vice versa. It is probably better to nest declarative logic inside imperative logic: The two advantages of imperative logic are being able to enforce a sequence and easy interaction with the user. Both of these are most powerful when done at the top level of the program. The advantages of functional logic involve flexibility in solving a well defined problem - so they are well suited to acting as a specialized module.

In many modern imperative languages, it is actually possible to write almost declarative, functional-style logic (in particular, look for "lambda expressions"). Because the language is not designed with purely functional programming in mind, this may be impractical (difficult to debug, clumsy to type out, slow and unoptimized) but in some small but important subset of problems you can actually mix the two paradigms together.

Object oriented programming (OOP)

The basic logic of OOP is:

  • Everything is an object belonging to a class of objects
  • Classes have their own variables (fields) and behaviors (methods)
  • Classes are taxonomically related to each other, and can inherit and extend each other's functionality (inheritance)

With an OOP project, a significant amount of work is spent on class hierarchies defining which class has what components and what it inherits from. The actual functionality of the program is supposed to flow naturally from those. There's a lot of analyzing the problem into compartmentalized units that interact with each other.

This way of thinking is suitable for some problems. For example, when programming a GUI, it can be convenient to represent all the scrollbars, buttons, checkboxes and textfields as classes with shared behaviors. At other times, adding OOP may just make a trivial thing difficult.

Strictness

There's quite a bit of variance between languages in terms of how much detail they require. Say you want to define a variable to store a number. Some languages are very pedantic, you are required to specify what kind of number, whether negative values are possible, what the max value should be, whether it's a whole number or decimal, and how many digits to store if decimal. Other languages just let you define your number and never ask questions, trying to make reasonable assumptions about all the things you left out.

High strictness can be useful in two ways. First, it gives you better control over exactly what the program is doing. This helps with optimization: If you know a variable will never store a number bigger than 255, there's no point in using a larger format and wasting memory. Second, they force you to constantly think about every detail of your code, and may help reduce bugs (but not necessarily). Examples: C, C++, Java, Haskell (functional).

Low strictness is good when you just have a simple idea, and want to quickly get it working without getting hung up about the particulars. Unfortunately, some of those details you did not specify will eventually cause subtle bugs that will be a pain to fix. Examples: Python, JavaScript.

Strict languages tend to be good for production-level software where reliability, close adherence to specs and high level of optimization is necessary. Non-strict languages are good for prototyping and hacking together one-shot scripts.

Extrinsic properties

Documentation

Always check what books, tutorials and help forums (or how many questions on StackOverflow) there are for a language. It can be the best language ever made, but not being able to quickly Google simple questions can really slow down your learning.

Libraries

Learning exercises aside, these days it's stupid to write a program from scratch. A lot of common functionality like file I/O, working with arrays, sorting, math functions, graphics, networking, etc have already been implemented, and hopefully packaged as libraries. You shouldn't reinvent the wheel.

It can be hard to gauge the ecosystem of a language, but try Googling things like "How to do X in language Y" - do you get short, easy to read results which use well-maintained and well-documented libraries, or do you get a bunch of people writing their own unreadable hacks?

Examples:

  • For a while C# was a very good choice for making games thanks to XNA (unfortunately Microsoft stopped developing it when Windows 8 came out). XNA handles many things like keyboard/gamepad input, 2D/3D graphics, sound, game update cycles, framerate, assets and so on for you, and has nicely documented functions and plenty of good tutorials. C# by itself is a decent language, but not that great - XNA was what allowed a lot of independent games like Terraria and Bastion to be made with a small team.
  • Python has a few libraries that are so good that doing webscraping (BeautifulSoup, etc) or scientific computing (SciPy) in something else is just stupid at this point.

Platform

In principle any language can run on any platform, but it's another matter entirely whether your favorite framework is available everywhere (for example even though C++ works anywhere, DirectX is Windows-only), what performance will be, and how much support is available. Some platforms are dominated by a language:

  • The basis for Android apps is Java. You can get others to run, but all the tutorials you find will be in Java.
  • If you want to program for iOS, you have to use Objective-C (incidentally, a language useless for anything else).
  • Webapps are usually made in Python (Django), Ruby (with Rails) or JavaScript.
  • Browser games use Flash or HTML5.

Performance

Langspeed.png

I'll put this into extrinsic, because its depends a lot on implementation. Generally, anything with a VM will take a performance hit. Anything interpreted will always be slowpoke. Garbage collection, dynamic typing, all slow things down. Luckily, computers these days are so fast that performance usually doesn't matter. But in high performance applications (3D vidya, cryptography, statistical computation) you need a language suitable for systems programming. Functional languages can sometimes be much faster than imperative, because you can optimize some things very nicely in them.

Perception

If you want to program as a hobby, this is irrelevant, but if you want to get a job, it's worth carefully researching what is in demand where. For example, Python, C# and Java are the top 3 if you want to write trader bots on Wall Street. Java and C# are shit career choices because you'll compete with millions of third-worlders for low-paying positions.

Community

Some languages seem to attract more faggots than others. For example, Ruby was once infamous for its hipster fans, and most users of Rust seem more concerned with social justice than software development.

What does /g/ use?

There are MANY languages, and there are constant arguments on /g/ about the best language, with no general agreed upon language. Below is a list of languages frequently voted for/against, and simple explanations as to why they are liked/hated.

  • C - Probably the most agreed upon language on /g/. Although there are many that claim C is dated. Most of the UNIX/Linux is written (and still being written) in C. TempleOS was written in Terry's own version of C; HolyC.
  • C++ - For those that like C, but think it is dated, C++ exists, and is very popular both on /g/ and in the real world.
  • Haskell/Lisp/Functional languages - Functional languages are very useful in changing the way you think about programming. Writing in a functional language will force you to think more about your code and design much nicer functions/algorithmns. However with that being said, functional languages do not accurately represent how the computer works, and this has its problems.
  • Python - A very controversial language on /g/. Some believe that it is good language for beginners. Others believe that it is the worst programming language in every aspect. It does have many flaws and many reasons not to use it, however it is very easy for someone with little knowledge to start writing code (which may or may not be a good thing).
  • JavaScript/Node.js - Recommended by those who hate Python, for those that are new. It is still an easy language for beginners, and it has many flaws, but next to Python it looks like gold.
  • Rust
  • Assembly - Recommended by /g/ because like Gentoo, you have to be a complete autist to use it (see how to write hello world in assembly). Probably the language with the best performance possible, as it is 1:1 with machine code instructions, however many people will be quick to point out that if you do something inefficient, then other languages may be faster as their compiler will not make the same mistakes.

Again, each of these languages is subject to through debate about whether or not it is good or bad, and most of the time the problem you are trying to solve will usually dictate what language you should use.

Individual languages

Ada

  • Designed to catch as many errors as possible, as soon as possible
  • Pascal-like syntax
  • Excellent for embedded, systems, or realtime programming, but suitable for pretty much anything
  • Programming by contract in Ada 2012
  • Many advanced features like tasking, generics, and exceptions were built in to the language back in the 80s
  • Good support for proving code correctness, especially in SPARK variant
  • Verbose code
  • Lacking in up-to-date tutorials and documentation for beginners
  • Not used much outside of the defense and aerospace industries

Assembly

  • Terse, but pedantic as fuck.
    • Small programs are simple to write, but larger ones become an unwieldy and complex mess in most cases.
  • Based Motorola ASM, so many variants, so much serial port downloading.
  • x86 ASM is pretty neat too, also known as PC ASM. Pain in the ass because AT&T ASM syntax is the UNIX standard, and Intel ASM syntax is the DOS standard and they are so close but its the little things that are different. Enough different to be a pain in the dick.
  • Not portable. This is as close to the metal as you get without writing actual machine op codes. Each instruction IS a 1:1 mapping to a machine opcode. Each CPU architecture has a different set of instructions.
  • Currently, Intel x86-64 ASM is the largest instruction set.

BASIC

  • >It can do anything C can do, guise!!1
  • Lots of proprietary implementations, only a few decent FOSS ones.
  • Still slower than C
  • >muh goto
  • muh excel programming

C

  • Designed to be a "portable assembly language"
  • Small, simple language whose parts compose well
  • Very small standard library
    • You will need to implement most non-trival things yourself.
  • Lingua franca for big libraries and APIs
    • If it has no C API, it's probably shit
  • Very mature compilers that produce extremely fast, well-optimized code
  • Implementations for pretty much every architecture or platform imaginable
    • If some hardware doesn't have a C compiler for it, chances are it doesn't matter in the first place
  • Lots of things are left undefined so that implementations can make the best choice possible in terms of speed
  • Easy to make dangerous errors in code
    • You manage your own resources yourself
    • You perform your own safety checks if you want them
    • Absolutely no hand-holding
    • Undefined behavior where anything can happen
  • Will force you to learn a lot about memory and lower level issues
  • Can also be used for applications programming

C++

  • Very, very large and feature-filled language
  • Considered verbose at times
  • C, but with OOP on top, and massive set of massive libraries
  • Industry standard for widely used commercial software
  • Considered dangerous to write in because, like C, there is no memory management
    • There are garbage collectors for C++
  • Almost as fast as C
  • Compiling takes ages because of archaic linking system, this is basically where the Compiling xkcd is about
  • Tons of very powerful features, many ways to do the same things
    • The guy whose code you're reading always picks the worst one
  • Despite being called C/C++ frequently, good C++ is completely different from good C
  • The designer of the language had this to say about it: "C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off"

C#/.NET

  • What Java should have been
  • Very similar to Java, but fixes a lot of Java's problems that Java is stuck with because of backwards-compatibility
  • Runs on .NET, which is Windows only and Mono, which is FLOSS and multiplatform.
  • .NET is a great library, and now open source
  • LINQ is a very powerful way of working with collections (lists/sets/arrays) and databases (if mapped to collections)
  • Visual Studio/ReSharper is very nice IDE for C#
  • 3rd most popular language on StackOverflow, very active community with many experts

Mono

  • Open alternative to .NET started when .NET was closed-source (Mono framework allowing you to run it on GNU/Linux)
  • Implements almost all of .NET, but leaves out a lot of WinForms and WPF (GUI stuff)
  • Dubious legal situation because parts of the language are encumbered with MS patent
  • Purchased by Microsoft, now safely legal.

Erlang

  • Makes concurrency/multithread shit a breeze.
  • Uses a specialised VM that has a hard time crunching numbers, and an even harder time handling strings.

Golang

  • Also known as Go
  • Created by Rob Pike (one of the original UNIX guys) and some other engineers at Google
  • Mascot looks suspiciously similar to the Plan9 mascot
  • Is basically C with minimal extras, but with garbage collection, and some core language features to make it really good for concurrent programming (doing multiple things at once). Not really as fast as C, though.
  • Directory structure must be laid out in a certain way to build projects
  • Has an interactive tutorial at their website, and a go tool which allows you to pull from github, and package go, etc
  • Uses Goroutines for concurrency, which are like lightweight threads which are then fit into threads for more efficiency. The compiler handles the threads for you.

Haskell

  • Extremely expressive, offers abstraction capabilities near Lisp
  • Focuses on pure functional programming and type systems
  • Very rigid language, if you do something wrong, it probably won't even compile
  • Takes a lot of time to learn completely
  • Can be unwieldy for inherently stateful problems

Java

  • Very portable; compiling down to bytecode, which is then executed by the JVM
  • The language that made OOP commonplace
  • Some initial design decision have turned out to cause problems, but can't be fixed because of backward compatibility
  • Very large and enterprise
  • Huge libraries and a lot of software is written in it, including code from academic papers
  • Very verbose APIs
  • Receives a lot of undue criticism
    • Used to be slow many years ago, but these days is very fast
  • Can be convoluted to write in sometimes
  • Both the language itself and the core libraries are very bureaucratic
  • Is made fun of for the design patterns people use with it, and for the verbose naming schemes often used
    • Example: public abstract class AbstractSingletonProxyFactoryBean

JavaScript/Node.js

  • Programming language of the web, most web browsers come with a native JS console
  • Usually used hand in hand with HTML/CSS
  • Good for learning how functional programming works with less explicit code typing (e.g variables are assumed as strings or integers)
  • Can be used to make desktop applications (albeit slow if not optimized properly) and server-side code with Node.js
  • Read JavaScript: The Good Parts by Douglas Crockford to get a better understanding of how this mess of a language can be used efficiently and with consistently
  • JSLint is an excellent way to check if your JS is shit or not
  • ES6/ES7 features are ready and available to use on modern browsers with Babel™

Lisp

  • Family of programming languages which have the most notable features of using fully parenthesized prefix notation and being homoiconic.
  • Intially appeared in 1958.
  • Lisp is said to change the way one thinks about programming, because it exposes the abstract syntax tree to the programmer for modification and extension of the language itself to fit the domain-specific needs of a particular task.
  • No (visible) limit to abstraction

Scheme

  • Based on Lisp with a focus on minimalism and simplicity
  • Popular in many universities and featured in SICP
  • Great for programs with a basis in recursion and iteration
  • Lacks portability and has little implementations

Mathematica

  • Beautiful language with extremely high-level capabilities for math
  • Amazing symbolic math capabilities (solving equations, theorem proving)
  • Official documentation has tons of cool math examples
  • Common with physicists, mathematicians
  • Error messages are fucking godawful
  • Proprietary
  • Creator is an insane megalomaniac

Matlab/Octave

  • Originally designed for working on matrices and linear algebra
  • Very fast matrix functions
  • Very full-featured IDE with nice visualization options and toolkits
  • Commonly used for engineering, machine learning and scientific computation
  • Interpreted dynamic language
  • Tons of shitty code out there written by clueless grad students
  • Octave is a FOSS compiler that accepts a superset of Matlab syntax, with slight differences (less bloat and much lower cost).

Pascal

  • Very strong, safe, and featured type system
  • Simple syntax that prefers words over symbols, and is highly-structured
  • Originally designed for teaching, and very easy to get started with
  • Fast, single-pass compilers
  • Covers both low-level and relatively high-level concepts well
  • Not very popular anymore, you won't find a job using it, and newer learning resources for it are lacking
  • The syntax is considered too verbose by some
  • Bias carried over from problems with earlier versions of the language
  • Large number of varied modern dialects and compilers may confuse newcomers

Perl

  • Write-only language
  • Very tacit and unreadable syntax
  • Called a "swiss army chainsaw" for its versatility
  • Slow for non-procedural tasks
  • Dynamic grammar makes it fun to write impossible code
  • Hated by Python fanboys worldwide
  • Can be OO, imperative, and even has functional elements.
  • Avoids the use of reserved keywords, prefers keyboard squiggles (&, $, @, ->, etc.)
  • Falling out of fashion
  • Great for code golf or obfuscation contests

PHP

PHP has an awful reputation among developers. There are far more marketable languages out there that will do everything that you would care to do in PHP. Despite the poor opinion of many, the language continues active development. There have been a lot of new features and a healthy amount of legacy code cleanup attempts in recent years.

  • Optional use of strict argument and return types (PHP 7.1+)
  • Choice to implement procedural, functional, or OOP design patterns
  • PHP 7+ is still slow compared to Java
  • Not designed to be long running
  • Can be memory intensive, especially when using community frameworks
  • Good documentation, and a large community of active developers
  • You'll get made fun of by other developers for using it

Python

  • Very easy to read and simple (and fun) to write
  • Enormous, versatile standard library (a philosphy they call "batteries included")
  • Kinda slow
  • Uses whitespace indentation to separate logical blocks
  • Excellent for scripting
  • Considered the antithesis of Perl
  • OO/imperative, has some functional elements but designer has a weird obsession with removing those
  • Is nice to start out with and program in, but after a few years of it, you'll start to want to play with some of the stuff Python sacrifices, like pointers, and speed.

R

  • Made for statistical computation, excels at that but not much good for anything else
  • Libraries like ggplot make beautiful, top-tier plots
    • R libraries are THE cutting edge of data visualization
  • Rstudio is a very good environment
  • Data frames are strongly typed native data types for working with tabulated data
  • Very commonly used in academia, data science, analytics etc
  • Fucking impossible to Google anything about it
  • Most polluted and inconsistent namespace known to mankind

Ruby

  • Focus on programmer happiness
    • The creator's idea of happiness may be very different from yours
  • Fully object-oriented
  • Elegant, readable code
  • As slow as any dynamic language will be
  • Excellent for general-purpose programming, scripting, text processing and web dev
  • Userbase full of hipsters and insufferable faggots
  • Getting displaced by less obnoxious languages that have the same advantages (Python and JS)

Rust

  • Developed by Mozilla
  • Also known as rust-lang
  • Like Golang, is also designed for concurrent programming
  • First stable release by the end of 2014


Vala

  • The GNOME foundation's response to C++
  • Compiles to C code, which can then be compiled with a normal C compiler
  • Uses the GTK and GObject (GNOME) libraries
  • Has elements of C++ and C#, but is more sane