|
FrantzX posted:
Ah! C# does have yield! I was curious if it did or not because it seems like the kind of language that would. Cool.
|
# ? Dec 21, 2013 05:20 |
|
|
# ? Jun 5, 2024 21:37 |
|
FrantzX posted:
code:
|
# ? Dec 21, 2013 05:43 |
|
Jewel posted:So technically it's exactly the same as what you do in every other language. What other languages have a feature like "yield", also? I never really noticed it in anything else, or if I did I forgot. Lua does, as part of coroutine support: code:
|
# ? Dec 21, 2013 05:53 |
|
Jewel posted:Python has that code:
|
# ? Dec 21, 2013 06:11 |
|
b0lt posted:
You can replace the Indexed<T> with Tuple<int, T> but C# doesn't have language support for tuples or pattern matching C# code:
|
# ? Dec 21, 2013 06:52 |
|
Opinion Haver posted:What are these strange 'for loops' of which you speak? 1. readable
|
# ? Dec 21, 2013 07:15 |
|
FrantzX posted:
|
# ? Dec 21, 2013 08:18 |
|
fritz posted:1. readable code:
|
# ? Dec 21, 2013 09:05 |
|
Why would you read the parameters before the function name, though?
|
# ? Dec 21, 2013 09:27 |
|
Freakus posted:I don't know if it can work, but I've always thought programming languages would be more readable if functions came after their parameters, rather than the current method where it's before. Then I wouldn't have to read right to left as often. E.g.: Have you seen the wonders of Forth?
|
# ? Dec 21, 2013 09:38 |
|
Freakus posted:I don't know if it can work, but I've always thought programming languages would be more readable if functions came after their parameters, rather than the current method where it's before. Then I wouldn't have to read right to left as often. E.g.:
|
# ? Dec 21, 2013 10:54 |
|
Opinion Haver posted:What are these strange 'for loops' of which you speak? That is a coding horror (or at least a little goosebumpy). Use forM_ and indentation! code:
|
# ? Dec 21, 2013 12:02 |
|
code:
code:
gonadic io fucked around with this message at 14:36 on Dec 21, 2013 |
# ? Dec 21, 2013 14:05 |
|
code:
|
# ? Dec 21, 2013 14:31 |
|
AlsoD posted:
Wow. So you can iterate over an iterable and also their indexes and perform some effectful computation on them (in other words, print them). Crazy poo poo indeed, my man.
|
# ? Dec 21, 2013 15:25 |
|
Scaevolus posted:Have you seen the wonders of Forth? In particular if you guys are interested in manipulating lazy sequences and creating functional pipelines you might find this post worth reading.
|
# ? Dec 21, 2013 15:28 |
|
hint: if your functional language supports a fold idiom you're able to provide that mechanism in one line, no matter what:code:
code:
or (foreach-i (lambda (i term) WHATEVER) LIST) whether someone decided to add this to the standard library or not decides whether you can feel smug in the last 2 pages I guess.
|
# ? Dec 21, 2013 15:48 |
|
The sad thing is that this is literally the only worthwhile thing about PHPcode:
|
# ? Dec 21, 2013 17:05 |
|
Freakus posted:I don't know if it can work, but I've always thought programming languages would be more readable if functions came after their parameters, rather than the current method where it's before. Then I wouldn't have to read right to left as often. E.g.: Clojure has the -> macro (and its relatives ->> some-> some->>), which does exactly this. Rather than writing h(g(f(x))) (Java) or (h (g (f x))) (Clojure), you can write (-> x f g h), which is, a lot of the time, much more readable. The best part is that it works on method calls too, so something that would be expressed in Java as h(f(x).g()) and thus needs to be read in both directions at once becomes (-> x f .g h). The some variants check for nil on each stage of the pipeline and return nil immediately, which means you can write the equivalent of h(g(f(x))).toString() as (some-> x f g h .toString) and if any of those functions or methods returns nil, the whole expression will return nil rather than throwing NullPointerException.
|
# ? Dec 21, 2013 17:11 |
|
ToxicFrog posted:Clojure has the -> macro (and its relatives ->> some-> some->>), which does exactly this. Rather than writing h(g(f(x))) (Java) or (h (g (f x))) (Clojure), you can write (-> x f g h), which is, a lot of the time, much more readable. I read your post and wondered why it was a macro, and the reason is a nice thing you didn't mention: if the forms after x are lists then it puts x as the first argument, so eg (-> 1 (list 2 3)) expands to (list 1 2 3). That's really convenient.
|
# ? Dec 21, 2013 17:49 |
|
The ML family usually has an operator like |> (or you can easily write it) that lets you make something that looks like a pipeline:code:
|
# ? Dec 21, 2013 18:19 |
|
Mustach posted:The ML family usually has an operator like |> (or you can easily write it) that lets you make something that looks like a pipeline: I haven't used those languages so I can't say for sure, but I don't agree that throwing more code in always makes something more readable. I could see this sort of thing being very readable if you were, say, transforming a point: code:
|
# ? Dec 21, 2013 18:45 |
|
Oftentimes, you don't even need new variables. In that case I would probably rotate x, invert x, and scale x in three steps.
|
# ? Dec 21, 2013 18:48 |
|
AlsoD posted:This all seems like stockholm syndrome for languages where anything could implicitly and silently be null. It depends on how comfortable you are with nullable database columns, where in a result set, any or all of the values could be null, no big deal.
|
# ? Dec 21, 2013 18:55 |
|
Mustach posted:Oftentimes, you don't even need new variables. In that case I would probably rotate x, invert x, and scale x in three steps. That works if the functions mutate x, but if they return a new value then you have to do x = rotate(x, 45) etc. or x = scale(invert(rotate(x, 45)), 6). They're both less readable (again, IMO), the first just because it's ugly and the second because now you have to read backwards. Sometimes I like terseness because it makes it easier to chunk things mentally. If you read that single line you can easily see what's happening at a glance, but when you break it up it takes a bit longer to figure out what's happening because it's not immediately clear that the code forms a conceptual unit until you read it all. It's only a slight difference of course but I find it helps. It's just important to distinguish between terseness that makes things clearer and terseness that obscures.
|
# ? Dec 21, 2013 19:00 |
|
vv I find x = rotate(x,45) very nice. C'est la vie.
|
# ? Dec 21, 2013 19:04 |
|
PHP has a shorthand version of the ternary operator for that, so you can do: PHP code:
|
# ? Dec 21, 2013 19:11 |
|
Deus Rex posted:Wow. So you can iterate over an iterable and also their indexes and perform some effectful computation on them (in other words, print them). Crazy poo poo indeed, my man. You can also nest the iteration arbitrarily deeply or even have it write the traversal for you! code:
code:
|
# ? Dec 21, 2013 19:31 |
|
https://plus.google.com/+GregorJRothfuss/posts/HnMp8JTurF2quote:Turns out that 18 years ago, PHP had about 100 functions. The function names got put in a hash map. The hash function chosen? Strlen. Thus, the function names were chosen so the hash collisions would be minimized (by creating a uniform distribution of function name length). Which means the origin of all those insane and inconsistent names in PHP is even worse than I'd always thought.
|
# ? Dec 21, 2013 19:41 |
|
Mother of god... I'm so thankful this holiday for not having to use PHP.
|
# ? Dec 21, 2013 21:35 |
|
Pee pee doo doo it is a bad language.
|
# ? Dec 21, 2013 21:46 |
|
Does anybody here notice a culture change when working with engineers in Mexico? I'm finding them to have a very strong attitude that their poo poo doesn't stink and my stuff is terrible, even without them having heard of it or looked at it. It's kind of hard to support a team over there when they're hostile to you from the get-go. I kind of wonder if I just need to throw on some macho and try not to be too modest. It's kind of a lovely question to be asking, but from seeing some of cultural factors towards working with code with Indians, to have full-duplex conversations* with Israelis, I wonder if there's just a cultural thing here. *At least the ones I run into just start talking over you like a bulldozer every time you open your mouth. After watching them talk to each other for awhile, I just figured out they all just talk at the same time to each other (full duplex) instead of taking turns (half-duplex). I still think it's rude but I know to just keep going, but I haven't quite figured out how to dart back and forth between what they're saying and what I'm trying to say. The world is a strange place.
|
# ? Dec 21, 2013 21:52 |
|
It's definitely the machismo. Are they the contractors or are you the contractor? If it's the former, then you have precedence over them. Dickheads like those don't respond to anything except acting like you have the bigger set of balls.
|
# ? Dec 21, 2013 22:30 |
|
Pollyanna posted:It's definitely the machismo. Are they the contractors or are you the contractor? If it's the former, then you have precedence over them. Dickheads like those don't respond to anything except acting like you have the bigger set of balls. Why are you posting like you know what you're talking about?
|
# ? Dec 22, 2013 00:23 |
|
Practise what you preach, I guess.
|
# ? Dec 22, 2013 00:24 |
|
Bruegels Fuckbooks posted:Why are you posting like you know what you're talking about? Yep, you're not terrible, but theres many conversations where you'd be better of listening and learning.
|
# ? Dec 22, 2013 00:30 |
|
Rocko Bonaparte posted:Does anybody here notice a culture change when working with engineers in Mexico? I'm finding them to have a very strong attitude that their poo poo doesn't stink and my stuff is terrible, even without them having heard of it or looked at it. It's kind of hard to support a team over there when they're hostile to you from the get-go. I kind of wonder if I just need to throw on some macho and try not to be too modest. It's kind of a lovely question to be asking, but from seeing some of cultural factors towards working with code with Indians, to have full-duplex conversations* with Israelis, I wonder if there's just a cultural thing here. http://xkcd.com/385/
|
# ? Dec 22, 2013 00:33 |
|
Oh god not this, argue about type coercion some more.
|
# ? Dec 22, 2013 02:26 |
|
Well I had a feeling I'd get negative responses so I'll grab the shovel and try to dig some more; whether or not I dig myself out or dig myself deeper is something we'll figure out. Generally where I work, I am not always certain of where somebody is when I'm first corresponding with them. I can go out out of my way and find their geographic location, although I usually don't. And in all cases, culture does take second place to management, and this organization's manager is pretty shady. I'm pretty sure he's hostile to us since he wanted to do all the work himself and build himself up a whole bunch. If we're talking about code quality, the code I've seen of theirs is indeed crap, but it follows a specific model that one regular old US white guy likes to do. So just from what that guy has done and proliferated, I have to be real humble about Americans. My angle was that when interacting with different cultures I have had to take different tact some times, depending on the circumstances. If I'm working with Indians working in India, I have to find clever ways to figure out what they don't know, because they try to cover it up very well. It's frustrating when it's domain specific knowledge they wouldn't know in the first place, like me trying to show them how to use something I made for them. So I have found prompts and ways to ask about their situation, and how what I'm explaining might affect it, to make sure they understand. Otherwise, they just don't do anything. The Israeli tact is that when I'm on the phone with them or in person, I just keep talking if I have to make a point, and not get butt-hurt about being interrupted. So with this group in Mexico I'm trying to figure out if I need to find a tact with them to try to subdue what I think is hostility, or if their manager is just a dick and it's contagious--it wouldn't be the first time.
|
# ? Dec 22, 2013 03:54 |
|
|
# ? Jun 5, 2024 21:37 |
|
Gazpacho posted:Oh god not this, argue about type coercion some more. Somebody post about a language feature so we can all post about how to twist our favourite language into doing it.
|
# ? Dec 22, 2013 04:57 |