Explore Programming Idioms
Written by Nikos Vaggalis   
Friday, 03 January 2025

Introducing a web collection of programming idioms in a variety of languages. How useful is that?

progid banner

Programming Idioms collects useful code snippets for day to day usage at work. The same snippet is presented in more than 20 languages so that you can make useful comparisons when working in multiple languages or want to learn a new one by observing how the constructs are mapped between the languages.

An example will make it more clear. A popular snippet among beginners is for instance "Print Hello 10 times". We find that in C you can do it as following:

#include <stdio.h>
for (int i = 0; i < 10; i++) {
printf("Hello\n");
}In Perl:

print "Hello\n" x 10;

while in Java as :

import static java.lang.System.out;
for (int i = 0; i++ < 10; out.println("Hello"));

For each snippet and for each language representation there are links provided to the official documentation and to Replit code spaces so that you can try them out yourself.

Other idioms presented are :

  • Create a function
  • Check if string contains only digits
  • Launch 1000 parallel tasks and wait for completion
  • Join a list of strings
  • Check if string contains a word
  • Create a 2-dimensional array
  • Shuffle a list
  • Iterate over list indexes and values
  • Create a 2D Point data structure

but there's a total of 300 idioms at the time of writing. The list is constantly expanding and accepts contributions too.

A very hardy feature is that of the Cheatsheet, where you can find all the snippets administered under a language as well as check all the implementations for 2 languages side-by-side as a long one-pager list.

idioms

Some would say, "is something like that relevant now in the age of LLMs when can you ask them just about any coding question?"

That's like saying that Wikipedia nowadays has no value. But is it so?

A collection site like this is useful in cases when don't want to wait for the LLM to formulate its answer which could span multiple paragraphs. I need the information asap and as straightforward as possible.

Yet another advantage of a Wikipedia-like site like this over a chatbot is when I don't want to look up something specific but instead want to casually browse the site to discover terms that I was totally unaware of just, or discover terms related to a topic that I'm doing research on. Plus I'm sure that the information presented is factual and not a figment of hallucination.

progidsq

More Information

Programming Idioms

 

Related Articles

The Data Engineering Vault 

 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Greenplum's Cloudberry Fork Enters Apache Incubator
17/12/2024

Cloudberry is the open source equivalent of Greenplum.
Now it is fostered by the Apache Foundation as it acquires incubating status.



GitHub Announces Free Copilot
19/12/2024

GitHub has launched GitHub Copilot Free, a free version of Copilot that provides limited access to selected features of Copilot and is automatically integrated into VS Code. The free tier is aimed at  [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

A web collection of programming idioms in a variety of languages. How useful is that?
Programming Idioms collects useful code snippets for day to day usage at work. The same snippet is presented in more than 20 languages so that you can make useful comparisons when working in multiple languages or want to learn a new one by observing how the constructs are mapped between the languages.
An example will make it more clear. A popular snippet among beginners is for instance "Print Hello 10 times". We find that in C you can do it as following:
#include <stdio.h>for (int i = 0; i < 10; i++) {printf("Hello\n");}
In Perl:
print "Hello\n" x 10;
while in Java as :
import static java.lang.System.out;for (int i = 0; i++ < 10; out.println("Hello"));
For each snippet and for each language representation there are links provided to the official documentation and to Replit code spaces so that you can try them out yourself.
Other idioms presented are :
Create a functionCheck if string contains only digitsLaunch 1000 parallel tasks and wait for completionJoin a list of stringsCheck if string contains a wordCreate a 2-dimensional arrayShuffle a listIterate over list indexes and valuesCreate a 2D Point data structurebut there's a total of 300 idioms at the time of writing. The list is constantly expanding and accepts contributions too.
A very hardy feature is that of the Cheatsheet, where you can find all the snippets administered under a language as well as check all the implementations for 2 languages side-by-side as a long one-pager list.


Some would say, "is something like that relevant now in the age of LLMs when can you ask them just about any coding question?"
That's like saying that Wikipedia nowadays has no value. But is it so?
A collection site like this is useful in cases when don't want to wait for the LLM to formulate its answer which could span multiple paragraphs. I need the information asap and as straightforward as possible.
Yet another advantage of a Wikipedia-like site like this over a chatbot is when I don't want to look up something specific but instead want to casually browse the site to discover terms that I was totally unaware of just, or discover terms related to a topic that I'm doing research on. Plus I'm sure that the information presented is factual and not a figment of hallucination.


 
More InformationProgramming Idioms

 
Related ArticlesThe Data Engineering Vault

 
 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.


Banner


Greenplum's Cloudberry Fork Enters Apache Incubator
17/12/2024

Cloudberry is the open source equivalent of Greenplum.
Now it is fostered by the Apache Foundation as it acquires incubating status.



GitHub Announces Free Copilot
19/12/2024

GitHub has launched GitHub Copilot Free, a free version of Copilot that provides limited access to selected features of Copilot and is automatically integrated into VS Code. The free tier is aimed at  [ ... ]


More News

espbook

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Friday, 03 January 2025 )