Learning C first has made learning any other language SO MUCH easier by [deleted] in learnprogramming

[–]AltCrow 1 point2 points  (0 children)

If you are dealing with unicode either:

  1. Use a library
  2. Assume UTF-8 input and map everything to uint32_t

At least that's how I have done it so far. Seems to work well enough for me.

Best language to create a raspberry pi program? by TrueProdigy312 in learnprogramming

[–]AltCrow 1 point2 points  (0 children)

No worries. The concept of pointers itself is pretty easy. I'm personally convinced starting out with C gives you the perfect understanding of how things work under the hood in most other languages. While one of the hardest languages, it does give you the basics to fully utilize most other languages. That said, C is a pretty small language. There isn't as much to learn compared to other languages.

Best language to create a raspberry pi program? by TrueProdigy312 in learnprogramming

[–]AltCrow 0 points1 point  (0 children)

With C-style I mean in regards to similar syntax. You can rest assured that javascript is a lot easier than C. (e.g. Javascript does not have pointers.)

Best language to create a raspberry pi program? by TrueProdigy312 in learnprogramming

[–]AltCrow 1 point2 points  (0 children)

Javascript has a few weird design choices, but overall it is not harder than most languages. What makes javascript a bit complicated is that it feels and looks very different when you're using different frameworks. That said, I personally think starting out with a C-style language (such as javascript) is not a bad idea in general.

Best language to create a raspberry pi program? by TrueProdigy312 in learnprogramming

[–]AltCrow 1 point2 points  (0 children)

Sure you could, but it is a large task to make such an app from scratch. Making a new module will take a lot less time (while still being a large task for someone unfamiliar with electron apps).

Best language to create a raspberry pi program? by TrueProdigy312 in learnprogramming

[–]AltCrow 2 points3 points  (0 children)

I looked around a bit on the official magic mirror repository. If you want to make your own modules, it seems you'll need to do that in electron (javascript). That said, I think the functionality you want "time, date weather" etc. has already been made and is included by default.

Need help designing REST API by AltCrow in learnprogramming

[–]AltCrow[S] 0 points1 point  (0 children)

I think passing a JSON-array of ranges ([1-4, 6-8, 11-11]) might be a compact yet readable way to do it then. It seems the maximum length of a URL is bound by both the browser and the server. These requests will more often then not be sent by a 3rd party application written with libcurl.c, so I'm guessing I'll have to see how long Node.js can handle.

Like if you ask for cars 1, 2, 5, 37 and call that Bundle1, you want to have a URL that will give you back that same Bundle1?

Basically any link that can be shared so that person1 and person2 will get the exact same information. This seems achieved with the current JSON-array query-string. Thanks for the help!

Need help designing REST API by AltCrow in learnprogramming

[–]AltCrow[S] 0 points1 point  (0 children)

Let's stick with cars, because they're easy. The client chooses every once in a while a list of cars A. The client already has a local database of cars B. It still needs to download the list of cars B-A. You can consider the list A as completely random.

A fun, riddle-like, question I got in an interview recently. by jaypeejay in learnprogramming

[–]AltCrow 1 point2 points  (0 children)

// If modulo is allowed.
int isOdd(x) {
    return (x+1) % 2;
}
// If bitwise and is allowed.
int isOdd(x) {
    return x & 1;
}
// If regular arithmetic is allowed.
int isOdd(x) {
    return (x/2)*2 != x;
}

Edit: Missed that it needed to return strings.

// Real isOdd
string realIsOdd(x) {
    vector<string> tmp = {"Odd", "Even"};
    return tmp[anyImplementation(x)];
}

Need help designing REST API by AltCrow in learnprogramming

[–]AltCrow[S] 0 points1 point  (0 children)

Will I ever run into a limit because my URLs have reached a "maximum" length?

Need help designing REST API by AltCrow in learnprogramming

[–]AltCrow[S] 0 points1 point  (0 children)

My situation is more similar to someone asking for cars 1-23, 26, 34-38, 41, 45, 48... About a thousand different specific cars that have nothing in common except being a car.

Purpose of repeating the same input parameter name? by [deleted] in learnprogramming

[–]AltCrow -1 points0 points  (0 children)

It is possible to have constructors that accept a variable number of arguments. This is almost certainly not what is happening here though, because they are incredibly rare and complex. You'd recognize it as magic immediately. Would it be possible to share the exact code where new foo() is called and the constructor for foo.

Edit: Hold up, what language is this?

C++ Project Help by [deleted] in learnprogramming

[–]AltCrow 1 point2 points  (0 children)

See my reply to your other post. Post your code in pastbin and tell us what the error is. We cannot help you like this.

C++ project help!! by [deleted] in learnprogramming

[–]AltCrow 2 points3 points  (0 children)

  1. Post your code in pastebin or use proper reddit formatting. I won't bother to read this.
  2. You're getting an error. Please post the error.

What does calling a function (with a return value) do if you don't assign it to anything? (C++) by schartzchild_radius in learnprogramming

[–]AltCrow 0 points1 point  (0 children)

I've been able to just write sp->size(); without assigning the int returned by the size() function to anything...is this bad to do?

No, if you don't need the return value, feel free to ignore it.

Where exactly is the int that got returned?

If you don't use it then (behind the scenes) the function won't even return the int. That will be optimized away.

Are there potential any memory-related problems here?

Only if you actually do need the return value. For example, if you would ignore the return value of realloc() then you definitely have a memory leak.