List Comprehensions in Python is an interesting one. I absolutely love them in some cases, and despise them on others.
# Simple and elegant...
squares=[n**2forninnumbers]list_a=[...]list_b=[...]# ...not on this one IMO, I'd prefer loops instead.
different_num=[(a,b)forainlist_aforbinlist_bifa!=b]
All these things almost look alien to me. I haven't done any heavy functional programming and let alone use a language that was specifically built for such purpose. This is something I'll definitely look into.
I'm not sure if I like it really, and I think its an anti-pattern in almost all cases, and some of it can be done via reflection in most languages, and I don't know the name for it...
Let's say that we have an application which could connect to either MySQL or PostgreSQL. In a config file, the software could detect which DBMS is used, and then link all the DBMS interface correctly. Like this
This is basically what is happening here. Since PHP is VERY weakly typed, any variable can be either an integer, float, string, boolean, a function pointer. In fact, they are all of those types. It is when you use them that they fall into the intended one #quantumTyped.
Of those, async/await is certainly my favourite. It makes asynchronous programming so wonderfully obvious. I'm not too big a fan of decorators, because they hide underlying logic, making code less readable, if you're not handling them with care.
Even though it's not yet a native language feature in JavaScript or TypeScript, Observables (reactive programming style) are on their way to become one. Until then, we're fine with rxjs.
I also like the unique concept of borrowing in Rust and I like its traits, which allow for a lot of flexibility in the type system.
I was thinking of adding traits here but I have not used it extensively while I was doing PHP. The same is true with it though I believe that it should be handled with care.
List Comprehensions in Python is an interesting one. I absolutely love them in some cases, and despise them on others.
It's my first time to see such syntax since I haven't really touched Python. Looks interesting , I couldn't understand what the last line does though.
The last line is:
All these things almost look alien to me. I haven't done any heavy functional programming and let alone use a language that was specifically built for such purpose. This is something I'll definitely look into.
Pattern matching like you see in OCaml variants (ReasonML, F#, etc.)
Elixir has something similar in guards:
+1 for Guards.
Also I really enjoy Pipes, like
instead of
I think they are even coming to JS.
Kotlin's function literals with receiver and infix functions are pretty cool.
Function literals with receivers:
Infix:
I'm not sure if I like it really, and I think its an anti-pattern in almost all cases, and some of it can be done via reflection in most languages, and I don't know the name for it...
This BS in PHP:
This comes from function pointer in C. You can create a function pointer, like this:
Let's say that we have an application which could connect to either MySQL or PostgreSQL. In a config file, the software could detect which DBMS is used, and then link all the DBMS interface correctly. Like this
So, in the DBMS manager module:
This is basically what is happening here. Since PHP is VERY weakly typed, any variable can be either an integer, float, string, boolean, a function pointer. In fact, they are all of those types. It is when you use them that they fall into the intended one #quantumTyped.
Of those, async/await is certainly my favourite. It makes asynchronous programming so wonderfully obvious. I'm not too big a fan of decorators, because they hide underlying logic, making code less readable, if you're not handling them with care.
Even though it's not yet a native language feature in JavaScript or TypeScript, Observables (reactive programming style) are on their way to become one. Until then, we're fine with rxjs.
I also like the unique concept of borrowing in Rust and I like its traits, which allow for a lot of flexibility in the type system.
I was thinking of adding traits here but I have not used it extensively while I was doing PHP. The same is true with it though I believe that it should be handled with care.
I'll definitely checkout Rust.
I would say variadics, multiple returns, and interfaces in Go.
golang's "empty" switch statement (a cleaner else-if).
The way switch case work on golang alone is already interesting 😁
It has been a while since I've used C#, but I remember I really liked LINQ queries and local anonymous types that can be type-checked on compilation