[ / / / / / / / / / / / / / ] [ dir / random / 93 / biohzrd / hkacade / hkpnd / tct / utd / uy / yebalnia ]

/prog/ - Programming

Programming

Catalog  Archive

Name
Email
Subject
REC
STOP
Comment *
File
Password (Randomized for file and post deletion; you may also set your own.)
Archive
* = required field[▶Show post options & limits]
Confused? See the FAQ.
Options

Allowed file types:jpg, jpeg, gif, png, webp,webm, mp4, mov
Max filesize is16 MB.
Max image dimensions are15000 x15000.
You may upload5 per post.


File: 55271e1daa3654f⋯.jpg (19.37 KB,334x302,167:151,Morpheus2.jpg)

4a40e5 No.5313 [Open thread]

What if i told you you can have a programming language that's simpler than Python and faster than C?

30 posts and 3 image replies omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

470cf9 No.5432

>>5425

In order to make use of domain specific features as matters of convenience and productivity. The theory of Turing completeness means that the functionality will be equivalent in the end. That doesn't mean that the programming effort to reach that point is equivalent.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

dacacb No.5443

>>5432

that's a fallacy.

as i already said same can be achieved with a library.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

3429c3 No.5444

>>5315

>C's compiler technology is probably the most advanced of all

LOL. Fortran has been far ahead of C forever. They just finally got a major optimization into C compilers on par with Fortran and there are others.

IIRC they also got Common Lisp (CMUCL?) on par with Fortran for some numerical compilations ages ago and kept it for a little while.

No specific memory but I bet Java got up there pretty good.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

f3bc26 No.5456

File: 610d1b36249c183⋯.png (501.14 KB,9611x2167,9611:2167,static_graph.png)

next milestone is first step in automatic concurrency

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

80ef2f No.5489

File: 666471a32e92c87⋯.gif (777.57 KB,300x100,3:1,4311mj.gif)

I would be happy

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



File: befc86f94e2f0e0⋯.png (143.37 KB,600x600,1:1,thonk.png)

ca80ef No.5396 [Open thread]

is it wise to write a password manager in an high level language like python?

1 post omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

c509e6 No.5399

I would say it's less safe because of the popularity of Python.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

a4684a No.5400

>>5399

Explain.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

c509e6 No.5411

>>5400

I didn't give it much thought to be honest. Consider it a shitpost

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

4b0393 No.5474

>>5396

>not writing down your password

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

5e9637 No.5479

If you're writing a production-grade (what that means is up to you) password manager, you're going to want a rock-solid crypto library and a stack that you can ultimately trust. If Python provides that for you, then sure. You also have to consider the vulnerabilities and limitations of the programming language itself. You might also write a front-end in Python to a more secure (read: low-level) back-end, but then you have to deal with vulnerabilities at the language barrier and in any kind of RPC system you might use if you're not doing everything locally. I'd just stick with a low-level language like C, C++, or Rust. Something like Go should be relatively fine too for a personal-use password manager.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



File: 83526d4560c2a80⋯.jpg (109.08 KB,394x600,197:300,manga_mutiny_cover_yt_BL9l….jpg)

File: 17c6c3503e2fe5a⋯.jpg (48.34 KB,259x400,259:400,6525081.jpg)

File: 2f65d23d757959a⋯.jpg (41.57 KB,300x446,150:223,30284832.jpg)

61a2b9 No.5475 [Open thread]

____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.


0211b1 No.4336 [Open thread]

whats a good first programming launguage

and is codeacademy any good

____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

0211b1 No.4349

java

yes

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

0211b1 No.4350

>>4349

>java

It's shit. Start with something like Python, Ruby or Scheme/Racket instead. After that, try C/C++ to get a slightly better understanding of how the machine works.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

ee6c1d No.5471

I would learn Java, though getting old. It's easy to learn and the main bulding blocks of the language are found in any other programming language. Furthermore it's quite similar to C#. But If you want to get a job you have to dive deeper in the ecosystem. Learn Frameworks, stuff like gradle, maybe kotlin. Do some research if you want to find a job. But Java is a good startibg point.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

ee6c1d No.5472

>>4350

Yeah it isn't the best. But the learning curve is high. And Python has a more distinct syntax which makes the transition between languages harder if you're a beginner. Ruby. Is good for web programming. If you want to go into that field, but then sure go for Ruby. C++ in my opinion is just too much if you're starting out. The language has too much to offer. As i said above. Start with Java, do some Job research and then make transition.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

4cf897 No.5473

>>4350

>java is shit

>try python, ruby

modern languages with the beginners charm fall apart quickly when you move to advanced stuff.

start with c/c++ , then java.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



e7a4dc No.5212 [Open thread]

Is there anything about x86 ASM? I want resources on x86 ASM. Does anyone here have any good books or have experienced programming in it.

8 posts omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

93a413 No.5457

what are some comfy systems to learn assembly for if you want to start from nothing like Terry and build something akin to an os? like easy basic graphics/hardware interfaces in assembly. i guess i could go for a ti-84 but i want something more featured, preferably better than a c64 but that's probably getting into graphics accelerators and i have no idea what i'm doing.

again i have no idea what i'm doing or what i want since i'd also want a system with a good emulator so i dont have to pay an arm and a leg. i guess i'm stuck with a ti-84 in reality. the c64 emulators i tried wouldnt even run BASIC commands so i dont think that's the way to go. just jumping into x86 or A64 (i have a rpi) seems like trying to learn to swim by diving in lava.

should i just focus on C and not give a shit about assembly?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

0bbc07 No.5458

>>5457

MIPS is popular for learning, it's relatively simple but had actual hardware.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

93a413 No.5459

>>5458

thanks, i'll take a look

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

7cf907 No.5466

>>5457

Learn RISC-V.

MIT's entire 6.004 class is open sourced, including the lectures which are all on YouTube https://6004.mit.edu/web/spring19/resources/lectures

You can buy these chips for next to nothing, and program them from the ground up yourself. A hardware hacker's dream. India and some other countries are working on a total replacement for ARM using RISC-V. Learn it now and get in on that action if it ever happens.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

49771d No.5467

File: 4f6b0f846dcc977⋯.png (347.1 KB,734x734,1:1,ClipboardImage.png)

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



99af03 No.5454 [Open thread]

There is a resurgence in programming languages and compilers that target native binaries. Go is already popular. Rust enjoys a lot of hype. D and Haskell seem to be making a bit of a comeback. New compilers are being worked on for existing languages, like Kotlin Native and Scala Native, and entire new languages are being developed, like Zig, Swift, Pony, Nim, Crystal and V. Which are you betting on? Which do you find interesting?

Do you think WASM will overturn the trend? There is certainly a lot of people trying to make "write once, run everywhere" happen with WASM for some reason.

____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

214004 No.5461

>>5454

WASM right now is just a MVP, meaning minimal viable product so it's missing tons of features. You need to jerryrig a lot of things to get it to work.

That said, when it finally is a real prototype, you will be able to compile WASM binaries in any language and yes it will likely eat the world as we know it where your browser merely pushes a binary and all those web app stores are obsolete. In fact almost everything will be obsolete because they want native resource access in the final prototype meaning an application that is just pushed through your browser and has native access to everything including your video card in order to render graphics. Programs like Windows Word or whatever will be this type of binary, fully owned by a remote company and just lended to you through a binary push. We're entering a radically different style of computation where RMS was essentially correct, the bulk of computation will be done remotely on closed source ecosystems and just pushed to you through a dumb terminal.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



33e233 No.5138 [Open thread]

Discuss and share Python related talks here.

This includes all versions just be explicit about it.

2 posts omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

97f363 No.5378

Hey, I'm learning Python, specifically Python 3.6. I came across an issue involving tuples, specifically with:

tuple.index(x)

Whenever x is a variable defined by an input, it gives me a value error saying it is not in the tuple. Is there some work-around?

I can provide the original code and error message as needed.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

43df32 No.5379

>>50378

if i remember then input is a string and needs to be convertet to an int if you want to use it with index

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

475d53 No.5391

>>5378

https://docs.python.org/3/library/stdtypes.html#index-19

"""8. index raises ValueError when x is not found in s. Not all implementations support passing the additional arguments i and j. These arguments allow efficient searching of subsections of the sequence. Passing the extra arguments is roughly equivalent to using s[i:j].index(x), only without copying any data and with the returned index being relative to the start of the sequence rather than the start of the slice."""

While this is poor design, it is documented behavior. The workaround is:


>>> import operator
>>> import functools
>>> def seqindex (seq, item):
... return next (
... map (operator.itemgetter (0),
... filter (operator.itemgetter (1),
... enumerate (
... map (functools.partial (operator.eq, item),
... seq)))), -1)
...
>>> seqindex ((1, 2, 3), 3)
2
>>> seqindex ((1, 2, 3), 4)
-1
>>>

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

97f363 No.5393

>>5378

OP here, fixed the code, works fine now. I appreciate the help.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

791c13 No.5445

>>5378

Was it a type thing? Did you have a tuple with integers in it, nad were trying to find the index using a string variable?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



File: dd70dffa3355902⋯.jpg (29.19 KB,680x383,680:383,1513536086815.jpg)

05f746 No.5259 [Open thread]

Having a million stickies and meta threads was annoying so I claimed the board and cleaned it up a bit. If you have any desires in regards to this board I'd like to hear them; what rules should we have, what settings to change (e.g. should we have images or not?), should we have banners, should we have a dedicated newbie/QTDDTOT thread, what do you think in regards to the board CSS, etc.

In case you encounter a thread that gives 404, you can fix it by logging in at https://sys.8ch.net/mod.php with the username "Anyone" and password "0", and then posting in the thread through mod.php. You can also post in this thread if you want me to fix it.

In case the board goes up for claims or there's an unresolved problem, I'd like to hear about it in this thread first. Since this board is not fast I may not feel the need to log in too often, but that doesn't mean I'm not active here.

--

/prog/ rules:

1. Common sense rules; no spam, stay on the topic of programming, don't bait for more specific rules, etc.

2. Don't start shit about the languages other people use if there's no good reason to, especially if you just plan to shill another language in it's place. You don't need to be a supreme gentleman or avoid arguments but basically don't shit up the board and derail threads needlessly.

3. Meta is only allowed in this thread.

4. Making new threads for your projects is allowed, but don't beg for people to do things for you, this includes "do my homework" type posts.

2 posts omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
Post last edited at

c20c33 No.5311

It would be nice if this place was more active, since the start of this year /tech/ has been filled with /g/-types who can't program and instead shit up the board with consumerist shit.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

9fabca No.5312

>>5311

I feel you. /tech/ was already filled with idiots beforehand, but it's gotten really bad recently. For what it's worth, I'm monitoring this board. Just start a thread about something you want to talk about.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

05f746 No.5436

>>5434

>Can we just get the standard board font here? This is unreadable.

--

Deleted meta thread. Any other opinions on the above? I can change the font to something else or let it be the default if it's annoying. Would a monospace font be interesting?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

a56dc1 No.5439

I find the font easy to read. However, could it be possible to wrap each post around a square or a line that separates from the post above? it would make reading a lot easier.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

05f746 No.5440

>>5439

Sounds straightforward enough, I added a faint line above replies.

8chan is a piece of shit though so the change may not be visible yet.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
Post last edited at



File: ce71e181dd0efc2⋯.png (29.77 KB,600x315,40:21,4130ADA2-3703-4A6F-985A-B7….png)

be7806 No.5417 [Open thread]

Hi, i am with the Haiku project here.

If you never heard about it: “Haiku is an open-source operating system that specifically targets personal computing. Inspired by the BeOS, Haiku is fast, simple to use, easy to learn and yet very powerful.”

The project have serious lack of manpower, this is why am i here.

Haiku and the HaikuPorts project searching for devs and experts for the following areas:

- CPP developers

- Go port developers

- Python experts

- driver developers

- marketing magicians

- media related developers

- infrastructure operators

- translators

And many more!

Join today!

https://www.haiku-os.org/ and

https://github.com/haikuports/haikuports

Sorry if this unrelated here.

I stay hete to answer your eventually questions.

Thank you guys!

6 posts omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

1623e6 No.5431

>>5430

Then GNU is not Unix-derived because it is an independent implementation of Unix that wasn't derived from any Unix heritage.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

29bbf3 No.5433

>>5431

"Unix-derived" referred to the design, not the source.

>GNU

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

1623e6 No.5437

>>5433

To be Unix means having a lineage from the old versions of Unix which was actually built from the source code. To be Unix-like is to reimplement the Unix system in a clean room implementation.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

29bbf3 No.5438

>>5437

Thanks for lecturing me on what my own words meant, clearly I wouldn't know that myself.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

1623e6 No.5442

>>5438

No worries friend, happy to be of help.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



File: 41e97c61f74be8d⋯.png (76.34 KB,500x500,1:1,competitive-programming.png)

776eac No.4405 [Open thread]

ITT we discuss Competitive Programming , is it useful ? have you tried to be part of team >> etc.

1 post omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

776eac No.4433

I'm classified for the regional competition of the acm. Didn't try the other ones.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

9eb7c9 No.5374

For real life it's more useful to just work on projects, but I believe learning to solve hard problems on comp. prog. sites really does give you some form of divine intellect.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

8a3873 No.5383

It's probably most useful if you're a researcher in algorithms or something.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

68d7cf No.5415

I've done some of this.

Anybody interested here's a good resource: https://contest.cs.cmu.edu/295/s19/

If you're American join the USACO Training program https://train.usaco.org/usacogate it's probably the best training to go from beginner -> strong competitor.

Topcoder and all that junk, I never bothered with. The only thing you should be doing on Topcoder is claiming bounty's for writing features (this is how Topcoder works, they post a feature they need, you write it, they give you the bounty). The actual online competition and whatever is meh, you should physically enroll in a competition if you're truly interested and build a team.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

4ac268 No.5420

>>4430

There's utility in experiencing different software requirements. I'm an experienced programmer that's spent much time writing business software. I've recently started learning about game programming and I've picked up many kinds of techniques and lessons that I can apply for my work in business software.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



e7c6e5 No.5134 [Open thread]

Discuss and share C++ related talks/questions here. All early and later standards are welcome (be explicit).

20 posts omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.
Post last edited at

299e9e No.5300

https://spit.mixtape.moe/view/a58b07a8

Why the unexpected behavior here? Instead of segfaulting it "fails" silently. Please excuse my lack of understanding here.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5305

>>5300




#include <iostream>
using namespace std;

void swap(int * p, int * q){
int temp;
temp = *p;
*p = *q;
*q = temp;
cout << "Hello" << endl; //this is the unexpected behavior point; cout does not work if int is passed to int* but it also doesn't just crash or not compile; why the unexpected behavior?
}

int main(){
int c = 5;
int d = 10;
swap (c, d); // this should be swap(&c, &d) yet this DOES swap the values but does not cout as expected or segfault
cout << "c is set to: " << c << endl;
cout << "d is set to: " << d << endl;
return 0;
}

It's because you are not calling swap, you are calling

std::swap
. It's getting included indirectly through the
#include <iostream>
, and when you write
using namespace std;
the entire contents of
std
gets brought into the global namespace. You have written a
swap
with a new signature, so that is fine, it just becomes a new overload. When looking at the
swap
call, the compiler performs overload resolution, and decides to call
std::swap
because that is the overload of
swap
which matches your arguments.

See https://en.cppreference.com/w/cpp/algoritPost too long. Click here to view the full text.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5306

>>5305

>>5300

You can prove this to yourself by deleting your swap function, the code still does the same thing.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

fb0d52 No.5320

>>5305

I swear, everytime I see a post like this, C++ is involved. But seriously I think this explains why "using namespace std;" is a bad idea. Beware of what you make implicit.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

bce316 No.5412

>>5320

>everytime I see a post like this, C++ is involved

this is a mistake even easier to make in C anon, as you and anon just demonstrated. The value semantics of good C++ as (opposed to anon's C-with-classes code) eliminates this issue. For example, this behaves as anon expected and calls his fubar version instead.

#include <iostream>

void swap(int a, int b) {
// fubar
}

int main() {
using namespace std;
int a{1}, b{2};
cout << a << b << '\n';
swap(a, b);
cout << a << b << '\n';
}
and as you said, beware of ignorance.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



File: 8d9e72129983fc2⋯.png (14.65 KB,800x400,2:1,https.png)

be209a No.4564 [Open thread]

I'm making a Node.js application for the first time without a tutorial and I am trying to use an external API someone else made to grab data.

I am getting a mix content error in the console log whenever I try to call the API because it is HTTP and not HTTPS.

I deployed on Heroku and Heroku is of course secure/https.

I have no idea how to convert the HTTP API into a secure HTTPS link.

Please let me know what tools I need and how to go about it. I have a feeling NGROK may be useful but I am pretty lost with this problem.

____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

be209a No.4566

I am doing the GET through an AJAX call which gets activate onClick.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

be209a No.4572

>>4564

var options = {

url : '',

method : 'GET',

strictSSL : false

};

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

4bd7c2 No.5410

>>4564

Your application should proxy the requests to avoid that.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



File: 3fba14b8e7c6895⋯.png (69.67 KB,286x306,143:153,question 2.png)

b7c11e No.5324 [Open thread]

Hi I'm been amateur programming for years and now go to school to learn it.

I've always been confused about what the best practice is for declaring variables. When I first did programming in highschool we were told to declare all the variables at the top of the scope (I guess for the convenience of the teacher) but also see people declare them in the middle of the code as needed (like a counter right before a while loop).

So redpill me on the variable question. Logically declaring it right before needing it seems like the best thing to do.

7 posts omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

d2220f No.5363

>>5327

honestly this. Many linters will give you a warning that you have too many local variables, and it's true. Local variables are helpers, and they should be set directly before they are being used. If you have a bunch of local variables, either use class/static parameters directly or split up the function. You probably don't need all 16 variables for the same thing, and if you do, put them in an array or something.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

d2220f No.5364

>>5343

this so much this. CS niggers in college will try to follow rules and make their code "super-readable". Newsflash: no code is readable. You just have to make is the most understandable, and even that will take a lot of rewrites before you find that yes, this way is the most optimal way of solving the problem at hand. So just do what seems right, get the functionality, and then review and see if you can make sense of the code.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

936bc0 No.5365

>So redpill me on the variable question. Logically declaring it right before needing it seems like the best thing to do.

Yes, this is best. It's not 1981 any more so we don't need to carry on antiquated practices that were required for the limited memory of the day.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

e3ba64 No.5407

>>5324

Just declare them so that the program can be maximally readable to all the people that are working on the code. If it's just you, then do what's most convenient to you.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

f1b3b5 No.5408

It doesn't always make sense to put everything on top.

If say I need a temp variable that I'm only gonna use in a "for" then I'll create that variable on top of that "for" that way everyone knows that that variable is only really used there.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



625a8d No.5385 [Open thread]

I'll have an internship at back-end of some huge service. But I've never programmed anything more serious than homework or site with 3 pages. What should I learn or do in order not to fuckup at my work?

Someone's advised me to read SRE book. Will it help?

____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

625a8d No.5387

File: f54bf0321f7d31a⋯.png (421.16 KB,570x367,570:367,15572540937850.png)

bump

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

8a2f5e No.5388

Keep your mouth shut and listen for the most part. If someone suggests you to do it a certain way, do it and then show it to them they'll appreciate it.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

8a2f5e No.5389

Also the redhead is obviously the hottest one

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

625a8d No.5392

>>5388

Thanks, it's obvious but important.

>>5389

Oh, she is.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



File: c254f3cd9699aae⋯.jpeg (9.75 KB,195x258,65:86,maxresdef.jpeg)

a6ace5 No.4597 [Open thread]

Is it snake oil garbage or is it really relevant?

What are some simple application that could be made better by using parallel computing or anything to play with OpenMP

2 posts omitted. Click [Open thread] to view. ____________________________
Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

a6ace5 No.4609

>snake oil

hadoop?

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

a6ace5 No.4620

Apply a map to an image. This is an awesome example of SIMD computing.

Anything that's isomorphic to the above example is also a good example, and there are a lot of those.

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

a6ace5 No.4643

>>4597

This free CMU book will show you all the algorithms and data structures that can benefit from being run in parallel http://www.parallel-algorithms-book.com/ which is a ton of things

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

413768 No.5274

It's certainly not snake oil OP. With multi-core cpus if you don't program intentionally to take advantage of them, then you are leaving a metric shitton of perf on the table. This is currently the best book on the subject in general so I'm shilling it for now.

https://www.manning.com/books/c-plus-plus-concurrency-in-action-second-edition

>t. own this myself

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.

0c50c1 No.5382

how the hell is it snake oil? its insanely useful. never read the book in your image but parallelism and concurrency are important concepts to know

Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the 8kun administration.



Delete Post [ ]
[]
[1] [2] [3] [4] [5] [6] [7] [8]
| Catalog | Nerve Center | Random
[ / / / / / / / / / / / / / ] [ dir / random / 93 / biohzrd / hkacade / hkpnd / tct / utd / uy / yebalnia ]