DEV Community

Ben Halpern
Ben Halpern Subscriber

Posted on • Edited on

What language features/concepts do insiders of the language love and outsiders hate?

People tend to love programming languages for the very reason others run away with fear. Whether it's out of familiarity, learning curve or other, what are language features that insiders love and outsiders hate?

Latest comments (65)

Collapse
 
xngwng profile image
Xing Wang

everything in scala

Collapse
 
dfockler profile image
Dan Fockler

Using functional style shorthand blocks { |i| puts i } in Ruby to make really nice one-liners to manipulate data structures.

I haven't used them very much but, Rust's traits are a really interesting way of building interfaces that are composable and clean.

Collapse
 
cess11 profile image
PNS11

S-expressions and dynamic binding.

They say "parentheses" but they mean the equivalence of code and data. They also say "unsafe" but they mean that they aren't used to decide themselves how and when and why evaluation happens, or to lock down the application by formal design.

Sometimes there's also a performance argument, usually it doesn't take development time into account or assumes the product will run forever without further work ever again.

Probably logic inference too, the original 'lazy generator both ways evaluating' programming style, that is used to query the database.

With great expressiveness comes great power and great responsibility, but also freedom.

picolisp.com

Collapse
 
blouzada profile image
Bruno Louzada

Groovy no return in last method line

Collapse
 
twof profile image
Alex Reilly

Optionals in Swift.

When I first started learning the language, I didn't understand at all why I'd want to decide if a value could be nil or not. It just felt like extra unneeded complexity, but after writing Swift for over a year, it's soooo much easier to reason about code when you can be sure you don't have to think about an entire set of fail cases.

It's also fantastic when you can take an optional, unwrap it at one level, and never have to worry about it being nil again no matter where you pass the value.

Collapse
 
francisco profile image
Francisco M. Delgado

I also like the guard statement in swift.

Collapse
 
evanoman profile image
Evan Oman

I'm assuming they are similar to Option in Scala and Optional in Java? If so, they are amazing.

Collapse
 
twof profile image
Alex Reilly

Yup! Exactly that, but they're supported at the language level and every variable is, by default, not optional.

So if I write var foo: Int = 0, I can be sure that foo will never be nil, because if I write code that even places foo at risk of being nil, my program won't compile! Pretty awesome stuff.

 
6temes profile image
Daniel

Sad but true.

Or you can view it from the other perspective: a good developer who can write clean code will never have problems to find good jobs. ;)

Collapse
 
6temes profile image
Daniel

Guys, please, don't use Metaprogramming in business logic.

Extract it to a library and put it behind a clear abstraction.

Collapse
 
rbanffy profile image
Ricardo Bánffy

Python for the whitespace. Ruby for the irregular but expressive syntax. C for the bare-bones language. Smalltalk for the language merged with IDE merged with OS and the underlying VM.

Collapse
 
shuzootani profile image
shuzo • Edited

I think Ruby is like natural language that I can communicate with ruby instead of natural language on a daily life.

after all, all my friend become able to write ruby or only rubist is your friends ?
That's why I am learning Javascript.

Collapse
 
restoreddev profile image
Andrew Davis • Edited

I'm becoming more of a fan of static types after using Swift. I used to hate static types because of the complexity and extra code. Once you get used to types though, it's hard to go back. They add an extra level of documentation to your code and peace of mind that a function/class will only be used a certain way. Here's a non-typed function in PHP:

<?php

function upper($value) {
    if (empty($value)) {
        return false;
    }
    return strtoupper($value);
}

The problem is that anyone using this function can pass anything into the function. It does not have to be a string, it could be a number or a boolean. Plus, we don't know if the function will return a string or boolean.

We could write the same thing in Swift:

func upper(value: String) -> String? {
    if value.isEmpty {
        return nil
    }
    return value.uppercased()
}

Looking at the signature of this function, we know that it can only be used by passing in a string for the value and that it will always return either a string or nil (the question mark says the return value can be nil). The types make the function safer to use and easier to understand.

Collapse
 
einenlum profile image
Yann Rabiller

You can achieve the same now in PHP since PHP 7.1 :)