Fork me on GitHub
#off-topic
<
2019-01-20
>
mattly00:01:47

Because people don’t see the benefit of relearning everything to avoid mutable state

mattly00:01:57

It is quite a shift in thinking

chrisulloa03:01:37

immutability also has performance costs right?

chrisulloa03:01:37

I guess you're saying it should be the default, not that mutability shouldn't also be available.

fellshard04:01:19

Not necessarily, but immutable-by-default seems to have a much stronger set of benefits for many things

futuro06:01:03

I think it makes sense to have mutable datastructures available when needed, but immutable datastructures have good enough ™️ performance now that reaching for mutable structures right away for performance reasons is a premature optimization.

futuro06:01:53

And should probably be kept to the specific locations your perf profiling has identified as being hot spots.

WhoNeedszZz22:01:24

I believe this is one of the key problem areas. People rely too much on "perf profiling" and often misunderstand the results, which leads to inaccurate assumptions and poor decisions based on those.

futuro06:01:52

Re: a shift in thinking, I think that's part of it, but another part is probably that it doesn't get talked about much. Typing is a popular flame-war, but mutable vs. immutable doesn't seem to be.

futuro06:01:55

I'm not sure why.

Vincent Cantin06:01:41

My theory on this: mutable data users mostly don’t know immutable data users, or consider them too weird to argue with … until they start to understand the benefits of immutable data and become themselves immutable data users.

Vincent Cantin06:01:20

Another reason is : inside each mutable data user, there is a part time immutable data user …. i.e. const. 😆

borkdude16:01:36

in bash, how can I compare the result of this in a conditional, saying “greater than zero”:

errors=$(cat out/output.txt | grep FOO | wc -l)

borkdude16:01:45

I’m trying this:

echo $errors
       0
[ "$errors" -gt "0" ]; echo "yes"
yes

borkdude16:01:48

so it kinda not works

borkdude16:01:03

it seems wc -l puts a tab or something in the result

borkdude16:01:47

I should be using grep -c

manutter5119:01:55

$ echo $errors
0
$ if [[ $errors -gt 0 ]] ; then echo "yes"; else echo "no" ; fi
no

borkdude19:01:18

ah, so you need two square brackets…?

manutter5119:01:34

Yeah, bash is weird that way. Something about “double-square-brackets == boolean” I think? Been a while, my bash skills are rusty (not that they were all that great to start)

manutter5119:01:12

but anyway, yeah, double-square-brackets for if

borkdude19:01:45

it also works with single ones 😉

Lennart Buit19:01:01

fun fact, there is actually a binary called [ on the average unix system

Lennart Buit19:01:46

If you have a shell without a [ built-in, it can fallback to that actual binary. Shell scripting is strange like that

borkdude19:01:17

what does that binary do?

Lennart Buit19:01:19

the same apparantly, I am unsure why it is a builtin in zsh/bash

dorab19:01:30

I'm guessing, but probably to avoid the overhead (fork/exec) of calling a binary just to evaluate a boolean expression.

Lennart Buit19:01:20

hmm yeah makes sense, but is asking for compatibility problems

mseddon21:01:25

I imagine the source is identical, or there is a very insidious set of standardized tests.

Alex Miller (Clojure team)21:01:38

if you haven’t found it yet, I find shellcheck to be immensely useful in checking bash stuff

borkdude21:01:05

I read about it on the Haskell reddit but never actually tried it. Thanks for the link!

mseddon22:01:43

That looks fantastically useful. Thanks!

borkdude22:01:07

The only thing where shellcheck doesn’t make a good suggestion imo is this one:

Line 21:
clojure -A:test:coal-mine:coal-mine-generator out/out.cljc $problem
>>                                                         ^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
clojure -A:test:coal-mine:coal-mine-generator out/out.cljc "$problem"
Wrapping the variable in quotes is passing an extra argument, while I want to ignore it when it’s not set.

borkdude22:01:37

Maybe there’s a better way in bash to do this.

borkdude22:01:00

probably this:

clojure -A:test:coal-mine:coal-mine-generator out/out.cljc ${problem:+"$problem"}

borkdude22:01:54

Now using it as a linter in emacs.

Lennart Buit21:01:11

I found out the hard way that MacOS shell scripting is quite different from Linux. Linux utils have so much more options compared to their BSD counterparts shipped with MacOS

👆 10
mseddon21:01:24

Can't you brew more standard shells onto MacOS?

mseddon21:01:16

Or is this a /bin/sh kinda deal? :/

Lennart Buit21:01:18

its not the shell, its the (what would on linux be called) core utils

Conor21:01:50

You can install the Linux versions AFAIK

Conor21:01:54

I seem to remember doing it

mseddon21:01:41

Might that start to break made for mac kinda stuff though? Like a system update.

Lennart Buit21:01:40

Yeah, not going to attempt that :’). Its not bad perse, I just thought that the BSD family of core utils was closer to the GNU family of core utils.

WhoNeedszZz22:01:15

This is the deal with being "unix-like". OSX is neither Unix nor Linux, but people keep trying to compare one or the other to it.

dpsutton23:01:42

i think mac is certified as a unix

WhoNeedszZz23:01:55

Right and we're talking Unix vs UNIX(R) Certified. As per the Wikipedia page (https://en.wikipedia.org/wiki/Unix) - The UNIX trademark passed to The Open Group, a neutral industry consortium, which allows the use of the mark for certified operating systems that comply with the Single UNIX Specification (SUS). As of 2014, the Unix version with the largest installed base is Apple's macOS.

dpsutton00:01:52

you claimed that > OSX is neither Unix nor Linux, but posted a link from the UNIX trademark owner that > As of 2014, the Unix version with the largest installed base is Apple's macOS.

dpsutton00:01:50

i don't follow.

WhoNeedszZz01:01:45

I explained. Unix vs UNIX(R) Certified. There's a difference that is explained in my previous message.

WhoNeedszZz01:01:42

I also didn't write the Wikipedia article. As with any Wikipedia article there may be inaccuracies within the page. The purpose of linking the two pages was to show the difference.

dpsutton01:01:14

Ah cool. I'll read them more carefully later. Thanks for the articles

👍 5
mseddon21:01:16

It is far older than that ;)

Conor21:01:37

They get added as g + <name> by Homebrew as far as I know so no clashes

👍 10
mseddon21:01:29

That is ideal. You could go crazy and chroot into a sane scripting environment and everything, too 😀

Lennart Buit21:01:04

off topic off topic: How often chroot has saved my Arch install :’)

👍 10
mseddon21:01:17

Quite 😀

Lennart Buit21:01:57

dual boot with Windows, and NVIDIA drivers

Lennart Buit21:01:10

Great ways to kill your Arch

facepalm 5
mseddon21:01:58

Nvidia on Linux has been the bane of my life... It's like tossing a grenade in the kernel.

Lennart Buit21:01:15

Have a love/hate relationship with it, I like that it at least provided performant drivers for linux

Lennart Buit22:01:42

But the ArchLinux tooling is great, even if you borked your kernel and it doesnt boot, boot from USB, chroot and fix whatever you broke

Lennart Buit22:01:45

The fact that ArchLinux is so barebone makes system maintenance so much easier

Lennart Buit22:01:23

But yeah, maybe not run it on your production cluster

mseddon22:01:22

You'd better be insured ;)

WhoNeedszZz22:01:36

Fellow Arch user here. Follow the instructions on the Nvidia Arch Wiki page and it works just fine. Miss some of the key steps on there and you'll see issues. I'm running nvidia blob and have better performance than my Winblows installation and am running Steam Native just fine.

👍 5
WhoNeedszZz22:01:49

Per your initial statement - you shouldn't need to boot into a live usb key. That's what the fallback kernel is for

WhoNeedszZz00:01:15

Here's one that is specifically helpful that is often forgotten (I know I did) - https://wiki.archlinux.org/index.php/NVIDIA#Pacman_hook

Lennart Buit07:01:17

I don’t really know the exact circumstances, but part of the problem was having a relatively tight root partition (10G or so). Maybe I could restore with the fallback, but windows breaking my bootloader had me use the USB and that was what was familiar