|
Notorious b.s.d. posted:...or perl, or ruby, or python, or java, or C#, or, you know, pretty much any language in common use other than C. i think you're just toying with me
|
# ? Mar 19, 2014 05:59 |
|
|
# ? Jun 11, 2024 03:28 |
|
worst case they'll fail loudly and obnoxiously, not silently turn your input into poo poo python is most likely to do something retarded, but its a toy language for idiots so w/e
|
# ? Mar 19, 2014 06:00 |
|
Python code:
|
# ? Mar 19, 2014 06:04 |
|
just lol if the library functions in your language aren't curried
|
# ? Mar 19, 2014 06:25 |
|
programming languages define my being and self worth as a person
|
# ? Mar 19, 2014 06:28 |
|
trip report: c#'s works as expected String[] test = { "10", "10", "10", "10", "10" }; var res = test.Select(e => int.Parse(e)); foreach (var e in res) Console.WriteLine(e + " " + e.GetType()); 10 System.Int32 10 System.Int32 10 System.Int32 10 System.Int32 10 System.Int32 its called select tho which is a little odd
|
# ? Mar 19, 2014 06:29 |
|
arrays, they're like databases you see
|
# ? Mar 19, 2014 07:34 |
|
Bloody posted:var res = test.Select(e => int.Parse(e));
|
# ? Mar 19, 2014 07:39 |
|
Bloody posted:trip report: c#'s works as expected Fixed your code code:
|
# ? Mar 19, 2014 09:04 |
|
Gazpacho posted:weaksauce, you had to adapt the function Yeah, if that's okay then js es6 is okay and equivalent. code:
I think wrangling over 100% language purity is a bit silly with a cobbled together language like JavaScript. It feels like there's two sides who disagree about agreeing. One says yeah its poo poo but really we've moved on and we can get past it because we need to use it, and the other says the language is poo poo and that's unacceptable. Problem is the only place to go from there is existing languages that compile down well to js, let me list them here: I'm a fan of Typescript these days because it addresses the key big picture problems, namely structure and maintaining contracts of behaviour, without getting hung up on syntax sugar like Coffee script. Even better is they aim to remain a superset, so any syntax sugar is ES6 based (like the example above)
|
# ? Mar 19, 2014 09:26 |
|
Notorious b.s.d. posted:javafx was originally a sort of flash-replacement library for use in applets and installers and things. It didn't build on top of, and wasn't really compatible with, awt/swing. as a result, i have never even seen a javafx app in the wild java 8's javafx is pretty much intended as a replacement for swing at this point. it doesn't have it's own terrible language anymore, and you can create javafx layouts with pure java, css, or xml. It also has a webkit based browser element, and a bunch of other nice things that are good for desktop apps and not just RIA. oh it also has opengl support built in (i think), so no more need for lwjgl for basic 3d java apps. Condiv fucked around with this message at 09:30 on Mar 19, 2014 |
# ? Mar 19, 2014 09:26 |
|
MononcQc posted:Basically JS has a non-obvious varargs implementation that is enabled for all functions and all calls no matter the arity, which is the same mechanism used to provide default values to arguments (via x == undefined comparisons in the implementation). ok no sorry octopus guy, but you're wrong, javascript has an official varargs mechanism. it sucks, as in it's too low level to be useful, but it's there: quote:15.3.5.1 length so for example: JavaScript code:
that said, parseInt has two arguments, not one argument plus an optional argument. look at how it's defined: quote:15.1.2.2 parseInt (string , radix) compare with a function with actual optional arguments: quote:15.4.4.16 Array.prototype.every ( callbackfn [ , thisArg ] ) e: that said, it isn't an error to pass more, or less arguments than the declared named arguments, meaning it's perfectly acceptable to ignore the arity of a function, so welp javascript is pretty crappy I guess hackbunny fucked around with this message at 09:53 on Mar 19, 2014 |
# ? Mar 19, 2014 09:39 |
|
Gazpacho posted:oh did they go back and change those so all the built-in / core library functions are curried, must have missed that Most of the time they just made sure map doesn't pass in second arguments to all the functions you're passing in, which was one of the thing I said should be fixed, and likely the simplest ones to make sure composability is preserved.
|
# ? Mar 19, 2014 12:48 |
|
hackbunny posted:ok no sorry octopus guy, but you're wrong, javascript has an official varargs mechanism. it sucks, as in it's too low level to be useful, but it's there: Now name one of these variables 'arguments' if you expect an array of things to be passed like this: JavaScript code:
code:
Python code:
Of course, checking arity isn't super reliable because (function f(a,b,c, ...args) { return x; }).length returns 3 (...args => 0), and you also can't use the varargs syntax and the arguments mechanism within the same function because that's invalid. hackbunny posted:javascript functions have arity, both declared and actual, and you can query both They use a lovely in-scope variable that isn't even a reserved word or anything. The javascript mechanism is as hidden as possible, and the arity is visible only to the called function by this mechanism, not the other one. See this scheme mechanism: code:
So what's the reasonable option? I'm guessing it isn't to blindly put your optional arguments into everything and see what sticks. My strongest argument is to change map to pass in a single argument, nothing in the second position. Then if you really want to avoid confusion, force the usage of a function of arity 1 in there. Error out when somone tries anything else. If you really, really want indexes, add a 'mapi' function or something and stop confusing people. And be strict on the arities you're ready to deal with. hackbunny posted:
MononcQc fucked around with this message at 13:21 on Mar 19, 2014 |
# ? Mar 19, 2014 13:18 |
|
notice how I'd been advocating JS borrows from PHP to have a saner model. That's how bad it is.
|
# ? Mar 19, 2014 13:19 |
|
MononcQc posted:Most of the time they just made sure map doesn't pass in second arguments to all the functions you're passing in, which was one of the thing I said should be fixed, and likely the simplest ones to make sure composability is preserved. i can confirm this is perl's behavior. you just map { whatever } @listofstuff, and it's like magic, where you go through the list/array one element at a time
|
# ? Mar 19, 2014 13:22 |
|
MononcQc posted:Woops: this errors out with TypeError: arguments.callee is undefined. And it makes sense, because we're shadowing a variable here. haha I never realized you can lock yourself out of that feature MononcQc posted:Of course JS made that lovely decision rather than doing a thing like using a function to get these values (like PHP does to name one) or using these values directly in the function head like Scheme: nah, not a function, in javascript they're possibly even easier to override than variables MononcQc posted:They use a lovely in-scope variable that isn't even a reserved word or anything. The javascript mechanism is as hidden as possible, and the arity is visible only to the called function by this mechanism, not the other one no, you misunderstand. arguments.callee is a too-clever-by-half way to get a reference to the current function, and just that. the caller doesn't need to reach into an obscure property of a hidden pseudo-array, it can just use .length: JavaScript code:
e: yeah map passing two arguments is incredibly counter-intuitive and I don't think any map-like function does it hackbunny fucked around with this message at 14:27 on Mar 19, 2014 |
# ? Mar 19, 2014 14:20 |
|
Luigi Thirty posted:arrays, they're like databases you see yeah their both set data.
|
# ? Mar 19, 2014 14:25 |
|
praise linq
|
# ? Mar 19, 2014 14:40 |
|
Languages that use map with an arity of 1: - clojure, if passed only 1 col to iterate over (1 arg per list being iterated on) - common lisp, same as clojure - D - Dart - Erlang - F# (also supports a 'mapi' function to get the index) - Factor - Groovy (through 'collect') - Haskell - OCaml - Perl - PHP (works like Clojure and CL, also has 'array_map' that works with 2 arguments for key/values) - Prolog - Python - Ruby - Scala - Scheme (all variations) - Smalltalk - SML Languages that use map with an arity of not 1: - Javascript - Coffeescript Graet job JS.
|
# ? Mar 19, 2014 14:41 |
|
hackbunny posted:haha I never realized you can lock yourself out of that feature Yeah, that's a huge part of my rant. It could be a nice feature, but you don't always have the possibility to use it. Good point of the function. In fact using a function might be worse in JS, because then you can't decide to do the scope exception thing (oh in this scope the variable 'arguments' overrides globals' sounds worse with functions) hackbunny posted:no, you misunderstand. arguments.callee is a too-clever-by-half way to get a reference to the current function, and just that. the caller doesn't need to reach into an obscure property of a hidden pseudo-array, it can just use .length: ugh. That's worse than I expected as a trick. I guess it could still work but bleh. hackbunny posted:in fact I think the earliest version of javascript didn't even have arguments.callee, and you had to use the function's name, or the name of a variable that contained the function (how'd you write recursive anonymous functions? you couldn't). that's why I mentioned that parseInt has an arity of 2: even if map checked the arity, or the language enforced it (forcing map to check it like you do in e.g. groovy, sorry if I don't use your fancypants flangs), you'd still get the stupid behavior my conclusion: js is bad.
|
# ? Mar 19, 2014 14:51 |
|
power botton posted:praise linq abuse linq for great success.
|
# ? Mar 19, 2014 14:55 |
|
Shaggar posted:yeah their both set data. I wish sql using multisets is a v bad thing since then u cant use the full relational algebra properly
|
# ? Mar 19, 2014 15:04 |
|
Shaggar posted:abuse linq for great success. linq owns, too bad it can't fuse streams
|
# ? Mar 19, 2014 15:04 |
|
you never fuse the streams
|
# ? Mar 19, 2014 15:05 |
|
yeah. that would be bad
|
# ? Mar 19, 2014 15:06 |
|
Welcome to functional programming, Shaggar!
|
# ? Mar 19, 2014 15:55 |
|
lambdas are pointless and dumb. the only reason I use them in c# is cause they're part of linq. would have much rather had Properties in java than lambdas
|
# ? Mar 19, 2014 15:56 |
|
zokie posted:Fixed your code
|
# ? Mar 19, 2014 15:56 |
|
MononcQc posted:Languages that use map with an arity of 1:
|
# ? Mar 19, 2014 16:18 |
code:
|
|
# ? Mar 19, 2014 16:27 |
|
C# code:
|
# ? Mar 19, 2014 16:33 |
|
man if only they'd quit dicking around and release a stable version of tomcat 8
|
# ? Mar 19, 2014 16:40 |
|
im still running tomcat 7 + java 6. probably never going to upgrade either since most of my stuff is moving to c#
|
# ? Mar 19, 2014 16:41 |
|
altho hopefully the security audit we have to go thru later finds the old javas and forces us to upgrade.
|
# ? Mar 19, 2014 16:42 |
|
Shaggar posted:
this is getting gross
|
# ? Mar 19, 2014 16:43 |
|
can someone remind me what's wrong w/ clojure again? i'm picking it up again i think
|
# ? Mar 19, 2014 16:45 |
|
its dumb as hell
|
# ? Mar 19, 2014 16:48 |
|
Shaggar posted:its dumb as hell bad shaggar clojure is great if u need a jvm scripting language and as a lisp it owns don't macro though it gets hairy fast
|
# ? Mar 19, 2014 16:50 |
|
|
# ? Jun 11, 2024 03:28 |
|
Malcolm XML posted:bad shaggar clojure is great if u need a jvm scripting language and as a lisp it owns if you need a scripting language use groovy. no one needs a lisp
|
# ? Mar 19, 2014 16:57 |