« first day (1152 days earlier)      last day (1263 days later) » 

10:00 PM
basically it's up to the compiler to evaluate/infer it
Makes sense
I notice there are a lot of types in C#, it gets a bit confusing deciding which is best to use
I should swap over to ANTLR or jison soon, I wrote my own tokenizer but it's easily the worst code I've ever written
there's a few type aliases in C#, the types themselves are defined in the .net framework
For instance ulong vs. UInt64
ulong being a C# alias for the .net UInt64
int being a C# alias for the .net Int32
string being a C# alias for the .net String
10:02 PM
Hm, do they basically have all the same functions/methods?
the aliases compile to the .net types
Latex looks so nice
i.e. they're exactly the same thing
@N3buchadnezzar feel free to share your clothing preferences in the Nth Monitor ;-)
So if I can do Math.Sqrt(int) I can also do Math.Sqrt(Int32)?
@Mat'sMug Whips mat
10:04 PM
LaTex I believe :)
How is it going?
Dammit :p
aka MathJax
Sure looks nice for typography etc.
10:06 PM
@nethken you may be looking for codereview.stackexchange.com Code Review Stack Exchange where people will review your code, this seems to be what you're after.... — Martin 31 secs ago
@Phrancis you'd do Math.Sqrt(42) and that 42 is a System.Int32 as far as the compiled/running code is concerned.
Really like how LaTex can import .py files directly from source.
@Mat'sMug do the C# aliases have additional instance methods?
Makes sense, so in reality you can just use whichever of the alias or .NET type and it makes no difference whatsoever
10:07 PM
except constantly switching between the two makes your code pretty ugly
rule of thumb, use the language aliases whenever possible, and stick to them.
@Mat'sMug I can imagine
I think I've got into an argument with every programmer at my workplace about String and string differences
@Quill You say what mate?! You wanna foight?
@Quill and who won?
One starts with a capital letter and the other doesn't?
10:09 PM
@Mat'sMug the code reviewers always win ;-)
Not always :(
Spagetthi sometimes wins
Sorry for all the questions, C# is kind of new to me and being used to Java's very strict typing syntax...
@Phrancis questions are good :)
I use string everywhere. some argue that when it stands for a type, it should be string, and when it's used as a static class for its static methods, it should be String because "it makes it more obvious that String is a reference type". I call BS. If you don't know that System.String is a reference type, you have homework to do.
goes to the homework cup of shame
10:11 PM
@Mat'sMug hahaha can you do our performance reviews here
BRB Googling "what is a reference type"
shortly put, a reference type is a class, and a value type is a struct.
Oh so value types are like the primitive types, while reference types are pointers to objects... right?
@Phrancis yup
waits for the "reference types are stored on the heap, value types are stored on the stack" comment
10:13 PM
similar to JavaScript's boxing; wrap the primitive in a pretty box with extra features
reference types are stored on the heap, value types are stored on the stack
I've used Java's int vs. Integer types so that concept is at least familiar
boxing is when you take a value type and "box" it in a reference type. the cost of this is "unboxing"
@Phrancis that's outright confusing imo
Integer have methods since they are objects, while int are just that, a number
in C# an int is a System.Int32 no matter what, and it has value type semantics no matter what, and the members and extension methods of a System.Int32 no matter what.
object foo;
foo = 42; // you've just boxed an integer
int bar;
bar = (int)foo; // you've just unboxed a boxed integer
10:19 PM
Object foo;
foo = 42;
System.out.println(foo.getClass()); // java.lang.Integer
System.out.prinln((int)foo.getClass()); //Main.java:6: error: incompatible types: Class<CAP#1> cannot be converted to int
@Phrancis wait till you get to C# generics.
@Phrancis or Integer foo; right?
@Mat'sMug I tried generics yesterday and it was.... different.....
@Mat'sMug yep, and I just added what happens if you try to cast an Integer to primitive int
@Quill C# generics don't incur boxing/unboxing penalty.
In that sense, C# does seem a lot more convenient than Java
10:24 PM
Yeah... I really need to write more C#
@Phrancis Another nice (depending on your outlook) thing about C# is that in C# generic types are not "erased" at runtime
in Java generic types are only for the benefit of type checking which means you can't use reflection to determine what generic type was used at runtime
Which is.. cumbersome when it comes to mocking in tests
in C# generic types are preserved at runtime
The upshot of that being that there has to be more information encoded in a C# binary so it may be larger
So in C# a generic remains generic up until it's assigned/used, vs. in Java it's only generic before compiling?
a type remains generic information in C# forever
In Java that generic information is erased after compilation
@DanPantry which is only a big deal if you're distributing your app on floppies
10:33 PM
lol floppies
So in C#, a List<int> is a List<int> which isn't a List<float> at runtime.
But in Java, technically speaking, a List<Integer> and a List<Float> are both List at runtime
There are a few situations where C#'s version is more useful
That sounds nasty
Anyway gtg now - later!
Cya @Mat'sMug
OOTH, you could also argue that preserving type information at runtime breaks static typing as it allows you to create unpredictable types at runtime, and so Java does it right
@DanPantry unpredictable as in proxy types and mocks? Heck I'll take it!
10:45 PM
that was a fast drive
WTF does that even mean
> CS1624 The body of 'UserQuery.ProjectEuler4.FindLargestPalindromeProduct(int, int, IEnumerable<int>)' cannot be an iterator block because 'int' is not an iterator interface type
yield return methods ("iterator blocks") must have a return type of IEnumerable<T>
because you are, literally, returning a collection of elements but rather than creating the entire collection and returning it after it's created, you hand back elements one-by-one
Maybe you just meant to use return without yield?
Maybe that's the case, let me try. I just want the loop to break as soon as it finds one value that matches the conditions
that would be return
@N3buchadnezzar writing answers?
10:57 PM
Getting a different error this time
> Cannot return a value from an iterator. Use the yield return statement to return a value, or yield break to end the iteration.
@Pimgd shackles fist angrily
15 answers, 29 upvotes, 4 accepts - that'll get you some rep
remove all yield return statements
and just use return
Q: Modelisation of a chain of springs

LepimentI'm writing a program which modelises the behaviour of a chain of springs when subjected to user-inputted force impulsions. Note : I've not included the real code as it is long and cluttered, and I only want advice on a specific part of the implementation for now. So I have an object Chain,...

10:58 PM
aaaand bold text died, GG chrome
@Pimgd 395 this week
@JeroenVannevel Ohhhh, very nice, works like a charm now :)
you can see a detailed log if you're interested
So in this method, yield return works because the method returns an IEnumerable, right?
private static IEnumerable<int> GetAllPalindromes(int min, int max)
    for(var i = (max * max); i >= (min * min); i--)
        if (IntUtils.IsPalindrome(i))
            yield return i;
11:02 PM
aaand I officially killed the biggest part of the project I'm working to improve
Thankfully, #sourcecontrol (fixed)
you can't use tags
@JeroenVannevel Is working with IEnumerable<T> usually faster than working with List<T>?
(I realize they are not quite the same thing, just asking in general)
There's so different, you can't really compare it
it depends on the situation
11:04 PM
IEnumerables can be lazy which can be faster
the thing you have to realize is that an IEnumerable sometimes represents something.. unmaterialized
Lists are eager, which can be faster for other cases
Like a LINQ query. Depending on the query, it basically acts as a blueprint that doesn't do anything by itself
like collection.Where(x => x.Age > 5)
That won't do shit
it's a blueprint that tells you to get all people over the age of 5
collection.Where(x => x.Age > 5).ToArray(), however, will use that blueprint and create an array out of it
these are materializing queries
@JeroenVannevel actually... it will
Makes sense I suppose
11:07 PM
There are several of them: ToList() and ToArray() but also Select(), FirstOrDefault() OrderBy() and Take() for example
they all perform some sort of materialization
@Vogel612 how so?
yield has many implications compiler-wise @Phrancis. What's running is so much more than what you write ;-)
it's a filter. just because it's not eager, that doesn't mean there is no result
A: LINQ extension methods - Any() vs. Where() vs. Exists()

Jon SkeetWhere returns a new sequence of items matching the predicate. Any returns a Boolean value; there's a version with a predicate (in which case it returns whether or not any items match) and a version without (in which case it returns whether the query-so-far contains any items). I'm not sure abou...

@Mat'sMug Sounds like I got some reading to do
> Where returns a new sequence of items matching the predicate.
Q: Organisation of javascript functions on a single web page

Peck3277I've created a web page for display a list of products that I get from a JSON string through an AJAX call. On this page I have several javascript functions in the head of the html file. I'd like to know what the best way would be for organising my code. In the head of my html code I have pretty ...

11:09 PM
@Phrancis C# in Depth by Jon Skeet covers it very nicely
@Vogel612 but it doesn't iterate the results
'course not.
that still doesn't mean it has no effect
> This method is implemented by using deferred execution. The immediate return value is an object that stores all the information that is required to perform the action. The query represented by this method is not executed until the object is enumerated either by calling its GetEnumerator method directly or by using foreach in Visual C# or For Each in Visual Basic.
Those are called promises in JS
no they aint
11:10 PM
It has no immediate effect then ;-)
Wow, refactoring my code based on the answers I got made by biggest test case go from 27s to 0.184s
promises are async stuff
@Quill nope those are different
kinda sorta maybe
@Quill that would be a Task<T> I think
11:10 PM
sorta maybe nope
Totally another thing
Or just a Task. Whatever.
@JeroenVannevel not a task?
Po-ta-to, Po-tah-to ... ;)
@Mat'sMug Yes, Task or Task<T>, both are fine
I was answering @Quill
@Phrancis promises, pro misses
If this works, but you want it to be better, why not use the Code Review Stack Exchange instead? — zero298 54 secs ago
11:29 PM
@SonuMishra: That's where eyes come in! I see why people use this, but I believe that it lulls people into a false sense of security, AND I believe that if you're not paying enough attention to spot a = vs ==, then what else are you missing? Pay more attention. Simply read your code. :) And get your colleagues to code review. tl;dr If you're missing this, you're almost certainly missing other things that yoda conditionals do not solve for you.Lightness Races in Orbit 49 secs ago
> 0==i is called a "yoda conditional". It is most certainly a personal preference, but it does have an advantage.

It was used in the dark ages by mystical knights of the realm who lacked the modern technology to tell them when they'd written 0=i by mistake.
11:43 PM
# I love Latex again
Latex can even make the title of the colorboxes automatically link to the Project Euler problem on the internet.
Q: Neural net in C++

David LernerI wrote a Matrix struct and a neural net that uses it. Why is this slow? Gprof blames Matrix::operator()(int, int) which I suppose is my constructor, and Matrix::operator*(Matrix) and vector<float>::operator[]. #include <iostream> //#include <C:/Users/David/Google Drive/Coding/neural_c/Launcher.h>...

@N3buchadnezzar Just curious, do you have any license concerns putting together a document like this?
(I'm not sure what license terms the PE website/content has)
Ah, looks like you're OK projecteuler.net/copyright
As long as not used commercially
@Phrancis They have a policy of saying please do not. However the solutions are already just a google search away.
@Phrancis Yeah.
Just need to make sure your document is also CC BY-NC-SA 2.0 UK
Darn it I was thinking of selling it on the streets to addicted programers =(
11:56 PM
However my idea with the document is not solutions. But overly optimized and generalized solutions . Not quite sure how to make that as clear as possible
Just write an Introduction/About page that precedes the index/table of contents
Short, to the point. Or even a subtitle would work

« first day (1152 days earlier)      last day (1263 days later) »