[QUOTE=andrewmcwatters;47717935]any time i see a "strength" of c# its almost always a strength of .net[/QUOTE]
Right now I can think of two advantages of C# over C++ that are purely about the language:
No headers
No need for forward declaration
That does it for me.
But I still use and somewhat like C/C++, there's no way i can avoid it as a Computer Engineering student.
I spent this week doing 3D-scanning. Basically I made a program that computes a point cloud out of an object that a robot scans with a laser. That was the simple part.
The difficult part was making the program that calibrates the scanner. Given an object with a known shape, I can now compute the calibration parameters that correct the rotation, translation and some other things so that the scanned results match the model.
All the equations turned out to be many times easier once I realized that I could define for each point on the known shape a coordinate system where points on the surface would have Z=0, instead of using an arbitrary coordinate system.
[QUOTE=thrawn2787;47719138]Not to mention some .NET stuff (well, some basic interfaces / classes) is engrained into the language. Like Nullable and IEnumerable.
Not sure if I'm looking at an older C# language spec or if the IEnumerable requirements are pretty low, but it only has 1 method to get an IEnumerator. That means that either all the LINQ methods were added later or Microsoft added them... which I hate. As much as I love C# and .NET I hate getting an IEnumerable back and not knowing if it is an actual collection or a lazy evaluated collection. They really should've separated out the interfaces more...[/QUOTE]
[I]IList<T>[/I], [I]IReadOnlyList<out T>[/I], [I]IDictionary<TKey, TValue>[/I], [I]IReadOnlyDictionary<TKey, TValue>[/I], [I]IReadOnlyCollection<out T>[/I], [I]ISet<T>[/I], ... There are probably more.
[URL="http://stackoverflow.com/a/18042379/410020"]Arrays implement a good amount of them.[/URL]
If you want to check whether you have a collection that's already evaluated, I suggest checking for [I]IReadOnlyCollection<out T>[/I] and [I]ICollection<T>[/I].
(Stupidly enough the latter doesn't implement the former, but most built-in classes that support the former [I]should[/I] implement the latter too. Same goes for [I]IReadOnlyList<out T>[/I] and [I]IList<T>[/I] if you need indexing.)
A lot of LINQ extension methods will check whether something is already evaluated to run faster if possible.
If you get an [I]IEnumerable[/I]([I]<T>[/I]), you should always assume the method is lazy. [B]All[/B] of LINQ (except the methods that return collections) is lazy, but some may need to pull in all data to return the first item, like [I]OrderBy[/I].
Set up my game states for Love2D, so I can do:
[code]
local state = states:NewState( "menu" )
function state:Init()
self:AddButton( screenW * 0.5, screenH * 0.5, nil, nil, nil, "sprites/menu_start_button.png", 1.5, 1.5, 0.5, 0, Play )
self:GenerateFloor( 32 )
end
local function Play( )
states:LoadState( "game" )
end
function state:GenerateFloor( blockSize )
local scaleFactor = blockSize / 64
for x = 0, screenW / blockSize do
for y = 1, math.Round( (screenH / blockSize) * 0.16 ) do
self:AddButton( x * blockSize, screenH - (blockSize * y), nil, nil, nil, "sprites/block_bluesteel.png", scaleFactor, scaleFactor )
end
end
end
[/code]
For the menu, very basic so far.
Looks like this:
[img]http://i.imgur.com/rjwlAKq.png[/img]
I can easily make other states like the pause menu, game state etc.
[QUOTE=MatheusMCardoso;47719418]Right now I can think of two advantages of C# over C++ that are purely about the language:
No headers
No need for forward declaration
That does it for me.
But I still use and somewhat like C/C++, there's no way i can avoid it as a Computer Engineering student.[/QUOTE]
I don't even understand headers/forward declarations. They seem like oversights that should have been handled with syntactic sugar as soon as possible.
[QUOTE=DoctorSalt;47719831]I don't even understand headers/forward declarations. They seem like oversights that should have been handled with syntactic sugar as soon as possible.[/QUOTE]
Took me 15min or so to fully get someone I know to understand them. This is why more and more institutions are starting programming with Java/C#/Python.
An hour later and I'm finally able to get back to work
Somehow a [I]shitload[/I] of include's in my project just stopped working, caused a bloody cascade of errors and fuckups.
I nearly shat myself, I thought that perhaps my hard drive was failing and that those files were corrupted or something.
Now, I'm working on a new file format for my maps. It used to look like an ugly single line for an object, but I really like going for this "object encapsulating" like approach.
What do you guys think? I'm thinking that by encapsulating map objects like this, I will easily be able to specify properties for an object.
For example, the first object may have an altered mesh which the map will use as an "override" if specified, otherwise any individual object can be as small as the second picture. In fact, all that would need to be defined is the first line of any object, the rest can be defaulted.
[t]http://i.imgur.com/9m6YRMB.png[/t][t]http://i.imgur.com/TlK3qOM.png[/t]
A small update on what the hell I'm doing:
I replaced Rant's NSFW filtering system with a more general-purpose "hidden classes" feature that hides entries belonging to specific classes from unfiltered query results. This means that you need an explicit filter rule asking for the hidden class in order for entries with that class to appear.
To demonstrate what this means exactly, this is an example using a dictionary with ONLY "nsfw" entries.
[IMG]http://i.imgur.com/2DtRUNV.png[/IMG]
The general query will fail because hidden classes are, well, hidden.
[QUOTE=Rocket;47721504]Here's a gamejam that's apparently going on tomorrow through May 25th: [url]http://publicdomainjam.com/[/url][/QUOTE]
This is a really neat idea for a Game Jam, I hope some people here take part
I've been working with GameMaker recently and learning the language. Does it have functions or something similar I can't figure out how to write one.
[QUOTE=Rocket;47721504]Here's a gamejam that's apparently going on tomorrow through May 25th: [url]http://publicdomainjam.com/[/url][/QUOTE]
sounds fun but I'd have to read. I think I'll attempt this.
[QUOTE=Garrison;47721744]I've been working with GameMaker recently and learning the language. Does it have functions or something similar I can't figure out how to write one.[/QUOTE]
Yeah, scripts. They're defined outside of objects so they can be used globally.
[QUOTE=MatheusMCardoso;47719418]Right now I can think of two advantages of C# over C++ that are purely about the language:
No headers
No need for forward declaration
That does it for me.
But I still use and somewhat like C/C++, there's no way i can avoid it as a Computer Engineering student.[/QUOTE]
hopefully c++17 comes soon and fixes those things
[editline]14th May 2015[/editline]
c++17 also has a bunch of other cool shit planned for it
like [url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4128.html]ranges[/url] so
[code]std::random_shuffle(list.begin(), list.end());[/code]
becomes
[code]std::random_shuffle(list);[/code]
and [url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4165.pdf]unified call syntax[/url] so that becomes
[code]list.random_shuffle();[/code]
good to see some D features appearing in good ol' C++
[QUOTE=WeltEnSTurm;47722154]good to see some D features appearing in good ol' C++[/QUOTE]
Modules have been proposed for C++17 which make it look even more like D.
[QUOTE=DarKSunrise;47722099]hopefully c++17 comes soon and fixes those things
[editline]14th May 2015[/editline]
c++17 also has a bunch of other cool shit planned for it
like [url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4128.html]ranges[/url] so
[code]std::random_shuffle(list.begin(), list.end());[/code]
becomes
[code]std::random_shuffle(list);[/code]
and [url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4165.pdf]unified call syntax[/url] so that becomes
[code]list.random_shuffle();[/code][/QUOTE]
All I see is yet another hack that will have 3 million special cases you have to be aware of, that each semantically differ so slightly you forget about them until one day they bite you in the ass.
wow did c++ kill your dog or something
[QUOTE=SteveUK;47722188]Modules have been proposed for C++17 which make it look even more like D.[/QUOTE]
The lack of proper modules in C++ has got to be my biggest problem with the language, well, that and the millions of corner-cases you need to be aware of whenever you're writing anything in it because every single thing is implicitly done unless you explicitly specify for it not to be done. .. give me back my sanity!
[QUOTE=DarKSunrise;47722208]wow did c++ kill your dog or something[/QUOTE]
I'd definitely like to see C++ die to open up room for a more modern language that fulfills the same need.
Currently C++ is still very popular which is an excuse for the education system to not replace ancient teachers that know nothing else. This in turn leads to generation after generation of "programmers" that know nothing else and only contribute to the mass that needs to be moved.
C++ is here to stay. I get it. Codebases exist, it's uneconomical to change them. That's why banks still run on COBOL. But for god's sake, would you start your new project in freakin' COBOL?
You can tape as many awkward lambda sugars on it as you want, it's still COBOL.
[QUOTE=DarKSunrise;47722099]hopefully c++17 comes soon and fixes those things
[editline]14th May 2015[/editline]
c++17 also has a bunch of other cool shit planned for it
like [url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4128.html]ranges[/url] so
[code]std::random_shuffle(list.begin(), list.end());[/code]
becomes
[code]std::random_shuffle(list);[/code]
and [url=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4165.pdf]unified call syntax[/url] so that becomes
[code]list.random_shuffle();[/code][/QUOTE]
When I see that type of thing I'm always afraid it's going to be a maintenance hell, where you have each programmer write on their own style and if you are somehow unfamiliar with a particular style you will stare dumbly at it or worse, wrongly assume it works a certain way.
[QUOTE=bunguer;47722234]When I see that type of thing I'm always afraid it's going to be a maintenance hell, where you have each programmer write on their own style and if you are somehow unfamiliar with a particular style you will stare dumbly at it or worse, wrongly assume it works a certain way.[/QUOTE]
That's what writing C++ feels like, you end up with all this useless domain-specific knowledge about different ways the language will bite you in the ass when it does something completely unintuitive. :v:
I know of a university in Sweden which has an engineering degree specialized in game development/engines and such, where C++ seems to be pretty much the only language they use, which is a bit sad as they'll miss out on a lot of opportunities.
The game industry may be conservative, but leaving students with such a narrow field of view isn't good either.
Like, it's nice that they're attempting to improve parts of the language, but it has so much baggage now along with it's voodoo-like templating system that it still is just utter pain to use certain parts of the language.
Languages like D, Rust or Nim prove that it should not be like removing a tumor to write something like a serialization system and have vastly better compile-time systems for generating and running code.
I mean, just the fact that it's relatively common to use something like python alongside C++ generate code says something about the state of things :v:
But I digress, people may use the languages they wish, and right now C++ is sadly still one of the alternatives with the better tooling, but that's just a matter of time.
nim and rust are really interesting, but they still seem to be in their infancy
they are constantly changing so i don't think they can be used for any long-term projects at their current state
[QUOTE=DarKSunrise;47722306]nim and rust are really interesting, but they still seem to be in their infancy
they are constantly changing so i don't think they can be used for any long-term projects at their current state[/QUOTE]
Rust 1.0 is actually coming out tomorrow I believe, if I can believe their twitter.
So at least there, we should have some relative stability now, nim however still seems to be out on the high seas.
Giving up is not my style
[code]
cout << put_time(localtime(new auto (time(NULL))), "%Y %b %d\n");
[/code]
Now it's a true one-line!
[QUOTE=andrewmcwatters;47718156]so if you really want to stretch it that way, you're comparing c# to c[/QUOTE]
yeah that's true, in my earlier attempt I used almost none of c++ features, except for lambda, but that was pretty ugly.
this all would've been easier with Haskell-ish functional style like "puts . localtime . time"
that leaks memory
[QUOTE=ThePuska;47719419]I spent this week doing 3D-scanning. Basically I made a program that computes a point cloud out of an object that a robot scans with a laser. That was the simple part.
The difficult part was making the program that calibrates the scanner. Given an object with a known shape, I can now compute the calibration parameters that correct the rotation, translation and some other things so that the scanned results match the model.
All the equations turned out to be many times easier once I realized that I could define for each point on the known shape a coordinate system where points on the surface would have Z=0, instead of using an arbitrary coordinate system.[/QUOTE]
Thats funny, I was thinking of making something like this, it would involve a range meter and a rotating platform taking measurements as it rotates and goes up.
[QUOTE=DarKSunrise;47722480]that leaks memory[/QUOTE]
This is fine, people can just install more memory. Duh.
oh nice
you can still make it prettier though
[code]cout << put_time(localtime(make_unique<time_t>(time(nullptr)).get()), "%Y %b %d") << endl;[/code]
[QUOTE=Garrison;47721744]I've been working with GameMaker recently and learning the language. Does it have functions or something similar I can't figure out how to write one.[/QUOTE]
as chaz said, scripts are your functions in GameMaker. They are found in the resource tree under scripts, right click > create new script.
Call scripts from objects codes by typing their name, for example if you wanted a script to check if the mouse was in a rectangle area:
scrMouseBox
[code]return (mouse_x > argument0 && mouse_x < argument0 + argument2 && mouse_y > argument1 && mouse_y < argument1 + argument3);[/code]
You use argument0-15 to define parameters for your script, if an argument isn't given when calling the script it is defined as 0 (false).
you could then call this script in an object for example:
objControl > step event
[code]if (scrMouseBox( 0, 0, 100, 100 ) && mouse_check_button_pressed(mb_left)) {
show_message("mouse is in [0,0,100,100]");
}[/code]
Sorry, you need to Log In to post a reply to this thread.