[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 315
Thread images: 23

File: ComputerLanguagesChart.png (1MB, 4912x3050px) Image search: [Google]
ComputerLanguagesChart.png
1MB, 4912x3050px
Previous thread: >>62173913

Serious discussion starter: What do you think are the most important developments in the theory and the practice of programming from the last 10 years, /g/?
>>
>>62180040
>Serious discussion starter: What do you think are the most important developments in the theory and the practice of programming from the last 10 years, /g/?
Adopting to GPU's model of execution where there are tons of execution units but they can only work in lockstep mode?
>>
>>62180040
> theory
Dependent types.
> practice
Widespread adoption of DVCS in general and github in particular.
>>
I was going make barebones game engine library in C that I could use as library in any language I wanted. I didin't want close the program, recompile and then run but I wanted live programming, but I didn't know what language to use for scripting because they all suck.
So now I wrote some elisp so that when I save the .c file it compiles it as shared library that my engine will reload at runtime.
>>
File: 1503781265028.jpg (1MB, 620x4144px) Image search: [Google]
1503781265028.jpg
1MB, 620x4144px
>>62180040
Reminder that you should always strive to get better and learn better languages.
>>
>>62180316
>Lisp is in the bottom half
Every time.
>>
>>62180040
Scratched my server monitoring software project and restarting.
Haven't been working on it for a few months and learned a lot in the meantime so going for a total rewrite. Hope I will some day be actually happy with it and finish it
>>
>>62180299
>they told me i could become language, so i became C
>>
File: 1503937708014.jpg (1MB, 500x2855px) Image search: [Google]
1503937708014.jpg
1MB, 500x2855px
>>62180316
Read the right books too.
>>
Kernel can now fully manage virtual address, so I can move the heap away from its physical hard coded area and put it in a mmaped area.
>>
Hey guys I made a dynamic programming algorithm that solves a multi-dimensional knapsack problem. But I'm really struggling to print it out correctly. I can get the profit made from memo[-1][-1][-1] but I also want to display how many items were used, and which ones they were. Anyone able to help at all? Below is my code:

def maximizeProfit2(productList, priceLimit, itemLimit):
memo = [[[0] * (priceLimit + 1) for i in range(len(productList))] for j in range(itemLimit + 1)]

for i in range(1, itemLimit + 1):
for j in range(0, len(productList)):
for k in range(priceLimit + 1):
if productList[j - 1].productPrice <= k:
memo[i][j][k] = max(memo[i][j - 1][k],
memo[i - 1][j - 1][k - productList[j - 1].productPrice] +
productList[j - 1].productProfit)
else:
memo[i][j][k] = memo[i][j - 1][k]

return(memo[-1][-1][-1])
>>
>>62180439
Looks good, it's a shame C++ isn't used more widely for OS development outside hobby projects.
>>
>>62180484
Thanks. I agree, the output assembly is really cleaner than I expected before starting the project.
>>
>>62180484
>it's a shame C++ isn't used more widely for OS development outside hobby projects
No, it's not a shame. C++ is awful.
>>
Which programing language should i learn?
Also recomended me some book to help me learn.

I have zero-knowledge.
>>
So what about C++ and FastCGI for backend webshit? Completely viable?
>>
You'd think that adapting the height of an ImageView to match the height of a neighboring view would be simple if not trivial in Android, but apparently you need fucking voodoo magic to accomplish that
>>
4chan has always existed
>>
>>62180766
Yes: https://www.webtoolkit.eu/wt
>>
>>62180766
>>62180800
I'm the anon who mentioned C++ and FastCGI in the previous thread. We don't use this. We just use FCGX library.
>>
>>62180667
C
K&R
>>
>>62180667
Lisp, C, OCaml, C++ in that order. Anything but K&R for C.
>>
>>62180667
https://www.tutorialspoint.com/pascal/
>>
>>62180884
>FCGX library
I tried googling the thing because I am interested and it seems... dead?
>>
>>62180324
it's ironic
>>
Why would you use Lisp in <current_year>?
>>
Invention of PHP
>>
>>62181252
>the last 10 years
You mean Node.js.
>>
Do you wish you were as good as him?

https://www.youtube.com/watch?v=DBXZWB_dNsw
>>
>>62181199
I wouldn't, except for trivial emacs configuration.
>>
>>62181199
Development speed.
so prototypes, simple applications, showing off.
Also, LISP makes you a better programmer.
>>
>>62181045
>>62181056
>>62181057
I have mixed answer here. Which one i need to learn first?

Come on guys im very serious/
>>
>>62181075
I mean this: https://github.com/eatonphil/fastcgi-development-kit
>>
>>62181340
there's no mixed answers, there's several options, pick one
>>
>>62181340
Java or C#.
>>
>>62181340
All I can say is with my current knowledge if I had to start learning programming today I'd do it in Lisp or Go.
>>
>>62181344
Thanks.
>>
>>62181344
>What's New: Version 2.0b1, 24 March 1997
>24 March 1997
>1997
>>
>>62181390
Yeah, I forgot, for /g/, the devs must be constantly adding more useless shit along with new bugs for the library to be considered alive.
>>
>>62181418
Are you pretending nothing changed in technology and no additional bug has been found since 1997? Most releases in software are bugfixes, not features.
>>
>>62181444
Nothing changed in FastCGI, yes.
>>
>>62181349
>>62181360
>>62181363
Why there so many language??
What makes it different to each other?
>>
>>62181452
>my implementation never crashes/has no more room for optimization
You don't have to shill it that hard senpai
>>
>>62181475
People use it happily.
>>
>>62181456
Just start with C/Lisp. HtDP, K&R, SICP. Dive deep and see where it takes you. Read htdp/kr everyday up until your head starts to hurt, do exercises like a good boy, understand most of it and report back to /dpt/. Don't procrastinate on choosing editor, color scheme or other unrelated shit

Were you good with math, geometry, logic in high school?
>>
>>62181547
This, but skip Lisp, HtDP and SICP.
>>
>>62181456
They are different from each other because programmers are autistic and like to engage in language tribalism. You should just ignore them and read SICP. It is free as in freedom and free as in beer here: https://mitpress.mit.edu/sicp/full-text/book/book.html
It will give you a good background in understanding computer science.
>>
>>62181340
what do you want?

Game coding? C++.
Systems/low-level? C.
Applications? Golang or Java.
Web? javascript. (use node.js)
Just for fun? Whatever interests you, just try stuff.
>>
File: lth2102.jpg (777KB, 1026x1302px) Image search: [Google]
lth2102.jpg
777KB, 1026x1302px
>>62181456
>>62181340
Go with Java. Very fun and easy to learn, gives you all the power you need and is the most widely used language in a professional environment.

Don't waste your time with C. It's super outdated and becoming less & less relevant in professional environments.
>>
>>62181599
what if I want to be happy tho
>>
>>62181611
Then I got 3 words for you:

Ruby on Rails
>>
>>62181599
> Applications? Golang
What? If you mean desktop/mobile applications with GUI, Goland makes no sense.
>>
>>62181611
learn processing
>>
>>62180667
Refer to >>62180316
>>
>>62181547
>>62181566
>>62181599
>>62181604
>>62181656
Okay,i think i will learn java first while read that SICP book (Thanks for the link).
Last question, any suggestion for book or website for learning Java?

Thanks guys for your help.
>>
File: 1503605450887.png (391KB, 638x480px) Image search: [Google]
1503605450887.png
391KB, 638x480px
>>62181611
See pic related
>>
>>62180439
colorscheme sauce?
really comfy
>>
https://github.com/cksystemsteaching/selfie/blob/master/selfie.c
>Selfie is a fully self-referential 7k-line C implementation of:
> a self-compiling compiler called starc that compiles a tiny but powerful subset of C called C Star (C*) to a tiny but powerful subset of MIPS32 called MIPSter,
> a self-executing emulator called mipster that executes MIPSter code including itself when compiled with starc,
> a self-hosting hypervisor called hypster which is based on a tiny microkernel implemented in mipster and provides MIPSter virtual machines that can host all of selfie, that is, starc, mipster, and hypster itself, and
> a tiny C* library called libcstar utilized by selfie.
Oh fuck.
>>
>>62181827
>There is a free book in early draft form called Selfie: Computer Science for Everyone using selfie even more ambitiously reaching out to everyone with an interest in learning about computer science.
https://leanpub.com/selfie/read
>>
>>62181800
:colorscheme says solarized. May be the default one from spf13, not sure I ever changed it.
>>
>>62181827
>subset of C
>only mips32
>>
>>62181725
https://www.codecademy.com/learn/learn-java
https://www.youtube.com/watch?v=Hl-zzrqQoSE&list=PLFE2CE09D83EE3E28
>>
>>62181827
>random prints all over the code

C fags I swear to god
>>
>>62181827

That's neat.
>>
help.
me.
>>
>>62182095
Do you need help?
>>
>>62181983
Thanks.
>>
File: KurtGodel.jpg (194KB, 727x1093px) Image search: [Google]
KurtGodel.jpg
194KB, 727x1093px
>>62181827
>There is also a simple SAT solver implemented in selfie that will eventually become part of a self-verifying theorem prover. This is ongoing work.
> self-verifying theorem prover
Absolute madman.
>>
Is CodeAcademy Pro worth the $199?
>>
I want to learn Java. Can you /g/ents point me in the right direction please?
>>
>>62182390
Why?
>>
>>62182390
>>62181983
never mind just saw this, thank you

>>62182401
I've covered html, css, and some mysql so it feels like the next baby step. Am I wrong?
>>
Thinking of learning Rust. Any advice?
>>
>>62180316
it's harder to masterize javascript than C.
>>
>>62182410
"dont"
>>
>>62182410

Don't do it.
>>
>>62182410
It's a good idea. There are a lot of good features.
>>
>>62182410
if you're decently competent at other proper languages and don't just want a brainless easy multi-purpose does everything for you language then rust is great if you can tolerate it being a little less mature because of its age
>>
File: c.png (344KB, 852x973px) Image search: [Google]
c.png
344KB, 852x973px
Trying to fix my broken dithering implementation.
>>
>>62182561
source?
I like that.
>>
>>62182410
Read the source of the standard library once you're comfortable with the language, it's well-designed and well-documented and utilizes the best practices for the language.
>>
File: ditherfuckcommunism.png (169KB, 744x563px) Image search: [Google]
ditherfuckcommunism.png
169KB, 744x563px
>>62182561

You can do it. I have faith.
>>
>>62182410
>autism driven development
lol
>>
>>62181199
Its OOP system is far superior to any other out there.
Fucking hell, give me one, just ONE decent imperative OOP language with full built-in support for multimethods and a user base of more than like 10 people.
>>
>>62182618
fuck off with your "lol" autism really can drive development
>>
So, I have to write a TCP interface for a device in C++ (don't ask), can anyone tell me what's the best library to do it. I've been checking Asio but the documentation is ass and barely explains anything.
>>
File: rust_safety_features.png (202KB, 594x395px) Image search: [Google]
rust_safety_features.png
202KB, 594x395px
>>62182804
sure thing lil buddy
>>
>>62182881
>the documentation is ass and barely explains anything
How so? You have everything you need there
>>
>>62182804

Oh, hi Terry..


>>62182881

W-which device, anon?
>>
I wrote a merge sort for words in a .txt in C on linux that works but when I make the list it is sorting too big it crashes.

My list of 30k words works but i need to do 150k words.
>>
>>62182618
>Rust
>autism
This doesn't even make sense, Rust is one of the most nomie projects out there.
>>
>>62182949
im not sure if the problem is my code but this is my merge sort
void merge(char arr[][32], int half, int otherhalf){
char temp[half+otherhalf][32];
int index1=0, index2=0;

while (index1+index2 < half+otherhalf) {
if ((index1 < half && strcmp(arr[index1], arr[half+index2])<= 0) ||( index1 < half && index2 >= otherhalf)){
strncpy(temp[index1+index2],arr[index1],sizeof(temp[index1+index2])-1);
index1++;
}
if ((index2 < otherhalf && strcmp(arr[half+index2], arr[index1])<0) || (index2 < otherhalf && index1 >= half)){
strncpy(temp[index1+index2], arr[half+index2],sizeof(temp[index1+index2])-1);
index2++;
}

}
for (int i=0; i < half+otherhalf; i++)
strncpy(arr[i],temp[i],sizeof(arr[i])-1);

}
void mergeSort(char arr[][32], int length){

if(length<2)
return;
int half=length/2;
int otherhalf=length-half;

mergeSort(arr,half);
mergeSort(arr+half,otherhalf);
merge(arr,half,otherhalf);

}
>>
>>62182909
>sure thing lil buddy
fuck off it's true
autistic people are susceptible to a thing called "hyperfocusing" where something fits so smoothly into their idiosyncratic (inb4 "hur hur hur u mean idiotic") thought process that they become consumed with an obsessive compulsion to continue pursuing it at all costs and stop eating drinking sleeping bathing or going outside for anywhere from twelve hours to entire weeks or months just to single-mindedly engage in that singular pursuit
usually this is a very bad thing especially because the autistic person in question is too autistic to stop even if they want to and if they did stop their unfinished work would bother them all day
however it can be a powerful tool when directed toward productive activities
>>62182943
terry is schizophrenic, that's a completely different mental illness
>>
>>62183016
>terry is schizophrenic, that's a completely different mental illness
why not both?
>>
>>62183041
could be, i wouldn't know
>>
>>62182949

Mergesort is a pretty bad idea for this kind of size..
Use some sort of Quicksort (which most databases use).
>>
>>62183059
>Mergesort is a pretty bad idea for this kind of size..
well it's my homework to do a merge sort, i'm thinking ill just break it into chunks or something
>>
>>62183002

Is this bait?
Sweet lord, you don't even work "in place"..

Just think about how much space you use in the first few iterations. And then calculate how much..

Well, forget it. Just use an in place algorithm, will ya?
>>
>>62183108
I-i just copied the pseudocode for a merge sort so I can analyze this algorithm stop being a jerk!
>>
>>62182931
i just find their explanation of how to start making an async client/server too basic.

Is Asio the best alternative, or is there a better way to do it
>>
>past 10 years
>2007+
nothing's changed
>>
Do you people think a common problem causing bugs/lack of features in software engineering is people using systems designed/people designing systems that are under-dimensioned for the scope they're used in?

I'm doing some consultant work and I'm starting to get the feeling all I'll be doing is dealing with issues like this.
>>
>>62183076

You are supposed to do mergesort with 150k words?

Oh well, you can of course do it differently, there are in-place implementation in merge sort, but they are kinda complicated.

What I would do (not beautiful, but should work):
1st iteration: MergeSort only pairs w[0] vs. w[1], w[2] vs. w[3] and so on
2nd iteration: merge quads: w[0..1] vs. w[2..3]
3rd iteration: merge octetts: w[0..4] vs. w[5..8]
..and so on.

I'm not 100% sure it works and of course you have to be carfull with indices and edge cases (you need to take care of the trailing "rest" at the end of each turn, include is in a seperate procedure somehow).

Godspeed..
>>
>>62183108
>Well, forget it. Just use an in place algorithm, will ya?
After googling how to do this with a merge sort I must say you are a nigger
>>
>>62183192
>Functional programming is taking off again
>JS is dying even more as better compile-to languages are releasing
>C is steadily dying
>type systems are becoming more prominent
>finally have multiple replacements for sepples

future looks alright desu, as soon as me get over this PC bike-shedding gimmick it will be good.
>>
>>62183152
You can always wrap syscalls by yourself if you feel it lacks depth
>>
>>62183257
>>finally have multiple replacements for sepples
Rust and what else?
>>
>>62180431
>zen of code optimization
Does this hold up?
I imagine it wouldn't given how different CPUs are now.
>>
>>62183265
Go
>>
>>62183257
Excellent bait.
>>
>>62183265
Nim & D
>>
>>62183265
D, Go (and soon JAI :^))
>>
>>62183279
>>62183285
>>62183291
All of these options are shit.
Except Nim and Jai. Nim I haven't looked at, and Jai could be good if it doesn't turn out to be vaporware.
>>
>>62183280
Would You) like to tell my why before a go to bed lad?
>>
>>62183016
What if there was no non-autist to control them. Y'know what comes out at the end of that anon? Nothing. The autistic person never ends, never finishes, it's just an ever expanding mess that other people sit back and wonder at.
This is why learning Rust is pointless. The language is doomed from the start.
>>
File: gc-final-01.png (9KB, 800x600px) Image search: [Google]
gc-final-01.png
9KB, 800x600px
>>62183279
>>62183285
>>62183291
>>
>>62183265
Rust for low-level, D for high-level
>>
>>62183310
D has a kernel, your argument means nothing.
>>
>>62183333
> Rust for low-level, D for high-level
Wrong.
>>
>>62183333
Rust can't even properly do strings yet.
>>
>>62183333
>wasting quads on a shitpost
Fucking aussies
>>
>>62183299
>All of these options are shit.
>except Jai
Arguably D is very similar in its ideas to JAI (or vice-versa).
I do prefer JAI as a concept so (assuming syntax will be nice, assuming features will be as promised, assuming nothing bad will happen). It does have the advantage of being incomplete, so I'm giving it quite a few favors here.

Something I'd certainly miss from D going to JAI (assuming*) is the contract programming, but that can be implemented quite easily in JAI even if it's not given in the standard library.
>>
>>62183249

Too stupid for Kronrod, brainlet?
>>
>>62183304
Rust is a Turing-complete compiled language with reasonable performance and many features.
You may not like the language itself. That's understandable. I'm not saying I like it either. But it's a language. It's Turing-complete. It has reasonable performance. It has many features. It's compiled.
That is not "nothing." On the contrary it's more than even most non-autistic people will ever accomplish with a computer.
I'd say the same for whoever made JavaScript, and JavaScript is awful.
So your argument is self defeating.
>>
>>62183339
They've written kernels in Common Lisp and Java, it doesn't mean anything. What matters is that the entire D's ecosystem (read libraries) is built around GC.
>B-but you can disable GC in D!
And you can add GC to C++, this doesn't mean anyone would do either of these.
>>
>>62183355
>UTF-8
>Not proper
>>
>>62183388
>this doesn't mean anyone would do either of these
/dpt/oddlers lmao
>>
>>62183243
is there a way to just increase my stack size or is this infeasible?
>>
>>62183484
fixed it, just copied this
https://stackoverflow.com/questions/2275550/change-stack-size-for-a-c-application-in-linux-during-compilation-with-gnu-com
>>
File: palm.jpg (534KB, 1920x1080px) Image search: [Google]
palm.jpg
534KB, 1920x1080px
I fucking hate math but I want my fucking CS degree so I can get a job make money and impress hot korean bitches with my cash fuck college I hate this shit
>>
>>62183539

Does it work now?

Theoretically you should be able to make it work somehow. Maybe debug and see where it crashes, if it doesn't work..
>>
>>62183612
yea worked the first time, just was my stack getting too big.
>>
>>62183574
>tfw no korean gf
>>
>>62183574
>>62183650
>caring about romance and sex at all
>>
Hi, I have just started to learn coding and have a beginner question:

> Why does the programm automatically assume that i is the variable for the amount of loops? Why do I not have to declare it as auch?

package main

import "fmt"

func main() {

// The most basic type, with a single condition.
i := 1
for i <= 3 {
fmt.Println(i)
i = i + 1
}
>>
>>62183701
Because
>Go
>>
>>62183721
I looked at some examples written in C and C++ and it seems to be the same. Am I wrong?
>>
>>62183741
That's a convention in many languages and Go basically included it as a part of its specification. Think of it like a built-in variable that is defined for you since it's used so often (like you've seen in C and C++).
>>
>>62180040
If you're still associating lisp with AI in 2017, you obviously don't know anything about lisp
>>
>>62183701
I don't understand the question. The condition for your loop to continue running is right there.
>>
>>62183701
> Why does the programm automatically assume that i is the variable for the amount of loops?
It doesn't.

> Why do I not have to declare it as auch?
But you did.

What that code is doing is repeat
        fmt.Println(i)
i = i + 1

until
i <= 3
is no longer true. That MAKES i the loop iterator.
>>
>>62183759
ruseman
>>
>>62183701
That program actually isn't assuming anything. All you've done here is moved the increment statement into the body of the loop and the declaration out of the loop. You could also write it like this:
for i := 1; i <= 3; i = i + 1 {
fmt.Println(i)
}

The way you have it written now is really just a while loop with the word 'for' at the beginning instead.
>>
>>62183701
>:=
>no statement terminator
>have to write { on same line as main
>function with capital first letter
it's shit
>>
>>62183809
>:=
This is a good thing though.
>>
>>62183809
>it's shit
Literally no one but you is surprised by this.
>>
>>62183786
>>62183804
Thank you a lot. I guess the part I forgot is that the "for construct" is especially and only for loops.
>>
>>62183822
no i'ts not you dumb fucking retard.
>>
>>62183701
for i <= 3

Check the condition "i<=3", if true do the block, if not skip the block
fmt.Println(i)

print
i = i + 1

add 1 to i
}
because this block was a for loop block when we get here we jump back up to the for statement
for i <= 3

Check the condition "i<=3", if true do the block, if not skip the block
[...]

See how this works? The program doesn't assume the variable is for the amount of loops. It's simply checking the condition repeatedly. Because you've changed the variable this way and continuously check it it will be the number of loops.
>>
>>62183845
it is though
:= is better than =
>>
>>62183822
How is it good? It's a minor syntax sugar that saves you a couple of key presses by making the code harder to read because suddenly not all local variables are explicitly declared.
>>
>>62183866
moron
>>
>>62183868
>It's a minor syntax sugar that saves you a couple of key presses
yes
>by making the code harder to read
wrong
>because suddenly not all local variables are explicitly declared
also wrong
>>
>>62183860
thank you,

see >>62183833
>>
>>62183895
> assignment is equivalent to declaration
You should really stick with Python, m8.
>>
>>62182410
Advice: 1) Its not C, its not Java, and its not C++. 2) Rust makes a few things hidden and implicit to make programming easier. Just because these things are hidden, doesn't mean they aren't there. Make sure you understand Deref and lifetime elision. 3) Being able to use the standard library is important to using Rust. Be prepared to use Result, Option and Iterator often, as these are some of the bread and butter of Rust. Also a few other traits like From, Into, and AsRef appear pretty often.
>>
>>62183920
:= is for declaration, = is for assignment. It's just as explicit. I don't see what your problem is.
>>
>>62183890
it's true though
also:
>struct is better than class
>lambda is better than function
>monad is better than imperative
>variant is better than union
>tuple is better than array
>abuse of struct layout to simulate inheritance is better than actual inheritance
>multimethod is better than method
>>
>>62183920
>> assignment is equivalent to declaration
> := is equivalent to =
you should really stick with python m7
because python is very much an imperative language and evidently that is the only kind of language you're capable of grasping
>>
what for do I need typescript and why it's better than js
>>
When listing your technical skills, would you put down your proficiency in a framework or library?
Like if you could use SDL or OpenGL would you put that as one of your technical skills?
>>
>>62184013
Typescript is steaming garbage but people like it because it helps trash JS programmers write slighty less-shit code
>>
>>62183929
>>62183952
Yet they are so close visually. The key point here is consistency - every variable declaration in C starts with a type, every variable declaration in Scala start with val/var IIRC, every variable declaration in C++ starts with either a type or `auto`. A regular variable declaration in Go looks like `var a int = 10`, but if you want for the compiler to deduce the type you should write `a := 10`, which doesn't look like a typical declaration at all: `var` is gone and `=` is now `:=`. Why don't you write "var" even if you're declaring a variable? Why do you have to write ":=" instead of "="? Why can't you just write "var a = 10" or "var a auto = 10"?

It's like Pike cares more about "cool tricks" than consistency and orthogonality of the language.
>>
>>62184030
I usually put opengl.
If they are looking for low level graphics the windowing library really doesn't matter.
>>
I'm a newbie programmer learning Python. I'm at a point where I want to store data for use later. I've been told that MySQL or some other database is what I need to do. If this is true, could anyone point me to a tutorial about how to do this, or if some other solution is better, point me towards it.
>>
>>62184113
>I've been told that MySQL or some other database is what I need to do.
It is A way suitable for some purposes, certainly. Without knowing what you want to do, I cannot judge whether it is appropriate here. But for most newbie projects, a MySQL database is not the right tool for the job, and will make things far more complicated than they need to be.

tl;dr Explain a bit more about what you need to do in regards to storing data for later.
>>
>>62182550
>don't just want a brainless easy multi-purpose does everything for you language
what if I do? what then?
>>
>>62184113
A database is certainly the most robust way to store data for later use, but depending on what you're trying to do, it can be overkill.

One alternative to look into serialization. Basically many high level languages, Python included I think, have a facility for I/O of arbitrary objects. It can convert any object you want to store into a runtime-independent representation that can be stored in a file and loaded again in a different session. That's called serialization. If you wanted to, you could just store as much of your program state as you need to in a single object, serialize it to a file, and load it up again later.
>>
>>62184209
Go
Ruby
Java
Python
to name a few
>>
>>62182147
Sounds like bunk. Gödel's incompleteness theorems show no system can prove itself.
>>
>>62182550
>don't just want a brainless easy multi-purpose does everything for you language
Why do people here not understand the concept of abstraction?
The easier and more effortless / brainless it is to express one thing in a language, the greater the ratio of things expressible over effort needed to express them.
Assuming the amount of effort a person can exert is at all limited, this of course means that the easier and more brainless it is to express things in a language, the higher the absolute ceiling of what that language is capable of in the right hands.
>>
>>62184283
Correction, Gödel's incompleteness theorems show no CONSISTENT system can prove itself.
>>
>>62184283
>>62184372
I assume he isn't going to prove his axioms, only their "implementation" by the theorem prover, with the theorem prover itself, which is doable but kinda meaningless.
>>
>>62184146
I wrote a program to calculate my grade in my class, I just need to store a few variables and a couple lists and dictionaries. MySQL seemed to be a bit of overkill. My brother works as a programmer dealing with large datasets, so it's probably the tool he's most familiar with and uses the most.

What sort of tutorial should I look for?

>>62184236

Serialization tutorials are what I need to look for? I asked my programming class teacher for some resources as well, but he hasn't gotten back to me yet.
>>
who the fuck cares about girdles incompleteness theorem if you wear one at all then you're fat so your opinion is automatically invalid
>>
>>62182789
#include <typeinfo>
#include <unordered_map>

typedef unsigned uint4;
typedef unsigned long long uint8;

class Thing {
protected:
Thing(const uint4 cid) : tid(cid) {}
const uint4 tid; // type id

typedef void (Thing::*CollisionHandler)(Thing& other);
typedef std::unordered_map<uint8, CollisionHandler> CollisionHandlerMap;

static void addHandler(const uint4 id1, const uint4 id2, const CollisionHandler handler) {
collisionCases.insert(CollisionHandlerMap::value_type(key(id1, id2), handler));
}
static uint8 key(const uint4 id1, const uint4 id2) {
return uint8(id1) << 32 | id2;
}

static CollisionHandlerMap collisionCases;

public:
void collideWith(Thing& other) {
CollisionHandlerMap::const_iterator handler = collisionCases.find(key(tid, other.tid));
if (handler != collisionCases.end()) {
(this->*handler->second)(other); // pointer-to-method call
} else {
// default collision handling
}
}
};

class Asteroid: public Thing {
void asteroid_collision(Thing& other) { /*handle Asteroid-Asteroid collision*/ }
void spaceship_collision(Thing& other) { /*handle Asteroid-Spaceship collision*/}

public:
Asteroid(): Thing(cid) {}
static void initCases();
static const uint4 cid;
};

class Spaceship: public Thing {
void asteroid_collision(Thing& other) { /*handle Spaceship-Asteroid collision*/}
void spaceship_collision(Thing& other) { /*handle Spaceship-Spaceship collision*/}

public:
Spaceship(): Thing(cid) {}
static void initCases();
static const uint4 cid; // class id
};
>>
>>62184431
>I wrote a program to calculate my grade in my class, I just need to store a few variables and a couple lists and dictionaries.
Then an SQL database is not necessarily a bad choice. Have a look at sqlite, it does the simple parts of SQL that you need and is much less of a hassle to set up.

SQL is a sort-of standardized language for interacting with databases; sqlcourse.com has a decent quick-and-dirty introduction. Mysql and sqlite both use it, as do many other databases. You'll need to look up how to talk to (say) sqlite in python; for that, see https://docs.python.org/3/library/sqlite3.html .

>Serialization tutorials are what I need to look for?
That's the other obvious approach, yes. For this, the approach goes something like this:
- build a python Dictionary containing everything you want to store, such as
{ 'name': 'anon', 'grade': 9 }
;
- use JSON (a popular serialization format, but by no means the only one) to store this object as a string, yielding something like
"{ name: \"anon\", grade: 9 }"

- store the JSON encoded stuff in a file.

The serialization approach is generally less of a hassle and easier to work with than an SQL database. The SQL database is more flexible, but it's unlikely that will be a problem anytime soon.

You DO need an SQL database of some form (or at least, something more elaborate than just a serialization file) if you need to access your stored data from multiple programs running at the same time. But I'm guessing that complication is not going to play a role anytime soon.
>>
>>62184590
Thing::CollisionHandlerMap Thing::collisionCases;
const uint4 Asteroid::cid = typeid(Asteroid).hash_code();
const uint4 Spaceship::cid = typeid(Spaceship).hash_code();

void Asteroid::initCases() {
addHandler(cid, cid, (CollisionHandler) &Asteroid::asteroid_collision);
addHandler(cid, Spaceship::cid, (CollisionHandler) &Asteroid::spaceship_collision);
}

void Spaceship::initCases() {
addHandler(cid, Asteroid::cid, (CollisionHandler) &Spaceship::asteroid_collision);
addHandler(cid, cid, (CollisionHandler) &Spaceship::spaceship_collision);
}

int main() {
Asteroid::initCases();
Spaceship::initCases();

Asteroid a1, a2;
Spaceship s1, s2;

a1.collideWith(a2);
a1.collideWith(s1);

s1.collideWith(s2);
s1.collideWith(a1);
}
>>
>>62182789
What's so great about multimethods?
>>
>>62184372
What good is an inconsistent theorem prover? I have a quarter in my pocket which can prove any system, but it only works half of the time and you never know which half you're getting.
>>
>>62184654
How much for your quarter?
>>
As I understand it, the best way to become actually good at programming is to learn algorithms and data structures.

CLRS is often recommended as a go-to book for both of those, but isn't it more like a reference rather than an introductory course?
What about SICP?
>>
File: xilinx.gif (74KB, 624x508px) Image search: [Google]
xilinx.gif
74KB, 624x508px
Is xilinix ISE shit for simulation or is it just me? Feels overaly tedious.
>>
>>62184686
> What about SICP?
SICP is a stale meme.
>>
Newbie java programmer here.

Lets assume that I want to take in user input that is going to involve a symbol and I was to store it as an int or double.

Ex:

>Please enter the percent of your bill owned:

12.50%

How would I convert that into a double if it has the symbol. My guess is that I have to do some sort of string char and convert it into double. I'm not sure though.
>>
>>62181604
>class based implementations of problems too trivial to ever need classes
OOP was a mistake
>>
>>62184721
https://stackoverflow.com/questions/34879500/java-100-to-number
>>
>>62184752
thanks anon. i just hope my professor doesn't think I'm cheating since I use this.
>>
File: c2.png (409KB, 852x973px) Image search: [Google]
c2.png
409KB, 852x973px
>>62182572
It's just basic dithering, super easy. I used JS for the canvas API, but I'll probably port it over to a [b][i]EXPERT[/i][/b] programming language afterwards.

>>62182605
I fixed it after taking a break. Should have ignored the alpha channel when diffusing the error down.
>>
>>62184590
>>62184600
this isn't even multimethods
instead it's a prime example of why multimethods are useful

>>62184607
see: >>62184590 >>62184600
but also i ask you: what's so great about single dispatch
single dispatch is just a degenerate case of multiple dispatch anyway, and it's actually the whole reason OOP works the way it usually does
there's really no reason methods should belong to the class of their receiver, because there's no reason methods should only have one receiver
that's all a conceptual mistake created by ignorance of the possibility of multiple dispatch
>>
When do I use the heap, if the stack is fifo why use the heap which requires manual mangment thanks and sorry for noob question
>>
>>62184596
Thanks anon!
>>
>>62184834
Use the heap when you need to create a resource which outlives the scope it's created in.
>>
>>62184710
What should I read to learn about data structures and algorithms then?
>>
What is better and why?

package main

import "fmt"

func main() {

// Here's a basic `else`.
i := 2
if i == 1 {
fmt.Print("Write ", i, " as one. ")
} else if i == 2 {
fmt.Print("Write ", i, " as zwei. ")
} else if i == 3 {
fmt.Print("Write ", i, " as drei. ")
}


// Here's a basic `switch`.
i = 3
fmt.Print("Write ", i, " as ")
switch i {
case 1:
fmt.Println("one.")
case 2:
fmt.Println("two.")
case 3:
fmt.Println("three.")
}

}
>>
>>62184962
switch is better if you need to select between a large number of cases with simple flat logic, especially if it's an enumeration.
if is better in all other cases.
>>
>>62184933
Introduction to Algorithms
>>
>>62184994
thx anon.
>>
>Scripting language
give me more info on this topic.
>>
>>62180040

Haven't programmed anything for more than a year. I used to know c,php,java. Which one would be the faster to brush up on and remember faster? Or should I learn a new one? I've been thinking of trying python desu. Anyway, I just want to program since comfy winter time is coming and I've got nothing better to do during weekday afternoons. Suggestions?
>>
>>62185125
scripting language is a misnomer. any programming language can also be used for scripting. someone calling a language a scripting vs programming language says more about how they view it than about the inherent features of the language
>>
>>62184962
Why are you not breaking cases in swithc?
>>
>>62185154
I just assumed Go removed fallthrough.
>>
>>62184962
Definitely the switch in this case.

DESU, more than anything else, it simply makes it easier to read.

Since you are using Golang, you also get the added benefit of in-switch ops. You can perform logical comparisons in each case. In such a case, just use an empty switch condition, though. Complicates the syntax otherwise.

Is it more efficient? Eh, probably not. Easier to maintain? Hell yes. Nicer to look at? Unless you're fucking retarded, yes.

package main

import (
"fmt"
)

func main() {
for j := 0; j < 10; j++ {
switch {
case (j < 3):
fmt.Printf("j is less than 3: %d\n", j)
case j < 9:
fmt.Printf("j is still less than the max: %d\n", j)
case j == 9:
fmt.Printf("j is max!!: %d\n", j)
default:
fmt.Printf("Too much or you fucked up: %d\n", j)
}
}
}


Also, if anyone is interested, we have a new /g/ Discord Server.
Feel free to join, if you like.
We also make use of Bots to handle self-assignable roles and cover more than just programming, but all technology-related stuff.
https://discord.gg/7nwb4J
>>
Learning Scala.
It feels like Haskell for brainlets, so it's the ideal language for me.
>>
>>62185154
Maybe I will learn this in the next chapter :)
>>
>>62185154
>>62185162
Golang ASSUMES break, but there is a way to fallthrough. It requires a separate statement.

"fallthrough" is a keyword

Here's a site:
https://github.com/golang/go/wiki/Switch

You can also do multiple comparisons, like and or or an and in each case, so it kinda eliminates the need in many cases
>>
>>62184793
Methods belonging to a single type is the desired case most of the time, and it makes it easier to grok the control flow of a program (and possibly optimize as well). I think languages like Haskell do it best, where "methods" are parameterized/instantiated by a single type, but this type doesn't have to appear as just a singler reciever.
E.g.
-- concat takes a list of things and turns them into a single thing
class Monoid a where
concat :: [a] -> a

instance Monoid [a] where
concat = foldr append []

instance Monoid Integer where
concat = sum

concat [1,2,3] = 6
concat [[1,2], [3,4]] = [1,2,3,4]


I see multimethods as slightly problematic as when you invoke them, you can't really predict what code will actually be called. I suppose this may be more of a problem with dynamic typing and becomes worse with badly specific pre/post-conditions.

Also, I've been using Scheme effectively with very little dynamic dispatch, so maybe I just have a low opinion of it.
>>
>>62185263
This... This was hard to read...
Lemme correct the last part:

>You can also do multiple comparisons, like and or or an and in each case, so it kinda eliminates the need in many cases
You can also do multiple comparisons, like an 'and' or an 'or' in each 'case', so it kinda eliminates the need in many /situations/

>>62185191
Also noticed I only put parentheses in the first switch... That was a fuck-up on my editing. Sorry
>>
File: 1502232323421.gif (2MB, 450x197px) Image search: [Google]
1502232323421.gif
2MB, 450x197px
I just bought K&R, Deep C Secrets, and the C Reference Manual, /dpt/. I'm as giddy as fucking school girl.
>>
File: CrossCoding03.png (1MB, 1127x1600px) Image search: [Google]
CrossCoding03.png
1MB, 1127x1600px
>>62185402
Cool, now just make sure you get a school-girl outfit and some colourful socks, and you're ready to go!
>>
Rust 1.20 is here: https://blog.rust-lang.org/2017/08/31/Rust-1.20.html , associated constants have been stabilized:
trait Trait {
const ID: u32;
}

struct StructA;
struct StructB;

impl Trait for StructA {
const ID: u32 = 5;
}

impl Trait for StructB {
const ID: u32 = 10;
}

fn foo<T: Trait>() {
println!("{}", T::ID);
}

fn main() {
foo::<StructA>();
foo::<StructB>();
}
>>
>>62185513
No one fucking cares
>>
>>62185513
Huh. I thought associated constants where only allowed inside traits, like associated types.
>>
>>62184933
Datastructures and Algorithms in [whichever language you prefer] by Goodrich
>>
>>62185513

>>>/lgbt/
>>
Is the stack or heap better for big data with the heap you have more control..
>>
>>62185646
You might overflow the stack if the data is unbounded so in that case you probably want to go with the heap
>>
>>62185646
The stack is generally not suitable for storing large amounts of data, and it doesn't survive outside the scope in which it was created.
>>
>>62185513
>version is over 1.0
>have something stabilized after 1.0
>>
>>62185646
The stack is suited for temporary data with a known bounded size that's not more than a couple megabytes.
The heap is suited for just about anything else.
>>
>>62185724
>>62185658
scoping should be the only factor in choosing between stack and heap
>>
>>62185771
>scoping should be the only factor in choosing between stack and heap
Should maybe, but that's not the world we live in.
>>
What's the minimum spec I should look for in laptop to ensure Android Studio doesn't stutter every 3 seconds or turn it into housefire?
>>
>>62185894
One with 16GB of RAM.
>>
>>62185917
>tfw that rules out most of used ThinkPads

I guess I gotta buy something new.
>>
File: 1408144979819.gif (2MB, 256x192px) Image search: [Google]
1408144979819.gif
2MB, 256x192px
>>62185894
These are the times we're living in
>>
>>62185942
Or buy additinal RAM sticks.
Personally, I use the Dell 9650 for Android development.
>>
>>62185894
when I was doing android development, android studio ran like absolute garbage on my high end desktop
so unless there has been significant improvements, I wouldn't even bother trying to use it on a laptop
>>
>>62185976
ThinkPad T440 can only accept up to 8GB, T450 goes up to 16GB.

The price T450 goes for on eBay, you might as well get a new laptop.
>>
How do I initialize and pass a 2d array to a function in C? Do I need malloc?
>>
>>62186070
You don't need malloc. Just start up the array, pass the pointer and give the two dimensions as params.
>>
>>62186100
>Just start up the array and get memory trash
>>
When I use <text.txt for input in C how do I make program ignore letters and words in file and only to read numbers?
I googled but couldn't find answer anywhere
>>
>>62186135
use atoi
>>
I'm a babby to C for my engineering major and I need to write a program that lists down several variables in ascending and descending order. Each of my variables must be within a specific range from 1 to 150, so I made an if statement in my array where
if(a[i] <=0 || a[i] > 150)
{
printf("Please enter a valid number between 1 and 150.\n");
scanf("%d", &a[i]);
}

How do I get it to repeat until a proper value is entered in event someone enters an invalid value yet agan in the above situation?
>>
>>62185978
What do I do then?

Manual Gradle config, use vim to edit source files, and compile from the console?
>>
error: variable-sized object may not be initialized
char resultantArray[y][X] = {0};
^
warning: excess elements in array initializer
warning: (near initialization for ‘resultantArray’)

What is happening here?
>>
>>62186338
>variable-sized object
so y and x are not constant, this is a vla.

In the case that y and x are 0, then you have excess elements there.
>>
>>62186059
Don't skimp on laptops if you plan to make money with them.
>>
>>62186425
>if you plan to make money with them.

I'm going to write a filthy OSS Android app.
>>
>>62186398
X is a constant (#define), y is a variable that is known beforehand. Is there any way to get a 2d array with the 2d array syntax under these conditions?
>>
>>62186464
>y is a variable that is known beforehand
Is it a local variable?
You can create it like that but I'm not sure you can initialize it the standard way.
>>
Redpill me on Typescript
>>
>>62186507
It's just Javascript ES6 with type checking.

You can use Babel+Flow if you prefer Facebook botnet to Microsoft botnet.
>>
>>62186496
Yes, it's local. It should be constant propagated in this example.
What I want to do is extract all the 3 character long substrings (e.g. "asdasd" -> "asd", "sda", "das", "asd")
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#define NGRAM_SIZE 3

void getNgramsFromToken(const char *token, int ngramsToGenerate, char *resultantArray[][NGRAM_SIZE]) {
for (int i = 0; i <= ngramsToGenerate; i++) {
strncpy(*resultantArray[i], token, NGRAM_SIZE);
}
return;
}

int main() {
char token[] = "asdasd";
int ngramsToGenerate = strlen(token) - NGRAM_SIZE;
char resultantArray[ngramsToGenerate][NGRAM_SIZE] = {0};
// memset(resultantArray, 0, ngramsToGenerate*NGRAM_SIZE*sizeof(char));
getNgramsFromToken(token, ngramsToGenerate, *resultantArray);
for (int i = 0; i < ngramsToGenerate; i++) {
printf("%.*s", NGRAM_SIZE, resultantArray[i]);
}
return 0;
}

This returns numerous compile errors. Could anyone help me?
>>
>>62186262
while loop, only increment counter on success.
>>
>>62186578
You can't do = {0} with a VLA.
>>
>>62185457
>PLEASE LET ME SNIFF YOUR ASSHOLE WHILE PAIRED PROGRAM-MING!!
who, is, meme,
the mas, ter of, the meme,
the mas, ter of, the meme,
the mas, ter of, the meme,
>>
>>62186599
Okay. So how do I solve the other error? I'm guessing I'm passing a pointer when I should be passing a value or the opposite:
search.c: In function ‘main’:
search.c:19:46: warning: passing argument 3 of ‘getNgramsFromToken’ from incompatible pointer type
getNgramsFromToken(token, ngramsToGenerate, *resultantArray);
^
search.c:7:6: note: expected ‘char * (*)[3]’ but argument is of type ‘char *’
void getNgramsFromToken(const char *token, int ngramsToGenerate, char *resultantArray[][NGRAM_SIZE]) {
^
>>
>>62186658
#include <string.h>
#include <stdio.h>
#include <stdlib.h>

#define NGRAM_SIZE 3

void getNgramsFromToken(const char *token, int ngramsToGenerate, char (*resultantArray)[NGRAM_SIZE]) {
for (int i = 0; i <= ngramsToGenerate; i++) {
strncpy(resultantArray[i], token, NGRAM_SIZE);
}
return;
}

int main() {
char token[] = "asdasd";
int ngramsToGenerate = strlen(token) - NGRAM_SIZE;
char resultantArray[ngramsToGenerate][NGRAM_SIZE];
memset(resultantArray, 0, ngramsToGenerate*NGRAM_SIZE*sizeof(char));
getNgramsFromToken(token, ngramsToGenerate, resultantArray);
for (int i = 0; i < ngramsToGenerate; i++) {
printf("%.*s", NGRAM_SIZE, resultantArray[i]);
}
return 0;
}

don't really know what you're trying to do, but I think this is it
>>
>>62185147
i suggest starting a project in c or java
i was in your position a couple of weeks ago and am polishing up some old projects
>>
what was that website that had all little programming projects to do on it ? and no I am not talking about shitty roll thread, although the actual website wasn't all that different.
>>
>>62186271
>Manual Gradle config, use vim to edit source files, and compile from the console?
literally nothing wrong with this
>>
>>62186738
Yes, more or less, thank you.
>>
>>62186926
do you mean this?
https://better-dpt-roll.github.io
>>
>>62183266
I would think not, given that this predates AVX and multithreading, one of the most important areas now, wasn't a big deal.
>>
@(function main () ()
(print_num (fibs_iter 10)))


@(function fibs (n) ()
(if (< n 2)
n
(+ (fibs (- n 1)) (fibs (- n 2)))))

@(function and (arg1 arg2) () (if arg1 (if arg2 1 0) 0))

@(function fibs_iter (n) (i a b tmp)
(= i 0)
(= a 0)
(= b 1)
(while (< i n)
(begin
(print_num a)
(= tmp a)
(= a b)
(= b (+ b tmp))
(= i (+ 1 i))))
a)

i can compile this to assembly
i am too lazy to fix my pointers though, so far only ints, cuz pointers get buggy

i could just go all heap, but who gives a shit
it has recursion(without TCO) and it has loops and it can print numbers

literally go functional bro, keke
>>
>>62185713
>Have no idea how SemVer works
>>
have not done C for decades and even when I did I only dabbled in it
I was looking at https://github.com/haikarainen/light/search?utf8=%E2%9C%93&q=light_free&type= today and I didn't understand what's going on with the light_free method, he says it frees up memory, but how does it do that all by itself by just calling an empty method?

void light_free()
{

}


I don't get it.
>>
>>62187223
he simply uses a common pattern for his modules which is

modulename_initialize()
modulename_free() // (should have been finalize)

in this case, the module has nothing to finalize but it may have in the future.
>>
>>62187223
>I don't get it.
he fucked up
>>
can c average two integers
>>
>>62187367
In other words, the code is half-baked?
>>62187378
I'm glad I'm not a shit programmer and noticed this. Just need to learn more C and git gud at memory manipulation.
>>
>>62187400
>and noticed this.
im sorry but you literally noticed the function is empty
you even wondered if this empty function actually does anything

you are most likely shit
>>
>>62187378
>>62187400
he didn't fucked up, his modular programming is good.
>>
>>62187420
okay but you are most likely a broken person
>>
>>62187427
yes it's good programming practices, 100% commendable
but the function still does not free memory nor does it do anything
>>
So, I am trying to solve K&R exericises, and I am having more problems understanding what I am supposed to do, than anything else. I guess that confirms that I am a brainlet.
>>
>>62187480
>and I am having more problems understanding what I am supposed to do
it literally says it there

just post an example, if you have an ebook just post a cap of an exercise
>>
>>62187449
because nothing need to be free _for now_. it's future proof.
>>
File: 1503268769266.jpg (9KB, 201x201px) Image search: [Google]
1503268769266.jpg
9KB, 201x201px
Brainlet here. I'm trying threading in Python, but it seems impossible to kill or stop a thread. Why is it so?
>>
Hello. What is this thread for?
>>
>>62187797
Conversations.
>>
>>62187827
I see. So it isn't anything specific, just programming related conversation?
>>
>>62187856
how is 'daily programming thread' difficult to understand?
>>
>>62187797
We usually talk about the Pepe here. We all love frogs :3
>>
>>62187797
95% shitposting, 4.9% people arguing over pointless shit, 0.1% people actually working on shit.
>>
>>62187750
Python doesn't have proper threading, everything is on a single thread.
Besides, you shouldn't be stopping or killing threads from other threads; try something else instead
>>
>>62187878
I assumed it was focused on the learning of programming, not discussions in general like the "daily japanese thread"
>>
File: 1483889196817.jpg (48KB, 600x600px) Image search: [Google]
1483889196817.jpg
48KB, 600x600px
>>62187750
Have you tried returning from the target function?
>>
If I'm finding it easy to learn C will I do ok with Java or it's impossible to say?
>>
>>62187941
Hard to say but C's harder so probably.
>>
>>62187919
How do I then cancel download from GUI (tkinter). I'm putting a download function on other thread, so if I want to cancel it I have to stop it. I specifically need to interrupt a download object.

>>62187928
I don't see how that would help. But then again, I'm brainlet.
>>
>>62187919
You're thinking about CPython.
It's possible to have proper threading in Python with the multiprocessing module.
>>
>>62188004
>It's possible to have proper threading in Python with the multiprocessing module.
it's super clunky, slow and awkward
'proper' is not correct at all
you get miniscule improvements that aren't worth it

python is awesome it's just not fast, in any way
it's still very comfy
>>
How do I find the sum of two numbers in Java.

Similar to the previous exercise, except that the program should ask for both the lower and upper bound. You can assume that the users first gives the smaller number and then the greater number.

Example outputs:

First: 3
Last: 5
The sum 12 (3+4+5)

First: 2
Last: 8
The sum is 35(2+3+4+5+6+7+8)

import java.util.Scanner;


public class TheSumBetweenTwoNumbers {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.println("First: ");
int number = Integer.parseInt(reader.nextLine());
System.out.println("Second: ");
int number2 = Integer.parseInt(reader.nextLine());
int i = 1;
int sum = 0;

while (i <= number && i >= number2) {
sum = sum + i;
i++;

}

System.out.println("Sum is: " + sum);




}
}
>>
>>62187975
It's complicated to suggest anything without knowing exactly how you're doing that.
>>
File: 1496948011567.png (611KB, 780x720px) Image search: [Google]
1496948011567.png
611KB, 780x720px
>>62188078
>How do I find the sum of two numbers in Java.
Here how real men do it
int main()
{
double a,b;
scanf("%lf %lf", &a,&b);
printf("%f", a + b);

return 0;
}
>>
>>62188078
>How do I find the sum of two numbers in Java.
write a java function that does that

literally wtf, try until you get it right otherwise you wont learn
>>
>>62187975
when you wish to cancel the download, set a bCancelDownload variable to true
have the downloading thread check the value of this variable every once in a while and return if it's ever true
>>
>>62188151
I've been trying for two days, my online tutorial hasn't started functions, i need to do it in a while loop.
>>
>>62188078
https://en.wikipedia.org/wiki/Summation
>>
File: FortranCodingForm.png (54KB, 1573x997px) Image search: [Google]
FortranCodingForm.png
54KB, 1573x997px
/g/, pls gib some encouragement to continue learning programming in Fortran.
Here's my code so far (from an example). A shitty program for reading & printing the seat reservations at a cinema.

! Seat booking arrangements in a theatre or cinema
!
PROGRAM cinema_booking
IMPLICIT NONE

! Number of seat rows, columns and floors
INTEGER, PARAMETER :: n_rows = 5
INTEGER, PARAMETER :: n_cols = 10
INTEGER, PARAMETER :: n_floors = 3

INTEGER :: row, column, floor
CHARACTER *1, DIMENSION (1:n_rows, 1:n_cols, 1:n_floors) :: &
seats = ' '

DO floor = 1, n_floors
DO row = 1, n_rows
READ *, (seats(row, column, floor), column = 1, n_cols)
END DO
END DO

PRINT *, 'Seat plan is:'
DO floor = 1, n_floors
PRINT *, 'Floor: ', floor

DO row =1, n_rows
PRINT *, (seats(row, column, floor), column = 1, n_cols)
END DO

END DO

END PROGRAM cinema_booking
>>
>>62188078
change two things and you've got it:
first set i equal to the lower number
then, while i is less than or equal to the higher number, do what you've already got
>>
>>62188170
just do
while (number <= number2)
sum=sum + number
number++
i++
>>
why do people who laugh at sovereign citizens not understand they're actually right? all government is a social contract and people have the right to refuse its terms.
also why do sovereign citizens not realize what that actually means? if you refuse the terms of the contract that is citizenship, you are not a sovereign citizen, you are a sovereign in your own one-person country, and also an illegal immigrant. law is a contract and you can refuse its terms but if you do so then you have to realize the government that offers the contract doesn't continue to be bound by their side of it. that's how contracts work, if either party breaks it then it's broken. if you declare yourself free of the law then the law is also free of its requirement to protect your rights, and is within its rights to fucking kill or detain you at any time without explanation, and justify it as war against an invading enemy nation with a population of one.
>>
>>62188162
I'm gonna try this.

>>62188092
I basically have a button that instantiates a new thread when clicked, and that thread downloads things. I need a callback function that will stop the downloading.

    def download(self):
# This is a callback function on download button
self.progress_bar.start()
self.queue = Queue()
DownloadThread(self.queue).start()
self.master.after(50, self.proces)

def cancel_callback(self):
# Cancel download
pass

def process(self):
try:
msg = self.queue.get(0)
self.progress_bar.stop()
except queue.Empty:
self.master.after(50, self.process)

class DownloadThread(threading.Thread):
def run(self):
try:
downloader = Downloader(self.destination_var.get())

downloader.download_files()
except Exception as e:
print(e)
self.queue.put('Downloading finished')
>>
>>62188228
It works, thank you.
>>
>>62188199
god damn, fortran was first programming language I've ever used. I remember how happy I was when I written a frist program that adds two numbers. But it has an ugly syntax, and the syntax was even uglier ten years ago. Why do you study fortran?
>>
>>62188228
Can you or someone else explain what does i++ do in this context. I understand ++ adds one each loop, but what does "i" do?
>>
>>62188407
it does nothing useful
you dont need i at all if you just increment number

my bad
>>
>>62188419
No problem, thanks for explaining, I've been ripping my hair out all yesterday and today because of this problem. I'm so stupid. But thank you again for your help.
>>
>>62188442
no worries, most people can learn most things
i remember i struggled with a similar problem when i started
you just need to get used to it, like with most things
>>
>>62180040
Icon mentioned :DD

Here's my kode from today's roll thread. Guess what it does.
procedure convert(n, r)
res := 0
reverse(n) ? while res +:= r ^ (&pos - 1) * move(1)
return res
end
>>
>>62188521
idk what move(1) does
>>
>>62184708
You really shouldn't be using ISE anymore, it's EOL. Switch to Vivado if you don't have $10,000 laying about for a Mentor Graphics license. It's much more intuitive IMO. And no, Vivado is not up-to-date with the VHDL or Verilog standards. There isn't enough money or interest in the field to further development. Not to mention the field's hate of open source. Most of the involved companies are very old and they aren't changing.
>>
>>62188549
It moves the current position in the scanned string to the right (inctements &pos).
>>
>>62188567
just use multisim in a vm
>>
>>62188633
Depends on what he's simulating. Multisim can't run Verilog or VHDL. If what he's trying to make is any more involved than an adder, he'll probably want an HDL.
>>
New thread:

>>62188731
>>62188731
>>62188731
>>
>>62182410
Prepare to have your perfectly fine code rejected by the compiler.
>>
>>62183257
>>finally have multiple replacements for sepples
Yet sepples is still better than all of them.
>>
>>62184793
it's fucking dumb, why would you ever want to use it

>>62183822
>>62183866
>>62183932
kill yourself fag
>>
Here's some longer kode:

procedure main(args)
file := open(!args)
seek(file, -355)

s := ""
while s ||:= reads(file)
tag(s[-128:0])
extended(s)

end

procedure tag(s)
if s[1:4] ~== "TAG" then fail
s ? every {
write(move(3))
write("Title: ", move(30))
write("Artist: ", move(30))
write("Album: ", move(30))
write("Year: ", move(4))
comment(move(30))
write("Genre: ", get_genre(any(&cset, move(1))))
}
end

procedure comment(s)
track := any(&cset, s[-2])
write("Comment: ", if track = 0 then s[1:-2] else s)
track = 0 & write("Track: ", any(&cset, s[-1]) ~= 0)
end

procedure extended(s)
if s[1:5] ~== "TAG+" then fail

s ? every {
write(move(4))
write("Title: ", move(60))
write("Artist: ", move(60))
write("Album: ", move(60))
write("Speed: ", ["unset", "slow", "medium", "fast", "hardcore"][any(&cset, move(1)) - 1])
write("Genre: ", move(60))
write("Start time: ", move(6))
write("End time: ", move(6))
}
end

procedure get_genre(i)
A := ["Blues", "Classic Rock"] #a big array of strings storing hardcoded genre names
while true do {
s := A[i - 1]
suspend if \s then s else "Unknown"
}

This one reads ID3 tags but only v. 1, as you can see.
The array in get_genre procedure didn't fit in the post so I had to delete it. Full list can be found here: http://www.multimediasoft.com/amp3dj/help/index.html?amp3dj_00003e.htm
Thread posts: 315
Thread images: 23


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.