barubary

joined 2 years ago
[–] barubary@infosec.exchange 2 points 2 days ago (1 children)

I disagree with pretty much everything you write here, but especially this:

First of all, you have exact same amount of parens as you would in a mainstream language like Java, C, or Js.

My Perl example uses "mainstream language" syntax. Apparently that doesn't count because it's Perl (scary! mental overhead! write only!), so here's exactly the same thing in JavaScript:

function hypot(x, y) {    return Math.sqrt(x ** 2 + y ** 2);}

... or

const hypot = function (x, y) {    return Math.sqrt(x ** 2 + y ** 2);};

... or

const hypot = (x, y) => Math.sqrt(x ** 2 + y ** 2);

Note how none of these involve four layers of nested parentheses.

[–] barubary@infosec.exchange 2 points 2 days ago (3 children)

OK, my code snippets are Common Lisp. But note that none of them involve list/vector/set literals. I was thinking of [] for array indexing and {} for code blocks.

As for infix macros, sure, that's not hard to do, but it's not built into the language and there being "plenty of libraries" is part of the problem: They're all subtly different, none are standard, and I suspect most people don't use them anyway. (Plus there's fun little design issues like whether a*x + b should parse the same as a * x + b, and if it does, then how do you refer to a variable called a*x from an infix environment?)

It doesn't solve the main issue anyway. Take this snippet from the "infix" readme:

(def hypot  (fn [x y]    (infix sqrt(x ** 2 + y ** 2))))

It ends with a cluster of )))) (reinforcing the "lots of parentheses" impression) and all of those parentheses mean something different: From the outside in, we have the end of a symbol definition (def ...), the end of a function (fn ...), the end of a macro invocation (infix ...), and the end of a function call sqrt(...). It definitely isn't just "the same number [of parentheses] as any other language that uses parentheses to make function calls".

Compare e.g. these versions written in Haskell:

hypot = \x y -> sqrt (x ** 2 + y ** 2)

... or Perl:

sub hypot($x, $y) {    sqrt($x ** 2 + $y ** 2)}

... or if you want to separate the function and symbol definition parts:

*hypot = sub ($x, $y) { sqrt($x ** 2 + $y ** 2) };
[–] barubary@infosec.exchange 7 points 3 days ago (5 children)

This is false. Lisp uses parentheses where other languages use (), [], {} or nothing at all. For example, in C I can write int i = 0, but the equivalent Lisp code involves three pairs of parentheses. Or take something like a[i] = f(i + 1) / 2 + p. The equivalent Lisp code is something like (setf (aref a i) (+ (/ (f (+ i 1)) 2) p)), and you can't tell me that's not a lot of parentheses.

[–] barubary@infosec.exchange 2 points 3 days ago (1 children)

I, too, love living in a society that never makes errors, ever, as I myself am quite infallible. https://www.web3isgoinggreat.com/

[–] barubary@infosec.exchange 0 points 3 days ago (3 children)

Transfers are predictable and rapid.

And don't forget how easy it is to reverse them in case of error.

[–] barubary@infosec.exchange 1 points 2 weeks ago (1 children)

That's just syntax.

>>> 10 .yearsTraceback (most recent call last):  File "<stdin>", line 1, in <module>AttributeError: 'int' object has no attribute 'years'
[–] barubary@infosec.exchange 4 points 2 weeks ago (1 children)

Does Ruby require the use of [] and {} there? Because those %w/%i/etc things look like custom quoting operators and at least in Perl you can use any delimiter you want: qw(a b c) is a list of strings, but so are qw+a b c+ and qw;a b c;.

[–] barubary@infosec.exchange 20 points 3 weeks ago* (last edited 3 weeks ago)

I like the original.

Comic by Jason Heeris, 2013. Panel 1: Person staring at screen with code: if c == ',': backtrack = 1 Panel 2: Zoomed out. Code now in big thought bubble Panel 3: Zoomed out more. Thought bubble: "... so if the current character is a comma, we set the backtracking flag ..." Panel 4: Zoomed out more. Thought bubble fills half the panel. It shows a state diagram, presumably part of a finite automaton corresponding to a regular expression. Panel 5: Zoomed out more. Thought bubble fills most of the panel. Flowchart. Step "parse" leads to decision "-i flag"; one branch to box with previous state diagram (scaled down), other branch to step "remote config", then decision "https" with branches out of visible area. Panel 6: Zoomed out more. Huge thought bubble with scribbled diagrams and notes and arrows connecting them. E.g. "commit #5763 to here caused bug or did it just expose it?", pointing to "new config format parser" and "callback for config state"; "CLI entry point" has a note on it saying "Sarah wrote this, maybe ask about weird parse logic?"; "remote config loader" has a note "no access to source - are we just recalculating its state later?". Panel 7: Back to normal zoom. Another person with a tie and coffee in hand peers over the screen: "Hey, so I just sent you an email about that thing". The thought bubble is collapsing into a black hole. Panel 8: Tie/coffee guy is walking off, whistling. Original person is back to staring at screen with code: if c == ',': backtrack = 1

[–] barubary@infosec.exchange 6 points 1 month ago (1 children)
$ python3 -c 'f = (lambda x: x + 0.5 - 0.5); print(f(2**52))'  4503599627370495.5

#python

[–] barubary@infosec.exchange 68 points 1 month ago (1 children)

If you had let me write the C++ code, I could have literally destroyed your dataset in a couple of seconds.

[–] barubary@infosec.exchange 0 points 1 month ago (1 children)

I believe now it is my turn to say you're spewing nonsense. Have you ever used a language with a type system? Because this whole idea of "testing external data to see if it is the right type" doesn't really make sense.

At the lowest layer, generally, external data is an array of bytes. It has no other type you could "test". However, you can decode or parse it into a form that makes sense for your program. And why couldn't I cleanly recover from parse errors? (And how do you think Python does it?)

[–] barubary@infosec.exchange -1 points 1 month ago (3 children)

Again, "strong types" doesn't mean anything.

But from a type theory perspective, having "dynamic types" absolutely means you don't have a type system. All Python has is runtime exceptions. The fact that one of them is named TypeError doesn't make it a type error in the formal sense.

The point of a type system is not that variables have types, but that types are assigned to expressions (i.e. pieces of code in your source file), not to values (i.e. pieces of data). This is important because it guarantees that certain errors cannot occur in a program that passes the type checker (assuming you have a sensible/useful type system). And you get this assurance without running a single line of code.

To get a similar guarantee from Python, you need to write exhaustive tests, just as with any other runtime error.

view more: next ›