What are you working on, Sup Forums?
Old thread:
/dpt/ - Daily Programming Thread
Other urls found in this thread:
learnyousomeerlang.com
chimera.labs.oreilly.com
elixir-lang.org
fsharp.org
en.wikibooks.org
0x0.st
gigamonkeys.com
cs.cmu.edu
braveclojure.com
ccs.neu.edu
realworldocaml.org
ocaml.org
guide.elm-lang.org
purescript.org
en.m.wikipedia.org
strawpoll.me
strawpoll.me
twitter.com
First for D
Second for D is garbage.
How do import statements work vs. #includes?
oop = poop
...
U S E E M A C S
A L L O F Y O U
I do
50%
17327/137771
Proud of you user
#include is just textual insertion of some file by the pre-processor
languages that use "import" usually have some kind of module system, or they work more like a namespace or new context for external functions.
What techniques/etiquette do commercial grade coders use that amateurs may not be aware of? Like for instance, using recursion wherever possible for its low cpu requirements? Or maybe mandating the use of only one/two types of sorting algorithms for optimization?
Does Sup Forums have any examples of such code?
1/3?
3/4 chance.
So I want to make small apps for Android that let me automate some common tasks, but I don't want to use Android Studio.
Apart from a text editor (nano), the Android SDK and adb, what do I need? I don't give a shit about cross device compatibility so an emulator is superfluous.
.
They shit in the street on the way to work to maximize the time they can spend coding.
>Like for instance, using recursion wherever possible for its low cpu requirements?
I think it's the exact opposite. If you're programming in a resource constrained environment you want to almost always avoid recursion, hell, you never even want to be more than a handful of function calls deep at any point in time.
t. embedded systems programmer
+1
Let G1 be: "the first ball you take is a gold one".
Let G2 be: "the second ball you take is a gold one".
The probability we're looking for is P(G2|G1), the probabilty of G2 under the condition of G1, expressed as this:
P(G2|G1) = P(G1 ∩ G2) / P(G1)
There are 4 gold balls over 9, so P(G1) = 4/9.
Now, let's find out P(G1 ∩ G2). It is the probability of taking a gold ball first, then another gold ball secondly, which means picking a box with at least two gold balls. There is 1 box over 3 which contains the two gold balls, hence P(G1 ∩ G2) = 1/3.
Thus, P(G2|G1) = (1/3) / (4/9) = 9/12 = 3/4.
Got it. Presumably would make sudden-exiting the program also more complicated.
Bust some more myths bruv.
Yeah but you have already taken the gold ball to begin with. The question wasn't 'what is the probability you pick a gold ball and then another one'. The question was 'what is the probability you will pick a gold ball after you have already picked a gold ball'
You could program with recursion smartly and still be embedded systems-friendly. All it takes is programming such that calls are tail-recursive and that the compiler is smart enough to make tail-call optimizations. But even then, the resulting code would still be iterative.
Well, I can't think of anything off the top of my head, but if you post more incorrect stuff I'll correct you ;)
Nah mate, P(G1) is irrelevant since we have already taken out o gold ball
>The question was 'what is the probability you will pick a gold ball after you have already picked a gold ball'
That's what P(G2|G1) means. As a conditional probability, you have to consider both the probability of picking a gold ball as first pick, and the probability of picking two gold balls consecutively.
The probability of the first pick being gold is irrelevant because it is stated to be gold.
Do you know nothing about conditional probability? When you have a statement "Probability of A given B", you are stating, "the probability of A happening given that we already know B is happening." This probability is given by Bayes' Theorem, which is P(A|B) = P(B|A) * P(A) / P(B).
If it is irrelevant for you, then you're placing yourself in a completely different experiment where there are only two boxes: one with two gold balls and the other one with two silver balls. I bet you think the answer to the question is 1/2. You may be right, too, because the wording of the question is ambiguous. Still, I'm not wrong.
Oh u!
I'm drawing a blank here. Could you point me at some code that you think would cut it in commercial environment? Perhaps a serious open source project on github?
Also, this is a vast subject but, C/C++ still relevant? Or take a hit and just load a Java environment?
Are there any good resources for learning Racket?
there was pasta from /fpt/ but it seems to be lost with /fpt/ threads
If only there was some sort of archiving site for Sup Forums threads. Someone should work on that
Fuck, I'm retarded. Here's the op in case anyone else is interested
Previous /fpt/: Daily programming thread: >Erlang
learnyousomeerlang.com
>Elixir
chimera.labs.oreilly.com
elixir-lang.org
>F#
fsharp.org
>Haskell
en.wikibooks.org
0x0.st
>Common Lisp
gigamonkeys.com
cs.cmu.edu
Common Lisp Recipes
Land of Lisp
An Introduction to Functional Programming Through Lambda Calculus
>Clojure
braveclojure.com
The joy of Clojure
>Scheme
SICP
Essentials of Programming Languages
How to Design Programs:
ccs.neu.edu
Art of the Propagator
Little Schemer
The Seasoned Schemer
The Scheme Programming Language by Kent Dybvig
Realm of Racket
Lisp in Small Pieces
>OCaml
realworldocaml.org
ocaml.org
>Scala
Functional Programming in Scala (Chiusano and Bjarnason)
Atomic Scala (Eckel and Marsh)
Programming Scala (Wampler and Payne)
Programming in Scala (Odersky, Spoon and Venners)
>Elm
guide.elm-lang.org
>PureScript
purescript.org
EVERYONE'S WRONG
en.m.wikipedia.org
>mobile posters
Lets fuckin go
Why does dressing up like an Anime girl make one a better programmer?
Is SQL /wdg/ or /dpt/?
/dpt/
either is fine but wdg may be more helpful with more webdev related sql stuff
just say you want male sexual attention user, no need to beat around the bush ;)
I learn Perl and don't know what fun stuff I should write. Advices?
What we want to know is
p(B_1|G), that is to say, we have box_1 given that we have a gold ball.
according to bayes theorem
p(B_1|G) = P(G|B_1) * P(B_1) / P(G)
that is the probability of drawing a gold ball given box1, the (a-priori) probability of box-1 and the probability of a gold ball
P(G) = sum(P(Box_i)*P(G|Box_i) for i = 1... 3)
so 1/3 * (0 + 1/3 + 1) = 4/9
P(G|Box_1) = 1
P(Box_1) = 1/3
so P(Box_1|G) = 1 * 1/3 / (4/9) = 9/12 = 3/4
if you want to check for box_2
P(Box_2|G) = 1/3 * 1/3 / (4/9) = 1/4.
(n/(n+k)) + ((k-1)/(n-1)) * (k/(n+k))
Anyone got that image of Lerdorf saying his stupid shit about PHP?
What anime should I watch in between of my coding sessions?
Must read beginner compsci books ?
Subete ga F ni naru, where integer overflow was an actual plotpoint. Its enjoyable as long as you can overlook the first years philosophy course.
Steins Gate
It's not limited to programming related anime but i'll check it out.
already reading that
naruto filler episodes
you should """code""" in between your """coding""" sessions
Pretentious pseudo-deep garbage
Reddit-tier garbage
I don't usually give suggestions about things when there is absolutely no context about what I person's preferences are.
Also, this is not the place to discuss such a thing.
Posting is slow at the moment though, so Shirobako is a nice series, I guess.
Shin Sekai Yori.
why would it be ""in"" ""between"" then? that doesn't make a whole lot of sense
>Also, this is not the place to discuss such a thing.
Why not? This is literally an anime thread and you could certainly make a case for Sup Forums being an anime board.
Thanks for the suggestion though
Obligatory polls post
strawpoll.me
strawpoll.me
Sepples really is the worst and has hold the world back more than Christianity.
I agree. It really a horrible and poorly designed language.
Anyone who thinks that it's good, or even passable, clearly has a metal problem.
*tips fedora*
Reminder that the "C++ is not suitable for kernels" meme is getting out of hand.
>coffee and tea are separate
really? why not just make one caffeine option? shit poll.
what if I drink yerba mate?
this! islam is white and based though
yeah... it's pretty retarded.
"not suitable for anything" would be more accurate.
learning django; where can I get a good tutorial on making a simple web app? I've got django/pip/venv etc. installed already
b-b-but
m-m-muh OOP in the OOL!
m-muh RAII!
muh borked C compatibility!
uint32_t arr[0x80];
typedef uint32_t arrType[0x80];
void fun(arrType& a){
cout
In other words. I know that arr name is a pointer to its first element, but i dont get why typedef and reference trick allows me to check entire array size.
>C++
>but i dont get why typedef and reference trick allows me to check entire array size.
Because sizeof reference is actually size of the type, and not the reference.
void foo(short short_val)
{
cout
but isn't parameter a in the function, while executing it's first line, just a plain pointer? just passed by reference isntead of making a copy of it.
>but isn't parameter a in the function, while executing it's first line, just a plain pointer?
Arrays are not pointers.
void foo()
{
int arr[2];
int* ptr = arr; // (or &arr[0]);
ptr += 1; // legal
arr += 1; // compiler error
}
It should be noted that a number of great scientists, such as Isaac Newton, did their work to try and understand what they believed to be the creation of God. All in all, taking into account the great works vs the great tragedies produced by Christianity, I'd say it has been worth it.
Because that's just how reference semantics were designed to work. C++ likes stronger type safety, but has to give in where compatibility with C takes precedence.
>Arrays are not pointers.
I get that I was talking about array identifier used as func parameter and explicitily about using it with sizeof operator.
Isaac Newton would have increased their understanding of the universe no matter if he believed in a deity or not.
His belief in God is more of an hindrance, rather than a benefit. If the discovery of Galilei, namely foreign heavenly bodies orbiting other heavenly bodies, wasn't suppressed and declared blasphemy by the church, there could have been another Newton explaining these orbits several decades before Newton did.
>I get that I was talking about array identifier used as func parameter and explicitily about using it with sizeof operator.
That's what I'm trying to tell you.
Keep in mind that this is C (not sepples)
void foo(int ptr[]) // this is syntactic sugar for a pointer (because no size is specified)
{
printf("%zu\n", arr); // sizeof(int*)
}
void bar(int arr[2]) // this is an array of size 2
{
printf("%zu\n", arr); // sizeof(int) * 2
}
Ignoring the wrong identifier and missing sizeofs, that is wrong. Specifying an array length makes to difference to anything.
It's really quite misleading, so that's why everyone typically just uses the *.
What actually makes a difference is when you specify a pointer to an array type:
void foo(int arr[2])
{
printf("%zu\n", sizeof arr); // sizeof(int*)
}
void bar(int (*arr)[4])
{
printf("%zu\n", sizeof *arr); // sizeof(int[4])
}
Oh.
So explicitily stating the size of an array in function parameter (typedef in my example) is what makes the difference?
Shouldn't you pass it by the reference in bar example?
If i pass int arr[2] by value I get the same compile message as with int ptr[]
3/4
n / (n + k)
pass it by reference (in C++) or by pointer (in C/C++)
I think I'm slooowly getting the idea as it's treated as completely different type
void fun(arrType& a){
cout
>That feel when implementing new, delete, and unique_ptr in your C++ kernel after you've gotten kmalloc and kfree working.
I imagine it would be a very disgusting feeling.
It's a great feeling that Cfags will never know.
You're wrong and is right, but it's not clear enough.
Let's label the three boxes respectively B1, B2 and B3 and the respective events:
- BN: "box N is picked"
- G1: "first ball picked is gold"
- G2: "second ball picked is gold"
Using Bayes' theorem again: P(G2|G1) = P(G1 ∩ G2) / P(G1)
P(G1) is easy to determine, there are n+k gold balls over 3n balls, hence P(G1) = (n+k)/3n.
Now, P(G1 ∩ G2) is another story, you have to take into account both possibilities of getting G1 then G2:
- the first one by picking box 1 (probability 1/3)
- the second one by picking box 2 (prob. 1/3), then picking a gold ball (prob. k/n), then picking another gold ball (prob. (k-1)/(n-1))
So, P(G1 ∩ G2) = P(B1) + P(G2|G1|B2) = 1/3 + ((1/3)*(k/n)*((k-1)/(n-1)))
(feels like I'm writting Lisp there)
With some simplification magic, we get P(G2|G1) = (n/(n+k)) + (k*(k-1))/((n+k)*(n-1)), which pretty much the same thing as .
Yeah, I may have autism.
On the seventh day Linus had finished the work he had been doing; so on the seventh day he rested from all his work.
Meanwhile, Bjarne was still struggling with operator overloading.
you're right, i went too fast and assumed k=1 like in the pics
Why is PHP a thing?
It's literally more fucking work to set up than fucking Java Server Pages, the thing that Java developers didn't like because it was too boilerplate-y.
It has zero reasons to exist, except for hosting applications already written in it. Why do people insist on this language? Why won't it die?
Is there any benefit to writing a kernel in C++?
Because lazy webdevs and lazier web hosts.
On a semi-related note, I just finished a homework assignment to exploit a vulnerability in an insecure PHP server on a virtual machine. This language really lends itself to being easily compromised.
Make sure to also make std::make_unique
RAII.
>Because lazy webdevs and lazier web hosts.
this
the web host i'm planning on using only supports PHP and ASP.NET (the older one, not even ASP.NET Core) and some web hosts don't even offer ASP.NET
so even if a web dev wants to use something other than PHP, they have limited options unless they do a more expensive cloud server thing (i think i'll do a hybrid ASP.NET w/ C# + microsoft azure w/ C++ solution)
How would you know?
It's PHP. It might be compromised, it might shut itself down, and it might hand you a root terminal that's logged into the neighbouring coffee brewer.
Depending on the three(!) configuration files, the massive changes between versions, how it does some things different depending on OS... The security holes aren't necessarily even portable. It's just PHP. It's fractally wrong.
Buy a VPS, install and set up stuff.
Done.
Hi /dpt/
I'm 23 and have 0 programming knowledge. Is it too late to make it as a programmer? I didn't study computer science so I know I'm already way behind. The only program I use occasionally is Matlab and did a little work in Java when I was a kid playing around with video games.
I want to pick it up as a hobby, which language is good for picking up fundamentals applicable across other languages and can be used to contribute to github and stuff. Recommend a good book too.
I have no use for make_unique because I have exceptions disabled
Van Gogh didn't start painting until he was 30. Believe in yourself, user.
It's never too late to pick something up, especially if it's just for a hobby but you probably have your learning skills off since you're most likely not in school anymore (unless you're studying still).
I'd recommend Python especially since you're dealing with Matlab you can later learn NumPy/SciPy but Python has its cons as well.