Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

12-14-2017 , 12:58 AM
Quote:
Originally Posted by Grue
The amount time type checking in javascript would have saved me while debugging is absolutely dwarfed by the amount of time typing out extra code in by doing it all in typescript would have taken.
Yeah. I'm fine with static or dynamic. I grew up with statically typed languages but sometimes they're not necessary. I've done a little TypeScript but not much and the little I have done made me somewhat skeptical of its utility. I think front-end programming is more suited to dynamic languages, generally.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 01:28 AM
Quote:
Originally Posted by lostmypw
Most type systems feel like a cancerous growth of unneeded complexity to me. I'm working with typescript alot lately and people create types for every config/options argument that gets passed, complete with generics and optional values and the whole thing just pisses me off.

I like go's type system because it doesn't have generics but then I see all sorts of comments and blogs about how this is bad and blah blah abstract data types blah.

I think it was gamingmouse here who said that the idea of types is fundamental to programming and in dynamic languages you basically end up implementing it yourself anyway. I think he's right but I'd rather just implement it myself.

Compare redux saga's little type library (https://github.com/redux-saga/redux-...l/utils.js#L20) to the cluster**** that is typescript and I'll choose the former every time.
this can happen but it's not fair to blame it on the type system. what they're doing (assuming your annoyance is well-founded, which it sounds like it is) is wrong on a much more fundamental level. it goes by many names 1) over-engineering 2) premature optimization 3) poor complexity management... etc. using a dynamic language won't fix those errors.

what i said earlier is that you use a type system whether you want to not -- the only question is if you use an implicit one or an explicit one. a type is just a set of values, and so if you have any assumptions about a variable's possible values, you have a type.

even if you think you it's best to keep your types as general as possible and avoid baking in assumptions too early (and i think this impulse, even though it can be correct, often comes from boilerplatey languages that make type definitions annoying), it's still no excuse not to make the assumptions you do have explicit.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 01:38 AM
Solution: Scala. Types + Type inference

Ill show myself out now
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 01:44 AM
Quote:
Originally Posted by PJo336
Solution: Scala. Types + Type inference

Ill show myself out now
haskell
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 01:48 AM
Never tried it quite yet. Im only pseudo functional neckbeard level
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 01:50 AM
I think that each function should be properly typed implicitly, and I'm not even sure I can conceive of writing a function that takes numbers or strings. This is obviously more binary than typical types, but I'm absolutely against using variadic arguments, and I think the use of "any" or whatever your language supports is obnoxious.

I find this kind of irritating:

Code:
>>> "a" + "b"
'ab'
>>> 1 + 2
3
Imagine how much more hardened your language would be if it had a concat() function instead of overloading the + operator. This is stuff Clojure does, for example, but really, being on the JVM, the type system leaks all over the place. I'd guess JPython and JRuby have the same unusual things going on?

At least Python does this:

Code:
>>> 1 + "b"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 01:59 AM
Here was an interesting bug I was dealing with recently, which the type-system people will enjoy.

Some Python functions are counter-intuitive, so you think you are grabbing the index of a char in a string, but reality is you are returning True or False.

Since the person who wrote the code didn't know this, they were trying to split the string at the char and concatenating where the split was. Since the return value was always True (1) or False (0), using something like my_string[res] += "more letters" was completely meaningless.

(a real bug with a contrived example)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 02:23 AM
Major DDoS that basically crashed the internet last year was developed by kids trying to win at minecraft: https://www.wired.com/story/mirai-bo...-the-internet/
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 02:37 AM
Quote:
Originally Posted by daveT
I'm not even sure I can conceive of writing a function that takes numbers or strings type(s)
What does this mean?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 03:16 AM
I mean that I agree with lostmypw: this is pure horse****. It should be in DailyWTF, not presented as an example of good code.

Code:
function padLeft(value: string, padding: string | number) {
    if (typeof padding === "number") {
        return Array(padding + 1).join(" ") + value;
    }
    if (typeof padding === "string") {
        return padding + value;
    }
    throw new Error(`Expected string or number, got '${padding}'.`);
}
It's too easy to make a comment on padLeft as it is...

This should, IMO, be split into clear functions: one that takes a string and the other that takes a number, and they should be called something semantic for the purpose. The idea of using an overloaded function to concat a string is just silly, but I'll pretend that the author was giving a non-real-world example.

In purely dynamic languages, doing anything that implies or allows this is horrible. If adding types is intended to remove that possibility, then I see the argument, but this is a matter of bad design, IMO.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 04:00 AM
Anyone got a resource for becoming a git ninja? Starting basic is fine. I've always used IDEs to interact with git and am thoroughly sick of it, as some random thing always goes wrong and then I click buttons for half an hour until it finally pushes and I still don't understand what it did. I'm just going to learn command line.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 05:44 AM
12-14-2017 , 07:45 AM
Quote:
Originally Posted by daveT


+1


Sent from my iPhone using Tapatalk
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 08:58 AM
Quote:
Originally Posted by PJo336
Solution: Scala. Types + Type inference

Ill show myself out now
Welcome to basically every modern (and many non-modern) language.

Quote:
Originally Posted by daveT
I think that each function should be properly typed implicitly, and I'm not even sure I can conceive of writing a function that takes numbers or strings. This is obviously more binary than typical types, but I'm absolutely against using variadic arguments, and I think the use of "any" or whatever your language supports is obnoxious.

I find this kind of irritating:

Code:
>>> "a" + "b"
'ab'
>>> 1 + 2
3
Imagine how much more hardened your language would be if it had a concat() function instead of overloading the + operator. This is stuff Clojure does, for example, but really, being on the JVM, the type system leaks all over the place. I'd guess JPython and JRuby have the same unusual things going on?

At least Python does this:

Code:
>>> 1 + "b"
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Why is that irritating??? Basically every language does this. I don't understand. This seems to be implemented perfectly imo.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 02:34 PM
That isn't really the point. I think that functions should have a single input and output type, and whether that is explicit or implicit is irrelevant. If you were writing functions, would you choose to write a function called "put_stuff_together()" that allows you to add numbers, concat strings, union sets, and append arrays? This is the exact same thing that overloading "+" does in Python. It's also the same thing that silly TypeScript example is doing, though not as extreme.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 03:13 PM
Ok so you just don't like the + being used for string concatenation. Fine. Seems pretty easy to me to wrap my head around, but not worth complaining about since it's in like almost every language.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 03:17 PM
I did say it's "kind of" irritating. Lisp and PL are two examples where the operator isn't overloaded, and I think it's actually much better. This is coming from someone who prefers dynamic language talking to someone who prefers static. I bet you'd agree with me after you were exposed to it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-14-2017 , 03:30 PM
Yea I'd definitely agree it's probably a much bigger problem in a dynamically typed language. If I was trying to add/concatenate and a string/int accidentally got passed in I'd probably want an error to happen asap.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-15-2017 , 07:58 PM
Quote:
Originally Posted by gaming_mouse
haskell
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-15-2017 , 08:14 PM
Quote:
Originally Posted by daveT
That isn't really the point. I think that functions should have a single input and output type, and whether that is explicit or implicit is irrelevant..
I am not sure I agree with this.

For example, in functional programming, there are valid functions which take inputs from a ange of different types, and return something of type associated with the original type. Maybe is an example of this. Monads areca more general example. It would be quite restrictive to insist the input is a uniquely defined type.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-16-2017 , 02:18 AM
Last day at work today. So I clean out my Mac, copy code and documents - standard. Then I delete all my internet history, passwords, personal docs etc. I almost get ready to hand over the computer and realize iMessage still has full access to my phone and has saved every text/iMessage I've sent for the last 5 years or so. Woopsie!

So I go to delete my account and all saved stuff - which again - is basically a record of every text I've received or sent for 5 years. Kinda sensitive stuff. Should be easy right? Guess again. Logging out of my account is pretty easy. But then they have this awesome flow where you can decide not to login, then another step where you can say Cancel or Skip. And if you pick Skip - boom iMessage opens with every saved message you ever sent.

Yes you can delete each conversation one at a time. But we're talking several hundred and each one is a multi-step "Are you sure you want to delete this conversation?" process.

So here's just one step of the fun instructions for actually deleting existing messages: https://www.imobie.com/support/how-t...ermanently.htm



So I do all that, temporarily forgetting that there is more than one /Library/messages dir on my Mac. Finally find all of them. Delete all the chat.mdb whatever file. Empty trash. Open iMessage - everything is still there. Naked texts from the gf - still there. I'm like wtf. How can I turn this in to my boss? Part of our instructions are we're supposed to give them access to our login when we leave.

Finally out of desperation I decided to reboot. And THEN it was finally gone. HYATHCHAYAYAYAYAY Why did that even work? I have no idea.

****ing hell Apple - think about **** every now and then. There is nothing more sensitive than your entire text history. Maybe don't make it like Raiders of the Lost Ark to delete? Should be one button - Delete All Saved Messages? Yes.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-16-2017 , 02:48 AM
Quote:
Originally Posted by river_tilt
I am not sure I agree with this.

For example, in functional programming, there are valid functions which take inputs from a ange of different types, and return something of type associated with the original type. Maybe is an example of this. Monads areca more general example. It would be quite restrictive to insist the input is a uniquely defined type.
I suppose I should clarify my thoughts here...

If you are going to be working with various types, which is inescapable at times, I don't think you should be using scalar or variadic arguments as your function args. If I run into this, I will do what I can to use a map and deconstruct that inside the function.

For streaming arrays / lists / tuples into a function, the entire structure should be the same type, or at least something that can work together (int, decimal, numeric). That should not be holding strings and booleans as well. This is a very narrow exception to variadic args, but once again, there should be no conflict between arg1 and argN. This isn't the same as positional arguments.

Doesn't Haskell's Maybe mean: return some X as a default of A not in B? That's a little different than what I'm talking about. I don't believe that a function output type should match it's input type...
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-16-2017 , 02:52 PM
I have the next 3 weeks off so I decided I'm going to explore learning the basics of a language I have no experience in.

Spoiler:
hindi


Results should be.. interesting.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-16-2017 , 03:41 PM
Is it static typed?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
12-16-2017 , 06:21 PM
Quote:
Originally Posted by daveT
I mean that I agree with lostmypw: this is pure horse****. It should be in DailyWTF, not presented as an example of good code.

Code:
function padLeft(value: string, padding: string | number) {
    if (typeof padding === "number") {
        return Array(padding + 1).join(" ") + value;
    }
    if (typeof padding === "string") {
        return padding + value;
    }
    throw new Error(`Expected string or number, got '${padding}'.`);
}
It's too easy to make a comment on padLeft as it is...

This should, IMO, be split into clear functions: one that takes a string and the other that takes a number, and they should be called something semantic for the purpose. The idea of using an overloaded function to concat a string is just silly, but I'll pretend that the author was giving a non-real-world example.

In purely dynamic languages, doing anything that implies or allows this is horrible. If adding types is intended to remove that possibility, then I see the argument, but this is a matter of bad design, IMO.
Been a bit since I used JS, but aren't tons of heavily-used libraries written like this? From what I remember of, say, mongojs, and also other stuff I used, APIs had functions that were "overloaded" to have several different forms where you might insert or not insert a callback, stuff like that, and the underlying implementation of those "overloads" is to figure out what version you called by dynamically checking the types of the arguments you passed.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m