Rosetta Code - ξεκλείδωμα των μυστηρίων των γλωσσών προγραμματισμού που τροφοδοτούν τον κόσμο μας

Δεν είναι μυστικό ότι ο κόσμος της τεχνολογίας κυριαρχείται από μια σχετικά μικρή ομάδα γλωσσών προγραμματισμού. Ενώ τα ακριβή στοιχεία είναι δύσκολο να ληφθούν (και αναμφίβολα διαφέρουν με την πάροδο του χρόνου), πιθανότατα θα μπορούσατε να ονομάσετε λίγες γλώσσες που αποτελούν τη συντριπτική πλειονότητα όλων των εξόδων προγραμματισμού για μια δεδομένη χρονική περίοδο.

Δύο ενδιαφέρουσες τοποθεσίες που επισκέφτηκα κατά την έρευνα αυτού του άρθρου σάς επιτρέπουν να απεικονίσετε τις γλώσσες προγραμματισμού κατά δημοτικότητα. Το IEEE Spectrum σάς επιτρέπει να προσαρμόζετε διαδραστικά τους συντελεστές στάθμισης διαφόρων μετρήσεων, ενώ το PYPL εξυπηρετεί έναν τακτοποιημένο πίνακα δίνοντας πραγματικά ποσοστά% μεριδίων με βάση τα δεδομένα του Google Trends τους τελευταίους 12 μήνες.

Τώρα, αρνούμαι να συμμετάσχω σε συζητήσεις σχετικά με το ποια είναι η καλύτερη μέτρηση της δημοτικότητας της γλώσσας προγραμματισμού ή όχι (και αν αυτό είναι ή όχι σημαντικό στατιστικό στοιχείο). Αυτό που ακολουθεί είναι απλώς μια βιαστική ανάλυση για να δείξει ένα σημείο (οποιαδήποτε δικαιολογία για να χρησιμοποιήσετε το R-Fiddle!)

Χρησιμοποιώντας τα δεδομένα από το PYPL, μπορούμε να δούμε μερικές σαφείς τάσεις:

1) - Οι 10 κορυφαίες γλώσσες αντιπροσωπεύουν σχεδόν το 90% των δεδομένων του Google Trends

Με σειρά, αυτά είναι: Java, Python, PHP, C #, JavaScript, C, C ++, Objective-C, R και Swift. Σε συνδυασμό, έχουν μερίδιο Google Trends 87,1%.

2) —Η δημοτικότητα της γλώσσας ακολουθεί μια κατανομή εξουσίας

Χρησιμοποιώντας το αγαπημένο μου πακέτο R, «igraph», για την αξιόπιστη λειτουργία power.law.fit (), διαπίστωσα ότι η δημοτικότητα των γλωσσών προγραμματισμού ακολουθεί μια κατανομή ισχύος-νόμου:

> pL = power.law.fit(shares)> pL$KS.p$KS.p[1] 0.9873141

Αυτή η $KS.pτιμή 0,987 είναι η τιμή p που σχετίζεται με μια στατιστική δοκιμής Kolmogorov-Smirnov, η οποία μας λέει ότι μπορούμε να είμαστε αρκετά σίγουροι ότι η κατανομή της δημοτικότητας (όπως ορίζεται από το PYPL) ακολουθεί μια κατανομή εξουσίας.

Όπως πολλά άλλα φαινόμενα, η σχετική δημοτικότητα των γλωσσών προγραμματισμού κατανέμεται άνισα. Αυτό συνήθως μπορεί να εξηγηθεί με έναν θετικό μηχανισμό ανατροφοδότησης (ή «χιονόμπαλο») - μια απλοϊκή έκδοση μπορεί να σημαίνει ότι όσο πιο δημοφιλής είναι μια γλώσσα, τόσο περισσότερες θέσεις εργασίας είναι διαθέσιμες σε αυτήν, οπότε περισσότεροι άνθρωποι έχουν κίνητρα να την μάθουν, έτσι αυξάνοντας τη δημοτικότητά του.

Λοιπόν, τι νέα?

Δεν είναι πραγματικά έκπληξη το γεγονός ότι ορισμένες γλώσσες προγραμματισμού είναι πιο δημοφιλείς από άλλες. Όλοι γνωρίζουν ήδη ότι οι Java, C, C ++, C #, Python et al. είναι μακράν οι πιο χρησιμοποιούμενες γλώσσες.

Αυτό που είναι πιο ενδιαφέρον, κατά τη γνώμη μου, είναι η παρατήρηση ότι για κάθε μεγάλη γλώσσα προγραμματισμού, πρέπει να υπάρχουν δεκάδες μικρότερες, πιο εξειδικευμένες γλώσσες εκεί έξω στην έρημο.

Πέρα από την περιέργεια, υπάρχουν καλοί λόγοι για να σας ενδιαφέρει αυτό. Όποιος έχει κάνει περισσότερες από λίγες γλώσσες προγραμματισμού γνωρίζει ότι διαφορετικές γλώσσες ταιριάζουν σε διαφορετικούς σκοπούς. Το JavaScript είναι για ανάπτυξη ιστού, PHP για προγραμματισμό από διακομιστή, R για στατιστικά, Matlab για πλήρη μαθηματικά. Με τις γλώσσες προγραμματισμού, η ποικιλία είναι καλό. Εκεί, μπορεί να υπάρχει μια γλώσσα ιδανική για την επίλυση του προβλήματος που δεν γνωρίζατε καν ότι υπήρχε.

Αλλά πού να τα βρεις; Ένα μέρος που πρέπει να κοιτάξετε είναι ο Rosetta Code.

Ένα σαφάρι προγραμματισμού

Δεν θυμάμαι ακριβώς πώς συνάντησα τον Rosetta Code, αλλά μόλις το βρήκα, ήμουν δεμένος. Περιγράφεται ως ιστότοπος προγραμματισμένης χοροθεραπείας και διαθέτει εντυπωσιακά 647 γλώσσες προγραμματισμού στα αρχεία της. Πηγαίνετε και δείτε το.

Το πραγματικά φοβερό πράγμα είναι ότι ο κώδικας Rosetta ξεπερνά απλώς ένα γενικό "Hello World!" παράδειγμα για κάθε γλώσσα. Όχι, αντ 'αυτού, έχει μια συλλογή από περισσότερες από 800 ανάλογες εργασίες προγραμματισμού, από μερικές τόσο απλές όσο "Odd ή Even", έως και πιο προηγμένα προβλήματα, όπως η επίλυση λαβυρίνθου και το web-scraping. Κάθε σελίδα εργασιών περιγράφει το πρόβλημα που πρέπει να λυθεί και στη συνέχεια δίνει λύσεις σε μια σειρά από γλώσσες προγραμματισμού.

Εδώ, η φήμη δεν έχει σημασία. Όπως και C, C ++, Java κ.λπ., θα βρείτε λύσεις σε γλώσσες που δεν έχετε ξανακούσει. Μερικά είναι ρετρό, μερικά είναι μοντέρνα. Μερικά φαίνονται οικεία, ενώ άλλα είναι εσωτερικά πέρα ​​από την πεποίθηση. Θα μπορούσατε να περάσετε περισσότερο από ό, τι θα θέλατε να παραδεχτείτε την περιήγηση σε όλα τα παραδείγματα - αλλά για να σας βοηθήσω να ξεκινήσετε, έχω συντάξει μια λίστα με μερικές από τις λιγότερο γνωστές και / ή πιο ενδιαφέρουσες γλώσσες που τράβηξαν την προσοχή μου. Ενεργοποιήστε τη λειτουργία nerd και κάντε βουτιά!

Αναμνήσεις απ'το παρελθόν

Ορισμένες γλώσσες διαρκούν για πάντα ή έτσι φαίνεται. Όπως και το C, οι γλώσσες που προέρχονται από το Lisp και το Fortran υπάρχουν εδώ και δεκαετίες, και άλλες όπως το BASIC και το Pascal μπορεί να έχουν ξεπεράσει τη μόδα αλλά ζουν στη δημοφιλή μνήμη.

Ωστόσο, ο χρόνος ήταν λιγότερο ευγενικός για τους άλλους. Ακολουθεί μια λίστα με ορισμένες γλώσσες με δείγματα κώδικα στη Rosetta, οι οποίες, για να το θέσουμε μονόδρομο, είναι απίθανο να σας προσλάβουν σύντομα.

Κωδικός παραγγελίας EDSAC

Το EDSAC είναι ένας διάσημος πρώιμος υπολογιστής, σχεδιασμένος και κατασκευασμένος από την ομάδα του Maurice Wilkes στο Πανεπιστήμιο του Cambridge στα τέλη της δεκαετίας του 1940. Η κατασκευή του EDSAC είδε τον David Wheeler να κερδίζει το πρώτο διδακτορικό στην Επιστήμη Υπολογιστών το 1951. Ενώ βρισκόταν σε αυτό, εφευρέθηκε επίσης το «Wheeler jump», ή κλειστή υπορουτίνα - την οποία συνήθως αποκαλούμε σήμερα «λειτουργίες».

Παρά την αμετάκλητη θέση του στην ιστορία, το EDSAC βρίσκεται εκτός δράσης από το 1958, οπότε μην βιαστείτε να μάθετε την προσαρμοσμένη γλώσσα προγραμματισμού του. Ακολουθεί ένα παράδειγμα από τον κώδικα Rosetta. Είναι το «κενό πρόγραμμα» ή το συντομότερο νόμιμο πρόγραμμα. Δεν κάνει καθόλου.

T64K [ set load point ]GK [ set base address ]ZF [ stop ]EZPF [ begin at load point ]

ΓΕΩΡΓΙΟΣ

Αυτή η γλώσσα, που εφευρέθηκε το 1957, είναι μια γλώσσα που θα είχε εισαχθεί μέσω ταινίας σε ένα μηχάνημα μεγέθους δωματίου. Παρ 'όλα αυτά, ήταν γεμάτο χαρακτηριστικά, όπως βρόχους, δηλώσεις υπό όρους, υπορουτίνες και δομές δεδομένων μήτρας. Διαβάζει ακόμη λίγο σαν μια πιο μοντέρνα γλώσσα.

Εξήντα χρόνια όμως, η GEORGE δεν είναι πλέον μαζί μας. Δείτε πώς θα μπορούσε να χρησιμοποιηθεί για τον υπολογισμό του αθροίσματος μιας σειράς:

0 (s)1, 1000 rep (i) s 1 i dup × / + (s) ;]P

BCPL

Η «βασική συνδυασμένη γλώσσα προγραμματισμού», ή το BCPL, αξίζει τη θέση της στην ιστορία των υπολογιστών. Εκτός από την εμφάνιση της παράδοσης του "Hello World!", Το BCPL είχε μια βαθιά επιρροή στο σχεδιασμό του B, που ήταν ο ίδιος ο πρόδρομος του C. BCPL ήταν η πρώτη γλώσσα που εισήγαγε τιράντες "{" ως τρόπο ορίζοντας μπλοκ κώδικα - μια σύμβαση που χρησιμοποιείται ακόμα σε πολλές από τις πιο εξέχουσες γλώσσες του σήμερα. Αξιοπρεπές, καθώς πηγαίνουν τα κληροδοτήματα

Here’s a “Hello World” program written in BCPL:

GET "libhdr" LET start() = VALOF{ writef("Hello world!") RESULTIS 0}

PL/I

Developed by IBM in the early 1960’s PL/I (Programming Language One) was widely used in its heyday, but never quite displaced its competitors Fortran and COBOL. PL/I was primarily a mainframe language, and with the advent of the PC and the rising popularity of languages such as C++ and Java, PL/I slipped out of favor.

There are many examples of PL/I on Rosetta Code; here it is generating a Fibonacci sequence:

/* Form the n-th Fibonacci number, n > 1. */get list(n);f1 = 0; f2 = 1;do i = 2 to n; f3 = f1 + f2; put skip edit('fibo(',i,')=',f3)(a,f(5),a,f(5)); f1 = f2; f2 = f3;end;

SNOBOL4

SNOBOL was developed in the early 1960’s and became a popular teaching language in the following decade. However, it ran out of steam throughout the 1980’s and 90's, but not before it was able to influence the design of Lua, which makes a top-20 appearance in the PYPL rankings we saw earlier.

Here’s a SNOBOL4 program that outputs the length of a string:

 output = "Byte length: " size(trim(input))end

FOCAL

FOCAL (‘Formulating On-Line Calculations in Algebraic Language’, since you asked) was introduced in 1968, and was an efficient language that could run on very memory-limited systems. One particular quirk of the language was its apparent phobia of strings. Inputting the string “HELLO” would be interpreted as asking the computer to calculate 8 ^ "LLO” , which FOCAL struggled to work out before spitting out a massive numerical answer.

Despite its eccentricities, FOCAL was used widely enough during the 70’s and 80’s. Coca-Cola even used their own version, which they imaginatively called COKE.

This example from Rosetta Code shows a FOCAL program that converts temperatures between different units:

01.10 ASK "TEMPERATURE IN KELVIN", K01.20 TYPE "K ", %6.02, K, !01.30 TYPE "C ", %6.02, K - 273.15, !01.40 TYPE "F ", %6.02, K * 1.8 - 459.67, !01.50 TYPE "R ", %6.02, K * 1.8, !

SETL

SETL was invented in the late 1960’s and was based heavily on set theory, the branch of mathematics that concerns collections of objects. The most recent stable release was back in 2005, but despite its decline from use, SETL has a couple of claims to fame.

The first compiler of Ada, which was developed by the US Department of Defense, was written in SETL. Also, it is said to have influenced ABC — the language which went on to inspire the design of Python.

Here’s how SETL calculates the greatest common divisor of two integers. See any resemblance to Python?

proc gcd (u, v); return if v = 0 then abs u else gcd (v, u mod v) end;end;

MUMPS

This unfortunately named language has been around since 1966, and is also referred to as M. A key feature is the built in database system, which allows for super-efficient access to stored data.

Although no longer in common use, MUMPS lives on the form of GT.M and InterSystems_Cache — which have a niche in hospitals and financial database systems. The European Space Agency has also used InterSystems_Cache for its recent Gaia mission.

This is how MUMPS can be used to reverse a string:

REVERSE ;Take in a string and reverse it using the built in function $REVERSE NEW S READ:30 "Enter a string: ",S WRITE !,$REVERSE(S) QUIT

Deliberately Confusing

What are the hallmarks of a successful programming language? Speed? Versatility? Readability? Nah, forget all that — let’s look at a branch of programming languages out there that are intentionally difficult and/or unintuitive to use.

Esoteric languages, or ‘esolangs’, are programming languages used sometimes for experimentation, sometimes for a challenge, and sometimes just as the ultimate nerdy in-joke. If you don’t quite get it, that’s ok — in fact, that’s usually the point.

Better-known examples include Brainf***, Befunge and the particularly migraine-inducing Malbolge. Here’s a list of a few others, ranging from the amusing to the interesting, to the outright obtuse. Include these on your CV/Resume at your own risk.

INTERCAL

The original esoteric programming language was invented in 1972, making it as old as C. It was introduced as a parody of programming practices prevalent at the time, but its continued survival to this day suggests it is still as relevant as ever.

On top of an obtuse syntax, INTERCAL confuses its users even further by requiring them to use the keyword PLEASE every so often, else the program refuses to run. However, being overly polite backfires — saying ‘please’ too frequently will also result in an error. Of course, this eccentricity was not officially documented, because that’d just be too helpful.

Here’s an infinite loop, written in INTERCAL:

NOTE THIS IS INTERCAL PLEASE ,1 <- #5 DO ,1 SUB #1 <- #54 DO ,1 SUB #2 <- #192 DO ,1 SUB #3 <- #136 PLEASE ,1 SUB #4 <;- #208 DO ,1 SUB #5 <- #98 DO COME FROM (1) DO READ OUT ,1(2) DO ,1 SUB #1 <;- #134(1) PLEASE ABSTAIN FROM (2)

Beeswax

This is a conceptually interesting language, which takes the movement of bees around honeycomb as inspiration for the movement of pointers across instructions.

Beeswax is capable of arithmetic, reading/writing files, and even modifying its own source code. Below is a program that calculates n-factorial (n!) of a user-input integer.

 p M"p~.~d >Pd >~{;

Chef

This is perhaps my favorite of the languages I found on Rosetta Code. I’d previously read about it elsewhere, but hadn’t seen anything like the range of examples provided here.

Unlike most programming languages, Chef reads almost completely naturally, as each program is formatted much like a recipe (hence the name!). For completeness, it also refers to variables, instructions and data structures with cooking-related names, such as “mixing bowl”, “refrigerator”, “mix”, “chop” etc. Why not?

Here’s a sample program that calculates the sum and product of an array of numbers.

Sum and Product of Numbers as a Piece of Cake. This recipe sums N given numbers. Ingredients.1 N0 sum1 product1 number Method.Put sum into 1st mixing bowl.Put product into 2nd mixing bowl.Take N from refrigerator.Chop N.Take number from refrigerator.Add number into 1st mixing bowl.Combine number into 2nd mixing bowl.Chop N until choped.Pour contents of 2nd mixing bowl into the baking dish.Pour contents of 1st mixing bowl into the baking dish. Serves 1.

Golfscript

Familiar to fans of code golf (a fantastically geeky hobby in which participants try to solve programming puzzles in as few bytes of code as possible), Golfscript is a language designed to do a lot with a little.

It certainly achieves this goal, and allows its users to solve complex puzzles very concisely. Its website tells us this brevity is attained through ‘using single symbols to represent high level operations’.

Would you use it in a production setting? Maybe, if you were a seasoned code golfer and had no regard for the sanity of any successor to your project. Otherwise… probably not.

Rosetta Code has several nice examples of Golfscript, and since it manages to be so damn concise, I’ve included three of them here:

[2 4 3 1 2]$ #Sort an integer array
[296,{3/)}%-1%["No more"]+[" bottles":b]294*[b-1<]2*+[b]+[" of beer on the wall\n".8<"\nTake one down, pass it around\n"+1$n+]99*]zip #99 Green Bottles Lyrics
[{"close"}100*]:d;10,{)2?(.d++:d;}/[100,{)"door "\+" is"+}%d]zip{" "*puts}/ #100 Doors Challenge

Hoon

Hoon is fascinating in that, although some would class it as an esolang, it does actually serve a practical purpose. It can be used to program web services on Urbit, which describes itself as a ‘secure peer-to-peer network of personal servers’.

Take a look at the ‘greatest element’ example below.

Hoon is described as Lisp-y, and note the two-character symbols at the start of each line. These ‘runes’ are used in place of reserved keywords, which is a great concept, but does impact readability for those unfamiliar with its logic, and probably qualifies Hoon as somewhat esoteric.

:- %say|= [^ [a=(list ,@) ~] ~]:- %noun (snag 0 (sort a gte))
> +max [1 2 3 ~]3

Piet

By far the most unique language I came across was Piet, named after the 20th Century Dutch artist, Piet Mondrian.

It follows one highly unusual design principle: Program code should be in the form of abstract art. How is this achieved? The solution is nothing short of genius.

Integers are represented by the number of ‘codels’ in a contiguous block of color. The pointer starts in the top-left corner, and moves around the image. Every time it encounters a color change, an instruction is executed. The exact instruction is specified by the changes in both hue and brightness.

Mind = Blown.

Playing With Arrays

One thing that caught my attention was the number of array-based languages there are out there. Array-based programming has been around since the early 1960’s, with the invention of APL, and although they’re not exactly mainstream, there are plenty of offshoots still used to various extents today. These languages all have a lot in common, so I’ll spare you too much detail, but they’re interesting in just how concise they can be.

J

J was invented by Kenneth Iverson, who was also the inventor of APL. J is a very terse language, letting you get a lot done with very few lines of code.

Below is a K-means clustering algorithm. For comparison, the same example in C runs to 184 lines.

NB. Selection of initial centroids, per K-means++ initialCentroids =: (] , randomCentroid)^:(<:@:]`(,:@:[email protected]:[))~ seedCentroid =: {~ [email protected]# randomCentroid =: [ {~ [: wghtProb [: <./ distance/~ distance =: +/&.:*:@:-"1 NB. Extra credit #3 (N-dimensional is the same as 2-dimensional in J) wghtProb =: 1&$: : ((%{:)@:(+/\)@:] I. [ [email protected]$ 0:)"0 1 NB. Due to Roger Hui //j.mp/lj5Pnt NB. Having selected the initial centroids, the standard K-means algo follows centroids =: ([ mean/.~ closestCentroid)^:(]`_:`initialCentroids) closestCentroid =: [: (i.<./)"1 distance/ mean =: +/ % #

K, q

These two languages were both developed commercially by Kx Systems. Both are APL-like, array-based languages that have applications in finance and big data. q is wrapped around K, and provides enhanced readability.

I’ve included a couple of examples of each below. These are super-concise languages, and would no doubt be good for a round of code golf, if that’s what you’re into.

/ 1-D Cellular automata in Kf:{2=+/(0,x,0)@(!#x)+/:!3}
/ Anagrams in K/a:#:'x{x [email protected]&1<#:'g:={[email protected]
    
/ Pascal's Triangle in qpascal:{(x-1){0+':x,0}\1}
/ 100 Doors Challenge in q`closed`open (1+til 100) in `int$xexp[;2] 1+til 10

Klong

Klong is similar to K and q, but its website claims it is less ambiguous. Judge for yourself — below is a “Middle Three Digits” solution written in Klong.

items::[123 12345 1234567 987654321 10001 -10001 -123 -100 100 -12345 1 2 -1 -10 2002 -2002 0] mid3::[d k];:[3>k::#$#x;"small":.p(mid3'items)

IDL

One more array-based language for you. IDL (Interactive Data Language), around since 1977, has been used by organizations including NASA and ESA. In fact, IDL found itself something of a niche in space research, and it was once used to help technicians repair the Hubble Space Telescope.

A more down-to-earth application is this function which generates a Sierpinski triangle.

pro sierp,n s = (t = bytarr(3+2^(n+1))+32b) t[2^n+1] = 42b for lines = 1,2^n do begin print,string( (s = t) ) for i=1,n_elements(t)-2 do if s[i-1] eq s[i+1] then t[i]=32b else t[i]=42b endend

Up-and-Coming?

Of course, some languages don’t see much use simply due to the fact they haven’t been around very long. Whether or not they catch on depends on a variety of factors, and the reality is that the vast majority won’t see widespread adoption. But you’ve gotta start somewhere, right?

Here are a selection of languages from Rosetta’s archives that are all relative newcomers to the show.

Crystal

This project is still in alpha-testing, so don’t switch over to it just yet — but keep an eye out. Influenced by the writing efficiency of Ruby and the running efficiency of C, Crystal’s authors seem set on producing an all-round best-of-both-worlds language. Time will tell if they’re successful at doing so.

Below is a ‘quick-sort’ algorithm written in Crystal — why not have a go running it yourself?

def quick_sort(a : Array(Int32)) : Array(Int32) return a if a.size <;= 1 p = a[0] lt, rt = a[1 .. -1].partition return quick_sort(lt) + [p] + quick_sort(rt)end a = [7, 6, 5, 9, 8, 4, 3, 1, 2, 0]puts quick_sort(a)

Frege

Functional programming is the new big thing, and Frege is a purely functional language first introduced in 2011. It’s been described as “Haskell for the Java Virtual Machine”. Named after the mathematical logician Gottlob Frege, this language compiles to Java, and is also available to try out online.

Below is a solution the “99 Bottles” challenge. It is virtually identical to the same solution in Haskell, which is to be expected.

module Beer where main = mapM_ (putStrLn . beer) [99, 98 .. 0]beer 1 = "1 bottle of beer on the wall\n1 bottle of beer\nTake one down, pass it around"beer 0 = "better go to the store and buy some more."beer v = show v ++ " bottles of beer on the wall\n" ++ show v ++ " bottles of beer\nTake one down, pass it around\n" ++ head (lines $ beer $ v-1) ++ "\n"

Futhark

Although suffering from a lack of comprehensive documentation, the Futhark project nevertheless seems like a promising line of research. The aim is to compile to high-performance Graphical Processing Unit (GPU) code — but not for producing graphical output.

Instead, Futhark’s goal is to harness the power of the GPU to carry out computationally-intensive procedures that would ordinarily take much longer using a more conventional language. Below is an example of a function used to calculate a geometric mean.

include futlib.numeric
fun agm(a: f64, g: f64): f64 = let eps = 1.0E-16 loop ((a,g)) = while abs(a-g) > eps do ((a+g) / 2.0, F64.sqrt (a*g)) in a

Sidef

Sidef is approaching its fourth year of active development, having started out as a project in March 2013. It seems well advanced and very well documented, and has over 600 examples of coding solutions on Rosetta Code.

Sidef is mostly used for research purposes, and looks to explore both OOP and functional programming. Personally, I really like the look of it. The example below shows it in action finding the intersection of two lines.

func det(a, b, c, d) { a*d - b*c } func intersection(ax, ay, bx, by, cx, cy, dx, dy) { var detAB = det(ax,ay, bx,by) var detCD = det(cx,cy, dx,dy) var ΔxAB = (ax - bx) var ΔyAB = (ay - by) var ΔxCD = (cx - dx) var ΔyCD = (cy - dy) var x_numerator = det(detAB, ΔxAB, detCD, ΔxCD) var y_numerator = det(detAB, ΔyAB, detCD, ΔyCD) var denominator = det( ΔxAB, ΔyAB, ΔxCD, ΔyCD) denominator == 0 && return 'lines are parallel' [x_numerator / denominator, y_numerator / denominator]}
say ('Intersection point: ', intersection(4,0, 6,10, 0,3, 10,7))
> Intersection point: [5, 5]

Sparkling

Like Sidef, this language started out in 2013. Its design has been inspired by features of C, Python and Lua — and a disdain for several features of JavaScript.

It aims to be a lightweight and extensible scripting language that runs pretty much anywhere. Below is a number guessing game, which you can try and get working in your browser here.

printf("Lower bound: ");let lowerBound = toint(getline()); printf("Upper bound: ");let upperBound = toint(getline()); assert(upperBound > lowerBound, "upper bound must be greater than lower bound"); seed(time());let n = floor(random() * (upperBound - lowerBound) + lowerBound);var guess; print(); while true { printf("Your guess: "); guess = toint(getline()); if guess n { print("too high"); } else { print("You guessed it!"); break; }}

Noah’s Ark

One more category for you — there were loads of potential languages and I couldn’t possibly get through them all to pick out every interesting example. If you spot any I may have missed, please leave a response below!

One thing I did notice was that a lot of languages were named after animals. Is there an explanation for this?!

I won’t go into detail, but here’s a quick run-through to finish up with:

Cat, Kitten

Cat is described as a functional language, but appears to be no longer in existence. However, Kitten seems to be currently under development, and calls itself a successor to Cat. Influenced heavily by Haskell, but aims to be more accessible.

"Hello world!" writeln //Cat
"Hello world!" say //Kitten

Cobra

OOP language, influenced by Python, C#, Eiffel and Objective-C.

class Hello def main print 'Hello world!'

> (“Fish”)

Another multidimensional esolang, if you’re into that kind of thing.

!v"Hello world!"r! >l?!;o

Heron

Inspired by C++, Python and Pascal, but no commits since 2012, so appears to be no longer under active development. Its only sample on Rosetta is a lengthy solution to the N-queens problem. For brevity, I’ve inferred a simple “Hello world!” program to show here instead.

Main() { WriteLine("Hello world!");}

Lobster

A game programming language that aims to be readily portable across platforms. Appears to be under active development.

print "Hello world!"

Panda

The website states that Panda aims to be simple enough that a Panda could program it. I’ve no idea how good Panda’s are at coding, though, so I’m still in the dark about that one…

say("Hello world!")

Pony

With influences ranging from C++ to Erlang, Pony looks to be an interesting project with thorough tutorial.

actor Main new create(env: Env) => env.out.print("Hello world!")

Salmon

Salmon aims to intermix the writing of both low-level and high-level code.

"Hello world!"!
print("Hello world!\n");
standard_output.print("Hello world!\n");

Squirrel

Squirrel is a lightweight scripting language that has been embedded in games like Left 4 Dead 2, Portal 2 and CS:GO.

print("Hello world!");

Phew!

That was a whistle-stop tour! If you’ve made it this far and enjoyed the ride (or spotted a glaring, glaring error), leave a response underneath — I’ll try and reply asap! Thanks for reading!

If you want to dive deeper:

  • Rosetta Code
  • PYPL
  • R-Fiddle

Thank you for reading!