[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr / vt ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Due to resource constraints, /g/ and /tg/ will no longer be archived or available. Other archivers continue to archive these boards.Become a Patron!

/g/ - Technology

View post   

[ Toggle deleted replies ]
File: 144 KB, 500x500, sample.jpg [View same] [iqdb] [saucenao] [google] [report]
62773038 No.62773038 [Reply] [Original] [archived.moe] [rbt]

old thread: >>62761229

What are you working on, /g/?

>> No.62773069
File: 3.00 MB, 1280x800, gl2.webm [View same] [iqdb] [saucenao] [google] [report]

First for modern opengl!

>> No.62773211

>What are you working on, /g/?
A userscript for HookTube. I really like it but it lacks lots of functionality that helped make YouTube so nice to use - if you ignore the fact that YouTube is slow as fuck. Been at it for nearly a week, JavaScript is still a confusing shitheap.

Got instancing implemented yet?

>> No.62773238

You mean drawing the same element array object again and again with a different model matrix every time?

>> No.62773243

Yes. I suppose I should have said 'instanced rendering' but oh well.

>> No.62773309

Why aren't Judy arrays used more often?

>> No.62773376

I suspect it has something to do with this.
>Judy arrays are extremely complicated. The smallest implementations are thousands of lines of code.[4]

>> No.62773383

How do you search through a sorted list the fastest? There are many duplicate entries, and the amount of duplicate entries vary (50-100). I don't think binary search is optimal here. Total amount of entries is known. There are almost no gaps.

Here's my idea
>seek to totalentries/size*desiredentry
>get value
>calculate (currentvalue/currentpos)*desiredentry
>seek there
>repeat until found
Is this optimal? I'm worried about searching the last part too slowly (achilles and the turtle style). Should I do something like ((((currentvalue/currentpos)*desiredentry)-currentpos)*2)+currentpos so I "overshoot" the estimate? But this might cause it to jump around a lot, what's the optimal solution here?

>> No.62773388

Thousands of lines of code is no big deal if you compile it in (not statically link or god forbid dynamically)

>> No.62773395

Ah, the name of the algorithm I'm looking for is interpolation search.

>> No.62773451

struct struct1{
vector<int> x;
vector<string> y;
vector<stuff> z;
struct1 structure;

struct struct2{
int x;
string y;
stuff z;
vector<struct2> structure;

The former acts as a key/value system but is ugly imo. The latter looks better but I would need to add a forloop to search for a key every time its used.

>> No.62773484


>> No.62773490

Maybe. Still, most people will look at such a thing and say "but I can just do it this other way, my program still works great". Until there's a real need for it I think it's too complex to gain popularity outside its niche.

Use the one that you find easier to read and understand. You can always come back and change it in the future if the need arises, until then just stick to what makes your development easier.

>> No.62773492

> Judy array

>> No.62773496


>> No.62773590
File: 1.00 MB, 640x800, 1500940757126.png [View same] [iqdb] [saucenao] [google] [report]

>'strcat': This function or variable may be unsafe. Consider using strcat_s instead.

>> No.62773921
File: 28 KB, 400x400, 1489068102323.jpg [View same] [iqdb] [saucenao] [google] [report]

>Kristina Lustig is a UX Researcher at Stack Overflow.
>UX Researcher

>> No.62773935


>> No.62773950

>reasearches how to use bootstrap for stackoverflow

>> No.62773965

In this case thats not a viable solution. In struct1, x, y, or z can act as a key and if I dont know the keys I can search by index.
struct1 is what I always do. struct2 is what I always want to change it to when I come back.

>> No.62773972

I'm sorry, this is /dpt/. You seem to be trying to post to the UX designers thread in /lgbt/.

>> No.62773981
File: 33 KB, 600x514, 1505612582142.jpg [View same] [iqdb] [saucenao] [google] [report]

I'm not fooled

>> No.62773983

Explain this to me
var poop = (int?) peep ?? 1;

>> No.62773998

no, use elixir

>> No.62774000

Christoph Hellwig <[email protected]> writes:

> memcpy for strings is plain ugly. memcpy will not null-terminate
> your strings and led to source-bloat.

This is why you use

*((char *) mempcpy (dst, src, n)) = '\0';

Which is more efficient than any of the str*() functions when
concatenating multi strings since the NUL termination only has to be
done at the end.

>> No.62774051

How come I didn't know about this before?

>> No.62774216

what lang? looks maybe like C#, in which case int? indicates a nullable int

>> No.62774233

if peep is null and not int, make poop equal 1, otherwise make poop equal peep

>> No.62774256

cast peep to nullable int, if its null, then assign 1, else assign peep's value

>> No.62774276 [DELETED] 

Yuru Yuri, Hajimaru yo!

>> No.62774390

he's wrong. And how do you compute n?

>> No.62774467
File: 49 KB, 500x573, crema.jpg [View same] [iqdb] [saucenao] [google] [report]

I want to learn a single language and stick to it for some time to actually get good at it. Between C++ and Python which should I learn in hopes of actually getting a job without a relevant degree?

I already know the following
>C++ is massive
Yes, I could spend a decade learning it and there'd still be more shit I don't understand
>Python is a scripting language probably not suited for large, OOP projects, also not compiling = slow
This is probably true, but a better bet than Java IMO.
>Why not Java?
Java is a clusterfuck filled with quirks that I don't think I'd like to deal with. Maybe a javafag can convince me otherwise.

What do /g/?

>> No.62774511

>Coddle me because im a woman

literally what shes saying

>> No.62774525

Language doesn't matter, having a portfolio of projects matters.

Java/C#/Python choose one of those if your only goal is to get hired.

>> No.62774538

>Java is a clusterfuck filled with quirks that I don't think I'd like to deal with. Maybe a javafag can convince me otherwise.
seriously? Java's very regular and sensible. Java is bad because it's too dumbed down, not because it's too complex.

>> No.62774624

I don't suppose you or anyone can point me in the right direction with this? My programming is good but my maths is kinda meh.

>> No.62774647


>> No.62774713

Guys help, I'm getting interested in the ml/data ""scienece"" meme. How do I stop this?

>> No.62774839

Stop reading reddit and HN.

>> No.62774945

Any software engineers here?
Can someone help explain what the difference between abstraction and encapsulation is?

>> No.62775061

Hi guys,

I'm trying to do polynomial fit on my scatter graph in python but It's not working. Anybody care to look at my code and tell me wtf im doing wrong?

Thanks in advance.


>> No.62775095
File: 44 KB, 636x616, 1474325315193.jpg [View same] [iqdb] [saucenao] [google] [report]

Employed Haskell programmer here

>Between C++ and Python which should I learn in hopes of actually getting a job without a relevant degree?

>> No.62775122

Abstraction: computers deal exclusively with numbers. If you want to deal with, say, text, it's terribly inconvenient to deal in terms of arrays of numbers, so you use a higher level abstraction, strings. Abstractions hide implementation details so you can focus on solving the problem instead of worrying about irrelevant details.

Encapsulation: hiding data and variables to make it accessible only to a limited portion of your program, so you don't get tempted to create too many dependencies that make your program harder to understand and debug.

>> No.62775274

The problem with Java is that people over-use a bunch of obtuse frameworks even in cases where the base language solves the problem just fine. Plain Old Jave Objects, POJOs, they call it, that they have a buzzword for just programming in plain Java shows how out of touch that community is. It's a bit how normal sex has now become a fetish, "cream pie".

But the language itself is fine if a bit verbose, it has way better semantics than either Python or C++.

My suggestion is to first get really good with OOP concepts (read Kaye, Fowler, et al) in a pure OOP language like Smalltalk, and then learn to apply it in Java. Too many Java codebases aren't object oriented at all, some people seem to think a few scattered class keywords in their spaghetti code makes it OOP, but it clearly doesn't.

>> No.62775394

In C++, say you have a class, which has a getter function which returns a const reference to a private member of that class. Perhaps that private member is a fuckhuge object and you don't want to copy it whenever someone tries to read it, but you still want it to be read-only. Or maybe that member is an int and you're just a faggot (or writing a memory-critical application).

Is it possible for someone using your class to fuck about with pointers and addresses to get a non-const reference to that member and thus be able to write to it? Effectively bypassing your efforts at encapsulation?

>> No.62775430

>Is it possible for someone using your class to fuck about with pointers and addresses to get a non-const reference to that member and thus be able to write to it? Effectively bypassing your efforts at encapsulation?
There's always a way. They could get the base address of the class or a neighboring variable and use pointer arithmetic.
It's fine as long as it's made clear to the user that the variable is meant to be read-only.

>> No.62775516

>Employed Haskell programmer here
I'll take two large ones to go.

>> No.62775534

How about
const& int foo() {
return read_only_int;


const int bar = foo();
int baz = *(&bar);
baz++; //you just edited the readonly variable

Would this work? Is it really that easy? Because if so, it sounds like if you ever create a pointer to something, you'd lose const without meaning to (int my_completely_innocent_ptr = &bar;
*(my_completely_innocent_ptr)++; //woops, forgot I shouldn't edit it
Sounds error-prone.

>> No.62775567

fuck opengl, though

>> No.62775602

No, bar and baz aren't references. They're initialized with a reference but are separate values themselves.

If you change their declaration to const int &bar and int &baz then you 'll get this error:

>error: invalid initialization of reference of type 'int&' from expression of type 'const int'|

And in your pointer example:

>error: invalid conversion from 'const int*' to 'int*' [-fpermissive]|

>> No.62775643

If you give someone a reference, what they end up doing with it is beyond your control.

Instead of one getter for the whole object, make separate getters for the primitive bits of information in the enclosed object.

>> No.62775653

UX means user experience, so she's not even actually in tech

>> No.62775805

A function takes 3 arguments, however I want to call the function with the type of one of the arguments changed. Using C.

Is this possible at all? Trying to avoid modifying original code and writing interface(?) functions instead.

>> No.62775807

In C++ you can cast away any of those restrictions and do whatever the fuck you feel like.

Access specification is just a suggestion for your own benefit. Personally I just call everything struct and use a naming conventions to indicate whether something is "public" or "private".

>> No.62775820

I can't take her serious at all because
"Lustig" in Germans means "Funny"

>> No.62775822

This is not possible. C does not have function overloading (multiple functions with the same name but different parameter types).

However, C11 has the _Generic macro. You can name multiple unique functions, then have a macro select which of those should be called depending on the type of your arguments. Just be careful since C has a few pitfalls with the types of certain literals and macros.

>> No.62775834


>> No.62775868

Anon, this code compile but is it a good way to initialize a pointer?
struct foo
int a;
int b;
foo(int a, int b) : a(a), b(b){}
class bar
foo * pfoo;
bar(int a, int b): pfoo(new foo(a,b)) {}
~bar() {delete pfoo}

My intuition said that it's better to change the bar(int a, int b) :pfoo(new foo(a,b)){}
into bar(int a, int b) {pfoo = new foo(a,b);}

which one in being considered as "good code"

>> No.62775878
File: 54 KB, 860x484, image-961108-860_poster_16x9-jewr-961108.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.62775885

The first one is better, I would change the pfoo(new foo(a,b)) part to pfoo{new foo(a,b)} though.

>> No.62775891

Don't use constructors, they're shit.

But if you do use constructors, try to use initializer lists as much as possible.

>> No.62775944

What do you mean with pfoo {new foo(a,b)} ??

Is the constructor became like this?
bar(int a, int b): pfoo{new foo(a,b)} {}

Is it possible to having a block with {} in the initializer list?

>> No.62775956


It's a matter of consistency. Some modern C++ guidelines recommend you use curly braces to initialize all objects.
Foo foo{1, 2, 3};
Personally, I stick to using () for constructor calls and = {} for POD initialization.

>> No.62775975

Yes, that is what I meant. Initializing an object using {} is something they added in c++11 to "fix" some problems with syntax ambiguity when using () to initialize an object.

>> No.62776021

Care enough to clarify what is the advantage of using {} in initialize list?
All answer in SO only tell how to use it, and the advantage than using '='

>> No.62776031

Why do people like you constantly insist on reverting to 80's graphics instead of using modern platforms that do this menial labor for you?

>> No.62776032

You won't hit the Most Vexing Parse by accident. I'm not sure of the other advantages.

>> No.62776059

>If it's not broken, then don't fix it

>> No.62776065

Who are you quoting? Are you implying I said something of this nature?

>> No.62776078

What's the difference between <cstdio>, <cstddef> etc. and the <stdio.h> <stddef.h> variants?

>> No.62776092

<c*> is the C++ ported C library
<*.h> is the native C library
I'm pretty sure, in the <c*> all of the function being included in std namespace

>> No.62776097

I'd say it depends on the regular access patterns for your data. If you're iterating only through x for example, the first one will have better cache locality. If you need to iterate through and access elements of x, y, z at the same time, the second one will do better.

>> No.62776140

How does the perl version of this look like:
curl something | grep -Po '(?<=<foo>).*(?=</foo>)'
Regex should be the same, right?

>> No.62776161


This is genius, why don't people use this?

>> No.62776204

>UX Researcher at Stack Overflow
Stack Overflow is a horrible user experience.

>> No.62776215

Well, no wonder why..

>> No.62776250

>You need to have 50 reputation to make a comment

FFS SO, I know that OP's code is flawed, and I can fix it.
But the code is a bit unclear, there is more than 1 possible intention.
I just wan't to ask OP about his intention so I could answer it accurately and get some rep

>> No.62776374

Because it's called Redis

>> No.62776552

Post your programming music

>> No.62776569


>> No.62776578


>> No.62776581

Redis is neat, but it has nowhere to put the business logic. You still need a separate domain model and a persistence layer, in which case you might as well use a RDBMS and get more features and flexibility for the same amount of effort.

>> No.62776598


>> No.62776705

I'm in the process of making a program that will ask the user to enter a string and then ask the user to replace a single character of that string with a character of choice. I've come to the problem to where I need the user to be able to change instances of that same character but I don't really know how to get everything connected.

I have a for loop that replaces the character they want to replace with the character they want to use and I have a for loop that counts the instance of each character they want to change.

At this point, how I would get everything to work together and have the user replace the exact instance of the character they want to replace?

>> No.62776737


>> No.62776756

in C++, How to make a file containing unsigned char?
My idea is some kind like this, but I don't know will it really make the file contain a single "FF" byte or will it produce something weird under certain circumstances.

std::fstream foo("FOO", std::fstream::out | std::fstream::binary);
std::string bar;
unsigned char x = 255;
foo << bar;

>> No.62776774


>> No.62776785

Have the user enter the index of the character to replace, perhaps?

Are you making a line editor? Perhaps take a look at other line editors to see how they do it.

>> No.62776804

>cast away
I assume you meant "remove by casting"?

>> No.62776813

I definitely have to have the user enter the index that they'd like to replace. If the user types in "GG" and meant "Go", then they would have to replace the first index of 'G' since java is base 0. My problem is that I can't think of a loop to make that communicate with my other loops. I've kinda gone brain dead.

>> No.62776817


>> No.62776824

That's exactly what you said. You considered the modern options good enough. I don't know what anon has in mind but there's certainly room for another system.

>> No.62776832

C/C++ users try their best to avoid using 3rd party libraries because they don't have a standard package/project/build management system.

All those "I don't need library abstractions because I'm too smart" are 100% bullshit

>> No.62776856

A module system or hack a namespace system in c would be great.

>> No.62776866

>implying 3rd party library always have a very good documentation

Sometimes, I found a really confusing documentation, and in the end I remake whole code myself.

>> No.62776873


>> No.62776885

Guys, why am I getting indent error here?


>> No.62776899

Padding might make this non-ideal/difficult.
If you want you can do #define private public. Then include the header and then #undef that.
Another way is to find a well defined state for the class and search your way into it.
That's useful for when it's a binary library. As you won't know what the binary has as it's padding.

My preference would be that you either conclude that the library should have those fields be public and make it so. Or that you replicate the fields of the class in code except with them being public and cast it to that type (given you have the source and will compile it).

>> No.62776900

Why not augment and contribute to the modern options?

>> No.62776904

Because you're using Python

Get a language without significant whitespace

>> No.62776917

I feel you.

I have started working on a side project --it's yet another CMake front-end, heavily inspired by Conan and Dub. I intend to use the front-end for personal use only, so it's not portable to platforms that
* do not support LLVM/Clang
* are not x86_64 *nix
* do not have POSIX compatible shell and file-system hierarchy
but if I feel proud of it, I'll share it in github.
Currently I am working on the big project class. Handling errors is pretty tiresome. But I think it's going to be a good C++ learning experience for me. I'd be interested on how C++ modules turn out to be.

However, no matter how hard I try the project won't be adopted by C++ standards committee or clang team.

>> No.62776953

>they would have to replace the first index of 'G' since java is base 0

Not really. No need to let a Java implementation detail leak into your UI. You can choose whether to index your columns from 0 or 1.

>> No.62776964

Alright that's fine and dandy. I'm just new to programming and I can't come with up with an idea on how to implement this idea.

>> No.62776965

I wasn't planning on a career in software politics but I'll consider it.

It's seriously not an option in most cases. You have to find something that's very close to what you like (especially in terms of api and overall programming preferences of the developer) and then fork it and maintain compatibility with them or have them accept your pushes.
It's really not that simple.
There's something to that. But it's not that hard really. It just takes time.
>I don't need library abstractions
In my experience it's more that the goals don't coincide. I'm sure all of us have tried out a library and found it uncomfortable to work with. At some point wrapping the library efficiently becomes more work than it's worth really.

>> No.62776977

I have the program to where I can get a for loop to print out the index of the char the user wants to replace, and I'm able to get every instance of that char replaced. So when I try to get GG replaced to Go, my program is replacing the String to oo. I don't know how to get my for loop to be under the restriction of only replacing the char at the specified index.

>> No.62777004

Are there any recommended resources for learning functional programming?

>> No.62777016
File: 31 KB, 378x499, 41DZ0WC0x3L._SX376_BO1,204,203,200_.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.62777034

anyone got a good c++ raytracer tutorial (pref on Visual Studio on vid) that doesnt fucking stop halfway through?

I already know the math so got that going for me.

>> No.62777038


>> No.62777050

Is this just a meme or is it actually helpful for this use case?

>> No.62777062

You're mixing tabs and spaces.

Don't blame Python if you can't control your text editor.

>> No.62777117

Why doesn't python interpreters just warn you? Why would you ever mix tabs and spaces?

>> No.62777146


>> No.62777203

Tabs for indent, spaces for alignment

>> No.62777212

I'm using notepad++, what should I use to avoid this in future? I'm really fucking despare now. I tried to reformat whole thing and I still get error.

>> No.62777215

In python 3.6, when you put append a variable with a value of 'x' to a list with the values [x, y, z], it's placed at the index 0 because the values are the same, so the list is still just [x, y, z].

Is there a way I can make it so that the list becomes [x, y, z, x]?

>> No.62777243

I must be missing something. Doesn't python presume you indenting more is opening a new block essentially? How would you do alignment under those constraints.

>> No.62777259

If you use java.lang.String you can simply call substring() on it to get the part before the character to replace and the part after. Concatenate those with the replacement in the middle.

I usually avoid writing explicit loops if there's some more specific way of doing it. See https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#substring-int-

>> No.62777317

are you saying openGL is 80's graphics lmao

>> No.62777337

You can use spaces freely inside braces
foo(a, b,
c, d)

1: 2,
3: 4

>> No.62777373

View -> Show Symbol -> Show white space and tab

>> No.62777479

I would still need a loop to count the iteration of the character in the index though, right? And use the substring (0, to the iteration I want to replace) and then concat the character I want to replace the character with?

I'm highly confused.

>> No.62777503

I literally can't stomach javascript, I CAN'T, I DON'T WANT TO. Fuck this shit, gonna quit today

>> No.62777524

Forget the string, just write the single byte the the file directly. The point of opening as fstream::binary is to write bytes instead of text.

>> No.62777543

Use TypeScript and transpile to JavaScript.

>> No.62777560

typescript have a sane type system.
but everything need to be in typescript or you have to find a def file to use javascript library

>> No.62777619

So I have a pointer in C to an array of characters of length 2, with the first char being 'd' and the second being '\0'. the pointer is called pass.

I tried to
printf("%s\n", pass);

and I even added fflush(stdout) after it, and yet it does not print it.
Can anyone help me find a way to get it printed please?

>> No.62777622

No, That code is only to show my intention. In my code, the string will be populated with other data such as text, char, and unsigned char being casted to char

>> No.62777645
File: 247 KB, 306x787, Shut_it_Down.png [View same] [iqdb] [saucenao] [google] [report]

>open a solution in VS2013 inside a VM
>starts hogging 50% of CPU usage at all times, regardless of how many cores I assign to the VM, complains about not being able to modify/create a file explorer database
>try to repair the instalation using the uninstaller
>it locks the entire workstation and I have to do a hard reset

How can a piece of software be this pozzed?

>> No.62777656

list += [x]

>> No.62777668
File: 175 KB, 884x974, energy.jpg [View same] [iqdb] [saucenao] [google] [report]

>using non environmentally friendly language

>> No.62777672

OK. Doesn't really collide with having a warning though.

>> No.62777722

Yeah, I'm telling you not to use a string. The string type will convert binary data into textual representations for you, which is not what you want if you're writing to a binary file. If you want your file to be human readable text, fine, otherwise, you should be using a plain ostream and not a string.

>> No.62777746

Show the rest of the code.

>> No.62777814


>> No.62777866


>> No.62777899

Ok I got it. I needed the loop for index iteration. All I had to do was pass an int value through a for loop that was equal to the number of times the Char appeared in the string. Then it was literally just as simple as making a substring from that index to index the user wanted to replace and then concat that char at that spot and then substringing the rest of the string back in. I tried to overcomplicate it.

>> No.62777915

Thank you for the willingness to help, but I already have hacked it by printing the characters instead of the string as a whole.

>> No.62777934


>> No.62777987

I might be wrong, since this is just my speculation so tell me if I am wrong. But I guess your code is like this:
int main(){
char pass[2];
pass[1] = 'd';
pass[2] = '\0';
printf("%s\n", pass);
return 0;

That code will not print anything, since lots of compiler put 0 to uninitialized variable, and C's array using 0 indexing system.
And that code will produce an array with value { '\0', 'd'}, and put another '\0' on another memory that not supposedly accessed.
The printf function found that the first memory it accessed contain '\0' and print nothing.

>> No.62777988

Just to be sure. You're not setting pass[1] = 'd' and pass[2] = '\0' are you?

>> No.62778004

Thx anon. that paper seems really interesting to read.

>> No.62778028

who chapel 1.16 here?

>> No.62778039


>> No.62778043


>> No.62778081

no, I am not, but thanks for the help
it in fact did not exactly work but I'm trying some stuff right now

>> No.62778085

Wow that's a cool paper.

>> No.62778106

anon, How to reclaim the memory being used by std::vector other than make tons of smaller block with {}??

>> No.62778138

std::shrink_to_fit will release unused memory if the vector is overallocated.

It's probably a waste of time to do this though.

>> No.62778189

If you don't have a relevant degree, then you'll be lacking a lot of the context that makes C++ and Java approachable. I'd recommend Python if you're just getting started, but only learning one language with the intention of being really good at it isn't going to help.

You may master the quirks/peculiarities of the language, but the useful concepts you pick up from reading/studying/implementing will be lost.

Take your time, man.

>> No.62778410
File: 60 KB, 553x683, BunnyWire.gif [View same] [iqdb] [saucenao] [google] [report]

how do they render an arbitrary mesh (like pic related) (not just sphere or boxes) with raytracing? Do they intersect each face/triangle of the mesh with a ray (with some sort of acceleration structure for each face within a mesh)?

>> No.62778439
File: 63 KB, 400x388, 1500826308222.png [View same] [iqdb] [saucenao] [google] [report]

programming is just an embrassing attempt to compensate lost control irl

>> No.62778446

I have found that for example, when the string pass is "aa", and I do
printf("%c\n", *pass)

then the value of pass changes to ""
and *pass is '\0'

any idea why?

>> No.62778480

>leftist tree huggers and C programmers
now THIS is an unholy alliance I can get behind

>> No.62778495

Not without seeing where you declare/initialize pass

>> No.62778505

What's the point of a linked list?
Is it just to control how things are accessed? The way it's been explained, I don't see what it does functionally different to an array other than how it's accessed.

>> No.62778536
File: 168 KB, 420x561, 1494587514458.jpg [View same] [iqdb] [saucenao] [google] [report]

now that I have your attention, redpill me on Go

>> No.62778553

It's the replacement for Java.

>> No.62778574


>> No.62778591

Linked lists give up efficient access in return for efficient insertion and deletion. Often it's a bad trade off. Use array lists by default and only try linked lists if you're profiling and spending a lot of time inserting or deleting elements.

>> No.62778597

It's clean
It's popular
Sepplesfags hate it because ken insulted their pile of garbage

>> No.62778719

Go is an embarrassment of modern programming languages

>> No.62778837

I found the cause of the problem, in case you are interested:
it was me not knowing that you can not return arrays from functions and that they get destroyed, so I created a buffer for the array

thank you for the help

>> No.62778841

I need to make a substring at a certain occurrence of a character. So if I have the string: "bbbb" and I need to make the substring "bb-b" by using concats and substrings. The challenge here is that the user has to tell me when to make the break in the string and concat the other string into it.

so if the user says "3" then it has to be "bb-b" but if the user says 2 then it has to be "b-bbb"

>> No.62778892
File: 4 KB, 163x90, index.jpg [View same] [iqdb] [saucenao] [google] [report]

In Git, you can do
git log

to get the commits history.

How can i see the issues that repo has without going to github and click on the tab issues?
something like
git issues


>> No.62778931

Oh boy.

>> No.62778948


>> No.62778952

github and git are different things. "issues" are a github-specific thing, which git itself has no concept of.

If you want a command line utility that integrates with github features, github maintains a "hub" utility that you can use

>> No.62778992


fucking cancer

>> No.62779206

>have basic programming project
>spend 3 hours practically reworking a single method with a single loop to try to work
>after spending 2 hours making a method that you think works
>can't get it without slackoverflow
>even then it probably wont work
>fail lab grade

I just want to kill myself man. CS is the only thing I like but goddamn it's not easy to me.

>> No.62779278

what was the problem about?

maybe you're just a retard

>> No.62779312

Wished people would actually do this.
All these rockstar developer made with <3 whatever without a license, why are people doing this?

>> No.62779313

I'm in the first cs class.
It's a project of taking in user input, sending the input through different methods that can alter the original string. I can make the skeleton of the project and everything I just fucking suck at implementing certain loops. What makes it tougher is that we can't use arrays and there are only 4 string methods we can all on. So finding iterations of characters in a string and then printing it out can be complicated.

>> No.62779323

Am I right in thinking the Singleton design pattern is just a convoluted way to create an immutable object literal?

>> No.62779337

can someone give me a quick and babby friendly rundown about the difference between
>object oriented

pls no meme posts

>> No.62779359
File: 45 KB, 932x554, 12w3ertghj.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.62779363

How do arraylists work?
Do they just have an array of pointers?

>> No.62779370
File: 77 KB, 667x659, ineverhadachoice.jpg [View same] [iqdb] [saucenao] [google] [report]

Could anyone help me with this? I have a constructor which is supposed to create a room and then assign it to the rooms array. In my main method I have created 5 rooms. But for some reason when I try to get the array of rooms using something like

Room n = new Room(blah blah blah){}

it only returns the current room object and the rest of the array as null.

Here's the Room class code.

private Creature[] creatureArray;
private Room[] rooms;
private String name;
private Room cRoom;
private String rDesc;
private State state;

public enum State {CLEAN, DIRTY, HALFDIRTY}

public Room(String name, String rDesc, State state){
this.name = name;
this.rDesc = rDesc;
this.state = state;
creatureArray = new Creature[10];
rooms = new Room[5];
for(int i = 0; i < rooms.length; i++) {
if (rooms[i] != null) {
else {
rooms[i] = this;

>> No.62779401

guys, is perl really that ancient?

>> No.62779422

how is getRooms() method implemented?

if they're private you have to do something like
public Room[] getRooms() {
return this.rooms;

>> No.62779425

i think this makes sense, thank you

>> No.62779442

pretty sure one of you faggots already made a markov chain based shitpost generator, if so, post it, so I dont need to write it

>> No.62779461


>> No.62779472

My current method is
public void otherRooms(){
System.out.println("The other rooms are: ");
for(int i = 0; i < rooms.length; i++){

I tried your method and it returns nothing

>> No.62779480

foo = "bbbb"
bar = int(input())
return foo[:bar + 1] + "-" + foo[bar + 2:]

>> No.62779498

I fucked up the indices but the general gist is the same.

>> No.62779499

≅≅≅ yee

>> No.62779500

lmao, knew it, ty

>> No.62779510


>> No.62779514

For python, look into markovify.

>> No.62779527

returns nothing because its filled with nothing

how are you setting the rooms? you have gets and sets right?

>rooms = this;
maybe this is the problem dunno

try to
rooms[0] = State.CLEAN;
rooms[1] = State.DIRTY;
rooms[2] = State.CLEAN;

and then print to test if it is doing anything

>> No.62779528

>easy, just import <program>
>t. python """programmer"""

>> No.62779529

this is user input so i don't actually know what the string is going to be. I can't just make a string object with that data saved into it and then pick it apart. I have to make a program that practically reads each character and recognizes when the characters are the same. So if a user wants to replace the character 'e' with 'i' at the 3rd instance, I'd have to be able to find what index that third instance of 'e' is at and then save that to a variable. then i'd have to use a substring to read up to that point, stop there, remove the 'e' and then print out the 'i' with a concat, then I'd have to print out the rest of the string.

>> No.62779530

It's a little more nuanced than that.
Open/closed principle is abstract vs. algebraic data types.
Yeah, factories and strategies are just functions.
Decorator is like functors/monads/etc.
Visitor is pattern matching.
The rest are buzzwords.

>> No.62779541

>easy, just #include <library>
>t. C """programmer"""

>> No.62779543

They're implementation dependent, but the usual approach is to allocate a fixed number of elements initially, say 4, and each time the capacity is reached, then to allocate a new block of memory twice the size, and copy the elements over and free up the other memory. This ensures the elements remain contiguous in memory which is good for cache locality when iterating through the lists.

There's plenty of other ways to implement them that don't require significant copying/allocation and can still have good cache locality. Bagwell's VLists are probably the best all round approach. They're O(1) for index/insert/delete.

>> No.62779563

>I must reproduce everything 10k times for every application.
Braindead windows users meme. Meanwhile we RE-USE instead of re-inventing the wheel.

Go install GNU/Linux system and learn why re-using things that already exist is the shit.

>> No.62779570

I re-use your mom every night and she doesn't complain.

>> No.62779571

this is my favorite meme

>> No.62779582

>O(1) insert/delete is only at the front
What makes them better than (circular) array deques?

>> No.62779602

usrstr = input()
needle= input()
sub = input()
usrocc = int(input())

occs = 0
for i in range(len(usrstr)):
if usrstr[i:i + len(needle)] == needle: occs += 1
if occs == usrocc: return usrstr[:i] + sub + usrstr[i + len(needle):]

>> No.62779617

is there a name for systems that need to run 24/7 ?

>> No.62779619

>private Creature[] creatureArray;
> private Room[] rooms;
If you need Room to hold a full list of Room objects, then rooms must be declared as static in the Room class.

However, this isn't really a recommended design choice and it's usually always a better idea to have a RoomCollection class, or use a core library generic collection such as List<Room> (not inside the Room class, but somewhere else like Main())

>> No.62779632

I appreciate the help but I don't know what language you're coding in. My school teaches in java. I'm trying to get the idea but the for loop is throwing me off.

>> No.62779642

High availability systems

>> No.62779650

Oh, I see, they're immutable for sharing. But indexing isn't really O(1), it's O(log n).

>> No.62779666

There's also Pattern matching vs Encapsulation.

FP languages like Haskell make it hard to do the latter without giving up the former, because the matching process is coupled to the constructor definitions.

>> No.62779682
File: 39 KB, 953x404, FB_IMG_1507311120916.jpg [View same] [iqdb] [saucenao] [google] [report]

First year science students learning java and asking why it doesnt work

>> No.62779700

you cant have a statement after the return

>> No.62779707


>> No.62779715

Encapsulation is shit though, it's just a roundabout way to enforce invariants. Not that Haskell has anything better, but any dependently typed language can do it.

>> No.62779726

Lol its not my code, he posted it in the fb group asking why it doesnt work. Its full of bad lol

>> No.62779736


>> No.62779765

You can, but it won't be called ever.

>> No.62779788

Seeing those kind of structures just makes me want to puke. fucking shitty .{extension} folders/files just need to die already shit was a mistake and it's the unix/linux loving retards that want to keep it alive for no good reason.

>> No.62779805

That's Python. In Java, it'd be

Scanner scanner = new Scanner(System.in);
String usrstr = scanner.nextLine();
String needle = scanner.nextLine();
String sub = scanner.nextLine();
int usroccs = scanner.nextInt();
int occs = 0;
for(int i = 0; i < usrstr.length(); i++){
if(usrstr.substring(i, i + needle.length()).equals(needle)) occs++;
if(occs == usroccs){
System.out.println(usrstr.substring(0, i) + sub + usrstr.substring(i + needle.length()));

>> No.62779809

Unix is a dead system from the 70s.
Linux is a kernel.
Thanks for listening.

>> No.62779814

>not for each

1 job

>> No.62779816

modules, view patterns or pattern synonyms

>> No.62779830

Just tested it.
The script only throws nonsensical sentence

>> No.62779835
File: 173 KB, 1300x918, 5480540-pretty-girls-looking-tv-and-making-a-little-party-Stock-Photo-laughing.jpg [View same] [iqdb] [saucenao] [google] [report]



>> No.62779848

Nothing in your post invalidates my statement.

>> No.62779866

>implying nobody use any BSD's distro

>> No.62779876

ah ok this makes more sense. what are the strings needle and sub though? In my program, I have a originalChar string and a replacedChar string and then inputStr is the original string from the user.

>> No.62779877

How do I declare them as static in the room class? Make the constructor static?

>> No.62779880

BSD isn't Unix or a kernel.

>> No.62779907

Is there a list out there of good books/papers to read? Programming, computing, science, math etc. Feel free to recommend some of your favorites as well. I've just graduated and have a few months till I start work and I want to stay sharp and learn some stuff.

>> No.62779908
File: 6 KB, 265x271, Are you fucking serious.jpg [View same] [iqdb] [saucenao] [google] [report]

>Windev Developers

>> No.62779910

Actually BSD is a kernel and a unix-like operating system.

>> No.62779911

nvm I got it. thanks man.

>> No.62779922

Needle is originalChar and sub is replacedChar. Sorry for my shitty variable names.

>> No.62779924

are you really that retarded?

>> No.62779933

Are you?

>> No.62779983

okay one last thing.
What is the reason for the output printing twice?

>> No.62780002

It's brainlet Rust with GC instead of BC and all the good features missing.

>> No.62780013
File: 39 KB, 665x574, 1505739270174.jpg [View same] [iqdb] [saucenao] [google] [report]

Am I stupid for thinking Ruby is comfortable?

>> No.62780031


>> No.62780052

>be me
>building a web crawler
>some features of the website are only visible after pressing a button

i'm using Jsoup for html parsing, but not sure how to get the information hidden behind the buttons

>> No.62780070

My favourite cognitive dissonance is when C faggots say Rust is for brainlets and simultaneously complain that they can't grok borrowing.

>> No.62780090

anyone use this? it's pretty neat

>> No.62780092

>can't grok borrowing.

>move unique_ptr around all the time.

>> No.62780094

my favourite mental illness is the one where go, java, rustfags etc instantly assume you're a C or Haskell programmer

>> No.62780098

Moving isn't borrowing.

>> No.62780110

unique_ptr isn't static resource checking

>> No.62780116

It's a safe assumption to make when you see a manchild in /dpt/.

>> No.62780132

my favorite mental illness is the one where C, Haskell, and other autists assume that Java and related are for the unintelligent.

go write a fucking compiler or something, we can see through your lies

>> No.62780147

>literally doing what i accused you of
>then going on to make false accusations

>> No.62780159
File: 20 KB, 1200x124, DGW9L_PUIAEAzWQ.jpg [View same] [iqdb] [saucenao] [google] [report]

>implying haskal or rust aren't mental illnesses

>> No.62780177

LOL rust btfo

>> No.62780186

my favorite mental illness is programing in any language besides Java, Haskell or C.

>> No.62780204

>mfw rust users can't even synchro-summon

>> No.62780206

>Programming in C instead of C++
Way to be a hipster.

>> No.62780291
File: 21 KB, 400x400, ohh.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.62780315

lol no, what ide will let you compile that

>> No.62780337

>I posted it again!

>> No.62780349

depends on if we're talking about java

>> No.62780359

Trailing type returns are a bless. Thank you, based C++11 for implementing them. C(ucks) stay c(ucked)

>> No.62780365

Zygohistomorphism btfo

>> No.62780389

This question may be stupid but I'm asking anyway: Why is nodejs/electon a thing? Doesn't javascript belong into the browser? Why are some many people programming in nodejs when it's totally slow and misplaced in general?

>> No.62780391


>> No.62780455

server side javascript
the idea is that you can do everything in javascript and not bother learning anything else. And it makes everything run """""faster""""" because everything is javascript and no interpretations are done between different code

>> No.62780466

This actually makes sense.

>> No.62780487

Ok, so I have this function that creates a sine wave. But the problem is that it's not guaranteed to end near 0. So if I try to use it to play a looping sound, there's a clicking noise where the beginning and end meet.

std::vector<int16_t> sine_wave(double frequency, unsigned sample_rate)
const int amplitude = 5000;
const double two_pi = 6.28318;
const double increment = frequency/sample_rate;
double x = 0;

std::vector<int16_t> raw;

for (unsigned i = 0; i < sample_rate; i++){
raw.push_back(amplitude * sin(x*two_pi));
x += increment;

return raw;

How can I make it so it will only generate a single "slice" of the wave that ends at 0?

>> No.62780613 [DELETED] 

so u like anime?

>> No.62780621
File: 94 KB, 1200x900, 20151013_twitter_bi.png [View same] [iqdb] [saucenao] [google] [report]

Because this industry is really dumb. They'd rather have webdevelopers 'carry over' their 'skills' into native application development by keeping them with their language and inconveniencing a more important group of developers.

There's no sensible reasoning for these frameworks other than that they reduce the barrier for webdevelopers to make inferior products.

It may seem very cynical and hostile but I don't believe webdevelopers as a group are closer to engineers as a profession than a fence painter is. There's some semblance of engineering thinking going on but the concerns are so light that you'd be laughed at for suggesting it's engineering to use masking tape. There's lots of these people. And to management they look the same as other programmers. So when the proposal of making this large group of 'programmers' able to put effort into areas they weren't able to before you're gonna get a push towards that.

Note things like how absolutely massive Twitter is as a company with employees. Even back in 2010 I'd say they're way too big for their workload. They have these people because they're a web-company. They're structured around having many stupid drones rather than few effective programmers.
You should also note how they scale. What new featureset of Twitter justifies them having 41x people at their company?
Also note that Twitter isn't a particularly bad example. This graph was motivated by BI wanting to make an article on the layoffs Twitter had because they realized that their engineering resources were more effective with less developers (they dropped 8% of all employees).

This isn't some grand explanation of why electron/nodejs exists. There's better people to ask. It's my ideas regarding the reasons for these situations.
We will see lots of web developers being thrown into startup companies more and more until they're just unemployed.

>> No.62780635

because it's easy to find js devs in silicon valley to put together a gui for your app, pitch your shit to investors and earn gazillions

sometimes I feel like the whole webshit industry was actually hurt by unbelievable amounts of cash

>> No.62780648

>sometimes I feel like the whole webshit industry was actually hurt by unbelievable amounts of cash
pretty much everything is

>> No.62780679

You have no idea how that shit works do you?
You don't hire people in silicon Valley to write your UI. Silicon valley is mostly independent application startups. Not contractors.

>> No.62780688

>a more important group of developers
stopped reading here

>> No.62780689

Didn't Twitter rewrite most of their backend in Scala (was originally Ruby)?

Twitter employee headcount is mostly just moderation/marketing. Probably only a fraction of it is programmers.

>> No.62780741

They laid off 8% of their employee count (300+ people) claiming that they'd be more effective in moving faster with less people around.
As for marketing people i don't find them to be justified either. But that's a separate issue. The reason I pulled up the graph was because it's a prime example of how these things go.
Are you arguing that there's not different caliber of developer? There absolutely is.

>> No.62780769

>using built in functions
>using functions at all

>> No.62780784

>using a language

>> No.62780789

>using anything but functions
do you even λ

>> No.62780812 [DELETED] 

cheeki breeki

>> No.62780839

explain reactive programming paradigm to me like I am a retard

>> No.62780846

If you've ever actually done full stack webdev, you'd have a better appreciation for it, methinks.

>> No.62780886

>using a computer to perform basic data manipulation and run algorithms that could be done using a pen and paper

>> No.62780994

An array is fast for random access but slow for insert and delete. A linked list is fast for insert and delete but slow for random access.

>> No.62781006

>needing equipment to do computations

>> No.62781034

It brings nothing new to the table. It's just a big pile of NIH syndrome, duplication of effort and just plain being gratuitously different.

>> No.62781040 [DELETED] 

>that kick
fuck, I could feel that in my balls

>> No.62781048
File: 67 KB, 680x743, 1503661228215.jpg [View same] [iqdb] [saucenao] [google] [report]

>not getting the answers to the computation by prayer

>> No.62781432

you know how large you vector must be
don't use puck_back ;_;

>> No.62781483


>> No.62781567
File: 160 KB, 1573x1051, Selection_022.png [View same] [iqdb] [saucenao] [google] [report]

>Fuck around in C
>discover something that should've been obvious
>still kind of intrigued

>> No.62781707

Knowing these languages should be able to get you hired for any programming job, whether it's Web dev, Applications, Mobile or DB - am I wrong?

I've been thinking of learning these langs. Is it realistic to know these?

>> No.62781718

Why is it not possible to take a pointer to an rvalue in C++?

>> No.62781790

Shitty handling of data flow.

>> No.62781827

it's better to dive balls deep in one

>> No.62781870

Thoughts on Flutter and Dart?

>> No.62781883

yeah dude really good, i like the bit where he goes 'BOO' ahaha

>> No.62781901

My priority is to learn C++ and Python as my main langs, with SQL and possibly Java.

>> No.62781906


>> No.62781911
File: 11 KB, 236x177, 8cfd2f0443c8cf2d644633a1f7659e00.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.62781943

>he doesn't know

>> No.62781966

>he thinks he doesnt know

>> No.62781973

>tfw dead inside

>> No.62781981

Shouldn't that be
>he thinks I don't know

>> No.62781990

>he thinks it should be he thinks i dont know he doesnt know

>> No.62782004
File: 54 KB, 714x682, 1507317275201.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.62782070

>tfw got a job offer
>place seems nice
>pay is good
>it's fucking actionscript gamedev
wew lads

>> No.62782080

Can a class have an instance variable of its own type?

>> No.62782084

I understand your frustration and I'll make sure to add something similar to >>62781483 later.

And as an update to my problem I realized thatsample_rate/frequency gave me a good enough solution when the sample rate is high. But if the sample rate is very low, like 440, then it falls apart. I've brute forced a few solutions to specific frequencies/sample rates. For example, with a frequency of 666 and a sample rate of 440, I need 38 samples to form a perfect loop. But I can't find any formula to calculate this consistently.

>> No.62782095

Why is it that, no matter what program you use -- whether it's Visual Studio, vscode, CodeLite, Dev-C++, Pelles C, Code::Blocks, or anything else -- the program's equivalent of intellisense always has the same sort of bugs, such as suddenly being unable to offer any argument tooltips or thinking a definition doesn't exist when it was able to jump to that definition just fine just a few minutes ago? How many years does this magic alien technology take to perfect, really?

>> No.62782136

C++ is computationally hard to parse so I guess a lot of code completion systems give up easily.

>> No.62782156

Can it?

>> No.62782157

This is C.

>> No.62782171

Absolutely. It would be one severely crippled type system if you couldn't.

>> No.62782180

God knows then.

>> No.62782374
File: 146 KB, 2228x386, Screen Shot 2017-10-06 at 1.53.18 PM.png [View same] [iqdb] [saucenao] [google] [report]

Trying to customize my .bashrc file

Anyone know why I'm getting this error? I'm following the code in this SO thread:

if[ -f ~/.bash_aliases ]; then
. ~/.bash_aliases

>> No.62782431

Is your value for 2pi accurate? Why not use 2.0*M_PI?

>> No.62782435

if [condition]

add new line and no semicolon

>> No.62782455

install zsh

>> No.62782459

Of course not, that would make any instance of the class need infinite memory.

>> No.62782469

New thread:


>> No.62782491

[condition] && {

>> No.62782510

This worked!!!
Thanks, man!

>> No.62783755

So I am trying to finish this CS lab. Im writing in java and I cant figure out the problem.

So there is a class called vehicle that has a child class named sedan. The vehicle class creates an engine object. There is also the main class called test. I am trying to call a method in the engine class called setEngine() which will change a boolean value from false to true from the main method called "test". I have already created the sedan object, but cant get it to call setEngine.

Does anybody know how to use super to call a method from a parent class? our textbook is shit and gives zero examples.

Thanks in advance

>> No.62783777
File: 385 KB, 5752x885, help pls.jpg [View same] [iqdb] [saucenao] [google] [report]

here is a screenshot of my current convoluted attempt at making this work

>> No.62783802
File: 692 KB, 5761x2241, better.jpg [View same] [iqdb] [saucenao] [google] [report]

here is a better pic that shows the console output

>> No.62783921

I feel I don't know enough to understand this joke, but know enough to know that it is funny

>> No.62783955

im Learning java right now in a class that only codes during the once weekly lab and its like learning the rules to a really bad board game without ever getting to play it.

Name (leave empty)
Comment (leave empty)
Password [?]Password used for file deletion.