/dpt/ - Daily Programming Thread

What are you working on Sup Forums?
Last thread

Other urls found in this thread:

sys.Sup
nayuki.io/page/unsigned-int-considered-harmful-for-java
en.wikipedia.org/w/index.php?title=Function_of_several_real_variable
twitter.com/NSFWRedditImage

first for C++ is faster than java

Sup Forums thread navigator in Haskell

why does "fast C++" need months to optimize and always starts with a bunch of #include lines and java which is pretty fast is just java anyone would write quickly in production ?

it doesn't

why does Java always start with a bunch of
import java.

>need months to optimize
you're a fucking idiot m8

changing %2 to &1 doesnt take months

implementing simd doesnt take months

implementing parallel/threadded coding doesnt take months.

maybe it does for_you_ but thats not how it works.

you hold onto that idea dearly for some reason but you're just scared for your job security or something

someone that actually knows shit about comp sci to write a well made algorithm doesnt make them autistic either.

anyways you're just scared or trolling but this is kinda silly

>why does Java always start with a bunch of
>import java.

it's import java, not import cjava to cheat

is importing a bunch of how all the great C++ books teach you to start implementing your C++ program? I didn't know that.

Somebody give me an actual legitimate reasons why "java is shit". Too much circlejerk and not enough explanation.

>Why does C++ start with C?
>I don't know but I hate it because of that

>if a multi-paradigm language extends upon another than using the language its extending upon is cheating

>thinks is a c library and not its backwards compatibility layer

here's some data
sys.Sup Forums.org/derefer?url=https%3A%2F%2Fbenchmarksgame.alioth.debian.org%2Fu64q%2Fcompare.php%3Flang%3Djava%26amp%3Blang2%3Dgpp

it's gonna make that javakid mad though

>OOP everything
>everything must use a class
>except primitives which exist for no reason
>no operator overloading
>== does not compare values
etc

...

the needless verbosity of java is absolutely fucking disgusting unless you're writing Enterprise Java Applications™ with a Team of Experienced Developers™

Ancient language that ignores trillions of years of research.

n^2 right?

O(n)

but aren't the new superior C++ libraries faster than java's?

what is the point of a speed comparison between C++ and java, guys ? apparently it's to prove that C code is really fast if you spend months optimizing it.

O(n^2)

do you honestly think native c libraries name their libraries "cstdio" and not just "stdio"

these are C++ compatibility layers. its C++ code.

>spend months optimizing it
read

don't listen to the unemployed retards and college shits, java is great

it's both fast to learn and fast to code, has great tools

>if you spend months optimizing it.
there it is again

Faggot pajeet.

>changing %2 to &1 doesn't take months
Every compiler should consider it the same.

>do you honestly think native c libraries name their libraries "cstdio" and not just "stdio"
This does not make sense.

java provides a nice learning environment before moving on to C/C++.

students can find themselves in silly language favoritism that makes them never make that jump from java to a more professional language.

>you spend months optimizing it.
You can read some C/C++ githubs right now and see that it does not take "months" for an algorithm refactor

if you have code that is centered around everything-is-an-object then youll spend a longer time refactoring in java than in C/C++ if anything.

> its C++ code

wow, new low in C++ fanboyism

go throw out your iostreams guy

tards

What does /dpt/ think of mobile development? (iOS or Android)

please report asshole

that's all his does on this board

>Every compiler should consider it the same.
No.

O(xy)?

worst case algorithm has to look at every single element of the array

Is this even an English sentence?
Are you the guy that was posting cars the other day?

Yes

I think its O(n) since it's just using two x y values to access a two-dimensional dimensional array. it's not a bubble sort or anything its a fairly linear algorithm with predictable "worst-case-scenario" time

>pajeet
>OOP is shit, Java is shit
>CS is a meme

hallmarks of a programming noob

Stupid nigger.

>pajeet
>OOP is shit, Java is shit
True

>CS is a meme
Only Java Pajeets think that.

>being this upset

are you talking to me, scumbag?

where are you from and what's your name ?

java doesnt support unsigned integer types

Retard fag.

who is that semen demon?

...aaand why would they need to?

Why does Java have a Boolean type?

He is always like this.

>please report asshole
>that's all his does on this board
This is not valid english.

>says that people who do not use java are anti-CS
>yet he like a language that ignores decades of CS research

oh lord

>java doesnt support this
>"y-yea well.. who needs em!" "who cares!"

I guess if I want to put an RGBA literal color value in an integer you just use an 8-byte integer since it can't support the higher integer values without it going negative

I guess that throws out SIMD operations too

image manipulation must be hell

>This is not valid english.
I asked for your name and location, you cowardly piece of shit

Ask me again after you learn English.

>clarisse (granblue fantasy)

No. It's O(xy). The algorithm has to evaluate each every element of the matrix in the worst case.

enjoy knowing that you are a fucking coward

n = xy

I fail to see what this has to do with the topic of java.

idiot.
nayuki.io/page/unsigned-int-considered-harmful-for-java

O(n) != O(nm)

I think you should pick up an algorithms book.

wtf I love feet now

wow man you sure showed him with that link

Enjoy

>language that ignores years of CS research would work terribly if it implemented unsigned integers

wow big news here

java ignored the need for unsigned types for so long that adding them now would literally break it.

you showed me duded

emulating something the CPU can do natively
adding another layer of overhead just for something as fundamental as unsigned arithmetic

right.

What's m in terms of n?

>char *array = (...);
>(uint32_t)(uint8_t)array[0]

what in the god-damn fuck are they doing

>40$ was deposited into your Java Viral Marketing Account

>l-lol who would ever need unsigned types?!
Jesus christ Javafag are fucking retarded.

more of that semen demon?

>arguing over ill-defined notations
I'm going to grab some popcorn

more like
>₹10 was deposited into your Oracle® Java™ Viral Marketing Account

...

such a juvenile way of thinking
>he disagrees with me, so he must be a paid shill!

so you just gonna ignore all the valid counter-points and specifically target the banter or

No, this is an obvious point
It is literally O(n)

it's code for "you're so bad at defending java I'm gonna make the jokey assumption that you're getting paid to promote it so hard to entertain idea that there is no other reason for someone to defend a language so militantly even after being proven wrong"

or you could just use another language. nobody ever claimed Java was the one true all-purpose language

What is n, in a 2-dimensional matrix?
Sometimes n and m are both used in O(...) to denote rows and collumns, respectively.
In the code example it makes sense just to use x and y as free variables, because those area literally the variables that the code uses as bounds.
Why bring up an arbitrary "n" without defining what it means?

...

I want to reimplement a subset of a language in the same language so I can make programming challenges that are in the same domain and not string reading from stdin and interpretation bullshit. Also, I want the user to write barely anything and be illegal to have syntax errors, so I don't need to parse anything, just straight to AST. Seems doable? It should be like Scratch to teach F#.

An x by y matrix is a list of length xy

You gonna give some analysis or what? Back up your claim. Why is it linear worst case?

Swift is best language, prove me wrong

Use Haskell + the free monad

->

not him but i imagine it this way

if you have a 5x3 grid of crops and you have to check each and every single one to find out which one is rotten, then the worst-case scenario is 5 x 3 = 15. with the worst case scenario being that you check every single one and none of them are rotten.

the process of checking each and every single one being linear.

you can go row by row or check each crop in a checker pattern. It's still a linear algorithm

now if you had to compare one crop to every single other crop, then its squared and non-linear. Because the worse case scenario is that you go to every single crop, check ALL the others against it, and them move on to the next crop to do the same thing. then the worst case scenario is that you check every crop against all others and find nothing,

Sure. In the case that n=xy, the code is O(n). Why not just say O(xy), isn't that a lot more clear?

f(x,y) = xy
is a quadratic function.

Another way to explain it is that, even if you have a 2d array, you are accessing it with the algorithm:

array[width * row + col] which is the same as array[row][col]

width * row + col being synonymous with y=mx + b. Linear.

each element is just being accessed the value is being isolated and tested for being equivalent against another value.

Is there a gentle introduction to Haskell for Java / C programmers?

Because normally when someone says big-O they want it in terms of a single variable which is usually called n

Increasing the size of land by one in both dimensions leads to a quadratic increase in crops.
Collapsing ij = n only makes sense if you fix one of the dimensions, but if both can vary freely it would not make sense to call the function linear.

O(nm)

for (int i = 0; i < x; ++ i)
for (int j = 0; j < y; ++ j)


for (int n = 0; n < x * y; ++n)

>for (int n = 0; n < x * y; ++n)
And that is a quadratic growth of x and y.
Multivariable functions are a thing you know...

I don't understand how you're not getting this

It's only quadratic if both x and y are increased, therefore O(nm)

en.wikipedia.org/w/index.php?title=Function_of_several_real_variable

A 2d m by n array on a turing machine is a 1d mn array

Yes?

The input is no bigger than |N|
It's not a function of several _real_ variables

>The input is no bigger than |N|
That's obviously the case for every algorithm (can't have an irrational or feactional number of cells on a tape)
>It's not a function of several _real_ variables
Yes it is.
f(x,y) = xy is only a straight line if you fix one of the arguments as a constant.

It could be a function on any magma if you interpret it that way

>json for Sup Forums posts doesn't necessarily have a "com" field

FUCK YOU MOOT
YOU DON'T EVEN WORK HERE ANYMORE
WHY DO YOU HAVE TO SCREW ME OVER FOR AN HOUR?

What does that image have to do with programming?

Not a fan of haskell syntax. I don't want the user to ever need to annotate a type, so a ML-based language seems easier to create code that is valid outside the program. My idea is make a challenge and give a signature so the user can solve the challenge. Something like:

Having a list of student info and today's date, return a list of the names of the students that will have a birthday this month.

Extra info:
type DateTime = {day: int; month: int;year:int}
type StudentInfo = {name:string; birthday: DateTime}

Expected signature: (stdList: StudentInfo list -> today:DateTime -> string list)

and then the user would solve with something like

stdList |>
List.filter (fun s -> s.birthday.day >= today.day & s.birthday.month = today.month) |>
List.map (fun s -> s.name)


It's a work in progress.