• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Is that the normal convention for Objects? Capitalizing them to differentiate them from variables?

It's a very common convention, yeah. Javascript and every other language I've seen are case sensitive. So if someone asks you to implement Circle, you need to implement Circle, not circle. Your code isn't wrong but CodeAcademy checks if a Circle object exists, and it doesn't (because circle and Circle are two completely different things).
 
Is that the normal convention for Objects? Capitalizing them to differentiate them from variables?

I guess in js capitalization is mandatory, but in most other languages it's a convention.
Usually classes are first letter uppercase (Pascal), variables have lowercase then upper case (likeThis), constants are in caps (LIKE_THIS). Rules and conventions change depending on the language though.
 
Swift is now open source:

Swift is now open source!

We are excited by this new chapter in the story of Swift. After Apple unveiled the Swift programming language, it quickly became one of the fastest growing languages in history. Swift makes it easy to write software that is incredibly fast and safe by design. Now that Swift is open source, you can help make the best general purpose programming language available everywhere.

For students, learning Swift has been a great introduction to modern programming concepts and best practices. And because it is now open, their Swift skills will be able to be applied to an even broader range of platforms, from mobile devices to the desktop to the cloud.

Welcome to the Swift community. Together we are working to build a better programming language for everyone.

– The Swift Team

https://swift.org/
https://github.com/apple/swift

Not up on Github yet.
 

JeTmAn81

Member
I guess in js capitalization is mandatory, but in most other languages it's a convention.
Usually classes are first letter uppercase (Pascal), variables have lowercase then upper case (likeThis), constants are in caps (LIKE_THIS). Rules and conventions change depending on the language though.

Capitalization doesn't matter in VB! Haha, stupid VB.

I work in VB every day. I kinda love it.
 

Kansoku

Member
Anyone has any recomendations for someplace to learn Ruby (for programmers)? I recently learnd Python through "Dive into Python 3", and it's great, very clear and consice and since it's directed to programmers, it doesn't go too much into the basics. That being said, I'm having trouble finding something similar for Ruby.
 

upandaway

Member
Hopefully with this assignment done I should be done with Assembly until operating systems. Actually assembly wasn't that bad but I'm glad it's over.
 

Makai

Member
After messing around with Haskell for a few weeks its amazing how easy Python is to work with. :lol

And its given me a newfound appeciation for the quality of the Python ecosystem. I love functional programming and F# is probably my favourite language, but Python has so many libraries for whatever problem you can think off its kinda hard not to use it. F# at least has the .Net world to tap into, but Haskell lacks too much stuff. Still a great language to help you understand functional programming though.

I do miss my typesystem when working with Python, it just feels right to have the compiler yell at me for doing stupid shit like trying to return a string when i should return an int.
Yeah, I immediately moved to F# from Haskell. I'll get around to Python eventually but I can't imagine working without strong static typing.
 
I've run into a weird issue with Visual Studio 2015 (community edition): if i want to select multiple lines i want to use shift + arrow keys, like i do in Word and Notepad and well, any other editor. But this doesnt work in (my version of) VS2015? Is this the expected behaviour and im simply missing some other shortcut to do this?
 

Makai

Member
I've run into a weird issue with Visual Studio 2015 (community edition): if i want to select multiple lines i want to use shift + arrow keys, like i do in Word and Notepad and well, any other editor. But this doesnt work in (my version of) VS2015? Is this the expected behaviour and im simply missing some other shortcut to do this?
Works for me. I have Pro 2015.
 

Makai

Member
I've heard more talk here of F# than anywhere else. Is this the sleeper language or do I need to get out more?
Userbase is small. I started using it two months ago. I was a longtime C# stalwart but it is now my favorite language. I can go into more detail about it if you want.
 

injurai

Banned
I've heard more talk here of F# than anywhere else. Is this the sleeper language or do I need to get out more?

It's been growing recently in general with Microsoft official support of Ximarian and Mono. Haskell has always struggled with purity, and OCaml is just relatively small in general and lacking some library depth despite being easier to work with. However F# has all of .Net behind it. I've seen talk elsewhere too. I think languages like Scala, Clojure, Swift, and Rust have all convince people to take a look adding functional touches to programming, and F# is starting to make it's rounds in mindshare.
 

Koren

Member
I'll get around to Python eventually but I can't imagine working without strong static typing.
That's one of the main things (maybe the main one) that makes me reluctant from doing large projects in Python...

But if you're totally against dynamic typing (since it's already strong in Python), you can always try the Cython superset. At the beginning, it feels a bit like a hack (Cython is a kind of Python extension that allow compilation of the code, but to get better performance, you can specify types associated to names), but it's interesting in that you can choose whether (and when) using static typing.


That being said, the Python standard / common modules are really handy and plentiful, even if it's a bit of a mess sometimes. I often think about Python as a swiss army knife.
 

Makai

Member
That's one of the main things (maybe the main one) that makes me reluctant from doing large projects in Python...

But if you're totally against dynamic typing (since it's already strong in Python), you can always try the Cython superset. At the beginning, it feels a bit like a hack (Cython is a kind of Python extension that allow compilation of the code, but to get better performance, you can specify types associated to names), but it's interesting in that you can choose whether (and when) using static typing.


That being said, the Python standard / common modules are really handy and plentiful, even if it's a bit of a mess sometimes. I often think about Python as a swiss army knife.
I actually haven't spent much time in a dynamically typed language. If I were to learn Python, it would be to see what that's like. I disliked my brief exposure to dynamic typing in Javascript.
 
Userbase is small. I started using it two months ago. I was a longtime C# stalwart but it is now my favorite language. I can go into more detail about it if you want.

It's been growing recently in general with Microsoft official support of Ximarian and Mono. Haskell has always struggled with purity, and OCaml is just relatively small in general and lacking some library depth despite being easier to work with. However F# has all of .Net behind it. I've seen talk elsewhere too. I think languages like Scala, Clojure, Swift, and Rust have all convince people to take a look adding functional touches to programming, and F# is starting to make it's rounds in mindshare.

Is it basically a functional (programming paradigm) C#? .NET backing only makes it sweeter.
I'm studying now so I'm trying to not look it up...
 

Makai

Member
I've taken a programming languages class wherein we did several assignments in Haskell. It was great, but I wished we would have spent more time in it :(
It's very similar to Haskell but with object oriented features. It's the inverse of C#

C# -> OO language with fun features
F# -> fun language with OO features
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
What is the "professional" way to handle multiple offers?

I have an offer from a mid-sized company in Boston that expires on the 9th, but I also have an interview on the 9th from a very large, Palo Alto company.
 
What is the "professional" way to handle multiple offers?

I have an offer from a mid-sized company in Boston that expires on the 9th, but I also have an interview on the 9th from a very large, Palo Alto company.

If you accept the Boston offer, consider your chances with the Palo Alto company over. Do not accept it, then wait to find out what happens with the Palo Alto company, then change your mind with the Boston people.

You can try to stall the Boston company and ask for a little more time, but they're not obligated to give it to you. You can also explain to someone from HR at the Palo Alto company your situation and hope they will bump your interview a little sooner and give you a 24 hour turnaround time on the decision.

In the end though, sometimes you have to make hard choices. Accept the safe bet and throw away the chance at that other company you really want to work at, or throw away the safe bet and risk ending up with neither.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
If you accept the Boston offer, consider your chances with the Palo Alto company over. Do not accept it, then wait to find out what happens with the Palo Alto company, then change your mind with the Boston people.

You can try to stall the Boston company and ask for a little more time, but they're not obligated to give it to you. You can also explain to someone from HR at the Palo Alto company your situation and hope they will bump your interview a little sooner and give you a 24 hour turnaround time on the decision.

In the end though, sometimes you have to make hard choices. Accept the safe bet and throw away the chance at that other company you really want to work at, or throw away the safe bet and risk ending up with neither.

Are there legal implications that would be possible if I accepted an offer and then backed out on it?

It would be an asshole thing to do, and I'm not saying I would, but I need to know all of my options before making this decision.
 

LegatoB

Member
Are there legal implications that would be possible if I accepted an offer and then backed out on it?

It would be an asshole thing to do, and I'm not saying I would, but I need to know all of my options before making this decision.
Well, if you think you're going to back out, I definitely wouldn't SIGN anything with them.
 
It's very similar to Haskell but with object oriented features. It's the inverse of C#

C# -> OO language with fun features
F# -> fun language with OO features

Sounds really cool. Saw on their page it works on just about every OS so I'll definitely look into it...........sometime :/
 
Are there legal implications that would be possible if I accepted an offer and then backed out on it?

It would be an asshole thing to do, and I'm not saying I would, but I need to know all of my options before making this decision.

I'm not sure.

Frankly I wouldn't do it simply out of professional integrity. And i say that as someone who's done it before, when i was young and stupid and didn't know better.

If the Boston company wants you bad enough, they should extend the offer for a few days. The palo alto company should be able to give you fast turnaround time if you explain the situation.

Don't change your mind after signing anything. That's my advice.
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
I'm not sure.

Frankly I wouldn't do it simply out of professional integrity. And i say that as someone who's done it before, when i was young and stupid and didn't know better.

If the Boston company wants you bad enough, they should extend the offer for a few days. The palo alto company should be able to give you fast turnaround time if you explain the situation.

Don't change your mind after signing anything. That's my advice.

Thanks. I appreciate the advice. I'll hold off on signing anything until I make a full decision. The Boston company may give and extension for the offer, and I'll explain the situation to the Palo Alto company and ask for a quicker decision.
 

Kalentan

Member
Hey guys, any idea why I maybe getting Segmentation Fault in this C code in Pico?

Code:
int my_strlen(char s []){
int length = 0;
int i = 0;
while(s[i] != '\0')
{
length++;
i++;
}
return length;
}

int my_strcpy(char s [], char t []){
int len1 = my_strlen(s);
int len2 = my_strlen(t);
int i = 0;
if ((len1 > len2) || (len1 = len2)){
        while (t[i] != '\0')
        {
        s[i] = t[i];
        i++;
        }
s[i] = t[i];
printf("%s", s[i+1]);
return 1;
}
if (len1 < len2)
{
return -1;
}
}

....
....

int lena = my_strlen(str1);
int lenb = my_strlen(str2);
printf("\n Length of String1 is %d, and length of String2 is %d.", lena, lenb);
printf("\n The original String1 is %s.", str1);
int rx;
rx = my_strcpy(str1, str2);
if (rx == 1)
{
printf("\n The mixture was successful %d.", rx);
printf("\n The mixture of String1 and 2 is %s.", str1);
}
else
{
printf("\n The two strings cannot mix. String1 is shorter than String2. %d.", rx);
}

Context: The code will run up to the point where it shows the length of String1 and String2 and it is always correct in my attempts. However after that, it get's a Segmentation Fault in the: "rx = my_strcpy(str1, str2)".

Weird thing is. It used to run, but would seemingly always believe that String1 is larger than String2, even when it wasn't the case. Now I just get a Segmentation Fault. Though even when it did that, it would also work incorrect. The idea of "my_strcpy" is that... Say you have "Hello" and "Bye".

The answer should come out to be: "Bye\0o." Yet in all scenarios, "Bye" would simply replace "Hello." Like somehow it always cuts off the rest.

Any ideas? The rest of the code I left out runs perfect.
 

peakish

Member
Hey guys, any idea why I maybe getting Segmentation Fault in this C code in Pico?


Context: The code will run up to the point where it shows the length of String1 and String2 and it is always correct in my attempts. However after that, it get's a Segmentation Fault in the: "rx = my_strcpy(str1, str2)".

Weird thing is. It used to run, but would seemingly always believe that String1 is larger than String2, even when it wasn't the case. Now I just get a Segmentation Fault. Though even when it did that, it would also work incorrect. The idea of "my_strcpy" is that... Say you have "Hello" and "Bye".

The answer should come out to be: "Bye\0o." Yet in all scenarios, "Bye" would simply replace "Hello." Like somehow it always cuts off the rest.

Any ideas? The rest of the code I left out runs perfect.
This line:
Code:
if ((len1 > len2) || (len1 = len2)){
In the second part you are assigning len1 = len2, not checking if they are equal. This evaluates to True.
I'd suggest using the greater-or-equal-to operator instead:
Code:
if (len1 >= len2){
 

Koren

Member
I actually haven't spent much time in a dynamically typed language. If I were to learn Python, it would be to see what that's like. I disliked my brief exposure to dynamic typing in Javascript.
I'd say it's nothing like Javascript. I don't enjoy Javascript at all myself.

There's a couple of things in Python I don't like (and I've some different views with Guido von Rossum, for example on functional programming, which he totally dislike apparently) but it's nonetheless a nice langage to use if I want to be honest. Dynamic typing can really be handy and useful.

It's just I like the way compilation can catch some errors for me, while in Python you have to do a hell lot of tests to check everything is correct (and it'll still be bad at the end because you haven't thought someone could provide an np.array instead of a list, and your code won't refuse it and return a value of the correct type which is still totally wrong...)

BTW, I agree that "dive into Python" Kansoku was talking about earlier is a great way to get a gripe at the language, in not more than a single afternoon, you should already be at ease with Python.

(and I'd like to hear if there's an equivalent in Ruby too, btw)

It might be a while, because F#'s type inference seems like the best of both worlds.
I'd say you don't come to Python because of the language, but because of the available modules and the whole ecosystem.

You want to make a program that retrieve a webpage, perform regular expression on it to extract relevant information and mail it to you? Done in minutes. A program that load a picture, perform a fast fourier transform, filter it and FFT it back? Same. Create a server that act as a website? Not much more work.
 
Thanks. I appreciate the advice. I'll hold off on signing anything until I make a full decision. The Boston company may give and extension for the offer, and I'll explain the situation to the Palo Alto company and ask for a quicker decision.

I'll also add that you might get a better offer from the Palo Alto company if you tell their HR about the offer you were given, along with all of its terms.

Very strong might, there. Especially if it's the one that I'm thinking of.
 
Goodness, is the kernel next?!

I've been saying they're going to open source the kernel for the past year. Wouldn't be surprised if they opened a few system libraries like ntdll and kernel32 also. Makes perfect sense for them in this new world, it's only a matter of time.

Everyone says I'm crazy but I'll be here to gloat when it turns out I'm right :)
 

Granadier

Is currently on Stage 1: Denial regarding the service game future
I'll also add that you might get a better offer from the Palo Alto company if you tell their HR about the offer you were given, along with all of its terms.

Very strong might, there. Especially if it's the one that I'm thinking of.

Well when they originally asked if I had any other pending offers or interviews I said "yes, expiring on the 9th". So I was a bit surprised when they scheduled the interview on the same day.
 
Well when they originally asked if I had any other pending offers or interviews I said "yes, expiring on the 9th". So I was a bit surprised when they scheduled the interview on the same day.

It's hard to speculate how that happened. I know of one large company that can make you an offer on the day of the interview, and that's Apple.

There's a bunch of Alphabet companies that are trying to hire fast, too, but I'm not sure about the turnaround there. They do seem faster than Google used to be, in general.
 

Kalentan

Member
This line:
Code:
if ((len1 > len2) || (len1 = len2)){
In the second part you are assigning len1 = len2, not checking if they are equal. This evaluates to True.
I'd suggest using the greater-or-equal-to operator instead:
Code:
if (len1 >= len2){

I actually used to have that the ">=" but I still kept getting segmentation fault.
 

Chris R

Member
How complicated is implementing SSO/SAML (ASP.NET)? Looks like I need to move what we currently use over before the end of the year, wondering if it will be possible or if I'll be putting in overtime these next weeks.
 

JeTmAn81

Member
I actually used to have that the ">=" but I still kept getting segmentation fault.

The segmentation fault looks to be coming from the copy function where you're trying to print the i+1st character of the array when i+1 is beyond the bounds of the array.
 

Kalentan

Member
The segmentation fault looks to be coming from the copy function where you're trying to print the i+1st character of the array when i+1 is beyond the bounds of the array.

Oh. I forgot to remove that... Wonder if it will fix it. Yet I worry that even with that no longer giving me an error. Somehow rx will always be 1, even if len1 is less than len2.

I'll try it out and edit this post.

Edit: Yup. Even when Len1 is less than len2, it always somehow satisfies the condition of (len1 >= len2).

It would be one thing if the getting length equation was wrong... But the output for the length of both strings is correct. But regardless it still does the combination incorrect. Somehow it's simply changing: "Hello" to "Bye" instead of "Bye\0o" Which is replacing the first 4 characters of Hello with Bye and the '\0' which is the enter key.

Edit2: Fixed the length problem. Whoops, forgot to add the second '='. Still the combination is still wrong.

Edit3: Okay- okay. So. I'm unsure if there is even a way to fix this... But this part:

Code:
s[i] = t[i];
return 1;

Which comes after replacing string1 parts with string2, is causing the rest of string1 to vanish because of the '\0'.

If I remove that line and use the same examples of "Hello" and "Bye". I get "Byelo". If I add the line, I get: "Bye."
 

JeTmAn81

Member
Oh. I forgot to remove that... Wonder if it will fix it. Yet I worry that even with that no longer giving me an error. Somehow rx will always be 1, even if len1 is less than len2.

I'll try it out and edit this post.

Edit: Yup. Even when Len1 is less than len2, it always somehow satisfies the condition of (len1 >= len2).

It would be one thing if the getting length equation was wrong... But the output for the length of both strings is correct. But regardless it still does the combination incorrect. Somehow it's simply changing: "Hello" to "Bye" instead of "Bye\0o" Which is replacing the first 4 characters of Hello with Bye and the '\0' which is the enter key.

Edit2: Fixed the length problem. Whoops, forgot to add the second '='. Still the combination is still wrong.

Edit3: Okay- okay. So. I'm unsure if there is even a way to fix this... But this part:

Code:
s[i] = t[i];
return 1;

Which comes after replacing string1 parts with string2, is causing the rest of string1 to vanish because of the '\0'.

If I remove that line and use the same examples of "Hello" and "Bye". I get "Byelo". If I add the line, I get: "Bye."

I don't really have time to go through all your code again but you should adopt a judicious debugging strategy. Test each small piece until you know it's working separately before testing those pieces in combination. So you fixed the length thing, and you would've needed to keep testing your length calculation until it produced the right result consistently.

Same deal with the actual string copying. Test what your i variable is set at in different parts of the code (after it exits the loop, for example). Test what your strings are set to (each individual character in the array). Look at all the data and test the smallest parts you can find first to make sure they work, then combine and test the combination.

Oh, and if you still can't fix it, write the whole thing again from scratch. You don't necessarily have to literally write every piece of code again. It's ok to copy and paste existing code, but if you do that you have to check the code you're transferring over very carefully to make sure you're not bringing any bugs over. Honestly in that situation and especially since it's not a lot of code, it's best to just write it again from scratch. That will cause you to reevaluate the way you're doing everything and might help you catch errors like assigning in an if condition instead of comparing, at least if you're keeping those rules in mind.
 

TurtleTracks

Neo Member
I seem to have pretty terrible luck with gpu-programming, at least on my laptop.

I thought I'd try my hand at path-tracing on the GPU using CUDA, but couldn't get the code-samples to run after installing the toolkit. The programs simply stall, don't even seem to reach "int main()" in the .cu kernel. The Nsight CUDA debugger doesn't work either, simply crashes visual studio. I moved on to implementing some other type of fast-GI cause I need to something in for my final project, but I'm really bummed out.

Do I have bad luck, or is gpu programming on the laptop generally a painful experience? This isn't the first time I've run into issues with the graphics card either. When I was first learning opengl, I would fail to open a context 1/6 times on the nvidia GPU, though running off the Intel chip generally worked flawlessly. Had to wait for a driver update before that got sorted out. I feel like Nvidia's Optimus technology is often the source of my grief.

Are there laptops that can handle this stuff reliably or do I have to move up to a desktop? I'm a college student so I kinda prefer the mobility of a laptop. Does anyone else ever have to deal with buggy drivers or software? Generally how do you work around issues in your coding environment?
 
Top Bottom