« first day (695 days earlier)      last day (3326 days later) » 

0
Q: Structure of client-server game

GLeBaTiThis is my game architecture on server side: "Shared" - it is shared static helpers without fileds (only methods, no states) for manipulation with data(cliend data - local collections, server data - database). Is my architecture normal? In my game, i want in any windows and dispatchers have acc...

0
Q: How to compute the height profile of a Tetris stack most efficiently?

ziggystarProblem Statement We're given an array of Integers stack of length height. The width tells us that at most the width-lowest bits in each entry of xs are set. Compute an array profile of length width such that profile[i] == max_i with: max_i is maximal with stack[max_i] having the i-th bit set. ...

 
Of course, Code Review requires code to be posted in the question itself. A Github link won't cut it. — Frédéric Hamidi 1 min ago
I'm voting to close this question as off-topic because it belongs on codereview.stackexchange.com — SamV 1 min ago
 
8:51 AM
0
Q: Project Euler #1 in Ruby with duration

Chris YeungI have done #1 of Project Euler's in Ruby. Using two different approaches. One uses set, another uses reduce. require 'set' start = Time.now s1 = Set.new (1..1000/3.floor).map { |x| 3 * x } s2 = Set.new (1..1000/5.floor).map { |x| 5 * x } sum = s1.merge(s2).to_a.inject(:+) duration = Time.no...

0
Q: Determining cell direction in a 2D grid

mr5I am making a simple function that retrieves a 3x3 cells out of NxM grid and determines the direction of cells base on their previous and next neighbor. It will return either any of the following HORIZONTAL VERTICAL TOP_LEFT TOP_RIGHT BOTTOM_LEFT BOTTOM_RIGHT or INDETERMINATE Suppose I have t...

 
If you would like to post a large project to be reviewed on Code Review, see My code is too long. — 200_success 1 min ago
 
9:16 AM
Please, do not suggest to move this question to codereview. I tried to and they don't want it. — ziggystar 48 secs ago
For the record, the question was rejected from Code Review only because of the author's insistence on simultaneously tagging it as scala, java, and c. That makes it such that Scala is merely being treated as pseudocode, which would be off-topic for Code Review. It would be perfectly acceptable as a scala question. — 200_success 54 secs ago
 
1
Q: FreeDNS update script

SuperbestI'm new to Python. I tried to write a script which takes a list of URLs, checks if their FreeDNS record points to the current IP, and updates the record if not. Intended use is that the script will be run periodically to keep FreeDNS always pointing to the dynamic IP. Also, a log is kept so the...

 
Monking
 
Monking
 
I think it's time for a bug report
16
Q: Reference to method is ambiguous when using lambdas and generics

skiwiI am getting an error on the following code, which I believe should not be there... Using JDK 8u40 to compile this code. public class Ambiguous { public static void main(String[] args) { consumerIntFunctionTest(data -> { Arrays.sort(data); }, int[]::new); ...

By now others would have jumped in to tell me I'm wrong, if I was wrong
 
9:32 AM
0
Q: Add user to a database and perform relevant checks

GiriI am new to Python and was hoping to get some advice on a part of my code. Below is a function that adds a new user to the database using their email and password. I am using Flask and SQLAlchemy. @app.route('/users', methods = ['POST']) @require_appkey def registerUser(): errorsList = [] userI...

 
10:04 AM
Bonus-optionnal question but it's more a "code review" one. Is there a better way to open the modal than using a watcher in the directive (and an isOpen scope var in controller) ? — Cétia 1 min ago
See also the File Browser GUI for 'file list in a table'. — Andrew Thompson 1 min ago
 
10:24 AM
Hmm. Odd. Yeah. It might be time to file that bug report.
 
Did it, still needs to be accepted though
 
10:37 AM
First answer:
1
A: Clear function for Stanford iOS 8 Calculator application

mrbhill(Also a beginner following Stanford CS193p 2015.) Two slightly different solutions here somewhere between steveclark's and nhgrif's. My @IBACTION in ViewController code is the same in both of my versions. In each case the newValue of displayValue is being returned as follows - In ViewController...

 
> $ git push
fatal: unable to access 'https://github.com/skiwi2/TCGHand.git/': Failed connect
to github.com:443; No error
Anyone else having Github issues?
 
@skiwi yes but I'm not sure if that's because I'm behind a corporate proxy or not.
monking
 
@DanPantry I'm not behind any proxy or thing here
 
works for me ;-)
 
I can still access Github itself
 
10:44 AM
You guys should upvote this first-answer:
1
A: Clear function for Stanford iOS 8 Calculator application

mrbhill(Also a beginner following Stanford CS193p 2015.) Two slightly different solutions here somewhere between steveclark's and nhgrif's. My @IBACTION in ViewController code is the same in both of my versions. In each case the newValue of displayValue is being returned as follows - In ViewController...

and my answer too.
 
try checking the twatter twitter?
 
@skiwi See:
panabox:~/git/MicroBench> git pull
remote: Counting objects: 237, done.
remote: Compressing objects: 100% (130/130), done.
remote: Total 237 (delta 70), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (237/237), 39.49 KiB | 0 bytes/s, done.
Resolving deltas: 100% (70/70), done.
From github.com:rolfl/MicroBench
   15f1792..423a3f9  master     -> origin/master
 * [new branch]      newton     -> origin/newton
 * [new branch]      stepper    -> origin/stepper
Already up-to-date.
panabox:~/git/MicroBench>
 
@rolfl yeah, but he pushed. I don't think POST vs GET would make a difference in server outage though :S
 
Apparently there's a DDOS attack going vs Github for a week already
$ git push
Counting objects: 17, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (9/9), 1.00 KiB | 0 bytes/s, done.
Total 9 (delta 2), reused 0 (delta 0)
efrror: RPC failed; result=7, HTTP code = 0
atal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date
Eh lol, almost posted the password there, thanks Git bash
 
use the git/ssh protocol?
 
10:47 AM
For protecting me, in this case ^^
 
@rolfl Yeah, I still need to do that one day
Heh, 3rd try worked
How hard is it to setup SSH for Github?
 
not hard at all
if you're already on bash you've done half the battle
it's a bit of a pain on windows though
but really, who uses windows? ha ha ha ha -closes Windows laptop-
curls into a ball and sobs
line 0   col 0   Bad option: 'camelCase'.
ironic
(it accepts camelcase but not camelCase)
 
lol
2
 
I have the guitar section of a song stuck in my head
so I can't even google what song it is because all I would write is "do doo do do do doo" |:
 
11:00 AM
How does it sound like?
 
"do doo do do do doo"
|:
 
@skiwi www.youtube.com/watch?v=H07zYvkNYL8
 
Was worth the try
 
Have you thought about posting this on codereview.stackexchange.com — Popey Gilbert 30 secs ago
 
11:05 AM
"I cannot read the question, therefore it is codereview"
albeit that question is a question for CR, @Duga
describe('api routes', function() {
  it('do nothing', function() {
    var next = sinon.spy();

    routes(next);

    return expect(next).to.have.been.called;
  });
});
also known as the "I swear I did work in this 15 minutes before this commit" test
 
0
Q: In python how should I break down this huge function into smaller parts

kuretaI am trying to understand good design patterns in Python and I cannot think of a way to break this huge function into smaller parts without making the code cluttered, overly complex or plain ugly. I didn't want to clutter my question by posting the whole file, I mean this function itself is alre...

 
11:20 AM
And, today, for your Monday entertainment, I present:
 
@cpicanco @Mat'sMug @nhgrif There is a meta question about this licensing thing:
7
Q: Which licenses are compatible with Code Review?

Simon André ForsbergIt is should be well known that code posted to Code Review are licensed under CC-BY-SA. I am wondering: Are there any licenses that are compatible with this licensing? Is it possible to use one license on the GitHub repository (for example "Simplified BSD" license) but still post the code to Cod...

 
I believe the best place to ask is here: codereview.stackexchange.comlviggiani 56 secs ago
codereview.stackexchange.com is indeed a better place for this kind of questions - there are many valid ways to refactor your function and it's mostly a matter of opinion. As far as I'm concerned (and not having worked on your project so I don't have enough background / hint), I'm not sure this function actually needs any refactoring , except for the handling of empty files which should raise a (custom) exception so the calling code can decide how to handle the case. Else, the function is indeed a bit long but not over the top and seems coherent (doesn't do 1000 different things AFAICT). — bruno desthuilliers just now
 
Ah right, 1 April is soon
 
11:38 AM
in MicroBench, 29 secs ago, by rolfl
I broke it.
@skiwi Unicoins!!!
2
 
@skiwi They've been under a DDoS for days now.
 
I thought they resolved it with the alert()?
 
I must say I'm pretty intriguieieied by the way they set up that attack though
it's so simple it's genious
a centralized ddos of sorts
 
I honestly don't know anything about the attack besides it's been happening.
 
11:44 AM
basically: the chinese government injects a request to a couple of github repos in baidu search queries for foreign users
this causes everyone that searches with baidu from outside of china, to fire off a request to the github repo
easily ddos'ing it
imagine google doing that. Suddenly a few billion requests hitting your server
 
That's like criminal
 
Where's @janos?
 
lol WhatsApp... I went to mute a group conversation, and default option it gives me is for 1 year, well that's a bit exaggerated.
@SimonAndréForsberg Haven't seen him for quite some time
 
Mar 25 at 18:58, by rolfl
When did Janos say he'd be back? ....
 
> Seen Mar 14 at 8:51
 
11:52 AM
Mar 25 at 18:58, by rolfl
(Did he say he was going somewhere...?)
 
twitter.com/janosgyerik he has a twitter post ^^
Not relevant, but at the same time relevant
 
0
Q: more better Utopian Tree in Golang

user69245Please lecture my code. I want to be more better Utopian Code in Golang. ploblem https://www.hackerrank.com/challenges/utopian-tree package main import "fmt" func main() { var n, x, res int fmt.Scan(&n) for i := 0; i < n; i++ { fmt.Scan(&x) res = 0 for j :=...

 
Argh, not publishing awesome Java libraries to mavencentral should be criminal
 
@skiwi like which ones?
 
@SimonAndréForsberg aurelienribon.com/blog/projects/universal-tween-engine is looking very promising
Now with Gradle you are in luck and can easily share jars in a lib directory, with Maven you are kind of screwed though if you work on a project with a team
 
12:03 PM
With Maven you would have to explicitly install it in your local repository, then you can use it.
Plan on using it for LibGDX, or what do you plan on using it for?
 
@SimonAndréForsberg Yeah, which is a hell if you work with a big team on a project
@SimonAndréForsberg Yep
 
@skiwi You expect it to be compatible with GWT?
 
@SimonAndréForsberg I hope so
 
I strongly doubt it.
 
I strongly doubt doubting it
@SimonAndréForsberg github.com/libgdx/libgdx/wiki/Universal-Tween-Engine it has a section for HTML
 
12:06 PM
for 2D things, LibGDX has Actors, which can have Actions assign to them, which are essentially tweening. For 3D, I do not know...
@skiwi Sometimes I love it when I am proved wrong.
 
18 mins ago, by skiwi
That's like criminal
That ^
 
@SimonAndréForsberg :)
Noooo, the library uses int tweenType, some enum version would've been cleaner
But in the real world we're not dealing with perfect code
 
> ln: creating symbolic link node_modules/.bin/karma' to node_modules/karma/bin/karma': No such file or directory
wtf?
if I touch node_modules/.bin/karma i get File exists. If I don't, I get no such file or directory.
 
sudo make me a sandwich
3
 
I'm not sure if ln is trying to create a symbolic link, or just be smart
$ sudo make me a sandwich
sh.exe": sudo: command not found
a man can dream :(
 
12:16 PM
@DanPantry Same issue here
How to fix?
 
@DanPantry what? you don't have sudo?
I was thinking that it didn't create your symbolic link because of permission issues
 
0
Q: C# DrawString better alternative for replacing text

user3009269I have a sliding puzzle table and after finding the solution I want to animate it and move the empty tile around until I reach the solution. I have no problem with the generation of the solution, but with the way it looks like. When I draw the table, I create some rectangles and keep them in a li...

 
:20811483
 
It would be awesome if whatever I'm making would just work
Unfortunately I don't even have a clue on how to use whatever I'm using
I'm expecting explosions everywhere
 
0
Q: Is my code compromising the encryption?

user230218The code bellow takes a String and encrypts it using AES/CBC/PKCS5PADDING as transformation. I am learning as I go and I have a few questions about my code. 1. Is SecureRandom ok for generating my KEY and my IV ? 2. Whats up with all these exceptions? 4. Is my code creating any vulnerabilities ...

 
12:25 PM
@SimonAndréForsberg @DanPantry needs to learn how to reply correctly:
oh, it was for me!
 
@Simon dan knows how to reply correctly :(
FML spent 15 minutes working out why karma wasn't working
almost logged an issue on karma's github
 
8 mins ago, by Dan Pantry
:20811483
^^ didn't ping me
 
turns out framework should be frameworks
@SimonAndréForsberg 0.o
 
in MicroBench, 19 hours ago, by Simon André Forsberg
I ¤"(/)"¤/)(!¤#=!¤#/( used the wrong Log method
in MicroBench, 19 hours ago, by Simon André Forsberg
hoursSpentHere = approx 4;
 
Something definitely happened
I put the Tween on a deck of cards, and they moved for a very short time and then simply disappeared.
 
12:29 PM
@skiwi sleight of hand?
O:
your card game is becoming a wizard
2
 
It's even sometimes crashing its host! (IntelliJ)
 
0
Q: Removing checks that are only necessary on first pass

Simon VerbekeI've got a function that's executed in a game loop. There are a couple of checks that are really only necessary during the first pass of the game loop. How can I remove these? There is more code like this, but this is the shortest example. public void Update(Frame rawBodyData) { //Catch the ...

 
1:02 PM
The library looks to be working
The rotations work
 
Psychadelic
 
Oh I get it
it's a cardgame for stoners
2
 
axis = [-3.0908616E-8, -0.7071067, 0.7071068]
This doesn't look like the Y-axis
 
That first value is small
0.707.... why is that familiar?
ahh, 1 / root 2.
 
It also looked familiar to me
The funny thing is that I have a matrix, I can set the rotation via an axis and an angle, but I can only retrieve the rotation by using quaternions
I'm trying to understand it :)
Is a rotation around the Y-axis for alpha degrees representable as a rotation around a different axis for beta degrees?
Maybe I should just KISS this problem
 
1:17 PM
Greetings, Programs.
 
Greetings, @Donald.McLeans.
 
hello
 
Another interview today.
 
good luck :-)
 
Hey @Donald.
@nhgrif - hope they can think like a programmer at least ;-)
 
1:26 PM
0
Q: code c++ for noise power

hoss91I want to calculate the noise power after getting received N samples of noise, I should implement this in C++. Here is my code and I think that is not correct #include "noise.h" noise::noise() { } //calculer les puissances moyennes des échantillons detectés float noise::noise_power(cvec rx_buff)...

 
they rebooted my computer over the weekend, so my refresher didn't run for sunday....dang it!
 
@Malachi Worst thing ever.
So happy I migrated my dailies from the desktop to the server.
 
now I have to try and remember what all I had open and working on, on Friday On MONDAY!
screw that, fresh start!
FYI
-3
A: Checking if a number is divisible by 9

MalachiI really didn't like the way that @Edenia wrote the code, mine is like her's, only I think it is much cleaner and straightforward int isDivisibleBy(int number, int divisor) { for (int i = 0; i <= number; i += divisor) { if (i == number) { ...

I removed all reference to C#
 
I just wrote a workflow for a new application I'm doing. only took 3 hours
didn't even notice the time and missed my lunch break, well fk
 
lunch is overrated
 
1:34 PM
@Malachi ouch, -3 on code review.. havent' seen an answer that low on here before :(
 
@Malachi I still don't consider it a good answer.
 
it's actually +4/-7
@SimonAndréForsberg did you see this one? codereview.stackexchange.com/a/85172/18427
 
I dont know enough to weigh in here
 
she has +8 on her answer, and I just twisted it a little bit to make it readable. (the code)
 
I don't like how her argument is "mine is less line numbers therefore better"
 
1:36 PM
@DanPantry Nobody bothered to ask you for lunch?
 
@Skiwi no
We only have half-hour lunch mon-thurs
So not really much point in going out
Most people walk to the shop 5 min away to buy grub and eat at their desks and browse reddit or something
w3c.github.io/push-api !! this is exciting
 
that answer was downvoted 4 times. I don't care. it works and my fun little unit tests ran perfectly to keep me from making mistakes in the code. so I am happy, I learned from the experience @SimonAndréForsberg
 
Hmm, rotate + translate == weird stuff here
 
0
Q: Is this the Best way to handle Add, Remove and Update on the Same Form?

Dawood AwanA bit of Background: I am using Angular/Knockout for this Type of Form, MVC C# and Entity Framework. It is a Dynamic Form, So users can Add Fields and remove Fields and also update on the Same Form. The Database is a one to Many Relationship, e.g. A User can have many contacts. So the Form lo...

 
Are you talking about orientation?
 
1:41 PM
@Malachi been there, downvoted that.
 
When I rotate an object around an axis, I first need to translate it to the origin, then apply rotation, then translate it back
That's as far as the theory goes
 
@CaptainObvious that question is written in sim-ese.
Honestly half of it is English and the other half looks like it's meant to be English but reads like a Sim is typing it
 
@Malachi I've reversed my downvote.
 
Unless this framework remembers the rotation when translating... nothing weird should happen
 
@skiwi im confused... But for the record... Rotation means you are adjusting two axes while translation means just one, I believe.
 
1:45 PM
@DanPantry That's C#
 
@nhgrif Translation means you are moving an object by a vector, rotation means you are rotating an object with an angle around a vector
 
@SimonAndréForsberg not what I meant but lol
 
rot_matrix * translation_matrix != translation_matrix * rot_matrix
 
@nhgrif thank you
 
Oh... That makes sense with what I read then...
Why do you have to move to origin in order to rotate?
 
1:49 PM
i think my coverage tool just tried to run code coverage on itself
 
I don't know exactly why, but it works now
@nhgrif Because if you don't move to the origin before rotating, you are rotating the object around the origin
Let's say you want to rotate an object 180 degrees around the up-axis
 
Amazing, I just took C Code and pasted it into a C# project, and it didn't yell at me...***</sarcasm>***
 
Oh that makes sense.
 
If it's located at (2, 0, 0) and you translate it by 180 degrees, you would not expect it to be located at (-2, 0, 0) afterwards
 
You can do it with just one translation then.
Translate it by 2x current cords.
 
1:52 PM
Erm, that's a typo up there, it should be rotating by 180 degrees, not translating
 
Yeah. Still though. You shouldn't need to translate before and after rotate.
 
-1
Q: multiple If statements that are similar

xygI have the following code: if(a>0){ print a} if(b>0){ print b} if(c>0){ print c} Is there a way to condense it to a single if statement ?

0
Q: Unexpected output for looping through a string and using str.replace

alanbuchananI am going through the CodingBat exercises for Java. I have got up to this problem which asks: Given a string, return a version where all the "x" have been removed. Except an "x" at the very start or end should not be removed. I wanted to solve this by checking each character from the seco...

 
2:19 PM
<-- learning about bits and shifting right now
check this out. way cool. but not really what I was looking for. --> forums.cisco.com/CertCom/game/binary_game_page.htm
 
2:36 PM
0
Q: Business Models and DRY code

PeteUse Case When modelling business objects, how can similar business models be kept DRY when the business objects have different meaning? I'm fairly new to modelling, so I'm not sure if I'm doing this correctly. Models The following example is from an application where the application takes in ...

 
21 GB in my trashbin.. What on earth did I delete?!
Time to update my resume and start looking for an internship in the US
 
Good luck @JeroenVannevel !
 
Muy gracias!
 
We are enabling CloudFlare routing on http://meta.stackexchange.com in a just a bit. Let us know if you see any craziness!
 
@Malachi learning about bits? importblogkit.com/2015/03/10-types-of-people
 
2:49 PM
I know a enough about binary to be able to translate (with a little help) but I want to be able to code shifts like those C nerds and show off how strong C# really is to that C Snob that was in here the other day.
@nhgrif thank you, I will read it right after I push some code into production
 
No you won't....
 
yes I will.
wait
 
You will watch and wait, to ensure your pushed code does not break things.
 
oh that.....
 
you don't push in and push off ;-)
 
2:50 PM
 
I tested this code all last week.
@JeroenVannevel ????
 
Leave the bear asleep
 
Self-testing is not the same.
 
Don't poke it with bits
 
oh, don't poke the bear
@nhgrif a business analyst ensured me that it is returning the correct information
 
2:51 PM
@Malachi Pretty clever, right? Right?!
 
Very
 
@Jeroen - how did the bear get a black eye?
 
@rolfl It's a black bear
 
Maybe they are just poking it to see if their knockout punch was successful?
 
Is manual memory management possible in C#?
 
2:52 PM
@nhgrif Yup, but you don't want to ever never do it.
Use the unsafe keyword
Aptly named
 
Sure it is, just make a call to a library
 
@nhgrif I can run the code from that question. I haven't tried everyone else's code yet from the answers though
 
Don't want to ever never do it?
 
C# is built with C as a Base, I figure that is why they call it "C"#
 
@Malachi that's different from the question of manual memory management. All of your memory is on the stack in that answer.
 
2:54 PM
@Malachi it's a sharper C
 
C# Confuses me:
    if (RawBody.IsNull())
    {
        RawBody = rawBodyData;
    }
How can you call the IsNUll method on an instance that is null?
 
@nhgrif I am running the code from the OP, in a C# project
 
because RawBody is a Nullable<T>
the instance isn't null
 
@Malachi that doesn't mean you can do everything in C# you could in C. C++ isn't a strict superset of C is. But Objective-C is.
 
@nhgrif Well, at least you shouldn't. The language was build to explicitly remove that aspect, there's no use using pointers then.
@rolfl It's composition at work
 
2:55 PM
@Mat'sMug So, that's worse, then, right, because RawBody.IsNull() returns true but it's not null?
 
I don't know C, so trying to emulate C in a C# project might not be a good idea....
brb
 
@JeroenVannevel all I'm saying is that you don't have the option which is what someone arguing for C will point out.
 
@nhgrif Not the option for what?
 
@rolfl I'm making assumptions here, Nullable<T> is meant to box up value types, which cannot be null
 
In Objective-C, I can do everything identical as you would in C without exception or special usage. And I'm not using garbage collector which has its drawbacks.
 
2:57 PM
@rolfl That's just bad usage/bad design by the user. == null is a lot more universally understood. I don't even recall a .IsNull() method so this might just be user/library defined
 
@JeroenVannevel right. Nullable<T> would be .HasValue()
 
@nhgrif I don't know to what extent unsafe works but at least you can use pointers and stuff like that there
 
Sounds like you have the beginnings of an answer for codereview.stackexchange.com/questions/85397/…
 
I would, but I'm in the process of starting to prepare myself to work on my resume today.
 
Your language choice entertains me ;-)
5
 
2:59 PM
fav'd, will look at it later. 2 hours is a young zombie.
 
You can use pointers, yes, but arguing "you will never need them" isn't going to do you much good arguing against someone who is arguing for C as a language. That's all I'm saying.
 
@nhgrif - arguing with someone about language choice is never "... going to do you much good...".
5
 
you actually shouldn't ever need to write unsafe code in C# - but it's there for whatever you need it for
 
Like GOTO?
 
nope, goto is managed code. dumb, but "safe" ;)
 
3:01 PM
I wouldn't call getting eaten by a dinosaur safe ;)
4
 
@skiwi no sense of adventure.....
 
Hmm. Swift has unsafe and I have come across plenty of needs to use it...
 
@nhgrif What do you use it for then?
 
anyway I need to get some work done so I can play some more. BBL
 
Java also has Unsafe though not officially in the public API, but I've never used it yet
 
3:03 PM
0
Q: C++: an implementation of the merge_sort from "Introduction to Algorithms" - comparing the timing of an array versus a vector

Jason BI am new to C++, and programming in general. I'm going through the book listed in the title. I made a comparison between merge-sort for an array of integers versus a vector. Could I have structured this program better? Why is the vector version so much slower? Sorting 2 million integers with ...

-1
Q: should URLs be meaningful where HTTP methods are explicit

nightographthere is a discussion in the group I'm working with regarding pattern of URLs for a backend api, although we are using different http methods to do different operations on an object, if the urls also should be meaningful or not. As a backend engineer I like things to have explicit meanings includ...

 
When I need to do manual memory stuff. Mostly when interacting with C libraries.
 
Haven't seen any use of that in C# so far although it's not my area of focus either
 
^^ indeed. it's for interop stuff.
 
People just use interop and be done with it
 
But arguing C vs C# is silly. One is OOP, one is not. One is GC, one is not.
C# vs VB is a more useful discussion. Or Objective-C vs Swift.
 
3:07 PM
23
A: Should you use pointers (unsafe code) in C#?

nzpcmadFrom "The Man" himself: The use of pointers is rarely required in C#, but there are some situations that require them. As examples, using an unsafe context to allow pointers is warranted by the following cases: Dealing with existing structures on disk Advanced COM or Platform Invoke scenarios ...

lol
> Specifically, an unsafe context should not be used to attempt to write C code in C#.
 
I miss the c troll-girl
 
next troll gets kicked. promise.
2
 
Right. You shouldn't write c code in c#. But there is nothing wrong with consuming a c library from c#, which may require some manual memory management.
 
right. that's what unsafe is there for
 
One of the CUDA samples provided by NVidia had goto in it, I decided to use X Macros. Maybe I got the bigger dinosaur.
 
3:13 PM
But it's important to understand that C# memory management isn't magic, it's GC, which has its downsides. Objective-C and Swift use magic memory management.
 
What is magic memory management ?
 
@nhgrif What's that and how is that better?
 
Hi Jamal
 
@rolfl: Why was this reopened?
@JaDogg Hi!
 
It's called ARC. It is manual memory management automatically written for you. So it's the advantage of GC and manual memory management combined.
The downside of manual memory management is that you have to write it. The downside of GC is less control and it can be expensive for the GC to run. With ARC, there is no expensive to GC to run, but I also don't have to manually write the retain/release/etc code.
 
3:19 PM
What if you don't want to release the memory yet?
 
Doesn't C# do this in a smaller manner? For example local variables are automatically deallocated even before the end of the method; as soon as they are accessed for the last time they are marked for the GC to clean up
 
that's the "magic" part ;)
doesn't mean they're actually collected though
 
While not collected, does it actually free the memory so it can be used before the collector runs again?
 
If I understand correctly. When new smart pointers are used in C++, It also get automatically deleted, but the trick is making it got out of scope like any other normal variable, if there are circular references, boom
 
@Hosch250 That wouldn't seem possible to me; how can you use the memory if stuff's already in it
 
3:26 PM
It gets deleted just like other variables, (when they are out of scope)
 
@JeroenVannevel Not sure.
Depends on what the GC does.
 
What do you mean?
 
Does the GC actually handle the release of the memory, or does it clear the memory of any values in it?
 
0
Q: Login and registration functions

seesharpI'm currently learning C# as first programming language and I've made a simple program to exercise the basic concepts. It's nothing fancy especially compared to advanced stuff you normally talk about, but I would like to know if I've made some common mistakes or I missed some good practices. Bas...

 
The first, right?
 
3:31 PM
Just signed up for an advanced Scala class through Coursera. Should be interesting.
 
@Donald.McLean I thought you were good at Scala already?
 
@Hosch250 Do not confuse "Have successfully delivered a Scala app to production" with "Knows everything there is to know about Scala" - they are really quite different. One is something to be proud of, and the other is a goal to aspire to.
 
OK.
You might already know everything though - depends on how good the course is.
 
No. There are some parts of Scala that are really quite advanced. At the moment, I'm more in the middling-average area of Scala knowledge and mastery.
 
There are parts of every most languages that are quite advanced.
LOLCODE is the exception, and maybe BF.
GS isn't so hot, either.
 
3:37 PM
@Hosch250 Hey now... LOLCODE is start of the art. 100 years from now all code will be written in LOLCODE because it so closely resembles common English.
Like BASIC was back in its hay day.
 
@RubberDuck C# looks more like English than LOLCODE.
 
@Hosch250 O RLY?
 
YA RLY.
 
... point & case ^^
 
@Jamal It was closed for having not-real code... and then was edited to have real code.
I could not see a reason to keep it closed.
 
3:40 PM
BOTH SAEM Num AN Fibo1, O RLY?
 
Sure, not worth a +1, but, it is a real question, or am I missing something?
 
if (Num == Fibo1)
 
badly written English, but English nonetheless ;)
2
 
That's my point. In 100 years, that is going to be what English looks like.
 
I don't ever want to hear the word "wedding" anymore either :(
 
3:42 PM
Anyone else have a teenage daughter?? lol
 
There is some courting going on in the family, and my family is discussing the wedding already.
 
@rolfl Then please explain that to me. Although it's Java code, it doesn't appear to serve a practical purpose.
 
It is moving really fast, but they haven't even met...
 
@Jamal Looks like example code to me, though @rolfl did give an interesting answer that perhaps validates the question
 
The only thing possibly 'example' about it is the variable names. The edit history does not help make the case.....
 
3:47 PM
I'm kind of missing the context in which it is being used
 
On a scale of great, good, bad, and off-topic, my assessment is that it is better than off-topic, worse than good.
We have many questions that are more examply than that, but are not closed.
 
Then you may need to double-check the questions that I close because I may not know what to close.
 
From my perspective, this is not a big deal. The original question was horrible, broken code. The revised code was a big step ahead. perhaps I was fooled by that.
 
just that got a bit less patient ;)
 
Missed that one ^^^
 
It's like the first time I see even a slight change in the tags.
Did something happen to trigger such an overhelming response?
 

« first day (695 days earlier)      last day (3326 days later) »