Post the little features in programming languages you really like

post the little features in programming languages you really like.
it doesn't matter whether you like the whole language or not.

Attached: zig-multiline.png (984x302, 44K)

Other urls found in this thread:

github.com/golang/go/blob/master/src/runtime/select.go#L105
twitter.com/NSFWRedditImage

Not really a language feature, but I really enjoy how in most DBMSes you can highlight individual queries or even parts of queries by mouse to execute just them, it's like DJing code.

there are a lot of pants-on-head retarded things in the language but this isn't one of them

Attached: go select.png (869x591, 73K)

Dim number As Integer = 8
Select Case number
Case 1 To 5
Debug.WriteLine("Between 1 and 5, inclusive")
' The following is the only Case clause that evaluates to True.
Case 6, 7, 8
Debug.WriteLine("Between 6 and 8, inclusive") 'Won't fall through from 1-5
Case 9 To 10
Debug.WriteLine("Equal to 9 or 10") 'Won't fall through from 1-8
Case Else
Debug.WriteLine("Not between 1 and 10, inclusive")
End Select

not a Go feature, it's a system call popularized by unix/posix.

Array operations in Fortran, the rest of the language is trash though.

Observer tool in Erlang

Attached: Picture-562.png (852x597, 59K)

>it chooses one at random if multiple are ready
why

is the feature supposed to be ranges in what;s commonly a switch statement?

Extension methods and all collections implementing IEnumerable in C#

it's same pattern, but in Go it's over channels, not file descriptors.

Just use "/* */" like a normal human being.

Attributes/constants having the same notation as methods in Ruby (that is, () is not usually required, though it can make code more readable in some cases)

it's the most expected result. you don't call "select" expecting to get back the first parameter or the last parameter or any of them really, you call it expecting to get the most ideal one, and short of getting the most ideal parameter back it picks a random one to prevent a single parameter from stealing all the IO time.

that's pretty cool to make code look like a comment when it's really a literal. in fact, if you ask me? it's positively based.

channels

>doesn't know what he's talking about
what a surprise

>unix/posix
fuck you, retard

/* */ Are for comments not strings.

list comprehensions in python
easy to understand and write syntax of ruby
strong typing of java

No specific examples or languages in particular but any language that allows me to write higher level functions with zero syntactic overhead are great.

github.com/golang/go/blob/master/src/runtime/select.go#L105
it explicitly shuffles them before trying, so I bet fairness was a motivation

>strong typing of Java
look up "type erasure" sometime

user-defined (string and numeric) literals in C++
I even believe they can be implemented in a sane manner without the C++-committee level of insanity.

You confused strings with comments, but the same argument applies for escaped /* */ comments versus multiple to-end-of-line construct single-line comments.
They don't need to be escaped. You can embed an arbitrary document format in them without change.
They can easily nest. Sure it's possible to implement /* */ style comments with nesting but:
It's dead trivial to implement in parser.
There is really no disadvantage and it's simpler in every way.

Attached: p0e9m1qpxvg1.jpg (1080x1080, 385K)

Guard syntax in Haskell is pretty fucking neat-o.

Ternary (?:) operator

lotta languages have if-then-else as expression. do you just like this feature or the syntax?

everything being serializable in Lisps

"or" operators that return the first non-nil value.
A few languages do it, and it's really quite nice when doing defaults for fields without any special magic.

pattern matching, when combined with proper sum types and generics
the nursery pattern for concurrent language features; sadly some of its features require destructors or at least some way of assigning finalizers to data
symbols/atomics or whatever they are called, in particular if they are used in place of built-in nil/true/false/...
local type inference
immutable first
explicitly declared closures and tail calls

I am traveler from other side does someone has the lure to this, I got to know are there some image and sound decoding skills I mean about the hidden data in image and sound I have to know how to do this please someone show me the way I can't post a thread they are blocking fast help

I don't know how go works, can you explain this a bit?

Short circuiting is beautiful

The obvious mistake is having nil values in the first place.

I really like integer division,
uint8_t
and pointer arithmetic

Function currying

Attached: Screen Shot 2019-08-17 at 12.16.01 pm.png (524x250, 25K)

whats the point of this?

sum = (a, b) => a + b
increment = sum(1)

five = 5
six = increment(5)

You can finally lie to yourself and pretend that functions are a good vessel for state.

I like how java isn't a huge pile of clunky horseshit oh wait it is

whats the point of this

>be writing java
>get annoyed at shitty core java API
>jump to class definition to see what asshole wrote this shit
>Author: James Gosling

Every time. Doug Lea was the only one with any elegance in that room.

Attached: 0990845e.jpg (263x322, 16K)

java reflection

kek'd

Even more useful:
map(sum(1), [1,2,3,4,5,6])
> [2,3,4,5,6,7]

>to prevent a single parameter from stealing all the IO time
Why random and not round-robin then? What reason is there to make the built-in language semantics nondeterministic?

They are so comfy. Every type I type a dot after a collection my day feels a wee bit better.

No, that you don't need to put a break after each case to avoid fall through
I thought the comments would make it obvious but apparently Jow Forums code blocks don't like VB.NET so the formatting looks wrong

i really love ternary operator and desu overuse it

oh, I thought no fallthrough defacto standard way everywhere except C. It didn't even occurred to me this could be it.

I love perfect hashing/matching constructs so you can efficiently either just switch on string literals, or on whole compound types. gperf provides a preprocessor generation for it into C, but this is a nice service to have from compiler.

The backbone of Go are it's coroutines (named goroutines because why not), communication with outer world through regular file descriptors and communication between the goroutines through channels.
The goroutines are very cheap to spawn, and Go's runtime provides context switching for them and feeds them into OS's threads. It uses cooperative implicit switching where reads on file descriptors, channels, and maybe few other things, jump into the context switch routines and might end up executing other goroutine, especially if no data are available.
Channels are usually randez-vous model. File descriptors are being opened as non-blocking, but the runtime uses epoll, kqueue and whatever is on Windows; in the background.
So the language looks like sequential processes with blocking semantics, but the runtime turns it into synchronous IO multiplexing and only wakes up the goroutines that actually have something to do.
There could be some skepticism: OS provides the same for its threads as well. I really don't know a numbers to back it up how much and if it is more efficient. There is also the exokernel culture hailing the exact same idea to let the applications decide on policies (scheduling in this case) and let the OS to only provide safe multiplexing mechanics as the application knows better what's efficient than the generic algorithms in OS do. But I really don't have any evidences to stand on either side of the argument.

Take that back!! Fortran 2008 is perfect

Attached: c2d.jpg (663x579, 38K)

I know Kotlin didn't invent the when statement and I forget who did, but I hope every language realizes that C-style switch statements are only for jump gates and their syntax is terrible for everything else.