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

twitter logo github logo Updated on ・1 min read

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?

twitter logo DISCUSS (68)
markdown guide

Rubyists love the expressiveness and readability but I've definitely heard people call it unreadable, or lament that they have no idea what's going on. Readability seems to apply less to folks with strong backgrounds in entirely different areas. Things like unless thing_is_true as an option instead of if !thing_is_true is a feature many Rubyists love, but outsiders have a real aversion to.


Wow, that unless throws me off waaay more than it should.


How do you feel about this:

If I write

[].count == 0

My linter will ask me to change it to


Actually, it your be more idiomatic to write:


I do love Ruby for those things. I can write business code in a way that is perfectly understandable the first time I read it.

But I like #zero?, and have found situations where x == 0 was not "working" and x.zero? was. Don't ask me what it was though – I can barely remember yesterday – but maybe someone can explain that.


As a non-native English speaker, when I read an unless on a codebase it gives my brain extra work to make sure when the condition will evaluate to true. It's possible that it is due to unfamiliarity, though.


Yes, and the same is true for English speakers as well I think.

I like to avoid #unless by ensuring that there is an inverse logical test available, just as #any? and #empty? are inverses.

I think that some Rails developers don't realise that just as you can call #valid? on a model, you can also call #invalid?, so you can avoid do_this unless my_model.valid? in favour of do_this if my_model.invalid?.

I think the latter reads much better.


It depends on context of course, but in general I tend to disagree. Keeping booleans as the "positive" form seems to make things easier.

I really like to use unless for checking state and arguments at the beginning of methods:


unless has_coffee:
  throw UncaffeinatedDeveloperError()

Coming from Perl, I really miss unless in other languages (I don't use Ruby).

# Python
while True:
    print("4 Spaces, Suck It Braces")

First time I tried Python, 2000 or so, was given code that did a thing. I didn't need the thing, I just wanted working Python code to see how/if it worked.

It was indented with tabs.

Somewhere along the line, one of the lines went " \t" instead of "\t".

It took me hours to figure that out.

I know that, w/ 2.7 and 3.5, it no longer would do that. I have tested and proven it.

I still hate it. Hate is emotional, not rational.



+1 one of the few things I really like about Python


I love Lisp for the parenthesis and prefix notation. I am a math dunce writing programs to create vector and generative art. Lisp is my calculator and math coach. Clear inside-out order with function/operand appearing first to call out what we're doing makes me feel like I'm pretending to be Russell Crowe, pretending to be a great mathematician in a Beautiful Mind ;-)


Here's one for you: I would like lisp if it wasn't for the dynamic scoping. I appreciate the theoretical / math / lambda calculus reasoning behind it but UGH


Scheme then maybe? I believe it's addressed there; I didn't get to far into Structure and Interpretations of Computer Programs.

Seems to make more sense how I gravitated to Ruby & Lisp.


I enjoy php, I think its just because its the first language I had to do real work with and it felt like it worked the way my brain thinks. Which is scary lol.


For my main language, Perl, the common complaint from the outside is programmable line noise, which is kinda funny because most programmers today weren't alive to use modems and experience line noise.

I like readable code, even if terse, so I don't do that, but knowing that

@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print

outputs Just Another Perl Hacker is interesting.


I first tried to teach myself to program using Perl. It ha(s|d) the most complete documentation with an expansive library of books and tutorials. I learned a lot about learning to program and asking good questions because of Perl.


On a Monday, I was asked if I knew Perl. I replied that I knew several languages it was based on (awk, sed, Bash) but not Perl exactly. They said "Cool. Your interview is this Thursday. Know Perl by then."

I spent three days on perldoc.perl.org to ace that interview, and found the documentation to be equal parts blunt, refreshing, informative, and horrifying.

Case in point: "If any part of LIST is an array, foreach will get very confused if you add or remove elements within the loop body, for example with splice. So don't do that."

It's common knowledge that modifying the list you're iterating over is a bad idea in almost any language. Safe languages have ways to detect this situation and prevent errors (like Java's ConcurrentModificationException). Unsafe languages trust you to know better. Perl... helpfully tells you not to do that.

I've certainly pushed onto the tail end of a looping array in Perl. You just need to be careful.

But I don't do it anymore.


I learned to program with PHP and JavaScript. I hate them know because I know how neat and logical Python is. It's like having to work with Chekov on a project. You love the guy because he trained you but you've been working with Spock for so long that you're no longer used to the haphazard way he does things.


Prototypal inheritance
Lexical scoping and closures.

The fact that you can construct almost any traditional design pattern with the above.

Closures and first class functions are also powerful instruments in functional javascript.




Who is complaining about Lexical scoping? A bunch of Lisp diehards?


Well I'd say Javascript only recently got proper lexical scoping with let before that you had global and function level and all the weirdness that brought about.

Plus prototypal inheritance is wonderful and it's a damn shame it confuses so many people.


Lol. No one really. Just necessary to point out what's possible with Prototypal inheritance.


Love first class functions. I miss that perhaps the most when programming in the other scripting language I use the most: PHP.


...doesn't PHP have first class functions? I thought first-class functions meant you could use them as arguments or assign them to a variable, e.g.:


$some_function_holding_var = 
            echo "I'm a function saying $inner_arg!"; 


// okay, not very random
$random_array = [1,2,3,4];



$pick_func_based_on_time = 
    function ($some_time) 
        $even_function = function () {echo "even";};
        $odd_function = function () {echo "odd";};

        switch ($some_time % 2) 
            case 0:
                return $even_function;
            case 1:
                return $odd_function;
                echo "I broke math...";

$chosen_function = $pick_func_based_on_time(microtime(true));


I'm honestly just curious as to if there's a meaning of first-class functions I'm missing. (And enjoyed the chance to do ridiculous code stuff.)

That's pretty much it. First class function means you can use functions wherever normal language primitives will go. It can be returned, used in expressions...


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.


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


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.


In C#, I'd say it's using generics, delegates, lambda and LINQ. I think it throws some people off so they tend to fall back on the classic programming structures written by hand.

Casting even a wider net, I'm always amazed at how many developers seem to have a mental block when it comes to working with SQL, particularly stored procedures and such.


I remember the first time another developer mentioned LINQ to me...he said it would change my life. I wouldn't go that far, but man...when I moved to writing Apex code it was frustrating not being able to pluck a single (or group)of objects from a list with a single query.

As far as stored procedures go...they confused the heck out of me the first time I encountered them. Then I decided to start tinkering with them in some throw away projects to understand them at least a bit better. I still struggle a bit with joins, but honestly, I really haven't needed to use them much thus far so I pretty much chalk it up to lack of real exposure.


LINQ is so elegant. Every time I use it I feel great.


The "verbosity" of Java (or other statically typed languages).

I love knowing exactly what things are and where they are coming from. Plus it is that same verbosity that allows incredible autocompletion -- meaning that I type a small fraction of the the code in my src folder.

All that being said some type-inference à la Scala is nice too :)


Followup: Type Inference coming to Java 10 (to be released this year).

Here is the JEP: openjdk.java.net/jeps/286


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:


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.


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


C++ Templates: Simply the most powerful language feature of any language, nothing else comes close. Just requires a few sacrifices to Cthulu to fully understand.


Ruby's Block, Proc, and Lambda are funky things. Took me a while to understand them and I still barely use it.


Functions are so central to functional programming that they get their own operators. This demonstrates function piping and composition:

-- basic version of a function with 3 steps
-- takes in a string which is supposed to be numeric
-- and creates a list of integers up to that number
createRange str =
    List.range 1 (Result.withDefault 0 (String.toInt str))

-- the problem above is that it reads inside-out
-- this piped equivalent reads just like my brain thinks of the steps
createRange str =
        |> String.toInt
        |> Result.withDefault 0
        |> List.range 1

-- composed "point-free" equivalent
createRange =
    String.toInt >> Result.withDefault 0 >> List.range 1

The last one is considered hard to understand at first. >> takes the output of the first function and provides it as an input to the second. Basically welding the functions together into one.


People who learned Ruby or JS as their first languages they really knew mostly love to use the standardjs-style trait of no-semi:


Also, I think Haskell is the most beautiful language ever but lots of folks thinks its unreadable. I really don't get this. I always tell them: just treat it like you're reading math functions. I figured it would help but no one really knows what a math function is.

On the other hand, there is so much weird stuff in Swift that I hate, I imagine it is leftover from the Objective-C heritage. Some things that might be syntax sugar for old awful Objective C syntax might be lovely to old-hand devs but not me.


For PHP the way isn't (wasn't) very type strict, and you could implement your own handle logic, based on method return value:

$result = $myClass->save();

if (is_array($result)) {
    // Validation errors!
    // Warnings are returned in structured array, where indexes are class attributes
    // Example:
    // $result['firstname'] = 'First name is required'
    // $result['email'] = 'Email address must be valid' 
} elseif (is_numeric($result)) {
    // New record created!
    // Method returns newly created database row ID
} else {
    // Record updated!
    // Method returns TRUE

I have to admit I've kind of converted to returning TRUE or FALSE, and implementing another method to get errors, if save failed using $errors = $myClass->getErrors(), but it was still nice shortcut, purely because PHP didn't enforce explicit return types.


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.


Python variable scope inside an if statement.

if True:
    var = “something”

This runs just fine. No need to declare outside of if block. Complete opposite of the verbosity of Java.


But var doesn't exist on line 3!! I know different rules for different languages, but allowing this would drive me crazy (esp. if you are just saving an explicit var = null statement)


Then you'll love this:

with open('foo.txt', 'w') as f:
    f.write('hello world\n')
f.write('also hello world\n')  # f is closed by still in scope!

Thing is, with dynamic languages this doesn't really matter - it's not like if it had stricter scoping rules it'd fail to compile...


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.



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.


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

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

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. ;)


Groovy has operator overloading. Oh, and metaclass overrides. Powerful but dangerous! Love it


I like explicit error-handling in Go, and I'm not as annoyed by the lack of generics in the language as most people are.


Always rust

Generics and actually explicit error handling


explicit error-handling

Is that how they marketed their C-style errors?


Java: the inherent verbosity. Or as I see it: the increased difficulty against making dense and inscrutable code.


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.

  • Python's lists comprehensions
  • Javascript as a whole :-D
  • Erlang syntax
Classic DEV Post from Jun 22 '19

Do you have your own Gatsby site? Let's brainstorm a dev.to cross-poster

I'd love it if my blog posts were automatically sent to dev.to - wouldn't you?

Ben Halpern profile image
A Canadian software developer who thinks he’s funny. He/Him.

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️