Old Thread: >>50711080
What are you working on /g/?
So is Emacs actually a legitimate IDE or are my classmates just trolling me? I downloaded it but I can't get it to fucking compile anything, it's retarded
>>50716284
it's an IDE that will destroy your wrists
>>50716307
Any alternatives then? My prof said we only needed notepad but I fucking hate notepad. It's a Java class
I'm gonna move my question over to this thread, not because I am against anime, but because I don't want the entire thread to either bash on or defend anime.
So . . . question. I'm about to finish my most recent course in programming languages, and I was wondering: What kind of curriculum / book / YouTube video / whatever (free or paid) should I go for to actually be able to make actual, modern applications that have some significance in modern technology.
Difficulty shouldn't matter much, as I already have a good foundation (I think). I can program in basic things in Java, Python, and C++ and more intermediate stuff in C and C#. Give me a suggestion. an be a completely different programming language. Swift, Ruby, JS, whatever, as long as it teaches how to make something really cool, and not just console applications.
>>50716214
top lel someone post template
>>50716389
All you need for programming is a text editor with a monospaced font and syntax highlighting for the language you're using. Everything else is a bonus on top of that. Notepad lacks syntax highlighting.
>>50716389
Yeah if you're using windows then use notepad, if you're using linux try gedit. Vim is a good text editor and it only takes a couple runs through the tutorial to git gud.
y u h8 traps fam
>>50716284
emacs isn't an IDE. It's allegedly a text editor, but it sort of does everything.
It is god tier, but also really hard to use.
>>50716389
i like notepad++
for windows only though
>>50716284
Try atom? It looks great, and I believe you can get packages that will make it run like an IDE.
Also, why not Eclipse, if you're looking for a straight IDE. Is that against some rule?
>>50716411
this is a big stumbling block for people learning to program for some reason
they just can't figure out how to apply their knowledge to anything outside of a homework assignment
try this
come up with your own homework assignment for yourself, something that you consider to be "cool" and then just do it
>>50716389
Notepad++. Compile and debug through the command line. You'll learn a lot more that way, too.
>>50716441
>>50716451
Thanks guys, I'll check it out.
>>50716448
>reccing atom
>ever
kill yourself
>>50716214
>tfw literally every function in your code has a "TODO: come up with a better algorithm" comment
>>50716214
I was bored, so here's an in-place implementation of quicksort:procedure Quick_Sort(Arr : in out Array_T) is
Pivot, Left, Right : Index_T;
begin
if Arr'Length <= 1 then
return;
end if;
Pivot := Arr'First;
Left := Index_T'Succ(Pivot);
Right := Arr'Last;
loop
while Arr(Left) <= Arr(Pivot) and then Left < Arr'Last loop
Left := Index_T'Succ(Left);
end loop;
while Arr(Right) > Arr(Pivot) and then Right > Arr'First loop
Right := Index_T'Pred(Right);
end loop;
exit when Left >= Right;
Swap(Arr(Left), Arr(Right));
end loop;
Swap(Arr(Pivot), Arr(Right));
if Right > Arr'First then
Quick_Sort( Arr(Arr'First .. Index_T'Pred(Right)) );
end if;
if Right < Arr'Last then
Quick_Sort( Arr(Index_T'Succ(Right) .. Arr'Last) );
end if;
end Quick_Sort;
>>50716411
Console applications are the usual focus since it is easy to print text to a screen.
If you want to learn to make graphical applications, use a library that allows you do to do that.
You should find that applications are still the same, but now you map a function call to a button or something instead.
I use Qt as they have good documentation and is fairly straight forward.
>>50716490
I wonder if Hiroshi will ever be bothered to get Ada highlighting working.
>>50716284
It's not an IDE at all, but that's by design. It's a text editor, and quite a good one at that. Actual IDEs, for all the functions they do have, don't really have particularly good text editors.
Not that you can't customize Emacs to do call compilers and stuff, but normally you just do the compilation part outside of Emacs, in a terminal or similar, as that's not the purpose of a text editor.
>>50716499
Will definitely do. Thank you.
no niggers talking in the other /dpt/
give ideas for somethign to make im bored
Just quit my boring corporate job writing information systems in C#.
I want to start contributing to an open source project? How do I start? What should I work on? Like how the fuck do I just start writing cool shit.
>>50716551
pick a book at random from here, go to a random section and do the hardest exercise you can find there
>>50716558
>how do I start contributing to an open source project?
The general process is get code -> write patch -> submit patch. The specifics depend on what sort of version control they use.
>>50716551
the only "generic" idea I'd ever had: make a UI/web interface for a random linux CLI program
I HATE SOFTWARE ENGINEERING REEEEEEE
>>50716551
generate "random" music that sounds good.
What is a good resource for learning cmake?
Right now it is frustrating to use and I know it is not meant to be.
Maybe if I learned about it I would accept it.
>>50716575
I need to get around to modifying that. LYAH isn't the best Haskell book and there are one or two others that should be added.
>>50716490
This is gross and verbose. Please use a better language next time.def sort([]), do: []
def sort([pivot | tail]) do
{smaller, greater} = Enum.partition(tail, &(&1 < pivot))
sort(smaller) ++ [pivot] ++ sort(greater)
end
>>50716581
>another wget_gui.png
Pls no
>>50716575
i've read them all already ;_;
>>50716581
oh dear that sounds pretty awful i really hate CSS
>>50716591
hm i might try messing around with some midi library and maybe do something like this
>>50716597
yeah it's my least favorite tbh, the order the stuff is put in the book is fucked up IMO
>>50716605
Did you not pay attention to the "in-place" part? That tends to make things significantly different.
Working on a multi platform Graphical Disk Usage Analyzer in the same vein as WinDirStat sans the whole file management (that's what you have ab file manager/terminal for, and its a un-intended feature for now) that's multi threaded for asynchronous I/O and the algorithm to create the treemap.
Wondering if you guys have any legitimate suggestions as to add as a feature or functionality.
Since this is for a project per documentation I will give credit to the originator, just leave like a name or initial.
>pic related, non-CSS integrated GUI
>>50716773
What's the gooey done in?
>>50716782
JavaFX2.2 group wasn't willing to take on Qt, and it was a compromise to make it look as and modern much as with coding as close as possible toto C++.
Currently looking in to contact numix/moka project for permission to integrate their icons into the final package of the GUI.
>>50716890
>wasn't willing to take on Qt
You could have used QtCreator. Makes using Qt less of a suicidal endeavor.
>>50716773
>Windirstat without the ability to delete files/folders
Literally useless. I use Windirstat when I want to click through, figure out what bullshit is hogging my disk space, and then clear it out with a couple of mouse clicks. That's literally the entire purpose of the program. Just visualizing the data doesn't help me if I want to delete three dozen folders all nested in some deep directory structure.
If you at least implement a right-click -> "Open explorer to..." or whatever the Linux equivalent is ("Copy path" maybe, idk?) then that's a bit better, but from there it's not much of a stretch to add a delete button, is it?
>>50716664
This may surprise you, but making it stable only requires one line.def qsort([]), do: []
def qsort([pivot|rest]) do
{equal, nonequal} = Enum.partition(rest, &(&1 == pivot))
{smaller, larger} = Enum.partition(nonequal, &(&1 < pivot))
qsort(smaller) ++ [pivot|equal] ++ qsort(larger)
end
>>50716664
>>50717034
Ok I'm actually just dumb and somehow interpreted in place as stable. The in place bit doesn't usually matter for a functional language since the compiler will essentially optimize the new array to just be an in place mutation of the old one.
>>50716917
Did, they were not keen on learning the ropes for Qt, and they said hell no to using Ceylon, and to be honest I don't really have much free time to invest in learning Python.
>>50716948
Read carefully, I said in the application itself that is last priority that's what file managers and terminal is there for. If you look at the work toolbar. The intent is to open up terminal and file manager to the exact path (user choice with accelerators and context menus). We want to avoid the handling of file manipulation until the end up making the deletion a move to trash/recycling to avoid having users accidentally permanently deleting data.
>>50717151
>Did, they were not keen on learning the ropes for Qt
Oh whale. JavaFX ain't too bad.
>>50717125
It does matter because he was making an in-place quicksort for fun in the first place.
So caring about shit like "oh but in place won't matter once the complier gets to it" doesn't matter.
>>50717151
Sorry, didn't notice the buttons. I am really bad with icons, 9 times out of 10 I have to hover over for tooltips to figure out what they mean.
>>50716411
It is time to download Android studio. Press Run and watch that Java code work with xml to make a hello world app on a device. It is devilishly simple to learn how Android works if you know Java. Udacity.com has free courses taught by the very same google engineers that design Android. Congrats, now you can begin to learn a framework. Your application logic is java and your display is xml, which is hell of a lot better than Javafx. It does take a few months to really learn Android but it is 80% java.
>>50717165
It's good, though I was hoping the bash shell would be a giveaway. Should've gotten better quality screenshots .
>>50717125
>compiler will essentially optimize the new array to just be an in place mutation of the old one
Nope. They're slightly different algorithms, with different spatial complexities. There are also a number of other differences in what you've done (is that Elixir?) and what I've done. You're using linked lists, I'm using arrays, (I assume) your list requires integer indices, while arrays in Ada can also use enumerations for that. You've also hidden a lot of the implementation in a partition function.
I want to write a strategy game in a functional language. Is this possible?
>>50717359
Yes. Functional languages are generally Turing-complete.
>>50717359
No. You can only write games in javascript
>>50717379
I heard functional languages were really bad with input and rendering so I wasn't sure.
>>50716484
Still can't come up with a better algorithm for doing a refill of a buffer with an input file. ;_;static int refillBuffer(FILE *inFile)
{
// TODO: optimize
// inFile.map(inFile.pos(), inFile.size());
while((encBufLast - encBufPos < BUF_REFILL_AMOUNT) && !(inFileSize <= 0))
{
*((char*)(encBuf + (encBufLast % ENC_BUF_SZ))) = (char)fgetc(inFile);
--inFileSize;
++encBufLast;
}
if((encBufPos == encBufLast) && (inFileSize <= 0))
{
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
>>50717258
The linked lists don't use integer indeces, they're just plain old linked lists, but will be quite efficient because I pattern match only on the first item and the rest of the list.
The partition function is hiding some complexity, but not alot, since it's just performing a map of the passed anonymous function on each element in the list to split it up.
Thinking about it some more though, the use of partition will likely result in new structures being created in the memory rather than a mutation. So I guess under the hood they actually will perform quite differently.
>>50717401
You do know that FILE * are already buffered, right?
How much faster is C than C++ for general computation, assuming both programs are coded optimally? I'm under the impression the difference is negligible.
>>50717498
It is.
>>50717502
Ok, thanks.
>>50717498
Assuming optimal coding, there is negligible difference between C, C++, Ada, Fortran, Forth, and Rust.
I'm learning C (actually programming in general). I've started with basic OpenGL animations. Right now I have a ball that bounces around the screen.
How do I make random a magnitude of a number? I have an array of two integers, these determine the direction this balls goes in.int ballSpeed[2] = {1,1}; //north-east
int ballSpeed[2] = {-1,1}; //north-west
int ballSpeed[2] = {1,-1}; //south-east
int ballSpeed[2] = {-1,-1}; //south-west
I know of rand(), but this gives me a random value in a range, a range that can't be negative.
Any help?
>>50717523
To clarify: how do I generate a random value, either of -1 or 1?
>tfw u can't find a good midi library so you just write directly to /dev/pcspeaker
>>50717523
add another rand() function that randomly makes the number negative.
>>50717522
Nope.
>>50717541if (rand() % 1)
num =- num * 2;
>>50717440
I should clarify, this is used for a compression scheme for a file. I am "chunking" the file into blocks with this.
Beginner here, why isn't the program finding this file? I'm using eclipse and I imported the text file into the SRC folder and configured the arguments tab to accept the file name that I want.
>>50717523
>>50717541
ballSpeed[2] = {(rand()%1 == 0) ? 1 : -1,(rand()%1 == 0) ? 1 : -1};
>>50717523int s = 0 - (rand() & 1); // 0 or -1
// this will flip the sign of x
x = (x ^ s) + (s & 1);
>>50717547
[citation needed]
>>50717523
>>50717544
make your range 2n
result minus n
...off top of head.. is this the worst way??
>>50717626
Exactly.
>>50717630
i was just thinking range n, then subtract n minus 2n
>>50717498
if by optimal you mean
>the fastest possible code that will compile
then they will be exactly the same, because it'll be exactly the same code (inline assembly)
if by optimal you mean
>the fastest possible code that will compile while also following the generally expected paradigm for the language
then it'll be exactly the same in most cases since most programs are trivial, and up to a small negligible difference favoring C for very complex programs
I'm using Valgrind on my code, and it looks fine, but it says i have 171kb of still reachable memory.
I looked through the log and it's all stuff involving gnutls and other things that aren't mine.
Do I need to concern myself with still reachable memory, and in this case is it even something that's in my control?
>>50717732
consider looking into it if it starts to get to 1gb
>>50717151
du -h | sort -h
>>50717732
Do you call all of the shutdown functions for the "things that aren't yours" before your app exits?
What's the best OOP language for programs that's good for running on embedded systems? I would imagine C++, but I read something saying it was bad for this. Not sure what would make it so.
>>50717748
Yeah.
>>50717758
Use Robertson screw heads. Unlike Phillips, they aren't designed to cam out so you can screw down your decking super tight with a power drill.
>>50717758
cfags will suggest you use C and implement your own OOP using structures
otherwise, just use C++
>>50717773
>Robertson screw heads.
>not Torx
Torx resist cam out, too, and they're leagues better than fucking Robertsons.
>>50717394
It's possible, but not as straightforward in a pure functional language as in a more traditional imperative one
>>50717394
If by input you mean handling things like key events, those tend not to be an issue. However, actually rendering things has side effects, so a pure functional language will require proper separation to do this.
>>50717758
Ada. It's literally one of the main things it was designed for.
>>50717778
lel, ctards wouldn't know the first thing about a good language for embedded programming.
https://web.archive.org/web/20070606023312/http://www.stsc.hill.af.mil/crosstalk/2000/08/mccormick.html
>>50717523
I just don't get it... how come people with this kind of level, i.e., veeeeeery basic knowledge, want to make games, while I can't make shit by myself? is this all about self-confidence? :/
>tfw working on cloud code editor for capstone design
the more I work on this the more quickly I realize just how shitty it is to be a developer. Literally every idea has been done at least five times, each better than I could ever do with 10x the time.
I still can't believe the requirement for a senior bachelors class was that I create some unique and innovative algorithm that contributes to the academics of my field and the industry. I'm only allowed to do this because my teacher is the kind of idiot who would give that kind of assignment in the first place. What I'm doing could NEVER compete with cloud9 or any of it's dozen or so lesser clones.
I should not try to be an entrepreneur in the future, my sense of potential can't survive that
>>50717892
>is this all about self-confidence?
yes
>>50717908
Also a lot of persistence.
>>50717758
Use C and don't do OO at all.
how come this isn't working? python fizz buzz functiondef fizzbuzz(n):
if n % 5 == 0 and n % 3 == 0:
msg = "FizzBuzz"
elif n % 3 == 0:
msg = "Fizz"
elif n % 5 == 0:
msg = "Buzz"
else print("That number didn't generate any fizzing or buzzing")
>>50717997def fizzbuzz(n):
if n % 5 == 0 and n % 3 == 0:
msg = "FizzBuzz"
elif n % 3 == 0:
msg = "Fizz"
elif n % 5 == 0:
msg = "Buzz"
else:
msg = "That number didn't generate any fizzing or buzzing"
return msg
print (fizzbuzz(2))
>>50718050
yeah i just figured out i wasnt doing anything with the msg variable. came up with something very similar to yours. Thanks
>>50717961
I feel like the only person who can legit say this is Linus. In most applications where more than one person is working on a code base or the code should be reusable, OOP is the way to go.
>>50718062
be aware that its every slightly more performant to only call print once. So returning msg and ending with
[code[print "\n".join(map(fizzbuzz,range(1,100)))[/code]
is faster than calling print in fizzbuzz.
Just a simple thing to add moc support to i3status:#!/bin/bash
# You definitely want to make sure i3status' output mode is is set to i3bar,
# because we're being evil and manipulating json with regex.
trigger_prefix="E:" # The prefix of the item you want this to be *after*
np_prefix="NP:" # This item's prefix
item() {
mocp -i | grep ^"$*" | sed 's/^[^ ]* //'
}
i3status |
while read line; do
echo $line |
sed 's/\('$trigger_prefix' [^"]*"},\)/\1{"full_text":"'"$np_prefix $(item Artist) - $(item SongTitle)"'","name":"mocp"},/'
done
>>50717564
num = -num
>>50716284
Emacs is a Lisp environment that includes an IDE for probably every language out there.
>>50717541
n =(rand() % 1 == 0 : 1 ? -1)
>>50716551
depending on what your background is, learn new technology related to it. If you're into webdev, learn an mvc framework, they're part an exponentially rising niche on the market.
pleb here
Can anyone help me in this basic stack class
why I'm getting an error (R6010 on visual studio), it seems it's an unhandled exception but I'm not sureclass StackException : public logic_error
{
public:
StackException(const string& message = "")
: logic_error(message.c_str())
{}
};
Small stack exception code to handle exceptionstemplate <class T>
void GStack<T>::pop(T& stackTop) throw(StackException){
if (isEmpty()){
throw StackException("Error this sucks");
}
else{
list<T>::iterator it = data.end();
it--;
stackTop = *it;
data.pop_back();
}
}
I'm too much of a pleb to tell what I'm doing wrong, can anyone help?
>>50716575
You can add "Programming in D" by Ali Cehreli (free version: http://ddili.org/ders/d.en/index.html) to the best-of-their-own-world-tier.
is there a way to disable IntelliJ/PyCharm from trying to correct my naming/whitespace/whatever-the-fuck conventions?
shits starting to piss me off
>>50716411
>>50717195
This. But if you still want to learn a new language, not just a new framework for the same language, I'd recommend Swift. Plus iOS devs are more in demand (seriously where are all the fucking iOS devs these days?).
Unless you're the kind of person who actually gives a shit whether you're android/iOS, in which case fuck you.
>>50717401
Your commenting is pointless, it's not a comment. How is that going to aid readability/comprehension of that block?
>>50717379
he's a big GUI
>>50718491
Settings -> Editor -> Inspections -> PEP8 naming conventions
>>50716411
Learn Qt or Electron.
>>50718551
That's not its purpose. It'd just a reminder for optimizing the thing in general, with the buffer fill taking the most time with this LZSS variant encoder when I did some benchmarking. I have not a single clue how to optimize this particular section, but I will rewrite it in the future if I can.
I have other priorities I need to work on before I can do that though.
>muh data structures
>muh algorithms
How much longer before software engineering jobs are reduced to the point where being a delivery truck driver or coffee maker pays more?
>Politicians and business owners pushing for programming classes in schools
>Media shilling the idea that kids can be the next Steve Jobs with 3 motherfucking movies about the dead faggot already
>H1Bs filling up the jobs like diarrhea filling up a toilet after a night of whiskey and taco bell
>>50718744
They already are, and good riddance. Smug Java/C#/web devs who think they are the shit because they can do what literally everyone else can do are the worst.
>>50718744
it will never happen
despite what a bunch of famous people say or think, programming just isn't for everyone
it requires a special kind "programmers thinking" to be good at it, i dont think your average Chad would want to put in the time needed to learn that, or even could in the first place
>>50718744
Not much longer.
The "anyone can code" movement already has most people (read: corporate efficiency consultants) believing that any soccer mom or truck driver could learn to code in a few weeks.
First the raises will end, then the wages will be lowered to match what most people perceive to be the janitorial work of the 21st century.
Same question as yesterday:
How do I into TDD with python? I made a class that uses curses to draw shit on the screen, now how do I assert() if everything is right? Most functions don't have return values
Also any good resources on python testing without a focus on Django?
>>50718759
Who the fuck are you?
>>50718744
depends where you live, I guess
my father is an electrician and he gets barely over the minimum wage
meanwhile I write shitcode in php and get 3x as much as him
>the thing boss wanted done has been production ready for two days
>still have 5 more days before i was "supposed" to be finished
>scared of getting laid off because there isn't enough work if i start turning everything in the moment its completed
everytime
>>50718830
You're doing good. Never ever do more than the bare minimum required of you.
Also, you could try experimenting with procrastination if you end up with days of extra time to burn.
>>50718830
>doing your work properly
>scared if getting laid off
you what nigger
>>50718864
>Never ever do more than the bare minimum required of you
Unless you want a raise. But even then just do a little more than what's required and log it so you can present it later.
>>50718830
Turn it in early. Might build grounds for asking for a raise eventually. Especially if your coworkers aren't as productive.
>>50718879
No, you don't get it.
If you start doing work faster than expected, your boss(es) will start to expect that level of productivity from you, and if that level of productivity ever drops, it'll just make you look bad and put you on the lay off list.
>>50718892
>will start to expect that level of productivity from you
Of course. What the fuck else do you expect him to give you a raise for?
>>50718787$ pip install pytest
$ mkdir tests
$ cat > tests/test_draw_shit.py
expected_shit = "...."
def test_draw_shit():
draw_shit()
assert curses_get_screen_shit() == expected_shit
^D
$ py.test
>>50718879
>>50718911
oh, anon, anon.
Remember: Every good deed will be accordingly punished.
If you show that you can work faster and harder, you won't get a raise. The only thing that will raise will be the management's expectations. If after some time your pace of work drops, you'll get reprimanded how you're not meeting the productivity quota, and then your second reminder will be a layoff.
>>50718911
Because you've spent X amount of time at Y company and this little pay raise will make you less likely to leave when the server room is on fire.
>>50718936
You just need a coworker that works slower as a measure for comparison.
>>50718936
>>50718938
>NEETs and mental midgets arguing business
cute
http://vim-adventures.com/
>implying vim isn't the most efficient text editor
>>50719048
>cute
okay. just don't come crying "my boss is an asshole i've worked so hard and didn't get a raise" in a few months.
>>50719102
>implying he didn't give me several already
>>50719066
>implying vim has anything on based acme
Let's see your text editor run commands by highlighting things :^)
>Put a promise inside of a .then
>It actually fucking does the .then THEN does the other promise inside of it
Nice fucking consistency.
Can anyone explain what I'm doing wrong?
I'm not how to do this double indirection thing.typedef struct {
int ID;
int age;
} someRecord;
typedef someRecord *someLink;
// This works.
int compareAge(const void* a, const void* b) {
someLink link1 = *(const someLink *) a;
someLink link2 = *(const someLink *) b;
return link1->age - link2->age;
}
// I want to do this, because it shows that I'm using a pointer to a struct.
int compareAge(const void* a, const void* b) {
(someRecord *) record1 = *(const (someRecord *) *) a;
(someRecord *) record2 = *(const (someRecord *) *) b;
return record1->age - record2->age;
}
int main() {
int recordCount = 1;
someRecord records[recordCount];
someRecord *tempLinks[recordCount];
for (int i=0; i<recordCount; i++) {
tempLinks[i] = &records[i];
}
qsort(tempLinks, (size_t) recordCount, sizeof(someRecord *), compareAge);
return 0;
}
>>50716284
Emacs is a cool OS, but it lacks a good text editor.
>>50719778
You do realize that you should kill yourself
Hi, I am learning JAVA and I am right now learning about Boolean Logical Operators by reading and typing the code in the book into the IDE.
But I have the feeling that I will just have a gist of what I am doing.
I have no real idea what I am doing it, aside from understanding the chapters that is.
It is difficult to put it into words.
My motiviation for coding is to express my scarce creativity and getting a job, but I have the feeling that I am missing something.
>>50719741
In C, don't cast void pointers. It'll silence any compiler warnings that may be there (such as discarding const) and does absolutely nothing of value.
Also, as a matter of style, you really shouldn't typedef pointers. It leads to your code being confusing as fuck to read.int compareAge(const void* a, const void* b) {
const someRecord *record1 = a;
const someRecord *record2 = b;
return record1->age - record2->age;
}
Is all you should need.
>>50719800
Gave it a try and it does't work.
ThetempLinksis an array of pointers to the structs.
So I need to get the value from a->pointerToStruct->struct->value.
>>50716597
what is the best resource/book for learning haskell?
>>50719843
Oh right, it's double indirection.int compareAge(const void* a, const void* b) {
someRecord *const* record1 = a;
someRecord *const* record2 = b;
return (*record1)->age - (*record2)->age;
}
should work
graham hutton's programming in haskell
>>50719913
Thx. It worked like a charm.
I was also fucking around and this happened to work.int compareAge(const void* a, const void* b) {
someRecord const *record1 = *(someRecord **) a;
someRecord const *record2 = *(someRecord **) b;
return record1->age - record2->age;
}
What the fuck is going on?
What does it even mean to do this*const*?
Or this*(someRecord **)?
If you don't wanna lecture, do you know a sight that explains this stuff?
I can't find this on my C book.
>>50719979
>*const*
A const pointer to a pointer. That is (const *)->(normal *)->(thing).
It means that you aren't allowed to change (normal *), but you're allowed to change (const *) or (thing).
You read declarations right to left, and keywords such as const apply to the thing to their right.
>*(someRecord **)
You're casting to a pointer to a pointer, and then dereferencing it once, leaving you with just a normal pointer.
Is this correct way to do this shit?
razlomak = fraction
imenilac = denominator
brojilac = numerator#include <iostream>
using namespace std;
class Razlomak {
int brojilac, imenilac;
public:
Razlomak(int a = 0, int b = 1);
// pre increment
friend Razlomak& operator ++(Razlomak&);
// post increment
friend const Razlomak operator ++(Razlomak&,int);
// pre decrement
friend Razlomak& operator --(Razlomak&);
// post decrement
friend const Razlomak operator --(Razlomak&,int);
};
Razlomak:: Razlomak(int a, int b) : brojilac(a), imenilac(b) { }
Razlomak &operator ++(Razlomak& r){
r.brojilac += r.imenilac;
return r;
}
const Razlomak operator ++( Razlomak &r, int i ) {
Razlomak tmp(r.brojilac, r.imenilac);
r.brojilac += r.imenilac;
return tmp;
}
>>50720067
Lots of things. Want to fix your typos and try again?
Also, as a numpy veteran, may I recommend an indirect sort that results in an array of array indices rather than an array of pointers into another array? qsort makes this difficult and reliant on globals since it doesn't allow a "context" parameter to the comparator function, but you might gain some inspiration if you are working with array indices instead of pointers.
Just been workin' on a mini-game for my portfolio for a internship. Using C++ and the SFML game library.
I'll post code-snaps from my particle system when I get home
>>50720067
There are several things wrong:
You forgot the brackets on the cast.
record1 and record2 are not pointer types, so you're trying to assign a pointer to a struct.
Even if it was a pointer type, you want to dereference a and b once before assigning it.
I'm taking my first programming class, one in C++. I've submitted two assignments, all of which circled my comments and said my commenting does not fit convention./* this is a multi-line comment
* perhaps it introduces a new function
* or a code block that needs explaining */
int i = 0; //this is a short comment
//this is a comment that if placed beside the below, would stretch beyond the page
for (int i = 0; i < width*height*depth; i++, k++, n++) {}
Don't tell me C commenting convention is like in Java with "@param" nonsense?
>>50720121
sry. Just deleted the post because of the ugliness.
I'm not sure what you mean by:
>you might gain some inspiration if you are working with array indices instead of pointers.
I'm using qsort only because it's in the standard library.
I'm sorting with pointers to structs so I can to reduce memory since an array of structs just uses count * sizeof(struct) of memory.
I know qsort has worst case O(n^2). Do you know of a better sorting algorithm in the C standard library?
>>50720141
Yeah just noticed that.
Hence deleted.
Any of you guys know of a good source about how the compiler interprets * and &?int compareAge(const void* a, const void* b) { // Doesn't work
someRecord const *record1 = (someRecord *) &a;
someRecord const *record2 = (someRecord *) &b;
return record1->age - record2->age;
}
Obviously I have no idea about how this works...
>>50720047
Besides the complete lack of indentation and whitespace, it seems correct.
>>50720202
>how the compiler interprets * and &
All pointers are just memory addresses, which are just integers. & just gets the location that something is stored in memory, and * will look at the address which the pointer contains.
Any beginner C textbook should have a section on this. It would probably be a lot easier to explain with a drawing with an array that represents all of memory, but I can't be bothered drawing one, and you'll probably find one in the textbook.
You can use printf to get the value of a pointer with %p.
>>50720249
That made it clear actually.
Thx. I think I got confused with the *(int) (int *) (int)* stuff...
>>50720305
Yes, casting pointers can get messy, especially if qualifiers like const are used.
Again, I just let the compiler automatically convert void *'s to variables for me. I just have to worry about getting the type right.
>>50716284
I've been using eclipse for C++ and I really like it.
>>50720202
>I'm not sure what you mean by:
>>you might gain some inspiration if you are working with array indices instead of pointers.
Here's one benefit. `records` is your array of structs. `tempLinks` is a sorted array of pointers into `records`. If you need to move `records` somewhere else, so you free the memory, then `tempLinks` will now be full of invalid pointers.
However, if `tempLinks` is a simple array of integers, instead of pointers into `records`, then you can avoid this problem. `tempLinks` will then give the same sorted order regardless of where `records` is stored.
This is what numpy calls an "indirect sort", and the function `numpy.argsort` returns such an array of integers.
>>50720198
>does not fit convention.
that just means whatever little anal pattern she insists on. just figure out whatever that is and you're code to it. If you want to learn more once you're done with the class, you can investigate several coding standards out there, that touch on commenting as well as much more. I suggest if you have no other preference then follow Stroustrup's simple guidelines.
http://www.stroustrup.com/Programming/PPP-style.pdf
>>50716605
Yeah.. it's not hard to write a sort when partition is already done for you. Not only that but yours allocates heap memory A LOT and is probably at least 10x slower.
>>50717498
There is no difference in the optimal case. In the general case modern C++ will be smaller and faster because it will be architected better and take less overall development time.
>>50720393
>smaller
Not likely. It may be in fact faster (it's actually easier for the optimizer to do good things with well-written C++ in general than C, since C forces you to dictate so many small details), but not very likely to be smaller. The difference may be negligible for everything outside embedded, but it's there nonetheless.
>>50720393
>smaller
Templates cause code bloat
>faster
Great C++ meme. All of those abstractions are FREE aren't they?
>it will be architected better
OOP (inheritance, design patterns and other shit like that) typically leads to inefficient abstractions.
>less overall development time
Pulled out of your ass.
Are C fags just people deluded into thinking you can't have a zero-overhead abstraction or safety mechanism?
>>50716389
if you're using a strongly typed language (java falls into this) you are shooting yourself in the foot not using an actual IDE. using emacs/vim/etc for these languages is always 99% configuration 1% development
I think people like IDEAJ the most for java generally
>>50720427
Oh look, another C-uck who doesn't actually know C++
Is this stuff you repeat a big game of telephone of what other C-ucks tell each other to rationalize not learning modern C++?
>>50720445
Among other delusions.
Remember, no one has learned modern C++ and then gone back to C. It doesn't happen.
>>50720494
If I was to learn a new "modern" language, C++ would be one of the last choices on my list. Life is too short to learn C++.
I already know Rust. Maybe I would go with functional language.
>>50720548
>I already know Rust
>>>/leddit/
>5:24AM
sup?
>>50720548
C guys always say 'you're just too stoopid to manage memory' and then they say 'no one can be smart enough to learn C++'
We all want to use Rust but the tools ain't there yet I'm afraid. When Rust has 4 separate compilers you can build a business around and multiple IDEs both commercial and free, it will be a grand old time.
>>50720581
>We all want to use Rust
lolno
>>50720567
Rust is a very interesting language. You're a fucking child if you let stupid non-technical issues stop you from looking at a language.
>>50720581
>no one can be smart enough to learn C++
I didn't say people weren't smart enough, it's just that C++ is a design-by-committee clusterfuck. So many things get added to the language with every new release. It would take an individual decades to "master C++" and even by the time that happens, more shit would have been added.
Rust's way of managing ownership and lifetimes is quite esoteric. It's better to use first-class capabilities that languages with dependent and linear types can get you.
>>50720605
>You're a fucking child
No, actually it's called having principles anon.
>>50719620
what
>>50720581
>wanting to know rust
>>50720621
'Having principles' means you refuse to change your opinion, regardless of the facts.
Fuck people who have 'strong principles'.
>>50720605
>if you let stupid non-technical issues stop you
>stupid non-technical issues stop you
>non-technical issues
>non-technical
Interesting you should word it that way anon. I have similar concerns with organizations that take a similar approach to technology development. Cuckzilla, for instance being one such group.
>>50720621
>having principles
No, you're just a stupid faggot who fell for the memes.
>>50720636
lolk. that perspective will serve you really well in the end i'm sure.
>>50720651
fuck off faggot.
>>50718936
I'm going to guess you do a lot of Java or Javascript (well, not a lot)
>>50720636
>>50720605
>>50720651
Rust will never be good. It's being maintained by extreme SJWs and is a political tool more than a programming language at this point. They'll burn it to the ground with their bullshit.
I keep my politics and languages strictly separate, and I do not trust anyone who doesn't.
>>50720715int main(int argc, char * argv[])
{
printf("Hello world");
}
>>50720629
I know it, I said I want to use it more.
Learn to read.
>>50720715
I don't even like Rust.
I just think having 'principles' is a sign of mental immaturity.
I'm not well but I need to do something or my brain will rot.
What should I be doing?
>>50720876
Watch anime.
>>50720876
Writing fizzbuzz in 20 different languages?
>>50720742
>that indentation style
>>50720882
Once I find some good anime. I'l consider that my last option.
>>50720883
Tempting.
>>50720893
dooeet
>>50720768
How do you create a tree in Rust where nodes also have a link to their parent? Legit question. Or any sort of graph where each node has a list of all the nodes it's connected to?
>>50720893
No one cares, please kill yourself you lazy child.
>>50720965
>How do you create a tree in Rust where nodes also have a link to their parent?
Weak reference.
>>50720971
Thanks fam. Things like that are so simple in Java, but in Rust any heap shit gets so complicated really fast. Btw does compiler optimize lending? Like, when I call a function with a non-mutable struct, does it copy the struct? It could potentially just reference the struct in the call frame in of the caller function.
>>50720965
A classical linked list needs to be made with pointers and unsafe in Rust.
You can do the same thing for a tree structure.
A much better way is to have a tree struct contain a vector of nodes and have the nodes contain indices that are used to look up into the vector.
This is better in any language, but in Rust it saves you from the borrow checker caring about the links between nodes.
>>50716588
me too.
>>50720715
>and I do not trust anyone who doesn't.
>trusting anyone
And if you happen to really dislike faggotry? What then anon?
>>50721002
>A much better way is to have a tree struct contain a vector of nodes and have the nodes contain indices that are used to look up into the vector.
I actually tried this in Java and it's somewhat slower than making a tree the obvious way (probably because of cache locality problems).
>>50721002
Best is hashed data system in which every leaf node has 16 children which are switched with a case switch. I'm 70% sure this is how a dictionary file structure works and why its faster than even a sorted list (which is probably an optimised red black tree in most implementations.
But like, why roll this yourself?
Can i learn in 2 days basics about c++/java OOP?
>>50720742
Hey, cool, I can do that too.procedure Main is
begin
Put_Line("Hello world");
end Main;
>>50718744
Never. To be better than a currynigger at programming requires a certain kind of mind, and every dipshit who can make a sprite move in scratch or writes a basic HTML page doesn't have that. This is just feels bullshit for people who aren't good enough to get the top paying jobs.
>>50721037
Maybe read the thread, someone asked a question.
Also more specialized data structures can benefit from knowing these things.
>>50721028
There are ways to optimize for better cache locality like having a vector for each level of the tree. Even better would be bulk inserts.
Don't forget that Java could be bounds checking the index lookup which would slow it down and doing other fancy JIT stuff which could speed up the other case.
>>50721459procedure Main is
begin
Put_Line("Hello world");
end Main;
>>50718789
>>50718744
>>50718764
Shit programmers who don't want to believe they are shit.
Anyone with two rocks to pound together inside their head knows that most people are total fucking idiots when it comes to programming. To be threatened means you are in that group too.
>>50718936
This is correct and I learnt this the hard way.
Being productive and fast generally results in getting more responsibility and work, not more money.
Good strategy is to diversify projects and overestimate delivery time if you want to earn more.
Example: Take two smaller project where each you can finish in a week, say it will take you 2 weeks for each -> Get paid twice for 2 week work, whereas you worked 2 weeks total.
>>50721551
So how is Ada? I have GNAT installed and I've tinkered around with it a tiny bit, but ultimately I'm going to need a good book to really get into it.
Why learn Lisp if you can't use it for anything? No up to date libraries, dead community, no job market for it... Oh, I guess you can script Emacs with it.
>>50721614
>No up to date libraries
Clojure can use any JVM library you want tbh
>>50721551
Literally nobody does this. Ever.
>>50721598
That is the big problem with it. Finding tutorials for Ada95 is easy, but learning the later features from Ada2005 (eg interfaces, collection library) and Ada2012 (eg programming by contract, general streamlining of pragmas) requires a good book.
>>50721582
I always thought that i'm very bad in programming, but then i saw people who working as programmers. They are like shit tier.
So i think i'm not that bad, i'm live average mb
>>50721666
So uh.. what are the good books, then?
I want to program fighter jets.
tfw lazy
integer square root function in C
please critique#include <stdlib.h>
#include <stdio.h>
unsigned int intsqrt(unsigned int x2)
{
unsigned int x = 1, px = 1, same = 0;
do {
px = x;
x = (x + x2/x) / 2;
if (abs((int)x - (int)px) <= 1)
same++;
else
same = 0;
} while (same < 3);
if (px < x)
x = px;
return x;
}
int main(void)
{
unsigned int x2, x;
for (x2 = 1; x2 < 1000; x2++)
{
x = intsqrt(x2);
printf("%u %u\n", x2, x);
}
return 0;
}
>>50721689
http://www.amazon.com/Programming-Ada-2012-John-Barnes/dp/110742481X
This thing is the gold standard, although I'm told there are a few other really good but more specialised ones, for tasking and such. I know there's a copy of Programming in Ada 2012 around on the internet *somewhere* if you want to pirate it, but if you find it be aware that the formatting is absolute shit.
Tutorials like http://www.adahome.com/Tutorials/Lovelace/master.htm are easy to find, as mentioned, so you can look through those to get a feel for the basics.
Ada isn't just for fighter jets. Literally any application you can think of where you would normally reach for C or C++, Ada can do it better. Programming fighter jets would come under the systems programming annex, just so you know.
What do you make of >>50716490?
>>50721751
>I know there's a copy of Programming in Ada 2012 around on the internet *somewhere* if you want to pirate it, but if you find it be aware that the formatting is absolute shit.
I prefer physical books anyhow.
>Ada isn't just for fighter jets. Literally any application you can think of where you would normally reach for C or C++, Ada can do it better.
I know, I was just being a cheeky cunt.
>What do you make of >>50716490?
Looks fine to me. In fact, it looks a bit more than fine since a lot of the typical detritus gets cleaned up with Swap(Arr(Pivot0), ..., etc.
>>50721751
Can you elide bounds checking?
>>50721751
>>50721836
http://www.adacore.com/uploads/technical-papers/Ada2012_Rational_Introducion.pdf
>>50721836
>looks fine to me
Just wondering where you were at with playing around with the language. To actually make that code snippet work you need to put it in a generic and instantiate it so it knows what Index_T, Element_T, and Array_T are, and Swap also needs to be defined.
>>50721843
You can turn the runtime stuff off. It's not recommended that you do so unless you first prove that it isn't needed, however.
apologies for sealioning but
>>50720605
>stupid non-technical issues
such as?
>>50720715
>a political tool more than a programming language
how so?
>>50721895
>Just wondering where you were at with playing around with the language.
I don't have a perfect understanding of things but looking at it, it makes sense (and everyone's done in-place qsort in their algos class, so it should).
Like I said, to gain a deeper understanding, I'll need to start reading.
>>50721751
NHB i think its use of apostrophes as a member separator is unfortunate.
Just started to learn assembly. What I'm trying to do is take input from the user but it gets stored as ascii and in the wrong order. I want to use the value of the user input in an operation but I have to do all this shit converting it to hex before I can use it. Are there instructions to make this easier?
for example user inputs a 23, I do this:mov ax, 3332
sub ax, 3030h
mov bx, 0000
mov bl, ah
mov cx, 000ah
mov ah, 00
mul cx
add bx, ax
>>50721908
There are few unusual bits of slight interest in that code. There's no mention of pointers, even though the array is obviously being passed by reference to sort it in-place. Instead there are the parameter modes in, out, and in out. There's liberal usage of type attributes, which is what's fucking up the highlighting. That's because in Ada, arrays can use enumerations as indices, and said indices don't have to start from zero. And that loop is set up to exit in the middle instead of at the start/end, which I haven't seen in many other languages.
>>50716214
Midterm coming up over linked list.
Anyone have a nice one I can memorize for it?
>>50722135
When you knwo what a linked list is you can write one.
>>50722135
1. Don't use linked lists.
2. See 1.
>>50722167
There's plenty of good uses for linked lists. They're very convenient.
>>50722182
linked lists are buns, m8.
>>50722135
A linked list is either an empty list or a node attached to a linked list.
Proposed authentication mechanism:
* User logs in, password is verified, random string of characters is generated
* Random string is called "sid" and is stored in a table mapping uid to one or more sid
* Gets cookie containing "uid" and "sid"
* On future requests, uid is read from cookie and its entry in the table is looked up
* If the sid in the cookie is found in the table under that uid then the user is legit, go ahead
Is this reasonably secure?
>>50722182
I'm not sure about plenty.
O(1) delete of large data chunks where you don't have to search for each element could be a valid reason.
Other than stringing together large chunks of data, I think their uses are pretty exotic.
>>50722204
Not sure if I follow the logic, but a user would be authenticated by one single string from a cookie?
Well then I hope you don't have any XSS holes
>>50722071
>And that loop is set up to exit in the middle instead of at the start/end, which I haven't seen in many other languages.
Algol 68 loops have the condition in the middle.WHILE
WHILE a[left] ? a[pivot] ANDF left < UPB a
DO left +:= 1 OD;
WHILE a[right] > a[pivot] ANDF right > LWB a
DO right -:= 1 OD;
left < right
DO swap(a[left], a[right]) OD
Why does introduction to algorithms uses 1 as the beginning of an array, is it just to confuse the readers?
>>50722293
Assuming it's pseudo-code, a lot of books do that. Pretty typical.
>>50717541
n = rand() % 2 * 2 - 1;
>>50722288
That looks like a normal nested loop partition function.
>>50722293
It is that way in maths and makes it easier for engineers.
>>50722204
I'm assuming that you are using SSL or some form of encryption...
That shit will not fly on plaintext HTTP.
By the way, does you auth system also have a attempts detection mechanism?
Otherwise if your string is short enough, you could technically brute-force...
>>50722288
Yep. That's because Ada is partly descended from Algol 68 via Pascal.
>>50722293
Is it written in Lua?
>>50722365
I'm a soon-to-be engineer and I'm reading that book because I want to have some programming knowledge, you'd think that books aimed at people with some coding knowledge would abide by the industry standards.
Whatever, it's not like it matters but it was bugging me.
>>50722293
Why should arrays be limited to start indexing at 0? Dealing with poor and inflexible representations of scalars is a major source of bugs.
>>50722385
no it's all pseudocode, it's not hard to write the algorithms in c++ which is what i'm using but i have to change the indices
>>50722416
Why would you change an standard that's been there since decades ago? It's like if I suddenly want to build a train with a nonstandard track gauge. If anything the source of bugs are the selfish people who want to change the status quo for no reason at all.
>>50722416
If you know how arrays and pointers work, you would know why it makes sense to start them from 0.
>>50722418
>but i have to change the indices
This injustice will not go unnoted.
>>50717745
>multi platform
>graphical user interface
go shove a Debian iso up your ass.
>>50722286
Well, they're authenticated by the cookie, yes. How else do you do it?
>>50722371
It's plain HTTP. How would I make it secure over non-encrypted connections?
>Otherwise if your string is short enough
It isn't- I'm thinking 64 alphanum characters.
>>50722385
>>50722462
Lua's 1-based arrays makes even less sense because since Lua is not standalone but meant to be embedded. Why would you have a different array base from the language you're designed to be embedded in?
>>50722462
>>50722504
Sure, it makes sense for array indices to start at 0. In assembly. When you're working in a decent programming language though, why shouldn't you be able to index an array with whatever discrete ordered type you want? The bugs come in when you increase the cognitive load on the programmer by requiring them to map whatever index seems natural on to the 0..n form all the time instead of having the compiler do that for them.
>>50722504
It's exactly when you know how pointers and arrays work, that you know that it's arbitrary to start from 0 or 1 in a highlevel language.
>>50722535
I don't think it makes sense, but in Lua it is an index and in C it is an offset.
>>50722530
Is this web server for production?
I mean even if you do make a secure auth system, if your traffic's unencrypted, anyone can see what you're doing.
What are you trying to do with your server?
What service are you providing?
>>50722588
Decent programming languages already let you iterate over the indices in an array without knowing what the indices even are.
>>50722182
The only valid reason to use a linked list anymore is if you're designing a functional programming language, or making a game engine
>>50722588
>>50722612
So I should make the compiler spend time calculating array[ i - offset]?
Why?
>>50722769
>he never uses malloc, free, new, or delete because they're slow fucking bullshit linked lists
hardcore
>>50722782
Because the compiler is better at it than you are.
>>50722769
That doesn't make sense for more reasons than there are words in your post.
>>50722612
I don't think it'd be comfortable reading code if you always had to consider where the array starts. There's few cases where I see it worthwhile.
>>50722789
So each time you make a new array, you have a choice to decide the initial index...
That's just make you're program bug prone, instead of the always 0 rule.
>>50722782
This >>50722789. Also, I stated *whatever discrete ordered type you want* not just numbers for array index usage.
>>50722788
>unless you're designing a language
Maybe saying functional was too exclusive. There's reasons to use linked lists behind the scenes in a languages design, but very, very few to use them in anything else. Entity component programming is the best example.
>>50722818
https://www.youtube.com/watch?v=YQs6IC-vgmo
How does one use a dictionary (associative array) in Haskell. Also what's the difference between type and data?
while(A && B)
In C++ if A is false, does B get evaluated as well?
>>50722840
Let the compiler decide the initial index, too. It really doesn't matter.
>>50722863
Yeah I've seen that video, it does nothing to reinforce what you said.
Why would games be the exclusive use of performance killing data structure?
Also that video is pretty retarded since he goes on about how vectors are faster for deleting because you can loop through the vector faster to find your object. Who the fuck would structure their program so that you have to loop through anything to find what they are going to delete if they care about performance? That's fucking retarded.
So linked lists usually suck, but that video also sucks because it emphasizes something that would never be done in practice.
>>50722895
No.
In php it does, but it doesn't if you use and instead of && for some reason
>>50722843
>why shouldn't you be able to index an array with whatever discrete ordered type you want?
You're gonna have to give me an example on that one.
How are you supposed to access an array without using numbers?
>>50722884
Data.Map iirc.
it's a pain because there's no nice syntax for it unlike lists
>>50722935
the alphabet is a discrete ordered type and can be used to index a list/array, e.g.
>>50722918
>Why would games be the exclusive use of performance killing data structure?
Because in videogames objects on screen are stored in a datastructure, but if they are destroyed, killed, or outside of the rendering distance they can check that and delete themselves rather than some auxilliary class managing it
>>50722755
>Is this web server for production?
>What service are you providing?
Yes but it is not a security-critical service. It's a control panel of sorts- no confidential data is served but I don't want an attacker to be able to perform actions on the server.
>if your traffic's unencrypted, anyone can see what you're doing.
I know, but there are still plenty of large public services which need to be signed into and don't default to https. So I figure it can't be all that grave a sin. All users of the service use trusted computers and connections.
If we assume that the user's connection is safe from interception and that there are no evil maids extracting cookies (I know these could be considered unreasonable assumptions), is the system I describe safe?
>>50722966
char is 8bit number...
a = 0x61
>>50722935
Consider the following trivial example:type Arbitrary_Enum is (A, B, C, D, E);
type Array_Type is array (Arbitrary_Enum range <>) of Integer;
Test_Array : Array_Type := (1, 32, 3, 47, 10);
Then you access the members of Test_Array by using Arbitrary_Enum. The only things you need for an array index type is that it's discrete and that it's ordered, ie it's a type that can be mapped on to the integers.
>>50722999
He said alphabet, not text encoding.
0x61 is the ASCII encoding for the letter 'A'. The letter 'A' itself is not a number. Furthermore, the abstract letter 'A' is not the same as the letter 'A' rendered in a particular typeface, and that too is not a number.
>>50722999
Only in shit-tier languages. In a good language a character is semantically different from a number and you cannot mix them without an explicit conversion function.
>>50722999
implementation detail.
mathematically the point is any discrete ordered type can be put into one-to-one correspondence with a subset of the natural numbers.
>>50722950
I've already imported it but I'm not sure how to use it.
I'm making an interpreter (It's an assigment so it's heavily guided)
And the lecturer wants us to save variables by creating two types Context and Memory.
Context will be used to draw out the memory address of a variable. I feed it a variable name and get an address.
Memory will have a Memory address and return an AST( Abstract syntax tree)
I'm coming from OOP so my first thought's were "muh hashmaps". Having said that I have no idea whether I'm thinking correctly or not.
How do modern Operating Systems deal with deadlocks?
They don't.
https://en.wikipedia.org/wiki/Ostrich_algorithm#Use_with_deadlocks
>>50722979
That's a use in video games, not a reason why they wouldn't be used in other areas.
Also linked lists are a very terrible way to do what you are describing.
>>50723113
>That's a use in video games,
That's what I was answering.
> not a reason why they wouldn't be used in other areas.
You already answered that, performance.
>Also linked lists are a very terrible way to do what you are describing.
Well then you should tell every 3d engine that.
You haven't explained why strousoup was wrong though.
>>50722988
>If we assume that the user's connection is safe from interception and that there are no evil maids extracting cookies (I know these could be considered unreasonable assumptions), is the system I describe safe?
"safe from interception" means that you have a direct link to the server, and no one else shares that link.
"no evil maids extracting cookies" means that you trust your clients.
But then why are you worried if it's safe or not?
The mere fact that you're providing a service to control something remotely means you need to encrypt the connection.
Without data encryption, there is no data integrity check.
Without data integrity checks, there is chance for an attacker to analyse what certain messages do, and change the message to perform what the attacker desires.
Usually when you use non-encrypted HTTP deliberately, is when you are only showing public information in read-only mode.
Is this only a in-house web server?
If so, you can create you're on CA service for FREEEEEEEEEEEE.
If you trust all your client hosts why are you worried about attacks?
>>50721976
It shold be something like that:...
mov di, 0Ah
xor ax, ax
xor bx, bx
mov cx, offset your_string
next_char:
mov bl, [cx]
test bl, bl
jz parse_end
sub bl, 30h
ja parse_end
mul di
add ax, bx
inc cx
jmp next_char
parse_end:
...
And no, there is no special instructions, you're on your own. That's the way of assembly. Enjoy. I know i do.
>>50723092
This is new to you?
>>50721409
http://pastebin.com/Z7PBansu
Should be enough to start. Though, there are a lot more features of the language considered *basic*. Like lambdas, defines, and templates.
>>50723092
Interesting.
I shall apply this algorithm to all of my code.try
{
//stuff
}
catch(Exception yolo)
{
DoNothing(yolo);
}protected void DoNothing(Object yolo)
{
}
>>50723037
>any discrete ordered type can be put into one-to-one correspondence with a subset of the natural numbers.
But then you're just describing a function with integers. (not natural numbers, you should be able to index with -1 with your theory.)
Array's are an easy way to store things. They are the most fundamental containers.
If you want more mathematically abstract structures, just build those structures.
I'm pretty sure they will use arrays at some level.
298th for putting 1000 lines of code in one try catch block.
>>50723154
True retardation is thinking you know things that you don't.
If linked lists don't perform well, why would they be used in video games and only in video games of all places?
A 3D Engine that uses linked lists like you are describing is an engine that is nowhere near optimal. Real game engines don't do this, they use many different types of allocation strategies specifically to avoid it.
I never said he was wrong, I said the talk is ridiculous because he compares the performance of deleting, but factors looping through the structure into the deletion time, which no one in their right mind would do. And I did mention that.
Illiterate. Fucking. Retarded. Child.
>>50723257
>fails to defend his point
>results to ad hominems and real girls have curves
>>50723272
> Illiterate.
I don't believe you are actually this retarded.
Well trolled.
>>50723212
Would have thought with so many years of operating system development, Unix and Windows might actually have a sane and efficient means of handling deadlocks.
>>50723284
>!=
>not <>
>>50723282
>hurr durr durr
Yep, you're right, the world is wrong.
>>50723291
There is no safe and efficient method for dealing with deadlocks, though.
You can prevent them or deal with them if they happen but both take quite a few extra instructions for what is honestly an edge case.
It's either safe or efficient, picking both is impossible as far as I know.
>>50723161
Okay you've convinced me, I'll take the time to put the server behind nginx and use self-signed SSL
Thanks
>>50723092
Multics did deadlock detection.
>>50723302
Show me evidence of whatever the fuck you are bumbling around trying to say.
Prove somehow that games are the only place to use linked lists.
Here is an entire video talking about EAs management of memory.
https://www.youtube.com/watch?v=8KIvWJUYbDA&list=PLHTh1InhhwT75gykhs7pqcR_uSiG601oh&index=9
I'm always floored by how little people can know and still act like an expert.
>>50722895
No, it won't. && is a short circut operator. If you want that B is evaluated as well you have to use the &-operator.
Why is go slower than java, when java is a full virtual machine that compiles bytecode to machine code on the fly while garbage collecting, yet go is compiled to native code and garbage is handled by a seperate runtime
>>50722979
>Because in videogames objects on screen are stored in a datastructure
I don't think games do it that way, likely you just have a list of entities that are "in range" (anywhere around the camera) and then you cull them based on some render cone and alternatively z-ordering
>but if they are destroyed, killed, or outside of the rendering distance they can check that and delete themselves rather than some auxilliary class managing it
I don't know all that much about game engines but I can't even picture what this has to do with linked lists. How can an element in a linked list "check itself"? You don't even reach it without going through other nodes.
But maybe you have experience and can motivate?
>>50723370
>that games are the only place to use linked lists.
Now who's illiterate.
>>50723379
Go can't do any JIT optimizations that Java can
And people talk shit about the JVM but for what it is it's actually pretty miraculously performant.
>>50723315
>It's either safe or efficient, picking both is impossible as far as I know.
Can it be proven that no efficient method is possible, or have we merely not come up with an efficient enough algorithm?
>>50723316
The total consulting bill is....
$1000.00
Please pay by tomorrow.
>>50723397
> Now who's illiterate.
> The only valid reason to use a linked list anymore is if you're designing a functional programming language, or making a game engine
Still you
Tell me more about video game engine architecture.
>>50716214
hey guis I'm having some issues with my code
what the program is supposed to do is get 5 integers, compare the integers and swap if they arent in order, and then output them in ascending order
instead I'm getting a jumbled mess of random numbers#include <iostream>
using namespace std;
int main()
{
int numb1, numb2, numb3, numb4, numb5, temp = 0;
cout << "Enter 5 integers: \n";
cin >> numb1, numb2, numb3, numb4, numb5;
int repeat = 0;
while (repeat < 5)
{
if (numb1 > numb2) {temp = numb1; numb1 = numb2; numb2 = temp;}
if (numb2 > numb3) {temp = numb2; numb2 = numb3; numb3 = temp;}
if (numb3 > numb4) {temp = numb3; numb3 = numb4; numb4 = temp;}
if (numb4 > numb5) {temp = numb4; numb4 = numb5; numb5 = temp;}
cout << "Result: " << repeat << " : " << numb1 << " " << numb2 << " " << numb3 << " " << numb4 << " " << numb5 << endl;
repeat = repeat + 1;
}
system("PAUSE");
return 0;
}
what do?
>>50723468
You should probably initialize numb1-5
>>50723467
That's 2
>>50723284
What's so wrong with anime? As long as it is tasteful of course.
>>50723492
didn't I already do that tho?
what do you mean anon it has to be something weird im missing cus I've been staring at this for half an hour and i cant figure it out
>>50723468#include <iostream>
using namespace std;
int main()
{
int numb1, numb2, numb3, numb4, numb5, temp = 0;
cout << "Enter 5 integers: \n";
cin >> numb1, numb2, numb3, numb4, numb5;
cout<< "1, 2, 3, 4, 5" << endl;
system("PAUSE");
return 0;
}
>>50723468
>cin >> numb1, numb2, numb3, numb4, numb5;
is that correct syntax? it looks wrong somehow, shouldn't the ,s be >>s?
>>50723515
> Obviously splitting hairs to not seem like a total fucking idiot
> Still wrong
>>50723468cin >> numb1 >> numb2 >> numb3 >> numb4 >> numb5;
You can also swap integers without temporary variable. And use an actual soting algorythm, not this madness.
>>50723541
I straight up gave you the answer, you should probably put in a little debugging work yourself.
NEW THREAD
>>50723567
>>50723379
The go developers value fast compile times over optimizations.
>>50723552
Thank you so much anon! I knew it was something stupid that I was missing.
I'll look up stuff about sorting algorithms thank you
>>50723573
>>>/lgbt/
someone make an actual new thread plzkthx
>>50723585
That's a joke right?
That has to be a joke.
So you're saying that the developers want to spend less time waiting for compiling and let the users suffer speed?
>>50723632
they're going for the python audience
NEW THREAD
NEW THREAD
NEW THREAD
>>50723674
>>50723674
>>50723674
NEW THREAD
NEW THREAD
NEW THREAD
>>50723573
>>50723683
Cant even make ONE thread?
F A G G O T S
^
^ ^
>>50724069
at least i can triforce.
C U N T
^
^^
>>50724069
Only one thread was created. Look closer, and you find that one of those "new threads" was actually a trap. Careful not to fall for it.
>>50723402
>And people talk shit about the JVM but for what it is it's actually pretty miraculously performant.
It's not very miraculous. All code that does allocation has to spend time in deallocation, so you're only talking about the overhead necessary for this to happen independent of the programmer's control structures, which is not very large. I'm not saying the JVM hasn't had a lot of smart fuckers producing good things, but overall it isn't very surprising that a JIT garbage collected language would be average-case performant.
>>50716411
Just keep programming. Make Chess, read clean code, do programming challenges simply keep at it and you will be ready for whatever is ahead of you.
It's weird how the human brain learns things as it practices them. At some point everything will simply be clear and you'll just "get it". Once this semester is done I'm thinking of making a 4chan browser for Android just to practice TDD and testing in general.