|
Abandon posted:we should do a survey of which languages have "lambdas" where you can do anything at all with the lambda besides execute it if you need to do more things than just execute it why not pass an object instead
|
# ? Oct 28, 2013 15:42 |
|
|
# ? May 23, 2024 15:25 |
|
Nomnom Cookie posted:java 8 adds function pointers too loving finally
|
# ? Oct 28, 2013 15:54 |
Zlodo posted:if you need to do more things than just execute it why not pass an object instead thats kind of the whole point of lambdas, theyre meant to be code as a first class object in the language
|
|
# ? Oct 28, 2013 16:01 |
|
Otto Skorzeny posted:loving finally its actually sugar for anonymous inner classes
|
# ? Oct 28, 2013 16:01 |
|
Abandon posted:we should do a survey of which languages have "lambdas" where you can do anything at all with the lambda besides execute it a function pointer and its attached surrounding environment at declaration time, i.e. closures. The correct argument is that closures are glorified objects, and that objects are glorified closures. Function pointers are not part of it, because they don't manage to carry contextual state around.
|
# ? Oct 28, 2013 16:18 |
|
quote:The venerable master Qc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said "Master, I have heard that objects are a very good thing - is this true?" Qc Na looked pityingly at his student and replied, "Foolish pupil - objects are merely a poor man's closures."
|
# ? Oct 28, 2013 16:20 |
|
Shaggar posted:like i'd rather have c# style properties in java than lamdbadas this a million times. I think lambdas are actually useful but c# properties own bones compared to The Java Way
|
# ? Oct 28, 2013 16:33 |
|
I declare Java classes consisting of nothing but public fields all the time, get at me
|
# ? Oct 28, 2013 16:36 |
|
Suspicious Dish posted:I work with a lot of people who really love Vala. It's not a terrible language, and it actually has some pretty awesome features such as method bodies in interfaces. My main experience with it is working with libraries that are written in Vala, and they usually expose void* everywhere as their interface. vala shouldn't even exist the gnome people are impossible to work with. first they had gobject, which was an attempt to graft OO onto C without any compiler changes or whackadoo crap. it was frustrating to read/write, but it worked pretty good then they had java-gnome. the bindings were high quality, it was documented and fully OO. but java's open source license wasn't open open source enough. so its use was officially discouraged. then they had a wonderful and actually mostly-documented set of C# bindings for use with mono, but mono was suposedly dangerous because microsoft and novell were flirting at the time and people kept talking lawsuits. so people started rewriting existing, working C# applications in buggy C or C++ just to get off mono so they went back to gobject and made a language out of it: vala. it's a half-baked bucket of crap that "compiles" to C+gobject code, which then has to be compiled. with all accompanying joy in debugging. also now gobject has a ton of poo poo that has to be generated by parsing C code and ugh please just die
|
# ? Oct 28, 2013 16:45 |
|
Mr Dog posted:I declare Java classes consisting of nothing but public fields all the time, get at me this triggers me but I've started doing it anyways cause I've been spending more time in c# and every time I go back to java getters/setters look so dumb
|
# ? Oct 28, 2013 16:46 |
|
Mr Dog posted:I declare Java classes consisting of nothing but public fields all the time, get at me reminder that awt is irrevocably slow because someone made this decision and they have to live with it for ever
|
# ? Oct 28, 2013 16:46 |
|
something i'm curious about: in java or c# or whatever, do lambdas like lambda x: x.foo() have a sensible type? my first guess would be no because you can't even express the notion that 'x has a method named foo' in the type system. does scala let you do this? the only languages i have experience with with real lambdas are python which just has a generic function type and haskell which isn't OO (unless you do something super wacky with fclabels/lens/whatever)
|
# ? Oct 28, 2013 16:47 |
|
Mr Dog posted:I declare Java classes consisting of nothing but public fields all the time, get at me uhoh your implementation is showing!
|
# ? Oct 28, 2013 16:47 |
|
Opinion Haver posted:something i'm curious about : in java or c# or whatever, do lambdas like lambda x: x.foo() have a sensible type? my first guess would be no because you can't even express the notion that 'x has a method named foo' in the type system. does scala let you do this? the only languages i have experience with with real lambdas are python which just has a generic function type and haskell which isn't OO (unless you do something super wacky with fclabels/lens/whatever) in scala function types are distinguished by their signature, so your lambda would have to take a specific "x" as an argument in its signature. if the type of x is just "a thing that has a foo() method" you would create a trait for "fooable" and the signature would look like "(fooable) -> Unit" the story for java is much the same. static type checking is static. type inference and sane collections libraries and lambdas make static type checking more pleasant and powerful, but it's still static. edit: bonus option in scala that doesn't work as naturally in java -- you can use pattern matching to handle a lot of specific types for x on the fly, and this is routinely done. then the signature is "(AnyRef) -> Unit" and the type is resolved at runtime in the pattern match Notorious b.s.d. fucked around with this message at 16:56 on Oct 28, 2013 |
# ? Oct 28, 2013 16:53 |
|
Opinion Haver posted:something i'm curious about : in java or c# or whatever, do lambdas like lambda x: x.foo() have a sensible type? my first guess would be no because you can't even express the notion that 'x has a method named foo' in the type system. does scala let you do this? the only languages i have experience with with real lambdas are python which just has a generic function type and haskell which isn't OO (unless you do something super wacky with fclabels/lens/whatever) From what I can tell from 30 seconds of playing around with C#, x => x.foo() has a halfassed type and you pretty much can't do anything with that expression except use it in a context that lets the compiler infer an SomeBoringOldType => AnotherBoringOldType type. foo.cs(3,5): error CS0815: An implicitly typed local variable declaration cannot be initialized with `anonymous method' foo.cs(3,28): error CS0023: The `.' operator cannot be applied to operand of type `anonymous method' foo.cs(8,5): error CS0411: The type arguments for method `Foo.f<T>(T)' cannot be inferred from the usage. Try specifying the type arguments explicitly
|
# ? Oct 28, 2013 16:56 |
|
Vanadium posted:From what I can tell from 30 seconds of playing around with C#, x => x.foo() has a halfassed type and you pretty much can't do anything with that expression except use it in a context that lets the compiler infer an SomeBoringOldType => AnotherBoringOldType type. it's not a halfassed type, it's just a type that gets inferred lambdas are just syntactic sugar where the compiler infers the type for you. the type still has to be resolveable. there are no variables running around with duck-typing applied, it just feels that way when type inference works well
|
# ? Oct 28, 2013 17:00 |
|
the way it works in c# is right altho sometimes in razor there are no types on the thing you're dealing with so you're flying blind calling any methods on the thing and you have to pray it works at runtime. I imagine that's what it feels like to do a p-lang.
|
# ? Oct 28, 2013 17:03 |
|
in ocaml you can write that function. using the repl: # fun x -> x#foo;; - : < foo : 'a; .. > -> 'a = <fun> the type reads: take an object with a method foo that returns 'a, and maybe some other methods too that we don't care about, and return type 'a. we get a type variable 'a (any type) because there's nothing in the function to constrain the type further. if i said x#foo + 1 then we'd have 'a = int. it works kinda like duck typing, but statically, and with type inference! the implementation of this is based on row types JewKiller 3000 fucked around with this message at 17:15 on Oct 28, 2013 |
# ? Oct 28, 2013 17:10 |
|
oops
|
# ? Oct 28, 2013 17:17 |
|
[]( auto&& foo ){ return foo.x(); } c++14
|
# ? Oct 28, 2013 17:17 |
seems like they really missed a chance in java to have proper features that support the language in the virtual machine like imagine something like const except it really means "this is immutable" and the runtime can prove that things are invariant and optimise stuff really well and all the getters and setters can gently caress off i mean they already have a fancy managed reference type instead of a pointer into some abstract machines flat address space so why not capitalise on that instead of make a language that barely does any more than C
|
|
# ? Oct 28, 2013 17:18 |
|
Opinion Haver posted:something i'm curious about : in java or c# or whatever, do lambdas like lambda x: x.foo() have a sensible type? my first guess would be no because you can't even express the notion that 'x has a method named foo' in the type system. does scala let you do this? the only languages i have experience with with real lambdas are python which just has a generic function type and haskell which isn't OO (unless you do something super wacky with fclabels/lens/whatever) Yes, they do. Func<WhateverTypeXIs, WhateverTypeFooReturns> i.e., WhateverTypeXIs -> WhateverTypeFooReturns (assuming you've declared this in a context where the type of x can be inferred). If not, you'll have to explicitly specify the type (like (ISomeInterfaceWithFoo x) => x.foo()), but yes they have sensible types that are in line with how functional languages type functions.
|
# ? Oct 28, 2013 17:20 |
|
JewKiller 3000 posted:it works kinda like duck typing, but statically, and with type inference! the implementation of this is based on row types code:
|
# ? Oct 28, 2013 17:20 |
|
JewKiller 3000 posted:in ocaml you can write that function. using the repl: This is the only meaningful way (that I've found) that F# diverges from OCaml (nominal vs structural subtyping), I'm sure because the CLR is nominally typed.
|
# ? Oct 28, 2013 17:21 |
|
Notorious b.s.d. posted:vala shouldn't even exist Building a desktop environment on top of Java or C# is loving stupid, the politics are just coincidental. They are entire Qt-like universes in their own right, so have fun churning out mountains of boilerplate converting back and forth between java.util.List or System.Collections.IList objects or w/e and the native collection types used by the system frameworks. Same issue if you want to interface with GStreamer or any other such native API. Mountains of loving boilerplate so you're going to have to hope that whoever does the tedious shitwork of keeping your C#/Java bindings up to date has a binding for the exact API that you want to use and it's been tested and shown to work. GObject still exists, there's still C-side boilerplate you have to write if you're programming for GObject in C, but you do that once and then dynamic languages can dynamically bind to it using GObject introspection, which is probably a whole lot better than the hosed up impedance mismatch resulting from trying to build a bridge to Qt's C++98 with string-identified signals and slots island of merry japes. More than using GObject as its type system, Vala uses GLib as its standard library (ish, there's also a Vala generic containers library called Gee) so you're not trying to collide the Java universe with the GNOME universe. It gives you most of the high-level stuff that C# gives you, except that you have to manage reference cycles yourself, and interfacing with native-code GObject libraries is very easy because Vala itself compiles to native code. It's a large part of why the official "default" language for GNOME is now JavaScript. JS sucks but at least it's just a programming language as opposed to a programming language with a gigantic compulsory standard library attached to it that duplicates a large chunk of the Gtk/GLib stack.
|
# ? Oct 28, 2013 17:25 |
|
Mr Dog posted:It's a large part of why the official "default" language for GNOME is now JavaScript. JS sucks but at least it's just a programming language as opposed to a programming language with a gigantic compulsory standard library attached to it that duplicates a large chunk of the Gtk/GLib stack. aren't the DOM and other browser APIs exactly that standard library for javascript? if you're using js outside of the browser, you're doing it wrong
|
# ? Oct 28, 2013 17:28 |
|
Mr Dog posted:Building anything on top of gtk/glib is loving stupid reminder: gnome only exists in the first place bc kde wasnt "free enough". then on top of that they decided to use c
|
# ? Oct 28, 2013 17:31 |
i was going to post "countdown until someone makes a loving javascript machine" but http://tessel.io
|
|
# ? Oct 28, 2013 17:32 |
|
Mr Dog posted:Building a desktop environment on top of Java or C# is loving stupid, the politics are just coincidental. Who are you and why do you know so much about GNOME? (Also, we're fixing a lot of the stupid boilerplate very soon)
|
# ? Oct 28, 2013 17:32 |
|
Just found this interesting article about PL history linked from Ryan North's blog.quote:Over and over again as I’ve dredged through this stuff, I kept finding programming constructs, ideas and approaches we call part of “modern” programming if we attempt them at all, sitting abandoned in 45-year-old demo code for dead languages. And to be clear: that was always a choice. Over and over again tools meant to make it easier for humans to approach big problems are discarded in favor of tools that are easier to teach to computers, and that decision is described as an inevitability. I don't actually agree with the article - it has a nasty tendency to go looking for facts that support its conclusion, find the opposite, and then blithely continue on claiming it was right on a technicality. (E.g., the yacht racing.) Probably worth reading only to argue with it, though. PleasingFungus fucked around with this message at 17:40 on Oct 28, 2013 |
# ? Oct 28, 2013 17:36 |
|
Somebody who spends too much time reading LWN and half of what I just wrote is probably wrong anyway. I don't work on GNOME in any capacity, I just like the ideas behind it, even if the implementation apparently leaves a lot to be desired from an application developer's perspective.
|
# ? Oct 28, 2013 17:36 |
|
Mr Dog posted:Somebody who spends too much time reading LWN and half of what I just wrote is probably wrong anyway. It was all correct. Do you have any feedback for us for app development?
|
# ? Oct 28, 2013 17:42 |
|
See above. I don't actually code anything GNOME-related. I'm planning to do something vaguely related sometime soon-ish, but what's the fun in doing something you enjoy when you can procrastinate on doing something you don't? keep doing what you guys are doing, I guess. Not everybody is a hater. I do hope GNOME re-finds some relevance in the future, because I don't think it entirely deserves the bad rap it's getting these days.
|
# ? Oct 28, 2013 17:45 |
|
Notorious b.s.d. posted:vala shouldn't even exist vala is not officially endorsed by gnome or anything like that. it was some guy's way to experiment with language design and it sort of became a thing that was pretty popular. some gnome people like it, some don't. i personally am not a fan. gobject-introspection is basically an automatic java-gnome / mono bindings generator, and java-gnome / mono now use it, along with pygobject (the replacement for pygtk) and gjs (the gnome/javascript hookup). it parses c code because the free software tools for extracting meaningful data from c are garbage. it also takes a bunch of annotations to give higher-level semantics to your c code.
|
# ? Oct 28, 2013 17:48 |
|
"C is just fine guys" *spend ten years frantically making bindings for and trying every language under the sun as replacement* lol gnome
|
# ? Oct 28, 2013 17:59 |
|
i wanna do some web dev in the best language (java) should i use play or is there something better
|
# ? Oct 28, 2013 18:04 |
|
Zlodo posted:"C is just fine guys" hey if people want to do that we ain't gonna stop them. i write c because it's just fine. yes you are correct that gnome not at all consistent in its technologies but its a project from like 500 people and 50 companies. all of them are engineers that all have spergy opinions on languages. we are trying to fix that but it's going to take a while. sheesh.
|
# ? Oct 28, 2013 18:08 |
rsjr posted:i wanna do some web dev in the best language (java) should i use play or is there something better stop trolling
|
|
# ? Oct 28, 2013 18:11 |
|
rsjr posted:i wanna do some web dev in the best language (java) should i use play or is there something better do it in asp.NET MVC4 instead. its way nicer.
|
# ? Oct 28, 2013 18:26 |
|
|
# ? May 23, 2024 15:25 |
|
rsjr posted:i wanna do some web dev in the best language (java) should i use play or is there something better java is bad. use php instead
|
# ? Oct 28, 2013 18:30 |