|
Munkeymon posted:Show us switch statement that can deal with greater than or less than and that would be a valid alternative. I submit, most languages can't handle this gracefully. On a completely unrelated note, I love C#'s ?? operator.
|
# ? Mar 4, 2011 19:16 |
|
|
# ? Apr 28, 2024 14:08 |
|
Hey, that sounds like a big timesaver! Then again, so did PHP when I was looking for my first job...
|
# ? Mar 4, 2011 19:18 |
|
The Reaganomicon posted:I submit, most languages can't handle this gracefully. code:
|
# ? Mar 4, 2011 19:21 |
|
Functional languages need not apply, they do everything gracefully.
|
# ? Mar 4, 2011 19:23 |
|
Munkeymon posted:Show us switch statement that can deal with greater than or less than and that would be a valid alternative. I'm OK with what GrumpyDoctor wrote and the only problem I would have with it is that I don't trust all other programmers to understand the ternary operator well enough to not accidentally gently caress it up. Several people I work with would be totally lost, for example. php:<? switch (true) { case 4 < 1: echo 'heads'; break; case 5 > 9: echo 'shoulders'; break; case 3 < 9: echo 'knees'; break; case 4 > 1: echo 'toes'; break; default: echo 'rear end'; } ?>
|
# ? Mar 4, 2011 19:31 |
|
The Reaganomicon posted:You would be the minority that likes using languages without a switch construct. Lua is quite popular Although it doesn't have the ternary operator, you can still use logic short-circuiting.
|
# ? Mar 4, 2011 19:39 |
|
The Reaganomicon posted:You would be the minority that likes using languages without a switch construct.
|
# ? Mar 4, 2011 19:40 |
|
yaoi prophet posted:
Does ML use semantic indentation like haskell or does everyone just line poo poo up because it looks better e: also does it make sense to learn OCaml directly if I have a kinda-sorta in at a place that uses it or should i LMAH (learn me a haskell) then make the (easy? i hope) haskell->ocaml transition
|
# ? Mar 4, 2011 20:35 |
|
Otto Skorzeny posted:Does ML use semantic indentation like haskell or does everyone just line poo poo up because it looks better White space is completely optional, afaik. Otto Skorzeny posted:e: also does it make sense to learn OCaml directly if I have a kinda-sorta in at a place that uses it or should i LMAH (learn me a haskell) then make the (easy? i hope) haskell->ocaml transition Christ, just do F# or something. OCaml is dead in the water.
|
# ? Mar 4, 2011 20:52 |
|
Of the 4 financials recruiting on my campus, 3 use ocaml and 2 use haskell, soooooooo
|
# ? Mar 4, 2011 20:57 |
|
OCaml will be easier to learn than Haskell if you are coming from a strict language background. You should still learn both, though; Haskell is fun.
|
# ? Mar 4, 2011 21:09 |
|
Yeah I ought to buy BONUS's book just out of principle anyways
|
# ? Mar 4, 2011 21:40 |
|
Munkeymon posted:Show us switch statement that can deal with greater than or less than and that would be a valid alternative. I'm OK with what GrumpyDoctor wrote and the only problem I would have with it is that I don't trust all other programmers to understand the ternary operator well enough to not accidentally gently caress it up. Several people I work with would be totally lost, for example. code:
|
# ? Mar 4, 2011 21:59 |
|
I was reviewing a buddy of mine's homework for an intro CS class I convinced him to take. He was asked to get a bunch of information from a '/' delimited string and store it an array. Since the class is taught with Java, the correct solution would have been String.split(). Instead he came up with this ugly workaround that made me laugh: code:
|
# ? Mar 4, 2011 22:21 |
|
I don't see the horror, this is a first year CS student who doesn't know the API.
|
# ? Mar 4, 2011 22:54 |
|
quote:Coding horrors: post the code that makes you laugh (or cry) Eggnogium posted:this ugly workaround that made me laugh: Not everything in this thread has to be straight from the demented mind of an enterprise Java/PHP veteran. I kinda like seeing the crazy ways new people solve problems, they are pretty creative (albeit in a terrible way).
|
# ? Mar 5, 2011 00:00 |
|
MEAT TREAT posted:I don't see the horror, this is a first year CS student who doesn't know the API. I remember doing my first exam in Java, with pen and paper ! One of the assignments was to take an arbitrary string, make it to lower case letters and then some other poo poo. Being a new (poo poo) programmer and not knowing or being provided with documentation telling me about toLowerCase(), I made a loop to iterate through the string character by character using nested if-elses for every letter in the alphabet all the way through the string because I couldn't remember how a switch worked. I got a 95% on that exam, with a comment about how most my code was horrible and slow as poo poo, BUT it worked It took the them 2 semesters to introduce us to patterns, which I think is a horror.
|
# ? Mar 5, 2011 00:15 |
|
ninjeff posted:What we really need to replace ternary operator chains is an inline switch like in SQL, though. code:
|
# ? Mar 5, 2011 00:17 |
|
I love that PHP broke me into this industry. I hate that breaking out of PHP will be so damned hard. I do have SOME python experience (commercial, too), but never enough to learn the real nature of it. Same for Java. I'm spending some of my own time re-learning these things, but without having commercial experience, I might as well be starting from scratch. Arse.
|
# ? Mar 5, 2011 00:24 |
|
zokie posted:It took the them 2 semesters to introduce us to patterns, which I think is a horror. Teaching CS in Java and introducing patterns at all are the real horrors
|
# ? Mar 5, 2011 00:42 |
|
zokie posted:I got a 95% on that exam, with a comment about how most my code was horrible and slow as poo poo, BUT it worked It took the them 2 semesters to introduce us to patterns, which I think is a horror. Our school starts with OCaml right off the bat. It's so cute watching 18 year olds come to grips with it and then ask in the most manner why things like PHP exist.
|
# ? Mar 5, 2011 01:28 |
|
The Reaganomicon posted:Our school starts with OCaml right off the bat. It's so cute watching 18 year olds come to grips with it and then ask in the most manner why things like PHP exist. Ah the naivety of youth. Answering those questions sounds like the perfect job for someone who likes crushing dreams.
|
# ? Mar 5, 2011 01:31 |
|
Otto Skorzeny posted:Yeah I ought to buy BONUS's book just out of principle anyways That's what I thought too. Even if I never get to use Haskell in a commercial setting, for all the fun I had reading his site I should really buy it. I was actually thinking about opening a thread for his book since he seems to be too modest to mention it... Links: http://oreilly.com/catalog/9781593272838/ <- Book http://learnyouahaskell.com/ <- Site
|
# ? Mar 6, 2011 10:26 |
|
We studied Haskell as our first language at uni (it was my first time programming as well). I was so happy when we made the transition to imperative programming. Seven years on and bits of the bible still give me trouble. I read it on the train every so often. I'm a software developer for a bank and I'm so happy we don't do functional programming. Wouldn't mind trying aspect-oriented on a proper production app.
|
# ? Mar 7, 2011 02:01 |
|
Milotic posted:I'm a software developer for a bank and I'm so happy we don't do functional programming. Wouldn't mind trying aspect-oriented on a proper production app. You're trolling, right? Or maybe you're just stupid. Edit: Yes, obviously dissing functional programming and mentioning aspect-oriented programming are the best ways to troll me. shrughes fucked around with this message at 05:04 on Mar 7, 2011 |
# ? Mar 7, 2011 04:50 |
|
code:
You see, I optimized the drawing (because native, i.e. OpenGl, calls are slow) by buffering all the edges of all the shapes into mDynamicBuffer and mStaticBuffer and then drawing them all with one OpenGl call. Except I drew them one at a time anyway and redrew the latest "other kind" of object with every object. The buffers are large enough to hold all the vertices of all the objects. That was their whole point. e: Moving the OpenGl code out of the loop tripled the frame rate. Wheany fucked around with this message at 13:07 on Mar 7, 2011 |
# ? Mar 7, 2011 13:04 |
|
shrughes posted:You're trolling, right? Or maybe you're just stupid. You sure do love calling people stupid when they don't agree with you 100%. Some people find it easier to think in relations of objects that do things, some people find it easier to think in formulas that manipulate numbers. White people drive like THIS, black people drive like THIS.
|
# ? Mar 7, 2011 16:16 |
|
NotShadowStar posted:White people drive like THIS, black people drive like THIS. (php programmers === asian people)
|
# ? Mar 7, 2011 16:22 |
|
Sure thing, nothing brings together disparate, warring entities like good old fashioned chink hating amirite!
|
# ? Mar 7, 2011 17:48 |
|
aspect orientated programming is for when you suffer trying to implement spaghetti code in normal oo
|
# ? Mar 7, 2011 18:00 |
|
NotShadowStar posted:Some people find it easier to think in relations of objects that do things, some people find it easier to think in formulas that manipulate numbers. im sorry about you`re brain damage
|
# ? Mar 7, 2011 20:28 |
|
The Reaganomicon posted:im sorry about you`re brain damage
|
# ? Mar 7, 2011 20:38 |
|
shrughes posted:You're trolling, right? Or maybe you're just stupid. Orzo fucked around with this message at 23:08 on Mar 7, 2011 |
# ? Mar 7, 2011 21:27 |
|
shrughes posted:You're trolling, right? Or maybe you're just stupid. Also, some ridiculous percentage (like 75-85%) of OCaml and Haskell programmers work in finance. It's like saying "I'm so glad I'm going to work in the games industry, so I don't have to write in C"
|
# ? Mar 7, 2011 21:30 |
|
Orzo posted:Are you serious here our are you just really out of touch with reality That's not an exclusive or
|
# ? Mar 7, 2011 22:58 |
|
Orzo posted:Are you serious here or are you just really out of touch with reality I am being serious. Milotic complained about how dumb he is. Which makes him seem stupid. [1] But then he seemed to rub it in by saying he wouldn't mind trying aspect-oriented programming. Which makes it seem like he's really just trolling. That's how I read it. [1] Actually, this doesn't make him seem stupid, since people who consider themselves stupid generally aren't that stupid. But then he mentioned aspect-oriented programming. Edit: also if you're exhibiting that sort of post-traumatic stress about functional programming, you have to be trolling or you have to be stupid. That's just the way objective reality is. Edit II: Fine, I'll concede that if it's theoretically possible for somebody to be smart and have problems with functional programming, then it's possible that Milotic is not stupid. Just ignorant. shrughes fucked around with this message at 01:54 on Mar 8, 2011 |
# ? Mar 8, 2011 01:41 |
|
Janin posted:He's implying that Haskell isn't imperative, so yes, he is But what percentage of developers in finance work in Haskell or OCaml?
|
# ? Mar 8, 2011 02:06 |
|
shrughes posted:I am being serious. Milotic complained about how dumb he is. Which makes him seem stupid. [1] But then he seemed to rub it in by saying he wouldn't mind trying aspect-oriented programming. Which makes it seem like he's really just trolling. I'm not a good functional programmer, but I'm a good object oriented programmer. I understand the basics of FP, but the part of the course where we had to write a maze-solving algorithm in it was not my finest hour. I've worked with aspect oriented programming in the past, but never on a production system. I can see it being useful to solve spaghetti code, or a specific instance where you have a model but the view is composed of several user controls. Janin posted:He's implying that Haskell isn't imperative, so yes, he is For your first point, I believe this thread has had that discussion in the past. I am sure you can do wonderful things with monads, but Haskell is not a conventional imperative language. Page 325, second edition of "Introduction to FP using Haskell" says: quote:In a sense, monadic style enables one to write functional programs that mimic state-based computation,...that mimic imperative programs, those programs constructed in imperative languages such as Pascal and C For your second point, the vast majority of developers in the finance sector don't do either Haskell or OCaml. That wasn't my point. My point was more like "I work in the games industry, but I'm happy I don't do Silverlight based mobile apps". Haskell is a niche. An incredibly lucrative niche, but a niche.
|
# ? Mar 8, 2011 02:08 |
|
Milotic posted:For your first point, I believe this thread has had that discussion in the past. I am sure you can do wonderful things with monads, but Haskell is not a conventional imperative language. Page 325, second edition of "Introduction to FP using Haskell" says: Functional/stateful is a matter of execution model. Functional languages are based on the lambda calculus, whereas stateful languages are based on the Turing machine. Even when using it for imperative code (eg, systems programming), Haskell is a functional language. Any tutorial/introduction/book about Haskell that doesn't explicitly mention using it as an imperative language (as a replacement for C) is terribly incomplete. For example, I've never even heard of the book you linked as a "bible", and if it was published in 1998(!!) then it's basically worthless for all intents and purposes. I mean, gently caress, that means it was written before Haskell had modules! Throw that poo poo out. If by "finance sector" you mean anyone employed by any financial company, then sure -- most of them are probably using something like COBOL or Java. But if you mean people actually involved in writing finance-related code, almost all of it will be in some sort of functional language. Whether that's ML, OCaml, Matlab, R, Haskell, doesn't really matter.
|
# ? Mar 8, 2011 02:37 |
|
|
# ? Apr 28, 2024 14:08 |
|
Yeah, I did a full year of Miranda in university (good lord so old, don't even think it's in use any more) to get my introduction to FP. I'd already taught myself Turbo Pascal and ANSI C at that point (oh man it gets even older) in high school, and man did I hate Miranda at first. However after the first quarter or so it was pretty neat how it made you think differently. I think I "got it" when I had to make a roman numeral parser/displayer and realized that the old way of planning it out was just plain wrong. That said, I look at the programming I do now, day in and day out, and just don't see how FP would do it. I can bet that the stuff it can do well is pretty awesome (which, I'm guessing would involve pure math and analytics), but tweaking web layouts, database massaging, file parsing, etc. doesn't seem to fit the bill. Which leads me to a question; has anyone been exposed to both Miranda and Haskell and can tell me how similar they are? Wikipedia says 'very similar' but doesn't really give specifics, but I'd be curious to know how much changeover would be involved if I wanted to pick up Haskell based solely on my Miranda exposure (I got to be pretty good at it at the end).
|
# ? Mar 8, 2011 02:40 |