So I herd games in Haskell were impossible

Discussion in 'Off Topic' started by MOOtant, Jun 24, 2011.

  1. MOOtant

    MOOtant Member

    Messages:
    4,047
    Likes Received:
    0
    Trophy Points:
    0
  2. Empty

    Empty Member

    Messages:
    14,912
    Likes Received:
    11
    Trophy Points:
    0
    wow new empires looks so good.
     
  3. w00kie

    w00kie Mustachioed Mexican

    Messages:
    3,863
    Likes Received:
    13
    Trophy Points:
    0
    OMG, I bet u either need a quadcore and dx11 or a pentium3.
     
  4. f1r3w4rr10r

    f1r3w4rr10r Modeler

    Messages:
    2,475
    Likes Received:
    4
    Trophy Points:
    0
    i still dont like procedural programming languages
    its just not the way i like to think :/

    and i already saw a quake like shooter made in haskell btw
     
  5. RappemongO

    RappemongO Member

    Messages:
    446
    Likes Received:
    2
    Trophy Points:
    0
    Lol, stunts. That wasn't yesterday. :)

    Does it still have the bug where your car would go zooming a million miles an hour in a random direction when you crashed while going real fast?
     
  6. MOOtant

    MOOtant Member

    Messages:
    4,047
    Likes Received:
    0
    Trophy Points:
    0
    It's not related to Stunts that much. It's a port to Bullet physics engine. I have no idea how original Stunts did car physics. Probably far more simplified.

    They have tracks from Stunts imported and that's pretty much it. If you download it you'll notice it handles more like GTA4 than Test Drive 3/Stunts.
     
  7. McGyver

    McGyver Experimental Pedagogue

    Messages:
    6,533
    Likes Received:
    31
    Trophy Points:
    0
    What advantages do procedural languages have over OO?
     
  8. f1r3w4rr10r

    f1r3w4rr10r Modeler

    Messages:
    2,475
    Likes Received:
    4
    Trophy Points:
    0
    dont ask me
    ask mootant

    i just used haskell at university and hated it (perhaps because i learned coding in OO languages before)
     
  9. MOOtant

    MOOtant Member

    Messages:
    4,047
    Likes Received:
    0
    Trophy Points:
    0
    There is so much more than C/procedural and C++/object-oriented.

    http://www.info.ucl.ac.be/people/PVR/paradigmsDIAGRAMeng101.pdf

    I know it'll end up as a huge rant but whatever. C++ advocates (who kind of fit early 90s, somehow they're still out there) tell you how C++ is better than C because it has OO, better than Java because it gives more access, better than high-level languages because after raping the language they can get kind of similar result (make 1 error and you get 50 screens of template errors) and how it's close to hardware. Since C++ is so close to C that in some cases you start to wonder why you chose C++ in the first place, they have to make themselves distinct. If people use C strings (N bytes ending with byte of value 0, so called \0 (NUL)) they promote versions that only C++ has as morally better (C strings are evil they say). Why? Because C++ doesn't have a garbage collector and it has exceptions which means memory leaks unless everything is packaged carefully into objects. That includes null-terminated strings.

    There are 2 advocated workarounds (sometimes even called as proper solutions) for lack of garbage collector:
    - using reference counted objects, which goes tits up in multithreaded scenario or when there are cycles between objects
    - adding garbage collector to C++, but because C++ doesn't expose appropriate roots only conservative garbage collectors can be used

    When it comes to abstraction I asked one question on #c++ once. How do I make a function that is function composition? Everyone who had derivatives remembers notation like f(g(x)) = f o g. In our case we want that o, which is a function that takes function f :: B -> C and g :: A -> B and makes f o g :: A -> C. Everyone was so clueless as in why would I ever want to do that it required a person who can read functional code to get the idea. The not so beautiful answer is to write a template function like:
    Code:
    template <typename F, typename G, typename A, typename Ret>
    Ret composition( F f, G g, A a)
    {
    return f(g(a));
    }
    
    I don't remember the details but it'd be similar to this.

    C++ compilation model is absolutely terrible. Good few years ago I had K6-2 350MHz and computers we had in the class were not that much better. So I wrote some stuff in C++, the recommended C++ with gcc. I used Dev C++. I wrote Hello world and I started to wonder: why the hell had it compiled so slowly? Since I had been really crappy programmer at that time I was just guessing it had to be gcc/Dev C++ fault. A bit later I compared how long it took to compile C++ hello world using C facilities and C++ ones. C++ ones took like 20x longer to compile because every compilation unit included megabytes of text describing basic libraries required to write stuff to screen, open files and so on. Not just included as in "hey, here's this, this and that". No, that'd be far too smart for C++'s design. It parses it, analyzes validity and generates final x86 code for every thing in it. Every compilation unit that you have will do it from scratch. All this compiled code gets thrown away later, only 1 version of it goes into final executable that you ship. People have found workarounds like getting 16 core machines but it's not enough. Because internal details like memory layout cause recompilation, you have to recompile every thing that touches the component if you changed tiny internal, hidden part of it.

    Because people switched to C++ around 90s and insanely huge amounts of code were written in it, compilers are really good at generating fast code from C++ source. But here comes the fun part: C++11 that is getting advertised as solution to threading problems with its memory model doesn't solve any real problem. Lots of things from that standard are already implemented but I haven't seen a single compiler fully implementing C++ memory model. You can sum up it as taking a shared memory computer (RAM + several cores) and pretending it's just flat memory with no additional cores, caches or whatever hardware manufacturers invent. Since these caches and cores exist in reality programmers have to be given a world where fewer "obvious" things are true. There are also people attacking problem from other direction, for instance Haskell. No one pretends that computer today is one big blob of instantly accessible memory. They give islands of "memory" that can communicate with each other. There are several methods of communication and several methods of executing code concurrently. They have already successfully done what is believed to be impossible in C++/.NET - software transactional memory. While in C++ world extremely talented people are struggling to make what standard says, Haskell people are far ahead and already have it working, they promised less but they delivered it.

    There's also Stroustrup having no experience while designing C++ and its consequences. Since lexing, parsing and semantical analysis are coupled together (which no properly designed language ever does) you can't have refactoring tools that are widely available for C#, Java and other languages.

    After this short introduction I have to say that there are many things that you can call procedural and many that can be called object-oriented. No comparison makes sense without going into details of what exactly do you have in mind.

    CMU announced they'll stop teaching object-oriented programming because it's unprofessional from engineer point of view. To have guarantee about correctness you either have to program imperatively with loop invariants or functionally with structural induction. Sure, you can mix objects with invariants (object invariants, pre, post, invariants within specific functions) but then objects feel like icing on the cake.

    I don't have anything against C++ when it comes to successful, well-written libraries. Whole Source is incredibly well-written, mostly by people immune to "good C++" constructs advocacy. Bullet is also a good library. Nice enough that you can bind it in C or even directly wrap from Haskell and use it just fine. Having said all of that C++ is really damn useful. That doesn't mean it's without huge flaws. For new software that is close to hardware I prefer C with no global variables, all functions operating on "objects". That type of libraries are easy to mix with not only C++ but also real high-level languages.

    fw: I have heard (and seen one case) of people who were good at math, never programmed, went to university and started from things like SML/Ocaml, Haskell. I can tell you that this girl that followed that path can "outcode" 90% people around here.
     
    Last edited: Jun 26, 2011
  10. Chris0132'

    Chris0132' Developer

    Messages:
    9,482
    Likes Received:
    0
    Trophy Points:
    0
    I really like the logic of OO programming, it just always made a lot more sense to me having everything so categorised, it's why I like 3ds max as a modelling tool as well, modifier stack appeals to me in the same way, because you have an object, then sub-modifiers of that object, and so on. Same with photoshop's layer system, very powerful and if you keep in mind how you built something up, you can go back at any point and tweak something further back to create the desired affect at the end. I really liked the idea of building a library of objects which you can expand upon and reference as neccesary, it's the most efficient workflow I've found in all applications I've used.

    But then I never really did any other types of programming, and never enough to know which is technically better. Only that I like the conceptual approach a lot.
     
  11. MOOtant

    MOOtant Member

    Messages:
    4,047
    Likes Received:
    0
    Trophy Points:
    0
    You can model as objects/classes in conceptual UML model and then implement it as SQL tables.

    Notice how you described that 3ds way of functioning isn't some weird object but it's a stack of modifiers, each "passing" modified mesh to higher one. Photoshop layers aren't some hidden object either. They form a tree of things that are blended together. That's very declarative while OO tends to grow out of things like i := i + 1 and keeps some part of the object hidden from the world.
     
  12. f1r3w4rr10r

    f1r3w4rr10r Modeler

    Messages:
    2,475
    Likes Received:
    4
    Trophy Points:
    0
    thats my point too
    i never got that deep into it to really worry about the problems mootant spoke about

    its just that i dont like the "interface" and workflow haskell offers
     
  13. MOOtant

    MOOtant Member

    Messages:
    4,047
    Likes Received:
    0
    Trophy Points:
    0
    fw: think about it from other direction. Assume you haven't ever heard of C/C++/Java. When you start programming in C you learn that x = x + 1 is valid expression. That means that you're unlearning equational reasoning that you've been learning for years in school.

    I don't know how practical it is for any of you but I was convinced once I saw friend making whole compiler in only 2000 lines.
     
  14. Chris0132'

    Chris0132' Developer

    Messages:
    9,482
    Likes Received:
    0
    Trophy Points:
    0
    Yeah x=x+1 doesn't really make much sense equationally, because = doesn't mean = in C, it means 'is now set to', loses the bi-directionality that = is supposed to have.

    I mean the C usage of = does make sense, but it is contradictory to general algebra and whatnot. If you had a programming language that obeys proper mathematical rules, that'd be interesting certainly. I imagine it would make it rather powerful. Although I never did much maths either so I couldn't really tell you what it'd be useful for.
     
  15. f1r3w4rr10r

    f1r3w4rr10r Modeler

    Messages:
    2,475
    Likes Received:
    4
    Trophy Points:
    0
    and there is the point
    math was my worst subject at the university xD
     
  16. Solokiller

    Solokiller Member

    Messages:
    4,861
    Likes Received:
    7
    Trophy Points:
    0
    I'm starting a bachelor in applied informatics next year, they originally had an optional C++ course, but they replaced it with 3D computer graphics since it wasn't really appealing to students much. They mainly use Java for teaching OO programming, and cover assembly as well.
     
  17. McGyver

    McGyver Experimental Pedagogue

    Messages:
    6,533
    Likes Received:
    31
    Trophy Points:
    0
    Thanks Mootant, that was certainly an interesting read (Although i only understood half of it).

    I learned C first at university and now (basics of) C++ and i absolutely prefer the C approach, maybe because it gives me a better overview about what is actually going on. Hate those C++ programs that only have one line of code actually doing something (e.g. creating a new object) in their main. Nevertheless almost every professor i asked recommends C++, because of better maintainability and supposedly it makes coding in a team easier. I wonder if the faults of C++ are necessary trade-offs or just coming from bad design.

    As for the math geniuses that program better than anyone else: I also noticed this correlation of maths and coding skills when i worked together with math students. They aren't even interested in programming and still exceptionally good at it...:s
    To me, writing a program is more like writing an essay or something and has not much to do with mathematics , maybe this will change if i delve deeper into it.
     
  18. Beerdude26

    Beerdude26 OnThink(){ IsDownYet(); }

    Messages:
    7,243
    Likes Received:
    13
    Trophy Points:
    0
    That's what Haskell is

    The language even has transformation rules that stem from this, so you can transform a certain piece of code into another (usually making it simpler or easier to understand) while retaining exactly the same functionality
     
  19. MOOtant

    MOOtant Member

    Messages:
    4,047
    Likes Received:
    0
    Trophy Points:
    0
    I finally set vertex array object properly and got this:

    [​IMG]

    I know I shouldn't measure perf without load but 1200 frames/s still seems kind of low.

    It shouldn't take a lot of time to finish SMD parser and start displaying Empires models (even if all having just 1 color, without textures at first).

    UPDATE:
    I got to a bit nicer FPS - 1600. That's Linux x86_64 binary using native code gen. GCC code gen gets the same amount. Latest LLVM changed a bit and fails to run so I can't test that. I'd be surprised if Haskell were more than 10% slower than C while keeping GCable object count low.
     
    Last edited: Jul 1, 2011
  20. Empty

    Empty Member

    Messages:
    14,912
    Likes Received:
    11
    Trophy Points:
    0
    I'm loving Empires 2's art style.
     

Share This Page