Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 4 5 [6] 7

Author Topic: What programming language?  (Read 17877 times)

Thief^

  • Bay Watcher
  • Official crazy person
    • View Profile
Re: What programming language?
« Reply #75 on: May 16, 2010, 05:42:57 am »

C++0x (technically should be c++1x by now, as c++ version are named after the year) has lambda expressions, and Intel's compiler already supports them. Intel already use them in their "TBB" parallelization library, which is truly awesome.
Logged
Dwarven blood types are not A, B, AB, O but Ale, Wine, Beer, Rum, Whisky and so forth.
It's not an embark so much as seven dwarves having a simultaneous strange mood and going off to build an artifact fortress that menaces with spikes of awesome and hanging rings of death.

darius

  • Bay Watcher
  • ^^
    • View Profile
Re: What programming language?
« Reply #76 on: May 16, 2010, 05:48:33 am »

C++0x (technically should be c++1x by now, as c++ version are named after the year) has lambda expressions, and Intel's compiler already supports them. Intel already use them in their "TBB" parallelization library, which is truly awesome.
Gnu compiler also supports C++0x and boost libraries have (had) lambda expresions for a while now, but they're kinda hackish (as everything in c++ using templates).
Logged

Symmetry

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #77 on: May 16, 2010, 06:34:23 am »

VisualStudio 2010 supports lamdas and some of C++0x too, the free express edition is out now.  Far superior to the blocks Apple invented.

At least one of the "C++ Sucks for game development" talks at GDC was speaking about memory layout.  There just isn't a language that allows you to arrange memory in the fastest way at the moment, memory layout for cache purposes seems to be an optimisation that has been totally ignored despite the slowness of memory reads.  The best you get is caching in registers.  C macros (ugh) or C++ with (insanely complicated) template metaprogramming can sort of help the programmer, but we really need a compiler designed for stream processing.  I guess implementing it as a meta language in D would work well.

It makes me sad that we won't get .lua versions of the .raw files.  I'd always hoped it would happen one day.
Logged

FACM

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #78 on: May 16, 2010, 09:26:10 am »

At least one of the "C++ Sucks for game development" talks at GDC was speaking about memory layout.  There just isn't a language that allows you to arrange memory in the fastest way at the moment, memory layout for cache purposes seems to be an optimisation that has been totally ignored despite the slowness of memory reads.  The best you get is caching in registers.  C macros (ugh) or C++ with (insanely complicated) template metaprogramming can sort of help the programmer, but we really need a compiler designed for stream processing.  I guess implementing it as a meta language in D would work well.

OK, I'm a programmer, and I've never really heard of this complaint before, at least not at this level. RAM isn't like a hard drive, the actual location of data in a RAM chip isn't going to take longer to access. If you mean searching for objects in memory, then hash tables are about the fastest way (that I know of, at least) to look things up at the cost of using up a bit more memory and CPU power.

The only actual bottleneck I'm aware of as far as RAM goes is the pagesize, which on most OSes is 4KB. That means that to load a 1MB object, the underlying system has to do 250 checks to see if a page is in RAM, and 250 reads, a best-case assuming that it doesn't have to load anything from the hard drive. An OS that uses 2MB pages, which is apparently starting to happen, can do the same check in 2 checks max, if the data happens to cross the page boundary. I don't think this is something that is under control by anything besides the OS handling RAM access, and I don't think it's a major deal for games in general anymore than any other type of application. Unless hard drives have had exponential speed boosts lately, 250 RAM accesses is still faster than 1 HD access.

I might be a little bit behind on this, since I've been doing .NET programming that handles a lot of memory stuff automatically and haven't gotten into much theoretical work since college graduation.
Logged

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: What programming language?
« Reply #79 on: May 16, 2010, 09:51:49 am »

He's talking about CPU cache optimizations, which can give you.. oh.... maybe another 5% speed boosts, at an immense cost in programming time. Considerably more than that in some specialized cases, but it's generally not worth worrying about.

(To my surprise, when I discussed this with Toady a while ago, it turned out that the DF map data structures were already about as optimized to fit in typical caches as it was likely to get. By sheer accident.)
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

NoahTheDuke

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #80 on: May 16, 2010, 10:10:07 am »

Baughn: that's pretty hilarious. Good on him, though. One less thing to worry about, wrt speed.

Noah
Logged

Inspiration

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #81 on: May 16, 2010, 10:41:03 am »

Use BASIC. It's an extremely versatile language with endless possibilities. It's name was a huge typo.
Logged

KoFish

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #82 on: May 16, 2010, 10:46:53 am »

You really should consider learning proper C to begin with instead. C++ is nice but it's alot harder to do correct then C is.
But C will teach you things that are a bad idea to do in C++.
It's true that C++ overall is a more complex language, but it provides many more safety mechanisms when used correctly.

You should never learn a language based on how much it corrects your mistakes.
Logged

unperson

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #83 on: May 16, 2010, 11:41:31 am »

Do you guys think its good idea for a complete beginner in programming to start with C#?
Logged

Baughn

  • Noble Phantasm
  • The Haruhiist
  • Hiss
    • View Profile
Re: What programming language?
« Reply #84 on: May 16, 2010, 12:04:48 pm »

You should never learn a language based on how much it corrects your mistakes.
Why ever not?

Probably the largest advantage of Haskell is how well its compiler catches mistakes. In no other language could I write a four-thousand-line program and have it work the first time it compiles.
Logged
C++ makes baby Cthulhu weep. Why settle for the lesser horror?

Symmetry

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #85 on: May 16, 2010, 12:15:19 pm »

He's talking about CPU cache optimizations, which can give you.. oh.... maybe another 5% speed boosts, at an immense cost in programming time. Considerably more than that in some specialized cases, but it's generally not worth worrying about.

Specialised cases like game engines :)  With 400+ cycles for a main memory access and 4 for L1 cache you can gain two orders of magnitude.  If the technique is appropriate to the problem then this isn't that unusual to see in practice.
On consoles the CPUs have no instruction reordering and are much worse at prefetching, so you can gain a lot more with manual cache optimisation.

I disagree with you saying 5%, this kind of thing is too sensitive to the problem domain for a number like that without context to be meaningful.

This is one article that touches on the subject
http://gamesfromwithin.com/data-oriented-design
Logged

jfs

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #86 on: May 16, 2010, 12:29:31 pm »

He's talking about CPU cache optimizations, which can give you.. oh.... maybe another 5% speed boosts, at an immense cost in programming time. Considerably more than that in some specialized cases, but it's generally not worth worrying about.

Specialised cases like game engines :)  With 400+ cycles for a main memory access and 4 for L1 cache you can gain two orders of magnitude.  If the technique is appropriate to the problem then this isn't that unusual to see in practice.
On consoles the CPUs have no instruction reordering and are much worse at prefetching, so you can gain a lot more with manual cache optimisation.
Then of course if you know the CPU has SSE you can use the PREFETCH instructions. I don't think I need to elaborate on its purpose.
Logged

NoahTheDuke

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #87 on: May 16, 2010, 12:38:26 pm »

Do you guys think its good idea for a complete beginner in programming to start with C#?

C# is a fine programming language. It's like java,  but with access to the xna, which is totally sweet, but sadly windows-centric. Still totally worth it.

Noah
« Last Edit: May 16, 2010, 12:43:22 pm by NoahTheDuke »
Logged

FACM

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #88 on: May 16, 2010, 12:51:14 pm »

Thanks Baughn, I didn't realize he was referring to CPU cache memory specifically. 400 CPU cycles on a modern 2GHz processor is what, 20ns?

Do you guys think its good idea for a complete beginner in programming to start with C#?

I think so. It's got everything you'll need to get the concepts of lower-level languages, it's syntax mimics that of the C family, if you're on Windows it's very easy to handle a GUI with, and it's freely available to anyone that doesn't mind the nag-box that C# Express adds into your developed programs. XNA is also freely available, which helps a little bit by simplifying down all the DirectX calls into something more intuitive and focused. I wouldn't expect any major titles to be done with C#, but it's certainly fine for learning.

« Last Edit: May 16, 2010, 12:54:02 pm by FACM »
Logged

Black

  • Bay Watcher
    • View Profile
Re: What programming language?
« Reply #89 on: May 16, 2010, 01:02:22 pm »

AI War is an indie RTS that is written in C#. It's pretty fun/awesome/successful too.
Logged
Pages: 1 ... 4 5 [6] 7