
Programming Idioms - decentralised
https://www.programming-idioms.org/about#about-block-all-idioms
======
hazbo
Previous discussion:
[https://news.ycombinator.com/item?id=21080606](https://news.ycombinator.com/item?id=21080606)

~~~
decentralised
I figured it would be ok since it's been over 6 months since it was last
posted and I only found out about it today :-)

------
natmaka
See also
[http://www.rosettacode.org/wiki/Rosetta_Code](http://www.rosettacode.org/wiki/Rosetta_Code)

------
saagarjha
These kinds of collections can be nice, but I think it’s fair to warn against
looking at them _too_ closely. Sometimes they’re not actually idiomatic and
often the implementations have differences in them that see non-obvious.

~~~
tgv
And some have problems: the Python example of reading a file into a string is:

    
    
        lines = open(f).read()
    

which doesn't close the file. The second C example of this task is tricky, and
seems to miss an offset.

The C and Go implementations of uniform random integer include the upper
limit, the Python and Rust implementations don't.

And that's just from quickly browsing.

------
LandR
The clojure one to reverse a string makes it a sequence of characters, then
reverses that sequence and puts it back together again as a string..

Why not jsut:

    
    
         (require '[clojure.string :as str])
         (let [s "hello"]
             (str/reverse s))
         => "olleh"
    

Reversing a string is in the core library...

~~~
boomlinde
On a related note, the problem is underspecified.

 _> Create string t containing the same characters as string s, in reverse
order. Original string s must remain unaltered. Each character must be handled
correctly regardless its number of bytes in memory._

What encoding? Assuming UTF-8, what is a "character"? A code point? A
grapheme? The result of the lack of specification is that the different
approaches really solve different problems. Some, like the C implementation,
have a naive approach that only solves the problem in fixed size encodings
where the width is equal to CHAR_BIT. Others I'm sure run into problems with
combining characters

~~~
bmn__
Submit a task/"idiom" with an improved/stricter spec and link back to the
original one.

------
jzer0cool
This is a nice to have all in 1 place.

This improves time when learning 1 language to another. I could get lost
spending time here advancing what I already know (or don't know) and enjoy the
format of the content here.

What was your process like in going about getting the original content for the
various languages? Are you you somewhat familiar with all these languages and
how to the curators go about accepting (or denying) a new submission.

~~~
val_deleplace
Author here: there were 2 initial use cases for me,

(1) I'm familiar with the language X but I forget e.g. how to "check if a file
exists"

(2) I'm learning a new language Y, I know that "checking if a file exists" is
a legit need and there must be an idiomatic way to do it in Y, so I look at
the entry, alongside implementations in other languages that I'm more familiar
with, so I can quickly spot the similitudes and the differences.

I do (1) all the time because my brain has very little onboard memory.

The website is open to contributions without prior validations. This means
that not all snippets end up being both correct and idiomatic. I manually
revert spam and "obviously incorrect" entries. For languages that I don't know
very well, I encourage actual experts to fix snippets, or add a better new
implementation, when they see poor contents.

~~~
decentralised
Great resource, thank you for building it!

------
KnobbleMcKnees
This is really cool and seems pretty up-to-date ... which leaves me surprised
that Obj-C is present but Swift isn't. (Even moreso considering that both Java
and Kotlin are present).

~~~
val_deleplace
You can vote for Swift here [https://github.com/Deleplace/programming-
idioms/issues/30](https://github.com/Deleplace/programming-idioms/issues/30)

------
kashfi
Thanks for sharing.

------
junke

        Sorry, [Common Lisp] is currently not a supported language.
    

New time sink avoided.

~~~
diggan
[Lisp] seems to be a tag though. Add it as [Lisp] (if you still want your new
shiny time sink) and write comment of which implementation it is.

~~~
junke
Thanks, I might write some idioms in it.

