←back to thread

498 points azhenley | 10 comments | | HN request time: 1.093s | source | bottom
Show context
munchler ◴[] No.45767832[source]
> Making almost every variable const at initialization is good practice. I wish it was the default, and mutable was a keyword.

It's funny how functional programming is slowly becoming the best practice for modern code (pure functions, no side-effects), yet functional programming languages are still considered fringe tech for some reason.

If you want a language where const is the default and mutable is a keyword, try F# for starters. I switched and never looked back.

replies(19): >>45767880 #>>45767882 #>>45767891 #>>45767892 #>>45767898 #>>45767926 #>>45767975 #>>45767989 #>>45768118 #>>45768188 #>>45768230 #>>45769840 #>>45769875 #>>45770104 #>>45770306 #>>45771134 #>>45771926 #>>45772136 #>>45775848 #
tasn ◴[] No.45767898[source]
Functional programming languages (almost always?) come with the baggage of foreign looking syntax. Additionally, imperative is easier in some situations, so having that escape hatch is great.

I think that's why we're seeing a lot of what you're describing. E.g. with Rust you end up writing mostly functional code with a bit of imperative mixed in.

Additional, most software is not pure (human input, disk, network, etc), so a pure first approach ends up being weird for many people.

At least based on my experience.

replies(7): >>45767931 #>>45768098 #>>45768136 #>>45769309 #>>45770165 #>>45771129 #>>45772143 #
rapind ◴[] No.45768098[source]
> come with the baggage of foreign looking syntax

Maybe they're right about the syntax too though? :)

replies(1): >>45768148 #
1. kragen ◴[] No.45768148[source]
Which one, Erlang, Lisp, or ML?
replies(3): >>45768958 #>>45770119 #>>45771398 #
2. nickpeterson ◴[] No.45768958[source]
Honestly I find ML derived languages the most pleasant to look at.
3. tmtvl ◴[] No.45770119[source]
Lisp syntax is objectively superior because you can write a predicate like thus:

  (< lower-bound x-coordinate upper-bound)
Instead of having to do the awful ampersand dance.
replies(1): >>45773270 #
4. rapind ◴[] No.45771398[source]
ML superfan here. I don’t mind lisp simplicity either. Erlang is too alien for me, but maybe once I was used to it.
replies(1): >>45772580 #
5. impossiblefork ◴[] No.45772580[source]
If you start programming in it though, syntax only matters during the first day. Familiarity comes very fast, and if you do five programming exercises, maybe one a day, 'implement a hash map', 'make a small game', etc. you will have no problems whatsoever once the week is done.

If you have a course where one day you're supposed to do Haskell and another Erlang, and another LISP, and another Prolog, and there's only one exercise in each language, then you're obviously going to have to waste a lot of time on syntax, but that's never a situation you encounter while actually programming.

replies(3): >>45772801 #>>45775112 #>>45777269 #
6. rapind ◴[] No.45772801{3}[source]
I disagree, at least for my own case. I greatly prefer reading ML code than C style syntax.
7. kragen ◴[] No.45773270[source]
In Python or Icon (or Unicon) that's

    lower_bound < x_coordinate < upper_bound
except that usually you want

    lower_bound <= x_coordinate < upper_bound
which is also legal.

In Python this is a magical special case, but in Icon/Unicon it falls out somewhat naturally from the language semantics; comparisons don't return Boolean values, but rather fail (returning no value) or succeed (returning a usually unused value which is chosen to be, IIRC, the right-hand operand).

And in SQL you have

    `x-coordinate` between `lower-bound` - 1 and `upper-bound` + 1
which is obviously the best possible syntax.
8. runevault ◴[] No.45775112{3}[source]
Eh, I'd say it depends.

I write way more algol-derived language code than ML, yet piped operations being an option over either constant dot operators where every function returns the answer or itself depending on the context or inside out code is beautiful in a way that I've never felt about my C#/C++/etc code. And even Lisp can do that style with arrow macros that exist in at least CL and Clojure (dunno about Racket/other schemes).

9. kragen ◴[] No.45777269{3}[source]
This is far from true in my experience. I'm no Lisp hater (I wrote a self-compiling compiler in Scheme) but different syntaxes have dramatically different degrees of familiarity, like Latin letters and Cyrillic. How long do you think it would take you to learn to read phonetically in Cyrillic as fast as you do in the Latin script? It takes the humans months or years, if they ever arrive. But, also, some notations are more usable than others, even for experts, just as with other kinds of user interfaces. Flat is better than nested, simple is better than complex, complex is better than complicated, Perl and MUMPS are unnecessarily error-prone, etc.
replies(1): >>45781214 #
10. impossiblefork ◴[] No.45781214{4}[source]
I shouldn't have mentioned LISP because I don't use it and I actually find the parentheses to be annoying, but it's a paradigm and you need them. Cyrillic at full speed is obviously weeks. But Erlang is very math-notation-y and when I introduced people to some Erlang code I'd written they understood it once I'd given a presentation on it and were then able to do similar things.