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

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

/g/ - Technology


View post   

[ Toggle deleted replies ]
File: 120 KB, 400x400, 1515584981438.png [View same] [iqdb] [saucenao] [google] [report]
67683795 No.67683795 [Reply] [Original] [archived.moe] [rbt]

What are you working, /g/?
Old thread: >>67675328

>> No.67683806

>>67683795
python best lang

>> No.67683809

>new thread before bump limit
retard animuposter

>> No.67683815

What are some languages with an effortless C ffi?

>> No.67683824

>>67683815
D
It's also going for some C++ interfacing

>> No.67683826

>>67683815
Nim and D. I would say Go too but it suffers from a massive FFI calling overhead.

>> No.67683838
File: 120 KB, 1102x1002, Nim.png [View same] [iqdb] [saucenao] [google] [report]
67683838

>>67683815
Nim.

>> No.67683862

>>67683815
foreign import ccall "exp" c_exp :: Double -> Double

>> No.67683863

>>67683815
D can call the C libs directly
void main()
{
import core.stdc.stdio : printf;
"hello world\n".printf;
}

>> No.67683886

>we don't make a distinction between O(n) and O(2n) because the constant member becomes irrelevant by using a better processor

Nani the fuck I'm reading

>> No.67683906

>>67683815
C++

>> No.67683907

>>67683886
Constants are usually not considered for time-complexity. Due to Moore's law, iterating 2N elements would take the same time as N elements in 18 months.

>> No.67683929

>>67683862
every day there is yet more proof that Haskell is the ultimate language for imperative programming

>> No.67683960

>>67683929
>imperative haskell
show me lol

>> No.67683965

>>67683907
I'll take their word for it, but to me it will always be twice as slow

>> No.67683998

>>67683965
O(2n) is only meaningful when compared to O(n) though, on its own it means nothing. big O notation tells you about how the complexity of the algorithm changes with the size of the input

>> No.67684015

>>67683965
It is, but >>67683998 explained it better.

>> No.67684087

>>67683960
What do you mean?

>> No.67684103

>>67684087
the only way haskell would ever be imperative is if you built a lambda calculus processor

>> No.67684210
File: 159 KB, 454x558, 1465542231484.jpg [View same] [iqdb] [saucenao] [google] [report]
67684210

>>67684103
what

>> No.67684316

>>67683157
>balancing an arbitrary BTree
>arbitrary
There's no hope, keep poping the elements and add them to a newly created tree. Then set the old pointer to the given tree to the new tree.

>> No.67684363

>>67683815
zig https://ziglang.org/documentation/master/#C
crystal https://crystal-lang.org/docs/syntax_and_semantics/c_bindings/

>> No.67684436

>>67684210
imperative means you are writing code that does that tells the system directly what to do with no ambiguity
assembly is the ultimate imperative language
the opposite is declarative, which is where you say what you want to happen but leave the implementation details up to the computer
all functional languages are declarative because processors don't operate on a lambda calculus model, thus the code needs to be converted to normal procedural style, which has alot of ambiguity involved

>> No.67684460

What is the closest thing to a private subnet in qemu/libvirt? I need to emulate a network infrastructure via kvm, with a main network for internet access and various subnetworks with hosts inside them.

>> No.67684997

>>67684436
looks imperative to me

import System.Environment ( getArgs )
import Data.IORef ( newIORef, readIORef, writeIORef )

-- imperative helper functions
new = newIORef
get = readIORef
put = writeIORef

pop listRef = do
(head:tail) <- get listRef
put listRef tail
return head

more listRef = do
list <- get listRef
case list of
(_:_) -> return True
_ -> return False

when boolRef body = do
bb <- get boolRef
case bb of
True -> body
False -> return ()

unless boolRef body = do
bb <- get boolRef
case bb of
True -> return ()
False -> body

while :: IO Bool -> IO () -> IO()
while condition body = do
more <- condition
case more of
True -> do
body
while condition body
False ->
return ()

-- haskell imperative language is best imperative language
main = do
argsRef <- getArgs >>= new
firstRef <- new True

while ( more argsRef ) $ do

unless firstRef $ do
putStr " "

when firstRef $ do
put firstRef False

value <- pop argsRef
putStr value

putStr "\n"

>> No.67685051

>>67684436
that's wrong anon

>> No.67685075

>Trying to do nested loops in C
>For some reason the program doesn't exit out of the inner loop and runs endlessly.

#include <stdio.h>
#include <stdlib.h>


int i, x, z;

int main(int argc, char** argv) {

i = 1;

scanf("%d",&x);

while(i <= x){
for(z = 1; i; z++){
printf("%d\n",z);
}
i++;
}

return (EXIT_SUCCESS);
}

>> No.67685080

>>67684436
>tells the system directly what to do with no ambiguity
even C fails this test, retard

>> No.67685084
File: 21 KB, 328x353, 1517483975801.jpg [View same] [iqdb] [saucenao] [google] [report]
67685084

>>67685075
what

>> No.67685087

>>67684997
doesn't look imperative to me because it's written in haskell

>> No.67685100

>>67685075
this better be homework, because if you can't see the error here you're a little retarded

>> No.67685120

>>67685087
>this guy doesn't compile his haskell to vhdl fpga layouts

>> No.67685142

>>67685051
nope

>>67685080
it's not a test, it's a scale. No language can be considered 100% imperative because CPUs optimize machine code as it runs. Assembly is just the most imperative language, and things like C are close because their abstractions map 1 to 1 to Assembly with little ambiguity. Functional programming is at the opposite end of the scale with things like lazy evaluation and all the caching the undoubtedly goes on to leverage the advantages of pure functions

>> No.67685146

>>67685100
it’s sspelled rarted

>> No.67685163

>>67685142
imperative doesn't mean "close to machine"

>> No.67685182

>>67685163
practically it does. you're issuing commands to the machine to tell it what to do. If processors were lambda calculus based, then writing functional code would be writing machine code, it would be imperative

>> No.67685192

>>67685142
>because CPUs optimize machine code
Not at my machine

>> No.67685209

>>67685182
no it wouldn't you idiot

>> No.67685212

>>67685100
Just saw what was wrong with it and fixed it.

>> No.67685235

>>67685209
it would. imperative is issuing commands. if your processor evaluated functions, writing functional code would literally be issuing commands to your processor. As it stands right now functional code is just something for your compiler to interpret into state-based machine code

>> No.67685273

>>67685142
functional languages don't automatically cache any more than imperative ones do. the optimizations there are largely the same.
I get what you're saying, but your reducing the concept to absurdity, which is why you're getting so much blow back.
imperative means you tell the system how to do something, declarative means you tell it what you want done
Even SQL is imperative if you know how all the backend machinery of it works. You know what kind of methods and performance you'll get from specifying joins in a given order or with given indexes.
Declaring that only assembly is imperative isn't useful. I was taking the piss with the imperative haskell example, but that really is imperative code so far as that sort of thing matters to other programmers.
I told it to mutate a set of variables following a particular line of logic. That step by step imposition on the process is the root of things.
To use a metaphor, you're not wrong with your insight, you're just screaming the world isn't really round since it's slightly bulged at the equator and has ridges and mountains, while failing to see why calling it "round" is useful for the common less granular view

>> No.67685288

>>67685212
good man. debugging is a pain in the ass, but it's a skill you have to have to be a good programmer

>> No.67685321

I think I'm in love again~~
fn get_default2<'m,K,V:Default>(map: &'m mut HashMap<K,V>,
key: K)
-> &'m mut V {
if map.contains(&key) {
return match map.get_mut(&key) {
Some(value) => value,
None => unreachable!()
};
}

map.insert(key, V::default()); // OK now.
map.get_mut(&key).unwrap()
}

>> No.67685343

>>67685273
>functional languages don't automatically cache any more than imperative ones do. the optimizations there are largely the same.
so are you saying that if you call a function twice with the same arguments it isn't using a cached result? that's like, the entire point of why you would use FP. Optimizations like that are highly ambigious but given the right domain, they're incredibly useful. And like I already said, imperative-declarative is a scale, not a boolean

>> No.67685360

>>67685321
wtf. why the hell would you have a function named get_default insert the default value every time you have a miss instead of just returning the default value?
if you scan a hashmap for a series of values, you're going bloat the shit out of it with useless default value entries

>> No.67685363

>>67685321
wtf

>> No.67685380

>>67685075
gcc -o program.c
gdb ./a.out
b 5
r
p i
p x
p d

>> No.67685389

>>67685321
wtf

>> No.67685421

>>67685360
I have my reasons :3

>> No.67685424

>>67685343
C can and does do the same thing. But those optimizations are always super localized in any language, because having a fat dictionary of values you might or might not need isn't a good optimization.
Haskell doesn't do any automatic memoization or anything.
The only weird optimization it does is keeping the computed values in lists that have infinite declarations. If you take the 50th element, you'll have all 50 in memory.
If the list is declared outside of a function so that it has global status in the gc, you'll be stuck with them, so don't take the 10000th item.
It's more of a pain in the ass than anything.
C has no generators or lists built via continuations, so any similar optimization doesn't make sense there.
But your average function isn't saving it's return values. Haskell just compiles really, really well, and will compute them again, just like C generally would
( either language can and do fold them into constants if they only take constants at compile time )

>> No.67685435

>>67685343
Maybe you’re privy to some new information but for the past 20 years, if you call a function twice in a functional language it isn’t using a cached result.

>> No.67685490

>>67683838
>cuint
watch your language

>> No.67685507

>>67685424
>Haskell doesn't do any automatic memoization or anything.
Seems wierd to me because that's the biggest advantage of having everything be pure functions, you don't need a big dictionary of values, you can do a much deeper compile-time analysis of pure functional code and optimize the hell out of it to the point it might not even resemble the code you've written

>> No.67685531

>>67685507
It's a common misconception. I had it myself before getting corrected and learning more about it a decade or so ago.

>> No.67685577

>>67685531
then why do people call functional languages declarative?

>> No.67685655

>>67685577
The truth is ugly.

>> No.67685659

>>67685577
my earlier example was tongue in cheek, all written in the IO monad.
in haskell, most functions don't touch "the world", and so the compiler is free to manipulate and change and twist and turn them as it will
they are much closer to SQL style declarative than C style imperative. but you can write imperatively in haskell if you find it useful, which is what I did.
C is much harder to optimize because every statement in it can be telling the compiler to change state in the program, so the optimizations must be much, much less aggressive.
in haskell, if I say to map a function over a list, haskell can and will return without having done so, and only actually map the function over the list as values from the resultant list are required to satisfy those imperative functions running in the IO monad.
it can leave work undone if the values are never used, and just forgets them via gc afterwards
functions don't memoize because it's a bad optimization to force, since it trades a lot of space and lookup and save time in order to maybe speed up some calls
better to leave it to the programmers discretion there

>> No.67685683

>>67685577
Most of them aren't declarative.

>> No.67685711

>>67685659
all lists, all expressions, all function calls, all of it just gets initially tossed back as a thunk, a function the runtime can follow if need be, or can ignore if it wants.
this is what laziness means
and why some call it "declarative"

>> No.67685718

>>67685659
>functions don't memoize because it's a bad optimization to force, since it trades a lot of space and lookup and save time in order to maybe speed up some calls
you can determine at compile time where functions calls can have the same result, its a zero-cost optimization

>> No.67685740

>>67685711
that is, you only write a definition for what you want done, you don't specify how it gets done.
>>67685718
that's constant folding, not memoization
memoization is remembering arguments to lookup return values instead of executing the function body

>> No.67685760
File: 7 KB, 272x130, &&.png [View same] [iqdb] [saucenao] [google] [report]
67685760

>>67685711
It's called declarative because you can do this

>> No.67685781

>>67685760
using top level pattern matching for an operator definition doesn't make something declarative

>> No.67685800

>>67685781
congrats on totally missing the point

>> No.67685857

>>67685800
How come you never congratulate me but you'll congratulate Anon in public?

>> No.67685881

>>67685857
be quiet you failure

>> No.67685888 [DELETED] 

>>67685740
You don't evaluate the function at compile time, you identify calls that will have the same input at compile time to reduce the total calls
like
function Lol(arg)
return Rofl(arg) + Rofl(arg) + Rofl(arg)
end[code]only has to evaluate Rofl once everytime you call Lol instead of 3 times[/code]

>> No.67685899
File: 99 KB, 540x675, 1454233711543.jpg [View same] [iqdb] [saucenao] [google] [report]
67685899

>>67685881

>> No.67685926

>>67685740
You don't evaluate the function at compile time, you identify calls that will have the same input at compile time to reduce the total calls,like

function Lol(arg)
return Rofl(arg) + Rofl(arg) + Rofl(arg)
end


only has to evaluate Rofl once everytime you call Lol

>> No.67685961

>>67685888
that's still not memoization, and that optimization is also done in C if the functions are declared pure or the compiler proves they are.
as I said earlier, it's often fairly localized optimization to make
If two different functions call Rolf with the same args, they're probably just going to call Rolf twice.

>> No.67685982

>>67685961
>declared pure
GCC extension before you turn the blade on me :)

>> No.67686256
File: 997 KB, 1000x1047, 1488107604585.png [View same] [iqdb] [saucenao] [google] [report]
67686256

Is there anyone that's good with EF Core here?
I'm conflicted as to how I should handle eager loading for a specific query, since my lazy loading with proxies is exponentially slower than eager loading in a few cases.
But I don't wanna disable lazy loading for good, since it's really useful for a lot of the rest of the things I do.

>> No.67686513

>>67685982
"C with GCC extensions" is not C

>> No.67686572

I wanted to thank the anons that pointed me to python for beginners.I'm enjoying learning this stuff and I feel less lost thanks a lot anons.

>> No.67686596

>>67683815
Pretty much everything that isn't some weird old compiler tech like COBOL.

>> No.67686598

>>67686513
I know, I know. But if you want to declare a function pure to help the optimizer undo your repetitive shit code, you'll mark it anyway.
The compiler can still prove the function is pure if it's in the same compilation unit to perform the optimization.

>> No.67686609
File: 112 KB, 675x949, 1521471013628.jpg [View same] [iqdb] [saucenao] [google] [report]
67686609

>>67685321
Your code won't even compile because K is not Hash + Eq, which is needed for HashMaps. The lifetime is not needed, it can be elided.
Also, just use the Entry API:
fn get_default2<K: Hash + Eq, V: Default>(map: &mut HashMap<K, V>, key: K) -> &mut V {
map.entry(key).or_insert_with(Default::default)
}

>> No.67686653

>>67686609
Actually, Entry has a default method already:
map.entry(key).or_default()

>> No.67686655

>>67686609
gods rust is fucking ugly. and people bitch about C++.

>> No.67686670

>>67686655
All C-like languages are ugly.

>> No.67686686

>>67686609
wtf

>> No.67686717
File: 310 KB, 1920x1080, shot0033.jpg [View same] [iqdb] [saucenao] [google] [report]
67686717

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything

>>67683795
Thank you for using an anime image.

>> No.67686746

>>67686717
>Ask your much beloved programming literate anything
CHICKEN or GNU Guile for gamedev and why?

>> No.67686756

>>67686670
I mean it doesn't have to be pretty just efficient no?

>> No.67686810

>>67686756
Code is read many more times than it is written.

Code must be correct first, fast second. If it is wrong then it will never be fast. Readability and conciseness aid understanding and make it easier to produce correct code. Here 'pretty' is shorthand for readable.

>> No.67686842

>>67686810
>Code is read many more times than it is written.
Code must be paid zeroth, correct first, fast second.

>> No.67686856
File: 1.66 MB, 480x360, dogot.webm [View same] [iqdb] [saucenao] [google] [report]
67686856

>>67686746
i am not familiar with both but chicken compiling to c, it's easier to interop with it (you can mix scheme and C code together). it also avoid stuff like bignum or complex numbers by default, you don't need that for video game development.
there is a new scheme: gerbil. see more here https://cons.io/
what game do you want to make?

>> No.67686931
File: 80 KB, 1000x1000, 1536063434957.jpg [View same] [iqdb] [saucenao] [google] [report]
67686931

>There's no mutability specifier called const in the language
>Can't switch over a string because supposedly it's not constant
>However just replacing the switch with if/else makes it ok somehow
BASED AND REDPILLED

>> No.67686945

>>67686810
Ok.So much to learn.

>> No.67686977
File: 939 KB, 240x426, lisper_be_like.webm [View same] [iqdb] [saucenao] [google] [report]
67686977

>>67686746
>>67686856
here an example of mixing scheme and c code with chicken-scheme
(define my-strlen
(foreign-lambda* int ((c-string str))
"int n = 0;
while(*(str++)) ++n;
C_return(n);") )

(my-strlen "one two three")

>> No.67686998

>>67686977
shit that's cool

>> No.67687007
File: 43 KB, 77x65, perdiste.png [View same] [iqdb] [saucenao] [google] [report]
67687007

I want to fetch the first 8 images from a google images search, given the keyword, in Java, any tips? dont know where to start

>> No.67687118

>>67686856
I plan on making a relatively simple crpg at some point. Nothing fancy graphics-wise. I know I could do it in Lua or something instead but I like Scheme a lot more than Lua.

>> No.67687189

>>67687007
Just download 8 pictures of black man - white woman couples, it's the same either way

>> No.67687234

>For instance, on KNC, we have found that reducing the number of target regions can improve performance, as they incur significant implicit synchronisation overheads, but might require extending the scope of the regions such that they include instructions that should be performed on the host for portability. Importantly, the target synchronisation overhead will not be an issue when targeting NVIDIA GPUs with OpenMP 4.0, as the compiler implementations can leverage the performant asynchronous queues provided by the CUDA runtime
how can you offload computation to a compute device asynchronously? what about memory coherence my anonymous friends? dont u want to let the calculation finish before proceeding? I dont think RAM have DIRTY bits dont they?

>> No.67687256

>>67687118
maybe lambda native will give you everything you need to do that.
http://www.lambdanative.org/
there is also Kawa scheme that will give you access to the java ecosystem. Kawa does mean river in Japanese.

>> No.67687567

>>67683795
any books on string parsing algorithms?

>> No.67687575

>>67687256
Thanks. Would prefer to avoid the Java ecosystem though.

>> No.67687628

>>67686931
>the language
What fucking language?

>> No.67687651
File: 708 KB, 350x198, 4LbbDEv.webm [View same] [iqdb] [saucenao] [google] [report]
67687651

>>67687575
Why? Java's ecosystem is rich and vast.

>> No.67687675

>>67687628
Based Java

>> No.67687893

>>67687675
Oh, right. Yeah Java is trash, it just took me off guard that anyone would be writing new code in it in September 2018

>> No.67687928

>>67687893
java is evolving, we are at java 9 now.

>> No.67687968

>>67687007
>where to start
not by using java

use python

>> No.67687990

>>67684436
Now you're just restating "low level" and "high level". Imperative programs use statements, declarative programs use equations.

>> No.67688022

>>67687651
So is a bog.

>> No.67688031

>>67687990
declarative programs use expressions but, ultimately, when we talk about programming languages, there is no declarative one (see sicp first chapter)

>> No.67688048

>>67683886
Big O notation doesn't actually denote runtime. It's easiest to think of it like a derivative, or to sub it in as a fraction. If your algo takes 2n steps for n inputs, it takes 2(n+1) steps for n+1 inputs. The ratio of inputs to steps grows proportionally to the input. Something that is O(1) for example doesn't grow with your input. It takes the same number of steps, no matter how many steps that is.
tl;dr Big O is not runtime, it's rate of change of runtime

>> No.67688232

>>67687968
>python
Python is nu-male garbage with shit performance

>>67687007
Look into http clients and web scrapers. You probably want Jsoup, unless google image search has a Json API, which I doubt.

>> No.67688237
File: 1.00 MB, 1280x1063, girls und comfy.jpg [View same] [iqdb] [saucenao] [google] [report]
67688237

I am working on a robotics project. I have experience with R/C stuff, but I haven't delved into microcontroller programming yet. I think that I will start with C, but I am not sure exactly where to begin. Do you guys have a book or instructional series that you would recommend? I have dicked around a bit with HTML and a very small amount of Python in the past, but I would be pretty close to starting at square one.

>> No.67688276

>>67684436
I can't tell if this is some sort of meme.
If it's not: that's not what those words mean anon, stop talking about things you don't understand.

Functional languages are not declarative, they describe algorithms to find results.
In declarative programming you describe the result you want rather than the algorithm or method of finding it, for example SQL, some constraint based languages, prolog...

>> No.67688308

>>67688232
>Python is nu-male garbage with shit performance
Yet it performs better than Java and isn't a steaming pile of shit.

>> No.67688326

>>67688237
anon I hope you make /m/'s dream come true some day.

>> No.67688362

>>67683795
Not very familiar with Java. is this the right Class and encapsulation convention?
public class Chromosome {
private double chromeFitness;
private ArrayList<Double> allChromeFitness;
private int chromosome[];
//private int allChromosomes[][];
private static int population;


public int getPopulation(){
return population;
}

public void setPopulation(){
try (Scanner reader = new Scanner(System.in)) {
System.out.println("Please Enter a population size\n");
Chromosome.population = reader.nextInt();
}
}

public int [] setChromosome(){
//random generation
return chromosome;
}

public double calcChromeFitness(){

return chromeFitness;
}

public ArrayList<Double> calcAllFitness(){

return allChromeFitness;
}
}

>> No.67688378

>>67688237

Why not fool around with an Arduino? That would be a great place to start.

>> No.67688383

>>67688362
for those high iq people out there it isn't supposed to do anything yet.

>> No.67688406

>>67688362
You seem to misunderstand what a setter is. A setter takes one argument and returns void, and does little more than update a member variable or throw an exception if that would violate some predicate.

>> No.67688410

>>67688308
>performs better than Java
Things delusional pythonlets say.

>> No.67688424

>>67688406
Are you referring to both of my setters?
Or just the setChromosome?

>> No.67688430
File: 106 KB, 670x950, blizzai wanzer.jpg [View same] [iqdb] [saucenao] [google] [report]
67688430

>>67688326
That's the idea! Starting at first with quadrupeds at a small scale.
>>67688378
That's where I am starting, but as far as I can tell, Arduino is based on C for the most part. Ideally, in the future I would like to write my own programs without relying on Arduino libraries. I am not very clear on exactly how programming works, or what half of the lingo I read actually means.

>> No.67688434

>>67685120
>this guy doesn't use his time machine to compile to aSoG instead

>> No.67688441

>>67688276
>Functional languages are not declarative
that's not what the rest of the world says, but I can see now that functional languages aren't as declarative as I thought they were
lazy evaluation qualifies as a declarative concept

>> No.67688445

>>67688410
They probably mean the C libraries they use wrappers of perform better than Java.

>> No.67688450

>>67688424
Both of them. Setters don't do I/O.
If you want to have a method that generates a random chromosome set, or reads in a population size from the console then that's fine. But those aren't setters and they shouldn't be called that.

>> No.67688457

>>67688406
>and does little more than update a member variable
a setter do whatever it want.

>> No.67688544

>>67688441
> that's not what the rest of the world says
https://stackoverflow.com/questions/129628/what-is-declarative-programming
https://en.wikipedia.org/wiki/Declarative_programming

> lazy evaluation qualifies as a declarative concept
The word "declarative" is used to descibe the manner in which a programs desired behaviour is specified.
Whether strict, concurrent, lazy, memoized or whatever makes no difference.

>> No.67688560

>>67688544
the wikipedia page says functional languages are declarative

>> No.67688586

>>67688430
Start with Arduino as the anon said. It less about the programming and more about understanding how doing shit to specific pins as an impact on the actual hardware.
Do not go study mechatronics at uni it is a meme. If you study anything and want to get into robots do Electrical Engineering or Computer Engineering.
If you don't want to do a degree it's gonna be hard to self teach a lot of the underlying concepts such as logic (your truth tables, how that applies to logic gates, other shit like that). You're going to have to teach yourself along side that Binary and how the conversions work (octal, hex, decimal, other number systems) so that you can later understand how microprocessors work and their opcodes, which is fairly important in robotics as not every chip has an interpreter available, you might be coding directly in machine code perhaps. Even still, an understanding of microprocessors helps with "debugging" or fixing broken shit.

Doing basic shit like making a thing go around a line using Arduino's is not too difficult as the software that you install handles a lot of the hand shit provided you are using an Arduino board. But once you get far enough it in the limitations become apparent, as you need x extension for this, or another chip for a sub-module for this.

Not trying to discourage you but actually building mechs or cool shit requires a long period of time of learning a dedication, even at uni it's challenging, harder to self teach.

>> No.67688591

>>67688560
I may have just been BTFO.

>> No.67688604

>>67688450
Thanks.

>> No.67688637
File: 15 KB, 766x185, waterfox_2018-09-19_20-11-50.png [View same] [iqdb] [saucenao] [google] [report]
67688637

>>67688308
>pthon has better performance than Java
God, you bootcamp pajeets are so fucking delusional and have no idea what the fuck you are talking about

https://www.techempower.com/benchmarks/#section=data-r16&hw=ph&test=db

http://pzemtsov.github.io/2018/07/18/building-queue-from-cpp-to-java.html

>> No.67688663
File: 73 KB, 900x900, 1537339578360.jpg [View same] [iqdb] [saucenao] [google] [report]
67688663

>>67688637
882 seconds

>> No.67688671

>>67688560
>>67688591
Huh, maybe people can't quite agree on this one in general.
https://en.wikipedia.org/wiki/List_of_programming_languages_by_type#Declarative_languages
This list certainly contains no haskell or lisps but only what I would have considered actual declarative languages.

A language being more or less declarative depending on what kind of hardware one is running seems rather odd to me.

>> No.67688709

>>67688637
>running n-body on a scripting language

>> No.67688740

>>67688237
https://www.tutorialspoint.com/microprocessor/microprocessor_8085_architecture.htm
https://en.wikipedia.org/wiki/Intel_8085
>>67688586


I forgot to mention. Probably worth learning assembly as well. Maybe just x86 would probably be fine for getting an understanding.
https://www.intel.com/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf

This is useful. Obviously don't read it all but control f some stuff if you want to know about it.

Most common processors/microprocessors will come with a manual listing their opcodes, especially if they are consumer grade. Generally people have also made interpreters for them as well. If not, you gotta reverse engineer them (this comes up when recycling parts).

>> No.67688758

>>67688740
>reverse engineer
And build your own, or just code in machine code.

>> No.67688763

>>67688709
>running anything on a scripting language

>> No.67688969

>>67688457
It's about convention

>> No.67689117

>>67688362
import java.util.ArrayList;

public class Chromosone {
private double chromeFitness;
private ArrayList<Double> allChromeFitness;
private int chromosome[];
//private int allChromosomes[][];
private static int population;

public Chromosone(double chromeFitness, ArrayList<Double> allChromeFitness, int[] chromosome) {
this.chromeFitness = chromeFitness;
this.allChromeFitness = allChromeFitness;
this.chromosome = chromosome;
}

public double getChromeFitness() {
return chromeFitness;
}

public void setChromeFitness(double chromeFitness) {
this.chromeFitness = chromeFitness;
}

public ArrayList<Double> getAllChromeFitness() {
return allChromeFitness;
}

public void setAllChromeFitness(ArrayList<Double> allChromeFitness) {
this.allChromeFitness = allChromeFitness;
}

public int[] getChromosome() {
return chromosome;
}

public void setChromosome(int[] chromosome) {
this.chromosome = chromosome;
}

public static int getPopulation() {
return population;
}

public static void setPopulation(int population) {
Chromosone.population = population;
}
}

>> No.67689125

Is moving from C# to C or C++ a good idea for learning?

>> No.67689147

>>67689125
NO

>> No.67689161

>>67689125
It's a good idea if you want to use C or C++ for a practical task
Learning languages just for the sake of it is a waste of time
Set some goals

>> No.67689187

>>67689125
Spend some time learning all kinds of languages, man. It'll expose your thoughts to more ideas and make the whole of programming easier to consume.
I can program useful shit in a dozen languages at least. I still have a ton to learn.

>> No.67689225

>>67689125
Grow up and fearn C++.

>> No.67689231

>>67689161
>>67689187
The goal is moving to assembly I want to learn how computers completely work

>> No.67689241

>>67689231
them move to assembly right now, it's literally the easiest language you can learn

>> No.67689258
File: 103 KB, 481x273, 1535404736371.png [View same] [iqdb] [saucenao] [google] [report]
67689258

I'm implementing a data layer in an application I'm writing, the application uses a database to store data and I'm writing service classes for each table to manage the insertion, deletion and retrieval of data.

Example Tables.

Product
Order
Customer

Ref tables

ProductOrder
CustomerOrder

Service Classes in application:

productService
orderService
customerService

where should I place the methods to retrieve things like customer orders?

e.g.

List<Order> getCustomerOrders(Customer customer)

inside customerService or inside the orderService?

At the moment I placed it inside the order service as it felt wrong that the customer service creates order objects, but I'm still not sure what best practice is for this is?

>> No.67689262

Is int int *a[10] equivalent to modern std::array<std::shared_ptr<int>, 10> a;?

>> No.67689264

>>67689117
Thank you.
But in this context, what is the purpose of this?
From what I understand it's for a specific instance of that object?
Also is public Chromosome my constructor?

>> No.67689272

>>67689262
jesus christ I hate C++

>> No.67689276

>>67683795
what are the best resources to get into MODERN openGL?

Most books/sites dont cover the new shader pipeline. (new as in like 10 years old)

>> No.67689288

>>67689262
Using shared pointers everywhere is a bad thing, anon.

>> No.67689309

>>67689288
I just try to implement the tree with exact ten leaves, in C++. Should I just go with the
std::array<Node*, 10> a?

>> No.67689318

So I'm looking at the Java source files and I found this

public ArrayList(Collection<? extends E> c) {
elementData = c.toArray();
size = elementData.length;
// c.toArray might (incorrectly) not return Object[] (see 6260652)
if (elementData.getClass() != Object[].class)
elementData = Arrays.copyOf(elementData, size, Object[].class);
}


I don't understand what the Object[].class actually means, can someone point it out where I can found something about it?

>> No.67689320

>>67689258
>but I'm still not sure what best practice is for this is?
you've pretty much stumbled upon one of the biggest issues people have with OOP
where a function isn't bound to one specific object
there is no real 'correct' way, either you can arbitrary decide which object is more important, or you just have it as a plain function which is bound to no object, which I think is the most correct, but isn't strictly OOP

>> No.67689351

>>67689309
Either that or unique_ptr. It depends on whether or not the parent owns the child.

>> No.67689363

>>67689258
Neither, create a new class that is only responsible for retrieving the info.

In general, if it's not obvious which class it should go in, you need another class.

I don't particularly like oop but if you're going to do it you might as well do it the right way.

>> No.67689375

>>67689318
Object[].class returns a Class<Object[]> instance corresponding to the Object[]. It's used for reflection.

>> No.67689415

>>67689258
Just leave a comment, and move on to the next thing. You'll have a better idea where it should go once you've gotten more of the code built. You can always change it later.

>> No.67689416

>>67689264

>But in this context, what is the purpose of this?

It's a template for creating chromosome objects

>From what I understand it's for a specific instance of that object?

No, it's just the template for the object, the object only becomes an instance once you create a new version of the object using something like:

Double doubleValue;
ArrayList<Double> doubleArray = new ArrayList<Double>();
int[] intArray = new int[100];
Chromosome chromosomeName = new Chromosome(doubleValue, doubleArray, intArray);


>Also is public Chromosome my constructor?
Yes.

>> No.67689586

>>67689416
Very helpful anon ty.

>> No.67689604

>>67683795
I'm working on a lab for my C programming class where I have to check if strings are palindromes by putting in the input 'palin("string here")' but I have no clue how I would have my program make sure the 'palin()' method is being called in the command line and how to pass it a string without closing the program. Do I have to make a for loop check every damn char I pass and see if it says 'palin' and then pass the rest of the chars as an argument to the palin() method? That seems super obnoxious if that's the case.

>> No.67689642

>>67677872
any luck?

>> No.67689648

>>67689604
google 'c argc argv'

>> No.67689677

>>67689604
int main(int argc, char **argv)
{
while (*++argv)
if (palin(argv))
puts("Palindrome!");
else
puts("Not palindrome!");
}

>> No.67689778

I just had slight hear attack
>https://www.gnu.org/fun/jokes/unix-hoax.html
please someone calm me and tell me that this is just a haha joke and that C was serious business from day one

>> No.67689780

>>67689677
puts( palin(argv) ? "Palindrome!" : "Not palindrome!");

>> No.67689814

>>67689780
argv is a char** not a char*

>> No.67689826

JavaScript rocks!

>> No.67689828

>>67689814
and?

>> No.67689835

Oh how I despise working on anything designed by a Java programmer.

>> No.67689840

>>67689677
argv is not null terminated

>> No.67689855

>>67689840
But *argv is

>> No.67689874
File: 214 KB, 812x693, wat.png [View same] [iqdb] [saucenao] [google] [report]
67689874

>>67689648
>>67689677
This is what it's supposed to look like I guess, I'm not sure what he means by "it's own computing environment", unless he just means a while loop. The argc argv stuff seems interesting but I'm not sure if that's what he wants.

>> No.67689876

>>67689840
Yes, it is. The standard requires that argv[argc] == 0. It's handy sometimes.

>> No.67689929

>>67689826
Are those like kidney stones?

>> No.67689946

>>67689876
Didn't know that. But thank for the information. C standard will always amaze me. If only it was free to download, I could read a copy.

>> No.67689967
File: 806 KB, 1679x943, anon idiot.png [View same] [iqdb] [saucenao] [google] [report]
67689967

>>67689840
https://port70.net/~nsz/c/c11/n1570.html#5.1.2.2.1

>argv[argc] shall be a null pointer.

>> No.67690007

>>67689967
Never send me again a fake C standard. It if isn't C89, it has zero value, zero.

>> No.67690028
File: 260 KB, 520x520, scattles.png [View same] [iqdb] [saucenao] [google] [report]
67690028

>>67689929
good one

>> No.67690040

>>67686977
If only Scheme used nil as false instead of #f

>> No.67690041

>>67690007
The C Programming Language = Latest C Standard = C18

>> No.67690046

>>67689946
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf

>> No.67690049
File: 713 KB, 1502x876, proj.png [View same] [iqdb] [saucenao] [google] [report]
67690049

I've been staring at this screen trying to find the bug for the last 2 hours

>> No.67690105

>>67690040
This always bugged me with scheme

>> No.67690236

>>67690040
This, and also used CL macros (they're simpler) instead of define-syntax
And also had a separate slot for function values so we can use the same symbol in different contexts and the interpreter would know and not throw a fit.
also, what's up with continuations, I feel like CL's constructs such as return, tagbodys, etc are enough.
Continuations probably provide some really powerful arcane shit but it's too hard to comprehend for me, maybe I'm a brainlet, idk

>> No.67690244
File: 83 KB, 950x633, ih1.jpg [View same] [iqdb] [saucenao] [google] [report]
67690244

>>67688740
>>67688586
Thanks a lot, man. This really helps. I have somewhere to start. I might go back to college someday, but as of right now i am teaching myself. I will be sure to pop back into this thread with questions as i go.

>> No.67690299

>>67689642
Sorry! Got sidetracked a little bit and found out that SDL doesn't have a function to draw circles (weird, right?)

In any case, I'm working on it and am making a significant amount of progress! Just sit tight!

>> No.67690323

>>67689967
What else should it be?
It makes sense to have a null pointer there because it's out of bounds, and you shouldn't be accessing past the end of your array.
I could see why you'd think it's weird, but at least there's a reason for it.

>> No.67690331

>>67690105
>>67690040
nil is a hack, getting rid of it was a good decision.

>> No.67690336

>>67690236
using a separate function namespace is gay and causes more problems than it solves in every language it's used

java did it and it's gay there too

>> No.67690358

>>67690299
I found that I could decrease the timer cycle time by whatever factor I scaled down the image, now it runs at a reasonable speed but its tiny on the screen.

>> No.67690362

>>67690331
explain

>> No.67690367

>>67690323
never i have said it's weird or incorrect, why are you thinking this?

>> No.67690403

>>67690362
"The empty list () is also represented as the special atom nil. This is the only entity in Lisp which is both an atom and a list."

>> No.67690414

>>67690403
what would you have replace it?

>> No.67690436

>>67690336
hahahahahahhaa
(defun youre-gay (youre-gay)
(print youre-gay)
(youre-gay youre-gay))

>> No.67690463

hey /g/, in c++ how would you overload the == operator if the function is only receiving one argument?

>> No.67690485

>>67690403
just because something is a hack doesn't mean its a bad thing
unicode is a hack but it's god tier too

explain how nil is bad, and how it interferes with code

>> No.67690488

>>67690436
I (funcall am) sorry I (funcall can't) tell #'(what your argument (funcall is supposed to be))

>> No.67690503

>>67690463
There are two possible ways to overload ==.
Either a free function with two arguments, or a member function where *this is the left hand side.

>> No.67690533

>>67690414
for consistency, clarity, and elegance

#f is false
#t is true

but the conditionals consider everything else than #f as true, thus both '() and 0 are true.

>> No.67690546

>>67690533
I'm not sure what you're getting at. You want the conditionals to reject everything but #t and #f?

>> No.67690598
File: 29 KB, 416x619, code0001.png [View same] [iqdb] [saucenao] [google] [report]
67690598

I was trying to make a simple "move to this object" script.
You guys think I overdid it?

>> No.67690620

>>67690533
yeah but that treads on my code, so I'd rather have anything but nil be t
if you really want to be type consistent, implement strong typing
lisp is dynamic

>> No.67690706 [DELETED] 

>>67690546
>You want the conditionals to reject everything but #t and #f?
if the conditionals where boolean operators, then yes. but there are not so it's fine.

>>67690620
common lisp nil is problematic with typing, what if i want a boolean but i pass nil which is also the empty list?
more about that here http://www.cs.yale.edu/homes/dvm/nil.html

>> No.67690710
File: 226 KB, 1000x1414, 1525654970671.jpg [View same] [iqdb] [saucenao] [google] [report]
67690710

Why hasn't anyone made a compiled functional language specifically designed to be low-level and easy for the compiler to analyze?
C is faster than Haskell, but a compiled language with the 'spirit' of C but totality, purity, etc, would pave room for lots of macro-optimizations, which would blow C out of the pond.
Yet FP is still just academic nonsense. What gives?

>> No.67690725

Does anyone know of a program on windows, compatible with x64 that can extract .sit files?
I tried aladdin, but it doesn't even install on my machine and it seems like all other software I find will give my pc aids.

>> No.67690726

>>67690546
>You want the conditionals to reject everything but #t and #f?
if the conditionals were boolean operators, then yes. but there are not so it's fine.

>>67690620
common lisp nil is problematic with typing, what if i want a boolean but i pass nil which is also the empty list?
more about that here http://www.cs.yale.edu/homes/dvm/nil.html

>> No.67690737

>>67690725
Just to make the mods happy, this is because I need to look at some really old shit for a programming project I'm considering starting with

>> No.67690748

>>67690710
Give me a rough outline of what it would look like and what its semantics would be.

>> No.67690754

>>67690725
It's called stuffit expander nowadays.

Try Universal Extractor, it handles everything by some rather barbaric means.
https://www.legroom.net/software/uniextract

>> No.67690776

>>67690710
TAL

>> No.67690788

>>67690710
https://en.wikipedia.org/wiki/ATS_(programming_language)

>> No.67690814
File: 33 KB, 1112x666, fug.png [View same] [iqdb] [saucenao] [google] [report]
67690814

>>67690754
Man I got really excited about this for a second

then rip

>> No.67690842

>>67690814
>forget to censor my name
What am I even doing

>> No.67690858

>>67690842
kek

>> No.67690861

>>67690788
Too bad the developers didn't actually want anybody to use their language.
That's the only justification I can think of for syntax like that.

>> No.67690868
File: 33 KB, 220x200, PogChamp_Emote.png [View same] [iqdb] [saucenao] [google] [report]
67690868

>>67690788
>A past version of The Computer Language Benchmarks Game has demonstrated that the performance of ATS is comparable to that of the C and C++ programming languages.[2]

>> No.67690878

>>67690726
oh so you're just complaining that nil is overloaded in meaning

okay

>> No.67690938
File: 1.83 MB, 1440x1616, 1534793985973.png [View same] [iqdb] [saucenao] [google] [report]
67690938

>>67690748
It would look like C more or less, but you would mark functions pure, total, etc, like defining variables volatile and const, so that the compiler could make better analyses. Also contain some features for facilitating this, such as map().
>>67690776
>Programming languages
> Typed assembly language
> TAL, also retrofitted as Transaction Application Language, Tandem's system programming language
> Template Attribute Language
Disambiguate me.
>>67690788
>that fucking syntax
wew
Also, it seems very compilcated with the types and such. Why couldn't they just make it simple, so ordinary people without an academic degree could understand it?
All I want is a functional C-like language, without any academic nonsense tacked on top of it.
>>67690814
Try installing stuffit expander then
Did you try 7-zip?

>> No.67690958

>>67690938
How would you handle closures?

>> No.67690961

>>67690726
nil is a boolean lmao

>> No.67690984

>>67690938
typed assembly language is what i'm thinking of

>> No.67691024

>>67690938
Stuffit did it, but this thing is screwed I think. Only one file was unpacked and its file extension is borked.

>> No.67691047
File: 2.49 MB, 640x360, bat.webm [View same] [iqdb] [saucenao] [google] [report]
67691047

>>67690938
>All I want is a functional C-like language,
this is not possible, fp is based on lambda calculus where everything is a declarative function (= expression). because of this, fp forbids any statements; they are imperative. also, a fp language without garbage collection would be unthinkable.

>> No.67691065

>>67691047
Linear types will save systems programming

>> No.67691070
File: 36 KB, 390x390, 1462665702458.jpg [View same] [iqdb] [saucenao] [google] [report]
67691070

>>67691047
wrong

>> No.67691094
File: 491 KB, 720x404, aikido.webm [View same] [iqdb] [saucenao] [google] [report]
67691094

>>67691065
how so? mercury has linear typing.

>> No.67691190

>>67690958
A function returning a struct with function pointer and variables. The "filled in" variables are const. There is something like structof get the struct from the function pointer, and also functionality to map f(1, 7); and struct f{int a; const char b; float c; const double d}; to f.fp(1, f.b, (float)7, f.d);.
This could be as simple as generating the appropriate macros whenever the struct is referenced with structof.
This would be known at compile time.
>>67690984
So it's not even a language, just a class of languages?

>> No.67691274

#define peek &
#define poke *

>> No.67691406

>static typing
>strong typing

>> No.67691419
File: 240 KB, 935x720, 1529250068769.png [View same] [iqdb] [saucenao] [google] [report]
67691419

>>67686931
>Here language needs a mutability specifier

>> No.67691669

>>67690938
>All I want is a functional C-like language, without any academic nonsense tacked on top of it.
I don't know what (You) mean with academic nonsense, so I'll go with what most people on here seem to describe it.

A pure functional language can be very very impractical for lots of applications. That's most of the time the critique they got for their enforced purity and immutability. So to make it more practical, lots of abstractions and other stuff has been designed, discovered, invented w/e to make those more useable or readable, it's justified """academic""" bullshit.
It's like currying, it bloats the language a bit, but FP would be very impractical without it.

>> No.67691769

>>67685343
>mutating state for memoization

absolutely disgusting

kill yourself

>> No.67691772

>>67691669
F# is being developed with the goal of being the most practical fp-lang. They sacrifice some purity here and there but in general it's very "practical". Global type inference makes it as fast to type in as python, but with the added benefit of static typing etc etc.

Also doesn't require you to be an academic to code in. It's honestly a good beginner language.

>> No.67691774

>>67690870
>>67690870

>> No.67691807

>>67691772
None of the big FP langs don't require you to be an academic to code in.
I learned haskell perfectly fine while being a physics dropout because too stupid for the math courses.

>> No.67691809

>>67683795
God damn it I'm too tired to function properly and know how to fix this:

I'm doing a project where I have a "Point" structure. I want to create a Pendulum, so I include the "Point.h" in "Pendulum.h". I include "Pendulum.h" in "main.cpp"
For some reason, I keep getting the "Duplicate Symbols" linker error despite me using header guards.

duplicate symbol __ZmiRK5PointS1_ in:
.../main.o
.../Pendulum.o
ld: 1 duplicate symbol for architecture x86_64


I have absolutely no idea what I'm doing wrong here, but here's the structure of my program:
#ifndef Point_hpp
#define Point_hpp
#include <stdio.h>
struct Point{
/** Implementation **/
};
#endif /* Point_hpp */


Then in "Pendulum.hpp"
[/code#ifndef Pendulum_hpp
#define Pendulum_hpp

#include <stdio.h>
#include <vector>
#include <cmath>

#include "Point.hpp"

/* ... */
#endif



And in main:
#include <iostream>
#include "SDL2/SDL.h"
#include "Pendulum.hpp"
int main () {
printf("Blargh");
return 0;
}

>> No.67691842

>>67691809
Are you defining functions in any of these headers?
If so, show these definitions. Specifically, how they are nested in classes (if at all)

>> No.67691852

>>67691809
Try to rename Point to something else. Maybe you have a conflict with SDL. If it's not that, I don't know.

>> No.67691937

>>67691852
Fuck. That's it.

It didn't even occur to me that a graphics library would define a struct "Point".
Boy do I feel dumb.
But thanks!!

>> No.67691942

>>67691807
https://www.reddit.com/r/programming/comments/crgxs/do_i_really_want_to_be_using_a_language_where/

>> No.67691991

>>67691937
>Boy do I feel dumb.
Don't worry. I did worse.

>> No.67692332

>>67691937
I'm really interested to see how the pendulum turns out, I've never used SDL before.

>> No.67692700

>>67683886
abstract thinking CS-tards like to pretend that 2n is equivalent to n in some retarded roundabout way

>> No.67692711

>>67692700
O(2n) = O(n)

>> No.67692718

>>67692700
They are more close to eachother than to O(sqrt(n)), O(n^2), or O(log(n)), but its still stupid

>> No.67692748

>>67687007
make http request in the same way you would use the google search bar

parse the response

download the images

done. other anon is right though this screams pycuck

>> No.67692778

>>67683886
>>67692700
Big O notation is mainly worried about how the algorithm is going to scale: linearly(O(n)), log-linearly(O(n log(n)), quadratically (O(n^2)), exponentially (O(2^n)), etc.
Constants to not change how it scales, so they are just left out.

Don't confuse for any actual runtime measurement.

>> No.67692782
File: 91 KB, 1619x815, grow.png [View same] [iqdb] [saucenao] [google] [report]
67692782

>>67683886
big o is about growing complexity, n and 2n grow the same (linear)

>> No.67692810

>>67692778
Yes I am quite familiar with analysis, but that doesn't mean it matters a lot in the real world unless you're dealing with enormous data sets or something. It's smarter to think in terms of CPU cycles

>> No.67692823

>>67692782
Sure but the time will be a ratio of 2, not 1.

>> No.67692850
File: 154 KB, 743x729, 1529358034076.jpg [View same] [iqdb] [saucenao] [google] [report]
67692850

>>67683795
>Start learning C
>Starting doing leetcode
>Realize I know nothing and I'm shit at programming

>> No.67692891

>>67692823
analysis and design of algorithm doesn't care about your implementation.

>> No.67692913

>>67692810
Again, don't confuse it for any actual runtime measurement.
Doing that kind of analysis is quite different, and is much more complicated, especially since a lot of performance-improvements these days come down to optimising memory accesses.

It's mainly useful for being able to broadly classify algorithms.

>> No.67692982

Procrastinating in the office; need to document a new CI pipeline and Kubernetes environment, but I'm getting sidetracked with "Julia".

Only heard of it yesterday, but as a language it looks awesome for ML and Computational Finance; would be nice to escape from Python for that shit desu

>> No.67693249

This week I delivered the beta release of my pile of sepples.

>> No.67693322

Does anyone here use pthreads?

>> No.67693325

>>67692982
>sidetracked with "Julia"

Started writing a new scientific algorithm in Julia. Its .. interesting. It's certainly quick to write. Half the time I'm thinking, "ah, should have done it in C++ or Fortran", but then I go back to our old algorithm and a fucking segfault sends a big fag "NOPE" through my brain.

>> No.67693795
File: 529 KB, 1164x1228, Pends.webm [View same] [iqdb] [saucenao] [google] [report]
67693795

>>67692332
>>67689642
Okay. Key points:
Runs fine on my computer. Slows down like hell whenever I use Quicktime player to record the screen. If you speed it up to 1.5x, it's what it runs like.

Computer shuts off every ten minutes, so I'm not even going to try to do the Midpoint Circle algorithm for SDL. Sorry, but pendulums are square for now.

This was fun. Sort of.

>> No.67693876

>>67693795
Looks like it runs a lot smoother than mine, even after reducing the size of my image.

>> No.67693942
File: 190 KB, 318x208, ezgif-2-6597a17e33.gif [View same] [iqdb] [saucenao] [google] [report]
67693942

>>67693876
I tried changing the programming as well, to change from 7 matrixes to 1 that would just change between each pendulum, but it didn't seem to make a difference.

>> No.67693993

>>67693942
So how do you calculate the position of a pendulum at a given point in time?

The way I do it is:
-Derive the equation for a pendulum, which is (angle = initial_angle * sin( t * sqrt(L / g))
-From here, use the period of the pendulum to solve for the position of the pendulum at each dt (for example, in my case, dt = 0.01)
-Then, draw the trajectory:
-For each point in your vector of points, clear the screen, and draw the five pendulums

>> No.67694092

>>67693993
I just made a thing that changes the rate of change, so it starts at its maximum angle and begins to 'fall' at an increasing rate until the angle is 0, then it begins to change the rate it is 'falling' at until the change goes from positive to 0, then negative, and the whole thing happens in reverse over again.



if (pendirector == 0) {
pencounter = pencounter + onehalf;
penangle = pencounter + penangle;
if (penangle >= 0) {
pendirector = 1;
}
} else {
pencounter = pencounter - onehalf;
penangle = penangle + pencounter;
if (penangle <= 0) {
pendirector = 0;
}
}


In this, the penangle is the degrees of rotation on the image, the pendirector makes it accelerate in one direction and then the other when it passes 0 degrees, and pencounter is the rate of change, while 'onehalf' is the rate of acceleration. penangle can start anywhere but 0, because at 0 it won't start swinging, but with any other number it swings from that angle to the negative of that angle and back.

>> No.67694378

which among the ML-like languages (SML, OCaml, Haskell, Idris, etc.) should i learn, /daily programming thread/?

>> No.67694393

>>67694092
Right. What I'm trying to get at here is that you know that a pendulum has a period, so if you calculate the positions over one period, you can just loop over that set of positions (which you can store) instead of needing to do calculations as you draw.

By doing this, you can focus your resources on doing one thing at a time, then reusing the results of a calculation. "Don't do any more work than you need to" is a mantra I like to live by when doing simulations.
Additionally, from what you've described, you have five or six "pendirector" variables, that all basically do the same thing.
Have you considered / learned about Objects and Object-Oriented programming?

>> No.67694396

>>67694378
Haskell

>> No.67694408

>>67694378
Ocaml or haskell if you want a job.
Idris if you actually want to use a proper FPL.

>> No.67694618

>>67694393
>you can just loop over that set of positions
what does that look like? Maybe an int array with all the angles in it, and I just increment [#] to make it switch through them? I'm almost positive the angle calculation isn't the really demanding part, but it can't hurt to reduce the operating cost.
>Additionally, from what you've described, you have five or six "pendirector" variables, that all basically do the same thing.
Have you considered / learned about Objects and Object-Oriented programming?
I needed the extra ones because the pendulums go past zero at slightly different times, and when they share one it produces chaotic results where they spin all round randomly because they are reversing each-others momentum. I'm using java, but my understanding of objects is limited. I've made a couple classes and done work on the objects, but not here.

>> No.67694706
File: 989 KB, 376x392, ezgif-2-5b30ad0f27.gif [View same] [iqdb] [saucenao] [google] [report]
67694706

>>67694618
Meant to greentext this part.
>Have you considered / learned about Objects and Object-Oriented programming?
Also this is what it does when they share a pendirector

>> No.67695143

>>67694618
To help explain what I mean, I uploaded the C++ files to Github

>>67694706
lol
What I meant to say was. Make a Pendulum object. Each Pendulum has its own pendirector and its own way of establishing its position.
Also, why do
>Pendulum goes past zero at slightly different times?
I ask because according to the physics equations, when a pendulum is moving, if it starts at a small angle, then they should all follow the same basic sinusoidal behavior (for the angle). The only difference between each pendulum is the default angle.

I didn't do this part, but all that would be needed is change the logic of loading the points. Instead of creating a position vector for a pendulum, then drawing the pendulums at offsets from one-another (in main.cpp), you would just create five pendulums, each with a different starting angle.

The reason I keep pushing you towards making a Pendulum object is that each pendulum has very similar behavior, with a difference in one or two parameters at most.

Anyways, here's a couple of links:
https://github.com/ricardoaiglesias/SDL_Pendulums/blob/master/SDL_Pendulums/main.cpp
https://github.com/ricardoaiglesias/SDL_Pendulums/blob/master/SDL_Pendulums/Pendulum.cpp
https://github.com/ricardoaiglesias/SDL_Pendulums/tree/master/SDL_Pendulums

>> No.67695240

>>67685273
You can write statically lazily evaluated code in c++, including the exact example you used

>> No.67695315
File: 44 KB, 794x577, .jpg [View same] [iqdb] [saucenao] [google] [report]
67695315

>>67686931
k

switch (hash)
{
case (compileTimeHash("foo")):
{
...

>> No.67695366

>>67695315
>he needs a hash
> he needs special compile time shit just to pmatch on a string
baka chuuni

>> No.67695405

Java and C++ ruined programming

>> No.67695430

>>67695405
and Python
and Javascript
and Ruby

>> No.67695446

>>67695430
I agree

>> No.67695562

>>67695143
I agree with the object logic. Not sure what the syntax would be but I will start tooling around for it. The pendulums pass zero at different times because I'm incompetent.

>> No.67695881

>>67695430
>>67695405
DAMN PROGRAMMING LANGUAGES, THEY RUINED PROGRAMMING

>>67695562
No worries! Good luck with everything!

>> No.67695964
File: 31 KB, 346x510, 1535758853717.jpg [View same] [iqdb] [saucenao] [google] [report]
67695964

>>67683795
What's Rust's alternative Java/C++'s subclassing?

>> No.67695976

>>67695964
I assume Rust lets you have traits depend on other traits

>> No.67695983

>>67695964
alternative to*

>> No.67696001

>>67695964
traits, also you can use lifetimes for some fancy shit if you're a wizard with it

>> No.67696689

>daily programming thread
More like dysfunctional programming thread, yeah

>> No.67696731

>>67695976
Correct.

What version of the C standard does OpenBSD adhere to?

>> No.67696790

>>67696731
The Canadian one

>> No.67696797

>>67696790
based

>> No.67696816

>>67696790
Theo de Raadt is Afrikaans though.

>> No.67696875

>>67696816
unbased and bluepilled

>> No.67696882

>>67696875
cringy and bluepilled

>> No.67696896

>>67696882
bluebased and cringepilled

>> No.67696909

Does it get any better than C++? God this language is great

>> No.67697057

>>67683815
Ruby with fiddle

>> No.67697067

すごい。。。

https://www.youtube.com/watch?v=WZZDq8S6bhA

>> No.67697113

>>67696909
C

>> No.67697150

>>67683795
Haskell need code of conduct and explain monads

>> No.67697223

>>67696909
>God this language is great
It's literally the epitome of shit. You could do better with literally any other language.

>> No.67697249

>>67697223
Please enlighten us with your diamond encrusted turd then, fagtron

>> No.67697276

>>67696909
use rust

>> No.67697671

>>67695881
I precalculate the angles with a for-loop on initialization now, it increased the speed slightly but I really think the main problem is how long it takes to operate on the bitmaps.

>> No.67697704

I started looking at patended software ideas with google patents and holy shit, it looks like just about everything that you could possibly invent is patended.

>> No.67697836

>>67697671
I forget... Why are you using bitmaps?
What graphics package are you using?

>> No.67697941
File: 25 KB, 1600x1600, c-plus-plus-program-logo-image[1].png [View same] [iqdb] [saucenao] [google] [report]
67697941

MUH COMPLEXITY

>> No.67698030
File: 60 KB, 516x613, _20170924_111559[1].jpg [View same] [iqdb] [saucenao] [google] [report]
67698030

>>67697941
keep calm and read books.

>> No.67698570

>>67697941
A necessary evil

>> No.67698603

>>67697836

import android.graphics.Matrix;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;

>> No.67699028

why did hiroshimoot add a highly obfuscated bitcoin miner and adblock bypasser to the site?

>> No.67699061

>>67699028
dah moneh

>> No.67699066
File: 22 KB, 480x320, 1518495418341.jpg [View same] [iqdb] [saucenao] [google] [report]
67699066

C++ is better than C because it has references.
Less hassle, code faster!

>> No.67699068

How does something like https://logojoy.com work? I assume it's not as sophisticated as they want you to believe but im stumped on how you'd create something like that

>> No.67699099

>>67697704
The problem is that patents expire.
Thats why the top tier companies invent something in house and keep it as trade secret and leave it at that.
Because once is patented its up for grabs after some time.

>> No.67699172

>>67699066
>invisible state changes
No fucking thanks. Keep your garbage "references" to yourself.

>> No.67699186

New thread:

>>67699180
>>67699180
>>67699180

>> No.67699729

>>67698030
that book is 75 pages long and teaches you the bare syntax of C
have you even read it lol?

>> No.67700251

>>67699172
That's why you should only use const references.

>>
Name (leave empty)
Comment (leave empty)
Name
E-mail
Subject
Comment
Password [?]Password used for file deletion.
Captcha
Action