Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,563 members, 7,820,035 topics. Date: Tuesday, 07 May 2024 at 08:49 AM

Programming Software That Will Change How You Think About Programming - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Programming Software That Will Change How You Think About Programming (1040 Views)

App Programming Software / Programming != Software Development / The Only Thing I Know About Programming Is Its Spelling, How Do I Start? (2) (3) (4)

(1) (Reply) (Go Down)

Programming Software That Will Change How You Think About Programming by Nobody: 6:40pm On Nov 11, 2019
there are programming languages out there that are concurrent by default. That is, every line of code is executed in parallel!

For example, imagine you wrote three lines of code, A, B, and C:

A;
B;
C;
In most programming languages, A would execute first, then B, and then C. In a language like API, A, B, and C would all execute at the same time!

Control flow or ordering between lines of code in ANI is merely a side effect of explicit dependencies between lines of code. For example, if B had a reference to a variable defined in A, then A and C would execute at the same time, and B would execute only after A finished.

Let’s look at an example in API. As described in the tutorial, API programs consists of “pipes” and “latches” that are used to manipulate streams and data flows. The unusual syntax is tough to parse, and the language seems dead, but the concepts are pretty interesting.

Here’s a “Hello World” example in API:

"Hello, World!" ->std.out
In API terminology, we are sending the "Hello, World!" object (a string) to the std.out stream. What happens if we send another string to std.out?

"Hello, World!" ->std.out
"Goodbye, World!" ->std.out
Both of these lines of code execute in parallel, so they could end up in any order in the console. Now, look what happens when we introduce a variable on one line and reference it later:

s = [string\];
"Hello, World!" ->s;
\s ->std.out;
The first line declares a “latch” (latches are a bit like variables) called s that contains a string; the second line sends the text "Hello, World!" to s; the third line “unlatches” s and sends the contents to std.out. Here, you can see ANI’s implicit program sequencing: since each line depends on the previous one, this code will execute in the order it is written.

The Plaid language also claims to support concurrency by default, but uses a permissions model, as described in this paper, to setup control flow. Plaid also explores other interesting concepts, such as Typestate-Oriented Programming, where state changes become a first class citizen of the language: you define objects not as classes, but as a series of states and transitions that can be checked by the compiler. This seems like an interesting take on exposing time as a first class language construct as discussed in Rich Hickey’s Are we there yet talk.

Multicore is on the rise and concurrency is still harder than it should be in most languages. API and Plaid offer a fresh take on this problem that could lead to amazing performance gains; the question is whether “parallel by default” makes concurrency easier or harder to manage.

Update: the description above captures the basic essence of API and Plaid, but I used the terms “concurrent” and “parallel” interchangeably, even though they have different meanings. See Concurrency Is Not Parallelism for more info.

Dependent types
Idris
Idris
Example languages: Idris, Agda, Coq

You’re probably used to type systems in languages like C and Java, where the compiler can check that a variable is an integer, list, or string. But what if your compiler could check that a variable is “a positive integer”, “a list of length 2”, or “a string that is a palindrome”?

This is the idea behind languages that support dependent types: you can specify types that can check the value of your variables at compile time. The shapeless library for Scala adds partial, experimental support (read: probably not ready for primetime) for dependent types to Scala and offers an easy way to see some examples.

Here is how you can declare a Vector that contains the values 1, 2, 3 with the shapeless library:

val l1 = 1 :#: 2 :#: 3 :#: VNil
This creates a variable l1 who’s type signature specifies not only that it’s a Vector that contains Ints, but also that it is a Vector of length 3. The compiler can use this information to catch errors. Let’s use the vAdd method in Vector to perform a pairwise addition between two Vectors:

val l1 = 1 :#: 2 :#: 3 :#: VNil
val l2 = 1 :#: 2 :#: 3 :#: VNil

val l3 = l1 vAdd l2

// Result: l3 = 2 :#: 4 :#: 6 :#: VNil
The example above works fine because the type system knows both Vectors have length 3. However, if we tried to vAdd two Vectors of different lengths, we’d get an error at compile time instead of having to wait until run time.
val l2 = 1

val l3 = l1 vAdd l2

// Result: a *compile* error because you can't pairwise add vectors
// of different lengths!
Shapeless is an amazing library, but from what I’ve seen, it’s still a bit rough, only supports a subset of dependent typing, and leads to fairly verbose code and type signatures. , on the other hand, makes types a first class member of the programming language, so the dependent type system seems much more powerful and clean. For a comparison, check out the Scala vs Idris: Dependent Types, Now and in the Future talk.

For
20
foo
Let’s walk through this line by line:

First, we declare a function foo. Note that functions in cat specify no input parameters: all parameters are implicitly read from the stack.
foo calls the < function, which pops the first item on the stack, compares it to 10, and pushes either True or False back onto the stack.
Next, we push the values 0 and 42 onto the stack: we wrap them in brackets to ensure they get pushed onto the stack unevaluated. This is because they will be used as the “then” and “else” branches (respectively) for the call to the if function on the next line.
The if function pops 3 items off the stack. “then” branch, and the “else” branch. Depending on the value of the condition, it’ll push the result of either the “then” or “else” branch back onto the stack.
Finally, we push 20 onto the stack and call the foo function.
When all is said and done, we’ll end up with the number 42.
For a much more detailed introduction, check out The Joy of Concatenative Languages.

This style of programming has some interesting properties: programs can be split and concatenated in countless ways to create new programs; remarkably minimal syntax (even more minimal than LISP) that leads to very concise programs; strong meta programming support. I found concatenative programming to be an eye opening thought experiment, but I’m not sold on its practicality. It seems like you have to remember or imagine the current state of the stack instead of being able to read it from the variable names in the code, which can make it hard to reason about the code.

Declarative programming
GNU Prolog
GNU Prolog
Example languages: Prolog, SQL

Declarative programming has been around for many years, but most programmers are still unaware of it as a concept. Here’s the gist: in most mainstream languages, you describe how to solve a particular problem; in declarative languages, you merely describe the result you want, and the language itself figures out how to get there.

For example, if you’re writing a sorting algorithm from scratch in C, you might write the instructions for merge sort, which describes, step by step, how to recursively split the data set in half and merge it back together in sorted order: here’s an example. If you were sorting numbers in a declarative language like Prolog, you’d instead describe the output you want: “I want the same list of values, but each item at index i should be less than or equal to the item at index i + 1”. Compare the previous C solution to this Prolog code:

sort_list(Input, Output) :-
permutation(Input, Output),
check_order(Output).

check_order([]).
check_order([Head]).
check_order([First, Second | Tail]) :-
First =< Second,
check_order([Second | Tail]).
If you’ve used SQL, you’ve done a form of declarative programming and may not have realized it: when you issue a query like select X from Y where Z, you are describing the data set you’d like to get back; it’s the database engine that actually figures out how to execute the query. You can use the explain command in most databases to see the execution plan and figure out what happened under the hood.

The good thing about declarative languages is that they make you to work at a much higher level of abstraction: your job is just to describe the specification for the output you want. For example, the code for a simple sudoku solver in prolog just lists out what each row, column, and diagonal of a solved sudoku puzzle should look like:

sudoku(Puzzle, Solution) :-
Solution = Puzzle,

Puzzle = [S11, S12, S13, S14,
S21, S22, S23, S24,
S31, S32, S33, S34,
S41, S42, S43, S44],

fd_domain(Solution, 1, 4),

Row1 = [S11, S12, S13, S14],
Row2 = [S21, S22, S23, S24],
Row3 = [S31, S32, S33, S34],
Row4 = [S41, S42, S43, S44],

Col1 = [S11, S21, S31, S41],
Col2 = [S12, S22, S32, S42],
Col3 = [S13, S23, S33, S43],
Col4 = [S14, S24, S34, S44],

Square1 = [S11, S12, S21, S22],
Square2 = [S13, S14, S23, S24],
Square3 = [S31, S32, S41, S42],
Square4 = [S33, S34, S43, S44],

valid([Row1, Row2, Row3, Row4,
Col1, Col2, Col3, Col4,
Square1, Square2, Square3, Square4]).

valid([]).
valid([Head | Tail]) :- fd_all_different(Head), valid(Tail).
Here is how you would run the sudoku solver above:

| ?- sudoku([_, _, 2, 3,
_, _, _, _,
_, _, _, _,
3, 4, _, _],
Solution).


S = [4,1,2,3,2,3,4,1,1,2,3,4,3,4,1,2]
The downside, unfortunately, is that declarative programming languages can easily hit performance bottlenecks. The naive sorting algorithm above is likely O(n!); the sudoku solver above does a brute force search; and most developers have had to provide database hints and extra indices to avoid expensive and inefficient plans when executing SQL queries.

Symbolic programming
Aurora
Aurora
Example languages: Aurora

The Aurora language is an example of symbolic programming: the “code” you write in these languages can include not only plain text, but also images, math equations, graphs, charts, and more. This allows you to manipulate and describe a large variety of data in the format native to that data, instead of describing it all in text. Aurora is also completely interactive, showing you the results from each line of code instantly, like a REPL on steroids.


outlines the motivation for Aurora in his post Toward a better programming: some of the goals are to make programming more observable, direct, and reduce incidental complexity. For more info, be sure to see that you get this software and Learnable Programming.

Update: “symbolic programming” is probably not the right term to use for Aurora. See the Symbolic programming wiki for more info.ask me question here

1 Like

Re: Programming Software That Will Change How You Think About Programming by Nobody: 9:54am On Nov 14, 2019
1st sign of dishonesty copying someone else's intellectual property and parading it as yours.
We all know all your threads are copy and paste

Re: Programming Software That Will Change How You Think About Programming by Nobody: 10:12pm On Nov 14, 2019
quote author=quexhub post=84033784]we all make a mistake to learn i don't care if you hate or rate, you can never stop river from flowing, get that into your head, the most popular people in the world today had people that tell them no during their time. reference to your comment on my ad[/quote]
LMAO typical Nigerian. Someone telling you the truth is hating. You stole intellectual property and paraded it as yours and you ran away from the place where I called you out on it to blab blab nonsense
Re: Programming Software That Will Change How You Think About Programming by Nobody: 4:45pm On Nov 15, 2019
I have come with more "hate". Since the truth classifies as hate for the dishonest

Re: Programming Software That Will Change How You Think About Programming by wapcali: 9:48pm On Nov 18, 2019
When it it Comes to The Best In Providing IT Solution Go for Raposoft & Associate.ltd .
Raposoft & Associate is an innovation-driven SEO marketing providing IT solutions that are scalable, proven, secure and easy to use.
Our goal is to deliver technologies that help our clients run more profitable businesses, and discover better ways to achieve their business goals and objectives.
Raposoft & Associate.ltd is the leading Web Design Company Nigeria that has served various niches of clients and has an experience of developing over 200 websites in a small span of 7 years. The company specialises in Creative Web Design, Graphic Design, Business Brandings, Enterprise Solutions, Mobile App Development, Web Hosting, SEO and Internet Marketing.
Website: https://raposoft.com , Customer Services: +234 9063256126
Satisfaction is our Target...

(1) (Reply)

Programmer Needed / Latest MTN 50gig For #200 / SQL Basics & Advanced Topics: Free Webinar!

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 37
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.