[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: 393
Thread images: 31

File: RMS_Dating_Sim.jpg (381KB, 1680x1050px) Image search: [Google]
RMS_Dating_Sim.jpg
381KB, 1680x1050px
What are you working on, /g/?

Old thread: >>57660748
>>
first (reserved for later)
>>
>>57667266
The next Facebook
>>
>>57667266
Should I learn x86 or x64 assembly?
>>
>>57667305
x86.

x64, amd64 or x86_64 is backwards compatible with it. Basically the architecture is "x86 in 64 bits". Most of the concepts related to asm language translate to amd64, and others architectures like arm.
>>
>>57667361
I sometimes see programs called pure x64 or distros called pure 64 bit and 32 bit programs won't work with it without the 32 bit libraries installed. What's up with that?
>>
I have a device that runs php for web stuff, also i can run python scripts, but cant use python for web stuff.

Is it possible to use a php proxy page to a django page? If so how?
>>
>>57667460
Thanks, I'll checkout out what line causes the issue.
>>
File: Capture.png (17KB, 727x422px) Image search: [Google]
Capture.png
17KB, 727x422px
I'm making a recipe-costing program for my sister! Wish me luck!
>>
>>57667617
It's somewhere in the reading, so double check what the args are
>>
>>57667525
There is no "pure 64 bits", probably some commercial thing. amd64 is a processor architecture that runs programs compiled in amd64 or runs programs in legacy x86 (32 bits) mode. You can run, on those systems, programs compiled in x86 because amd64 is compatible with that architecture and understands those instructions in legacy mode.

You need the 32 bits libraries because the program compiled in x86 needs them, it is called dynamic linking. In Debian/Ubuntu
dpkg --add-architecture i368
. You can make a x86 program that is just return 0; in main and you won't have any library dependencies so you can run it without installing anything else.

>>57667595
Configure your http server properly to handle CGI requests.
>>
>>57667273
>pass user since 2016

what a gay
>>
>>57667647
Any recommended x86 assembly books?
>>
>>57667654
>using haskell in 2016
that's gay
>>
>>57667703
Compile something with some functions and some input/output and play with ollydgb. I never read anything, just resources on the internet and general computer knowledge. A friend at that time was helping me as well (he was decompiling some binaries into C).

The best books on asm are the manuals from intel or amd (amd one is simpler iirc).
>>
>>57667703
http://support.amd.com/TechDocs/24592.pdf

You are welcome.
>>
>>57667703
Just find some 1980/90s textfile guides
>>
>>57667763
>>57667794
I have an Intel processor. How compatible is the AMD manual going to be?
>>
>>57667850
The architecture is the same on both processors. The manual is on the architecture, not on specific AMD processors. They have different extensions but it doesn't matter.
>>
File: Screenshot_741.png (191KB, 900x680px) Image search: [Google]
Screenshot_741.png
191KB, 900x680px
Anybody mind giving me a helping hand for my homework?
Like they are 4 more questions but only this first one confuses me.
It's supposed to be written in pseudo code.
Am i supposed to reach the input of data id last name etc.
or is that data already in the program and i have to read the data from the program then print?
>>
>>57667907
>The data entry clear is required to enter data
The data shouldn't be in the program, you have to read it, do the calculations, and print.
>>
>>57667628
Anon when you're done with the primary functions you have planned. Make a tool that scrapes advertisement PDF's (the ones that local stores send you if you ask for it) for deals so she can optimize her purchases. More often than not they got all the info embedded. I'm not sure if stores have good databases for prices, likely not. Because it's a competitive edge to keep that less accessible. But if you can find that too she would probably be super impressed.

And then maybe you could get genuine girl-worn panties. With +2 to programming skill. That would be amazing.
>>
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
This is the best thing I've ever seen.
>>
>>57667907
So the program should start of as.
Print "Enter employee last name, gross pay and tax"
Read Last Name, Gross pay, Tax.

something like that?
>>
Anybody uses Java?

How Do I pass a value from a JFRAME to it's parent JDialog?
>>
What's the best way to host a static html site, /dpt/? Github?
>>
How do I edit a buffer in WebGL?
I'm wanting to make a game with terrain deformation (tunneling and shiet) but I don't want to recreate the whole buffer every time a swuvle hits the wall.
>>
>>57668194
Raspberry Pi
>>
>>57668116
>no design plan or documentation
>no UML class diagram
>no test plan
>no coding guidelines

0/10 wouldn't pass code review
>>
>>57668192
>Java
see >>57668116
If you have proper code infrastructure to show off, come back and ask that question again.
>>
>>57668198
re-submit the edited data?
>>
Are there any instruction extensions that GCC doesnt compile for on my computer (AMD FX6300)?
>>
>>57668226
Yeah, no and that's not the answer I was looking for, thanks for trying. (only answer if you really know and not pretend)
>>
hi people
I'm next to enter to high school and my father wanted me to pick a real programming language (I used pascal a lot to solve math problems during mid school). I read a lot of things about haskell in this forum, so I think I will pick haskell
just a question I have: what is haskell good for? my father uses a lot of fortran which is good for maths, so I wonder that in what haskell excells? thanks you
>>
File: 1475296277247.jpg (17KB, 319x240px) Image search: [Google]
1475296277247.jpg
17KB, 319x240px
>>57668235
>person who doesn't even know WebGL tries to answer WebGL question and says to do what I specified I didn't want to do
>as is usual for /dpt/ and /sqt/, because the question now has a reply it won't be answered
>>
>>57668261
abstraction safety sanity conciseness flexibility
>>
>>57668283
>>>/s/tackoverflow/
>>
>>57668221
There are some issues related to that, for examle https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition/issues/248
It has a very active community.
>>
>>57668292
well, what I mean is what problems does it solve? thanks you
>>
>>57668283
>re-submitting is the same as re-creating
anyway look for a bufferSubdata
>>
>>57668318
it's a general purpose programming language
>>
Code validation works now!
The error messages are crappy but that's a whole another topic!
>>
>>57668366
is that the abstract syntax tree, on the left?

how did you implement it?
>>
>>57668345
so, you are saying it really doesn't excell at anything? my father told me that fortran is very good at numbers while being very bad at text processing, that's why I wondered what are the strenghts of haskell? thanks you anyway
>>
>>57668261
Learn C
>>
File: 1455996230188.jpg (289KB, 797x748px) Image search: [Google]
1455996230188.jpg
289KB, 797x748px
>>57668302
>stackoverflow

>>57668320
Oh, I totally forgot bufferSubdata was a thing!
>>
>>57668194
https://neocities.org/
>>
>>57668384
composability
it's pretty good for DSLs too
>>
Is TIS-100 reference manual really only 14 pages? I thought it was a hundred pages.
>>
>>57668246
like avx512?
>>
>>57667361
TempleOS isn't compatible with x86 asm
>>
>>57668386
I was reading about C right now. I mean, both C and haskell are compiled, and C is faster than haskell while also being general. As a plus, seems like there aren't jobs for haskell programmers. I think C will be my pick then.
Thanks you all very much.
>>
>>57668408
but what are the specific strengths of it? thank you
>>
>>57668558
i've told you like 6 or 7 at this point
>>
>>57668569
those aren't usable strenghts faggot, tell him real strenghts
>>
>>57668383
It is indeed an abstract syntax tree.
I wrote this shit in C, and the cleanest way I found was to have a union with a struct for every specific node type. For nodes with a variable number of children, I used my generic implementation of a linked list. Pic related, it's the node struct.
>>
>>57668613
I should also say that I used recursive descent parser (https://en.wikipedia.org/wiki/Recursive_descent_parser) which is the simplest way to parse code.
>>
>>57668613
Also known as tagged unions, they're the poor man's ADT.
>>
>>57668613
really nice.

i had to build a compiler for my class, and i had to do something like this, but didn't.

is the code available somewhere, so i can study?

if not, its alright
>>
>>57668501
Does TempleOS come with 32 bit libraries to make use of x86 assembly?
>>
>>57668613
It's places like these where I miss OOP the most.
>>
>>57668645
It's pretty shitty at the moment, and everything's implemented from scratch (yay, learning), but sure. The code's on my own server, I'll make a GitHub mirror in a moment. It doesn't take parameters, and just loads "test.txt" from the current directory.
>>
>>57668530
If you are still considering it, pick Python. It's simple, you write what you think if you are already used to write code. It also makes you very hireable in scientific related fields (I think your father is one). It also has many libraries. Per se is slower than anything, but a lot of libraries are in C or FORTRAN, so you gain speed there. It also supports a functional style if you want to pick haskell later. Just avoid the 3.x version and stay in 2.7
>>
>>57668685
thanks anon!

i really appreciate it.
>>
>>57668700
my father also use python, that's why I wanted to learn haskell, so I can troll him as you shitpost here with haskell.
Thanks you anyway
>>
>>57668676
Absolutely. I found no better way to do this in C, and C++ comes with just too much baggage and stuff. It's probably some form of compulsive behavior for me to prefer C, but idk.

>>57668709
https://github.com/DanilaFe/chlang/tree/development
>>
>>57668600

this is the exact thing haskell is exceptional at
>>57668613
>>
How do I break an infinite while loop that is inside the main using a function that is inside the header file ?
>>
>>57668753
>https://github.com/DanilaFe/chlang/tree/development
thanks!
>>
>>57668762
Can Haskell do this? Jk. To each their own. I use C because I'm probably on the spectrum.
>>
Code A (source: Haskell Data Analysis Cookbook)
import Text.CSV

-- Parses a CSV file
main :: IO ()
main = do
let fileName = "input.csv"
input <- readFile fileName
let csv = parseCSV fileName input
either handleError doWork csv

handleError csv = putStrLn "not a CSV"
doWork csv = (print.findOldest.tail) (filter (\x -> length x == 2) csv)

-- Finds oldest person.
findOldest :: [Record] -> Record
findOldest [] = []
findOldest items = foldl1 (\a x -> if age x > age a then x else a) items

age [a,b] = toInt b

toInt :: String -> Int
toInt = read

vs Code B (source: me)
import pandas as pd
table = pd.read_csv("input.csv")
print table[table.age == max(table.age)]
>>
>>57667266
Is that a boy or girl's room?
>>
>>57668882
birl
>>
>>57668827
unlikely desu

but working with tagged unions is exceptionally nice in Haskell

>>57668860
I'm sorry to hear that you suffer from amnesia, and apparently have forgotten we already discussed this

The haskell library you are using does not have as much of the work boiled into it, it's a pure language and so you can't do the C style sideEffectFunction(sideEffectFunction()), and the example code is shit
>>
>>57668912
I'm more sorry to hear that you are stuck in haskell. Btw, that's the recipe of the book and I find a book being a better source than you.
>>
>>57668945
Why are you so mad that people use Haskell?
Mad enough to write such dishonest posts?
>>
>>57668945
nigga, i wrote the book
>>
>>57668860
/dpt/ will still argue about this
>>
>>57668956
I'm not mad at people, I'm mad at false promises. At least I didn't bought that book.
>>
I'm new to Java and I have a question about JComboBox.

I would like to add an array to a JComboBox. The array objects would have 3 different variables, including a name string. In the JComboBox I would only want the name to appear in the options that you can select. How would I go about this? It does sound pretty simple.

I could add the names of the array objects one by one but that wouldn't include the other variables, would it? That is, if one were to pick one of the objects with the names, it would not include the other different variables so you can't really use it, or perhaps I'm thinking about this the wrong way.

I suppose I could add a second step by going through the arraylist again and look for the one name that matches the one that was picked but is that really the simplest approach?
>>
>>57669014
You're butthurt about Haskell
It's clear for everyone to see

If you were mad about false promises you would be a lot more honest
>>
>>57669034
Honest in what sense? I cited even the source of the code, so it wasn't a lie. Or maybe the buthurt is someone else who needs to write a fuckton of code to do simple tasks?
>>
>>57669069
Wow, I guess you really DO have amnesia then.
To so conveniently forget all the responses.
>>
>>57669021
a dictionary or hashmap with the name of the array mapped to the array itself.
only put the name of the array in the JComboBox, and then get whatever is selected in the JComboBox from the hashmap.
>>
>>57669094
so convenient is to avoid the argument
>>
>>57668860
in Haskell this is just

import Data.List (sortBy)
import Data.Function (on)
import Text.CSV (parseCSV)

filename = "input.csv"

main = do
Right success <- parseCSV <$> readFile filename
work sucess

work = oldest . tail . filter ((==) 2 . length)
oldest = last . sortBy (compare `on` age)
age [_, b] = read b :: Int

>>
>>57669188
whoops
parseCSV filename <$> readFile filename

Not sure what that duplication achieves though
weird library
>>
File: scrotum2.png (120KB, 1156x565px) Image search: [Google]
scrotum2.png
120KB, 1156x565px
>>57669188
too bad man, too bad
>>
>>57669222
whoops

print $ work success
i don't have Text.CSV so i can't really work with it
>>
>>57667266
>dat pic
>>
What the fuck is this Haskell shitstorm?
>>
File: 1480012823873.png (674KB, 800x2637px) Image search: [Google]
1480012823873.png
674KB, 800x2637px
>>57667266
Gnosis... knowledge storage and "Question Engine" for GeneralAI.
One of the constexpr lookup-tables is giving me hassle.
Like C++14 but it's an ass-ache that you can't appear to use floaing-point in constexpr classes.
Taking a rest from that fucker...

You?
>>
>>57669257
the guy bought a book from a pajeet who doesn't even know haskell
>>
>>57669257
There are a series of autists in these threads desperate to show how horrible Haskell is by taking some badly written Haskell code and comparing it to importing a Python library.

This is the latest incarnation, "data scientist" anon posts the code and yet mysteriously when you reply to him with an improvement, he doesn't make the change the next time he posts it. I'm guessing next time the code will somehow become even worse.
>>
>>57668800
Yo, do you mind cloning the code and letting me take down the mirror? It's bothering me that the code is in two places at once... Sorry.
>>
>>57669282
I tested your code, it didn't worked, so another false promise.
>>
File: 148002698855.png (245KB, 800x2637px) Image search: [Google]
148002698855.png
245KB, 800x2637px
>>57669272
your png is now optimized
>>
>>57669307
>it didn't work
Do you mean it didn't report the error when you gave it bad data?
That's because I didn't handle the error.
I was trying to match the python code.
>>
>>57669303
sure.

i'll download the repository
>>
File: scrotum3.png (28KB, 658x169px) Image search: [Google]
scrotum3.png
28KB, 658x169px
>>57669324
Data seems good enough for python to handle, so the question is: what's wrong with haskell?
>>
>>57669352
the library you're using is broken then

>what's wrong with haskell
i thought the question was
"why is haskell so verbose"
did the original code you posted work
>>
File: scrotum4.png (28KB, 678x143px) Image search: [Google]
scrotum4.png
28KB, 678x143px
>>57669368
the output is a little uglier, but works well enough
>>
>>57669368
>blaming the library for working correctly
>>
>>57669385
>leonardo
where u from?
>>
>>57669352
>>57669385
wait, you didn't even do >>57669204
did you? let alone >>57669233
>>
Python is shit but more useful than haskell
>>
God member initialization lists are so ugly. It's impossible to make longer ones look nice, either you get this fucked up half-indent with random shit trailing and then your opening brace on the last line or you have to put your opening brace on the new line and get what looks like a lot of wasted space.
>>
File: xvYrFVv.jpg (96KB, 944x712px) Image search: [Google]
xvYrFVv.jpg
96KB, 944x712px
I'm probably going to get a couple "figure it out retard"s, but how do you guys determine what company you want to work at?

Does the company make shit you think is cool? Does it just pay the bills? Give me your motivations.
>>
>>57669447
They accept to pay me for doing OCaml.
>>
>>57669447
Does the company make shit you think is cool and pay the bills?

there you go.
>>
>>57669447
I'm more for shit that I support. Money will come eventualy and but stress is worse than $5k per year (that you will expend in your stomach ache).
>>
In Java, is it best to create an Array of 300 Sprites, each with individual coordinates, but the same position and size.

Or create an Array of 300 Vector2s, and draw the single texture to these positions?

I need optimal performance
>>
>>57669403
Why exactly is python shit?
The only flaw of python is performance, which was specifically given up to improve everything else.
>>
>>57669487
the guy will say that indentation and stuff, but haskell will also break the ball at bad indentation
>>
>>57669481
Whichever follows the flyweight pattern
>>
>>57669385
>>57669400

import Data.Function (on)
import Data.List (maximumBy, intercalate)
import Text.CSV (parseCSVFromFile)

main = do
Right success <- parseCSVFromFile "input.csv"
work success

work = putStrLn . intercalate "\t"
. maximumBy (compare `on` age)
. tail . filter ((==) 2 . length)

age [_, b] = read b :: Int


>>57669487
>the only flaw of Python is performance
this is bait, right?
>>
>>57669481
int[][] spriteIds;
Use like:
for y in range (0, 30):
for x in range (0, 100):
draw(x, y, spriteSheet[spriteIds[y][x]])


Or whatever your language's equivalent is.
>>
Potentially retarded question from a non-programmer inc:

Do the majority of bugs in software come from typos during the writing of the source or just incorrect usage of otherwise correct pieces of code?

I guess another way to phrase the question would be do most bugs come from mistakes at the keyboard or mistakes at the brain?
>>
File: scrotum6.png (108KB, 1114x312px) Image search: [Google]
scrotum6.png
108KB, 1114x312px
>>57669523
amazed that took you 20 minutes to come with a non working code, again.
>>
Is dynamic programming great or what?
>>
>>57669597
I have no idea why that isn't working

You did test the code you originally posted, right?
>>
>>57669590
IDE's pretty much highlight syntax errors, so most bugs are just things that were unaccounted for or lack of experience.
>>
>>57669546
Hadn't heard of this, thanks anon.
I can actually not use either array, as I already have one for the particles (i am so dumb)

>>57669546
I'll look this up, thanks for the suggestion
>>
>>57669590
Generally mistakes at the brain. Typos usually result in compile-time errors, or in simple terms, the program won't even start and its very clear why. Those often never go into release. Most bugs come from simply overlooking certain use-case scenarios or failing to fully understand how their code works. A lot of software depends on other software in the form of libraries and often programmers will use them without fully understanding them, and causing "random" behaviour.

That isn't to say typos aren't common, they do happen and cause problems sometimes. I recall a project that had a commit on github removing a space from the uninstall function, which caused the program to delete /usr instead of /usr/programname.
>>
>>57669590
99% of errors made by "real" programmers, that is to say not beginners but career professionals, come from errors in the program logic, or from unforeseen consequences of something etc.

The whole "oops I missed a semi-colon teehee" thing is a meme from first-year comp sci students. Those things are caught immediately by any decent compiler/interpreter (basically the program that turns your code into something the computer can execute).
>>
File: csv.png (3KB, 225x86px) Image search: [Google]
csv.png
3KB, 225x86px
>>57669597
>>57669609
Works fine for me
>>
>>57669664
The csv has the age as the first row. And that makes me think why the longer haskell code needs explicitly the structure of the csv file? what if the csv file has hundred of fields?
>>
Which programming language will land be a well paying job?
>>
wtf is going on here
λ> import qualified Data.Map.Strict as Map
λ> Map.insert 5 3 Map.empty
fromList [(5,3)]
λ> let a = Map.insert 5 3 Map.empty
λ> a
fromList [(5,3)]
λ> let a = Map.insert 3 2 a
λ> a
fromList


it just says fromList and then does nothing. i have to ctrl c
>>
>>57669698
Java if you don't mind pajeet competition.
>>
>>57669693
>the csv has the age as the first row
Nuh uh.
>>57668860
>age [a,b] = toInt b
>>
>>57669698
JavaScript
>>
>>57669710
You're trying to create a strict infinite map
It won't terminate
>>
>>57669698
Java, JavaScript, Scala, F#, C++. Scala being the highest paying, Java being the easiest to employ.
>>
>>57669710
>let a = Map.insert 3 2 a
that yields an infinite loop, the same happens if you do
>x = x + 1
>>
>>57669698
Java/C# if you like enterprise cubicles, JavaScript if you like web development, C++ if you like giant ancient codebases and actually getting the official job title of "Software Engineer/Developer"
>>
>>57669733
>F#,
wut
>>
>>57669743
$128,000 Average, but probably the hardest to employ.
>>
>>57669771
F# and Scala are both just shitty OOPified knockoffs of OCaml and Haskell
>>
File: reeeeeeeeeeeeeeeeeeee.jpg (7KB, 275x275px) Image search: [Google]
reeeeeeeeeeeeeeeeeeee.jpg
7KB, 275x275px
>>57667266
>%USERNAME%
>not $USER
REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>57669781
Scala is growing pretty fast in popularity. I don't know about F#. They might be OOPified, but that's just where the market is right now.
>>
>>57669794
Dumb frogposter.
>>
>>57669732
>>57669738
λ> let b = Map.insert "mary" 14 a
λ> b
fromList [("mary",14)]
λ> let a = Map.insert "bob" 21 b
λ> a
fromList [("bob",21),("mary",14)]
λ> let b = Map.insert "mark" 16 a
λ> b
fromList [("bob",21),("mark",16),("mary",14)]
λ>


this seems retarded
>>
>>57669813
In GHCI new definitions replace old definitions, but those previous expressions refer to the previous definitions.
>>
decltype


Pronounced "deckell-type".
Jesus fuck, Bjarne.
>>
>>57669813
Go to tell to the functional guys. Those live in the delussion of making the cpu, who knows only to sum and point to memory address. to make very abstract mathematical stuff. The memory is there, you can use a pointer to point it, but no, it's better to just reference.
>>
>>57669825
pronounce
std::declval<std::deque<char*>>&&
>>
>>57669852
... what?

It is a REPL.
Each line is entered from the command line seperately.
When he types in "b", it prints b (the line without the \> prompt)

You can write definitions in a REPL, e.g.
value = 3
f x = 6 ^ value + 9
he is confused by the fact that if you then do
value = 4
that f is unchanged
>>
>>57669853
r-value reference to ess tee dee deckell-val of ess tee dee deck of char pointers
>>
>>57669905
>char pointers
POINTER TO CHAR
YOU HAD ONE JOB
>>
>>57669933
FUCK FUCK FUCK
>>
>>57669853
>c++11 + 5
>raw pointers
>>
>>57667266

5
6
7
8
9
10
11
12
13
14
15
16



import socket

new = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

host = 'irc.freenode.net'
new.connect((host, 6667))

ip = socket.gethostbyname(host)
print('connected to', host, 'at', ip)
msg = (':NICK huehuehue')
newmsg = (':JOIN #learnpython')
txt = msg.encode('utf-8')
txt2 = newmsg.encode('utf-8')

new.sendto(txt, (ip, 6667))
new.sendto(txt2, (ip, 6667))


messing around wiht irc server stuff but i don't know how to properly communicate with teh irc servers....
>>
>>57669967
you do it in haskell
>>
>>57669981
false flag
>>
>>57669981
no fuck that

what is going on how ?
>>
>>57669878
i'm confused by the fact you can't do
λ> let a = Map.insert "mary" 14 a

without it entering an infinite loop
>>
#define gay "haskell"
>>
>>57669955
>c++16
>>
>>57670006
For a start, it's a strict map.
Second, the elements are stored in a tree fashion, which means you have to sort the element into a tree.
You've created an infinite tree.
>>
>>57670025
suck my dick
>but later let me suck yours daddy
>>
>>57670006
Isn't calling 'a' inside 'a' a recursion?
>>
>>57670025
 const std::string gay = "Haskell" 


Please don't use define strings.
>>
>>57670046
In Haskell this is just
gay = "Haskell"
>>
>>57670055
It doesn't have a type so it doesn't work, your code is broken.
>>
>>57670065
>It doesn't have a type so it doesn't work, your code is broken.
The compiler infers the type.
>>
>>57670076
>The compiler infers the type.
That's unsafe. Stop.
>>
>>57670076
>tfw the compiler is less brainless than those haskellers
>>
>>57670081
It's entirely safe, I assure you.
>>
9223372036854775807
>>
>>57670105
No it isn't. If you define a variable from an I/O function that takes from a UI element or input you'll have to explicitly cast the value without knowing what it is - or run a bunch of tests to ensure your element returns the correct inferred type. That's not very safe.
>>
>>57670123
I don't think you know very much Haskell
Casting isn't normally our thing
>>
>>57670142
I don't know any Haskell. All I know is that if you don't cast your value and you're defining variables that are dynamically typed at run-time you can and will run into unsafe points during programming in which you fetch a value - especially from a user.
>>
>>57670156
They aren't dynamically typed.
>>
>>57670156
>I don't know any Haskell.
i believe you
>>
>>57667266
what're some encryption algorithms built into python or built into default python libraries (similar to import hashlib letting you MD5, yes I know MD5 isn't encryption it's an example)
>>
in the end, i won against the python guy right?
>>
I'm still working on my decentralized TV system. I'm just taking notes on the V4L2 API so I can force frame rates and resolutions, better debug errors, and possibly stream the video out of a video device as well.

I'm also scoping out prices for in-bulk USB SDRs, so I can pull police scanners and random radio frequencies and broadcast that out automatically. I don't want to go with standard FM or AM because of IP laws, but non-commercial should be free for the taking. The SDRs I find have a bandwidth range from 25 MHz to 1800 GHz, so what interesting things can I find on those bands (in America)
>>
>>57670188
You're not me

Are you the Python guy?

What the fuck are you even trying to achieve by starting shit?
>>
>>57670163
>>57670176
Not an argument.
>>
>>57670191
*1.8GHz or 1800Mhz
I'll make a webm of it when I get color and a decent frame rate
>>
>>57670201
ids or gtfo
>>
>>57670213
They aren't dynamically typed.
>>
>>57670230
Not an argument.
>>
What is a good convention for naming modules and functions? Everything I write is someThingHandler someThingProcessor someThingParser or some shit.
>>
>>57670188
I don't know who you're refering to, but I'm the one that said that only flaw of python is performance, then someone said without any explanation that I surely must be trolling, so I didn't find that conversation worth pursuing.
>>
>>57670255
because you lost and that demonstrate haskell superiority
>>
>>57670252
That depends on the language. Java has some serious rules about naming conventions. Personally, I just have a verb and a noun in all lowercase (add_buffer, request_buffer, start_capturing) in C++
>>
>>57670255
He probably wasn't even in the conversation to begin with. He's just some randomer who wants to start shit. Though I was the one who asked if it was bait
>>
>>57670252
What language are you writing in, and what are you programming?

I would definitely go with camelCase though
>>
>>57670282
don't believe him, I was
>>
https://groups.google.com/forum/#!msg/golang-nuts/XoOhzUClDPs/jgSWxng7CAAJ

LOL
>>
what's the normie word for a permutation of string?
>>
>>57670252
That's fine. As long as you make it clear what your get functions and set functions get and set, that your loggers log and your handlers handle, and your interfaces are interfaces, it's fine. Don't be this guy.

https://dev.to/naveen/how-to-write-an-object-oriented-program-that-doesnt-suck
>>
>>57670364
anagram
>>
>>57670373
ty
>>
>>57670343
I don't see what's funny senpai
>>
>>57669933

Pronounce it "char star". It rhymes.
>>
>>57670478
char tsar d
>>
>>57669905
A lot of C++ committee guys call the "std" the "stud", like the bits of metal in the wall you try to detect with a yellow handheld device.
>>
Chip-8 compiler guy here.
I'm moving on to code generation, and I need help determining how to structure my code.

Pic related is my representation of an abstract syntax tree node. Assembly instructions would look very similar, as there a many multiple types all with potentially different parameters. So should I have another giant union? Is there a better way?
>>
>>57670529
I legitimately think you would've been better writing this in Haskell

I've not tried Rust but that apparently has tagged variants. Maybe you should write it in that?
>>
>>57670541
I'm not switching languages now. Sorry!
>>
why is this not working i'm in the cahnnel and i literally don't see my bot join up?
>>
>>57670559
from socket import *

new = socket(AF_INET,SOCK_STREAM)

host = 'irc.freenode.net'
new.connect((host, 6667))
ip = gethostbyname(host)

msg = 'NICK pusieater\r\n'
msg2 = 'JOIN #learnpython\r\n'
txt = msg.encode('utf-8')
txt2 = msg.encode('utf-8')

new.sendall(txt)
new.sendall(txt2)
new.close()
>>
Is Perl dead for systems programming? Which lang is the next best?
>>
>>57670529
>>57670541
for instance, here's Haskell:

data AST' = 
Block { isRoot :: Bool, nodes :: Dsll, table :: Symtable }
| Function { type :: String, id :: AST, block :: AST }
| Call { id :: AST, nodes :: Dsll }
| Global AST
| Op { left :: AST, op :: String, right :: AST }

type AST = (Int, AST')


Creating a value is this simple:

example :: AST
example = (,) 0 Function { type = "someType", id = someId, block = someBlock }
-- (,) a b is (a, b), but I don't want to put parentheses around the whole thing


Pattern matching:

collectIds :: AST -> [AST]
collectIds Call { id } = [id]
collectIds (Global ast) = collectIds ast
collectIds Function { id, block } = id : collectIds block
collectIds Op { left, right } = collectIds left ++ collectIds right
collectIds _ = []


>>57670550
C with good variants would be really nice honestly
>>
>>57670529
It's a hack, but if you'd rather define each struct separately (maybe next to/in the same file as related functions) this might be an answer (though a write-only one at that).
struct ast_node_s {
int type, line;
};

#define node_data(node, cast) (*(cast*)&(node)[1])
>>
>>57669453
Jane Street is a dream job. I hear compensation is bretty good too
>>57670123
>cast the value
lol no
>run a bunch of tests
no, you can see a type error if you made it infer the wrong type
>>57670156
Haskell uses static typing. in fact, it's better than Java, which relies on a lot of dynamic type information because of bi-directional casting required for their system of subtyping (as well as having instanceof, etc.)
>unsafe points during the program
I assure you there are less of these than in your language of choice. The Maybe/Either monads handle exceptional values if you're reading in a string, for example.
>>57670233
yes, it's just a fact
>>
>>57670605
Ive been programming in c++ lately and I always crave a C with tuples, variants, and maybe even unsafe lambdas. Then I realize thats BASICALLY what Rust is, isn't it?
>>
>>57670605
I've heard good things about Rust and Haskell. C, in my opinion, could use some improvements that aren't C++.

>>57670626
Not exactly what I'm looking for, but I should consider writing macros to save myself from shit like
node->data_u.function_s.id->data_u.id_s.string

>>
>>57670661
You could get rid of a few .x or ->x by using anonymous structs&unions
>>
>>57670680
I'm writing C90 for maximum compatibility, and anonymous unions / structs are not a thing. Thanks for the suggestion, though!
>>
File: 1479655918483.jpg (86KB, 900x788px) Image search: [Google]
1479655918483.jpg
86KB, 900x788px
How can I make this C# code better? Been learning for about 3 weeks and it's a program to convert between bits, bytes, nibbles etc.

https://ghostbin.com/paste/zpwqm
>>
>>57670703
>I'm writing C90 for maximum compatibility
Compatibility with what? You don't seriously give a shit about microsoft's shitty compiler, do you?
Clang and GCC can be used on every major desktop platform and both default to C11.
>>
>>57670703
Ah, I see. Good luck anon
>>
>>57670656
I think so, but there are things in C++ that aren't in Rust, e.g. stuff from C and better templates
C++ doesnt have good variants yet though, there's one added to the standard library but it's pretty mediocre and doesn't have proper pattern matching

>>57670605
here's a much simpler example

data AST = 
Literal Integer
| Variable String
| Add AST AST
| Mult AST AST
deriving Show

eval env (Literal n) = n
eval env (Variable s) =
case lookup s env of
Just n -> n
Nothing -> 0
-- return 0 if it isn't found
eval env (Add x y) = eval env x + eval env y
eval env (Mult x y) = eval env x * eval env y

instance Num AST where
fromInteger = Literal
(+) = Add
(*) = Mult
negate x = Mult (Literal (-1)) x

example = 3 * Variable "X" - 7 * Variable "Y" + 23
result = eval [("X", 17), ("Y", -13)] example


>>57670661
Maybe you could try out one of those languages after this compiler?
>>
>>57670736
It's just what feels right to me. I might be retarded, but there's no changing that.

>>57670738
Thanks!
>>
File: 1480016751239.png (220KB, 600x480px) Image search: [Google]
1480016751239.png
220KB, 600x480px
>linux
>apple OS
>relevant, competitive enterprise grade software
You can only puck ONE (1)
>>
>>57670779
> Maybe you could try out one of those languages after this compiler?
I will for sure.
>>
File: java9-meta[1].png (18KB, 580x300px) Image search: [Google]
java9-meta[1].png
18KB, 580x300px
Java 9 will feature the ability for AOT compilation along with the ability to run any language that can compile to LLVM IR.... has Java finally won!?!?
>>
>>57670780
>It's just what feels right to me. I might be retarded, but there's no changing that.
If you're going to do something, at least try to justify it.
Doing something "just because" is fucking stupid and shows that you're an idiot.
>>
>>57670793
>pick
Fixed
>>
>>57670805
>all other languages implement Object
>>
File: screen.png (15KB, 418x602px) Image search: [Google]
screen.png
15KB, 418x602px
>>57670529
your code looks great in my vi
>>
>>57670805
and nobody will use it because it just breaks everything just like java 8 did.
>>
>>57670779
I'm really not interesting in C++ attempting to badly shove another feature into the standard in 5 years.
>doesn't have proper pattern matching
Pattern matching is what makes variants useful. I'd like to try to "redo" C++ by not trying to copy Java OOP but I'd probably end up with a slightly worse, slightly less "safe" version of Rust
>>
>>57670806
¯\_(ツ)_/¯
I've started the project in C90, might as well finish it in C90. Changing a fuck ton of "char" to uint_8 etc doesn't appeal to me right now. And if I don't do that, then the project will be an amalgamation of C versions, which also doesn't appeal to me.

>>57670837
> [cpp]
disgusting
>>
>>57670849
I think you could write a pattern match function for C++, though it'd end up looking like this:

variant.match(
[](){ ... },
[](){ ... },
...)

They added this really fucking stupid "visit" function instead of pattern matching

Anyway, there was a proposal to add it to the standard. Like:

lvariant var {
type1 a;
type2 b;
};

var x = someA;

match (x) {
...
>>
>>57670857
>Changing a fuck ton of "char" to uint_8
Nobody said you had to do that. In fact, I'm against needless uses of the <stdint.h> types.
By using C89, all you're doing to needlessly limiting yourself, and introduce some other subtle weirdness into your program.
I hope you're not doing modulo on negative numbers, using non-double variants of <math.h> functions, reading from union members that wasn't the last one written to, declaring variables not at the start of a block, and other shit off the top of my head that is different/missing in C89, otherwise you're a stupid hypocrite.
>>
>>57670186
anyone?
>>
File: 1479883677181.jpg (143KB, 833x696px) Image search: [Google]
1479883677181.jpg
143KB, 833x696px
>>57670896
>>
>>57670896
In fact, I'm not. I've even set my compiler to check for this stuff. I haven't felt any limitations until now, so there's that.

I don't need math.h for a compiler for an int-only platform.
Similarly, there are no negative numbers.
My unions are definitely always accessed properly and consistently.

>>57670917
Thanks, but we're just having a discussion here.
>>
>>57670186
What are you looking for? Do you know anything about encryption?
>>
>>57670857
hmm... I think char and uint_8 have different semantics, at least in edge case scenarios with smaller systems
>>
>>57670934
a little, working on a script to bruteforce stuff using wordlists so far added md5 sha1 sha256 sha512 now looking to add other stuff
>>
>>57670935
Perhaps. Now that I think about it, I'd use just int8_t, and for my purpose, actual ints should do the job better. What kind of edge cases are we talking about?
>>
>>57670779
dont trust this guy, can even write even a simple csv parser
>>
>>57670992
You don't even know what a parser is you little shit. In that little spat you kids were having, neither of you wrote a parser. You just used a parser someone else wroet.
>>
>>57670708

This seems significantly longer and more indented than it needs to be...
>>
File: kirino-008.jpg (550KB, 1280x720px) Image search: [Google]
kirino-008.jpg
550KB, 1280x720px
neocities is actually pretty cosy

why didn't you tell me about this before, /dpt/?
>>
>>57667266
Working on learning openGL and C++ via a few projects at University. Rather enjoying C++ although openGL is rather odd as a finite state machine.

Any tips from experienced programmers of these languages (I have prior experience in object orientated languages like C# and Java.
>>
dunno if this is the right place to post this but:

I want to build a computer, but I don't mean buy modern components and connect them together. I want to buy an 8080, a few kb of ram, and other components and make my own computer with inputs kind of like an altair 8800 (switches and lights for I/O). I'm studying computer organization and architecture and have already designed an ALU chip (pretty simple compared to other digital logic circuits.) You can still buy 8080 chips, but RAM is difficult to find. Can I buy ram chips which I can connect to an 8080, or am I better off trying to use a more modern processor with a reduced instruction set? I'm trying to stay in the 8 bit family to keep things simple.
>>
>>57670708
You need enums.
>>
>>57670962
sizeof char is always 1, as we know
I don't think int8_t or uint8_t have a guarantee to be char though, in a case where you're on an exotic architecture
>>
>>57671078
RAII is C++'s greatest asset
Smart Pointers are your friend
Don't build a towering hierarchy of classes
>>
>>57671118
Thanks, I'll look into those areas.
>>
>>57671015
mad?
>>
>>57671079
I think >>>/diy/ might be a better place to ask for that. They have an electronics and microprocessor threads there, if I'm not mistaken, but you might find somewhere here who knows.

>>57671097
>in a case where you're on an exotic architecture
I can't imagine a possible architecture where (u)int8_t is not a char. short and int must be at least 16 bits, so it cannot be those. Since they can't have padding bits, they can't just use a bigger type.
The ONLY possible way I think it could happen, is if an implementation has some weird non-standard integer type (similar to an extended integer type), However, I'm not even sure if an implementation is even allowed to have extra integer types like that.
>>
>>57671166
amd?
>>
>>57671182
dam?
>>
>>57671199
adm?
>>
then lets all agree that I won against the python user ok?
>>
>>57671132
To ramble further, what makes RAII great is it gives you scope-based control of a resource's lifetime. For the vast majority of resources you acquire (90% of which are objects in heap memory, but also sockets and such), this is the exactly kind of lifetime management you want, and in the other cases, the fancier smart pointers do the trick (usually with reference counting, which has the nice characteristic of being predictable)
>>
File: 1017-judge-judy-show-1200x630.jpg (62KB, 550x450px) Image search: [Google]
1017-judge-judy-show-1200x630.jpg
62KB, 550x450px
>>57671220
>>
>>57671178
>/diy/
Thanks, I posted over there
>>
>>57671223
Look lightly into it at the moment. Does that mean that it removes the need to delete objects created on the heap via delete statements or destructors? If so that'd solve many of the memory leak problems associated with heap memory and would be very useful for me!
>>
>>57671178
I did say exotic :D
Consider a system where the base word size is larger than 8. I'm not familiar with them, but have heard of systems with 16 bit words, even ones with 32 bit words
I believe the standard demands no definition of the uint8_t type on those systems though, so it would result in a compilation error which is good.
>>
>>57670837
Mind if I ask, are you the guy who asked to see it for school? Or someone else?
>>
double avg(int x, int y){
double x1 = x / 2.0;
double y1 = y / 2.0;
return x1 + y1;
}
>>
>>57671287
the guy who asked to see it for school
>>
>>57671220
Shut the fuck up you annoying fucking shit starter
Did your parents not fucking love you as a child or something
>>
>>57671290
y tho

>>57671291
What do you think?
>>
>>57671258
Correct. In fact a lot of recent C++ idealism is that you should almost never have a raw delete or explicit destructor call in your code, due to the other better facilities offered for resource lifetime management (with very little performance overhead).
Herb Sutter has some nice arguments about it
https://herbsutter.com/elements-of-modern-c-style/
>>
>>57671305
i think its pretty good, it has all the necessary steps to build a compiler for a restricted language.

the one i was supposed to do, had a bigger grammar though

but overall, i like it

might take inspiration for my compiler project in a few months
>>
>>57671319
Very interesting, I always did think it was terribly bad practice to have to call delete encase you forget while getting into another part of functionality. I'll check out what he has to say, it sounds very reasonable.

Also do you typically just use the code and fix method like 99% of people or do you follow any development process practices?
>>
>>57671346
Glad you like it.

The language is restricted because the platform is restricted - Chip-8 really doesn't have much stuff in it. I didn't think it'd need much.
>>
>>57671377
i noticed you used clang instead of gcc

personal preference?
>>
I'm currently using perror() to print out the right message when failing to open a file, for example, permission denied or file does not exist. How can I store that same error message as a string?
>>
>>57671375
I just try to focus on separating concerns by responsibility (rather than by stage of processing), and decreasing complexity anywhere I can
Often times this means a prototype first that gets thrown out when I realize what the proper design for the system could be

Out of the Tar Pit is a nice paper on complexity and avoiding it
Warning though, it's a long one, so maybe just read a bit every day
http://shaffner.us/cs/papers/tarpit.pdf
>>
>>57671427
Found it. Not the safest, but better than generic messages, strerror prints the system dependent error number its parameter takes and errno contains the last procced fail code as a global in some headers.
>>
>>57667628
Don't make it in WinForms.
Use WPF
And make it all flat-design so it looks like Facebook and your sister likes it
>>
>>57669272
>2016
>falling for the blockchain meme
>falling for the EVM meme
>falling for the official Ethereum instance of the EVM meme
>not realizing that the time required to finalize decentralized consensus outside of a proof-of-authority scheme with leaders determined via BLS threshold signatures for immunity from tampering with outcomes via signature withholding just turns any real time market into a game of who can best manipulate the networking layer of consensus formation and in that naivety also recreates the same issues that were taken advantage of by high frequency frontrunners as detailed in "Flash Boys"
>being BTFO by a poster on /g/

Don't mind me, I'm just a mad computer scientist who knows too much.
>>
>>57671617
this. WPF a cute
>>
>>57667628
Yes good practice with your sister just as G*d intended hehe
>>
>>57671677
I don't think you actually wrote this post
>>
>>57671691
If only there was a cryptographic system for validating who made what posts... hope this made you go hmmmmmmmmmmm
>>
Question to all the vets how important are design patterns in software engineering interviews? Is singleton and factory enough for an interview or have you been asked otherwise?
>>
>>57671745
I had a similar idea: create a thread where all posts are PGP/GPG signed
>>
>>57671871
Design patterns are fucking cancer and objectively make code worse. As such, they are incredibly important in enterprise code interviews.
>>
>>57670708
>>57671025

To demonstrate that this program is too long, I have reduced the number of lines of code from 815 to 99.

http://pastie.org/10969492
>>
>>57671961
>
{
>>
what do real programmers think of me
>hobbyist
>self taught
>has/uses github
>scripting only
>python
>make money making small scripts for people (mostly mix and match source code from stackoverflow)
>make websites for people (use squarespace ftp the files out, set it up on their server and they pay me)
how would you describe me and what is your opinion of me?
>>
File: 1468295290162.jpg (73KB, 800x800px) Image search: [Google]
1468295290162.jpg
73KB, 800x800px
>>57672028
>Python
>>
@57672028
your shit
>>
>>57672048
but my post didn't have an opinion in it
>>57672054
true but atleast I know the differance between your and you're
>>
>>57672075
i discarded it anyway
>>
>>57672028
I think it's impressive that you can get people to pay you for shit. Also, you have no honor.
>>
>>57671985

Is there a problem with a misplaced brace? It compiles fine with the dotnet CLI tools on Linux...
>>
>>57672150
Yes, there are a lot of misplaced braces.
I think your compiler might be broken.
>>
Norwegian is the best language for discussing programming.
>>
>>57672304
Unfortunately the rules demand you speak English or at least weeaboo
>>
>>57672182

Well it is a developer preview. Where are the misplaced braces? Where should they be?
>>
>>57672304
How so?
>>
>>57672422
lines 7, 12, 26, 33, 46, 52, 54, 60, 71, 77, 79, 85, 93, 95 and 97
>>
File: ricardo-stallmanu-peppers.png (2MB, 1240x930px) Image search: [Google]
ricardo-stallmanu-peppers.png
2MB, 1240x930px
"I am really thinking now." - Richard Stallman
>>
>>57667266
Zzz no idea what I should work on. Want to learn openGL and SDL though, idk where to start. Pls help
>>
>>57672654
Start with getting a window and rendering context up in SDL.
Then do the Hello World of OpenGL programming: A multicolored rotating triangle.
>>
>>57672654
This tutorial does not use SDL, instead using SFML, but it does provide a nice introduction to OpenGL programming in a modern manner
https://open.gl/
>>
>>57672690
>>57672708

Thank
>>
>>57672439

Where they are already located?
>>
I'm reading the microsoft visual c# book and I like it, but I'm feeling that I need something more technical. What's the best c# book?
>>
>>57672730
I used "Essential C#" and "C# In Depth" as my go-to books for getting good at the language and .NET in general
>>
>>57671961
I always read that this styling:
int a()
{
}


Is better for readability but it's the complete opposite for me.
>>
Starting to regret switching to Linux idk what the fr*ck is going on or how to use it uwu
>>
>>57672810
write 'man' in the terminal.
>>
>>57672833
I-is this a trick!?!
>>
>>57672714
Additionally, you could consider the OpenGL ES 3.0 programming guide. It's a great reference packed with realistic examples (instead of the "just use our library first" bollocks so many graphics books and tutorials do). It covers a lot.
>>
>>57672846
man touch
man abs
man finger
>>
>>57672708
>https://open.gl/
This tutorial looks pretty good, at a glance.
>>
>>57672810
Just install windows 7

Linux is a hassle for pretty much everything
>>
>>57672786

It's not so much about it being good for readability. In C#, that's the community standard.
>>
>select() can monitor only file descriptors numbers that are less than FD_SETSIZE;
>poll(2) does not have this limitation. See BUGS.

What did they mean by this?
>>
>>57672949
I hate it though. Well not that it matters since my visual studio just auto formats it to what i like and vise versa.
>>
>>57672858
man date
>>
>>57672786
>>57672949
I think it's good for readability to have opening and closing of code blocks line up.
>>
>>57672858
Fucking linux perpetuating the patriarchy, iis "woman" a valid command too??
>>
>>57673005
In emacs, the 'man' command will read a manpage and convert it to an emacs buffer.

There is also a 'woman' command that will do the same thing, but it parses the pages internally, so you don't need the actual 'man' executable.

The emacs 'woman' command is worse than the emacs 'man' command in every way that matters, pretty fitting :^)
>>
>>57673022
>does the same thing
>is worse
>>
>>57673039
They attempt to do the same thing, but really don't. Try them both out on the same manpage, and do a side-by-side comparison.
>>
>>57673022
T R I G G E R E D
>>
>>57671691
>>57671745
>>57671893
kek, I'm curious where you think I got it from then

odds are we've met in person :3
>>
What's /dpt/ reading?
>>
Can you get hired based on a portfolio?
For example if you want to be an artist, no one cares if you have a degree because they can just look at your art portfolio. Is software similar at all?
>>
>>57673154
your mind
>>
>>57673169
better be darn good
>>
>>57673154
C++ Concurrency in Action
The Linux Programming Interface
>>
>>57673154
The Algorithm Design Manual
It's great

On Lisp
It's a nonstop barrage of Lisp wankery

Paradigms of Artificial Intelligence
It's ok, not really about Artificial Intelligence though (especially compared to modern AI miracles)
>>
>>57673234
it's solely optimal solutions to the entire "cracking the coding interview" book written in haskell
>>
File: theAnimeGallery_202325_1280x1024.jpg (821KB, 1280x1024px) Image search: [Google]
theAnimeGallery_202325_1280x1024.jpg
821KB, 1280x1024px
challenge:
Generate a list of random floating point values between -1 and 1 that have a mean of 0. The list can be a fixed size.
>>
>>57673359
the values wouldn't be truly random then. if you're saying you can toss out some values if you don't like them, then my solution is to have it be a list of size 1. if the random value is 0, i accept it. if not, i retry.
>>
I have a question about radix sort.

If we have n integers in the range 2^n, can we still sort in linear time?

I keep going over the math and can't get it right but I feel like as long as you group by base 2, it should work? I keep reading Lemma 8.4 but it's not sticking...
>>
>>57673359
>that have a mean of 0
I don't understand.
>>
File: theAnimeGallery_202199_1600x1200.jpg (497KB, 1600x1200px) Image search: [Google]
theAnimeGallery_202199_1600x1200.jpg
497KB, 1600x1200px
>>57673375
>>57673424
The values in the list are random, as in you could not possibly predict their value, but their mean is 0. You can have an error of 0.05 if you'd like.
>>
>>57673375
this cheeky algorithm is quite bad. There is an infinity of floating point numbers between -1 and 1.
>>
>>57673154
Rationality: From AI to Zombies

>>57673359
'()
what do I win?
>>
>>57673496
the eternal title of "stinker"
>>
>>57673340
try Jane Street
>>
>>57673486
no there bloody isn't
>>
>>57673379
No, radix sort would be quadratic. For it to have linear complexity the number of digits should remain fixed.
>>
>>57673519
not that can be represented by a computer, no, however there are so many that the algorithm is terrible. there is as much chance that you will generate 0 as there is that you will generate 0.49559
>>
>>57673543
The algorithm is dead simple though.
>Generate a float from a uniform distribution
>Append it to the list
>Repeat
As the size of the list approaches infinity, the probability of the mean being 0 approaches 1
>>
>>57673359
This doesn't seem possible. For the numbers to be random, every possible value of the integers should be equally likely. But if the mean has to be 0, then extreme values (-1 and 1) are discouraged, no? For example, the combination 1 1 1 1 is invalid while 0 0 0 0 is valid.
>>
>>57673541
*actually, I change that: the number of digits should remain less than lg(n).
>>
Is there a better way to do this?
All instructions grouped here only have one value, but all of their names are different. I know i'm overwriting name a shitton of times, but this is the most concise way I see.
>>
>>57673639

What's the nature of the latter two having their type set while the former two are actually just comparisons?
>>
>>57673541
>>57673612
Here's where I'm at

2^r = n (since we have n integers, I think this is where I'm going wrong)

r = logn

b = log2^ n -> b = n

d = b/r -> d = n/logn

which will give us not O(n)..
>>
>>57673674
The nature is me fucking up. they're all supposed to be ==. thanks
>>
>>57673639
Ignoring for a moment that you haven't even allocated memory for your string, I think you should just use a string of if statements. You are over-engineering the problem (and making it less efficient) just to reduce the number of lines.
>>
>>57673684

No problem, boss.
>>
>>57673697
It shouldn't need to be allocated. This is inside a print functions. I'll be printing and throwing away a string literal.

String of statements is the other way. But it implies a lot of copy-pasted code.
>>
>>57673587
when you put a restriction on randomization, the set of values you can output become smaller. that's like saying "generating a number between -1 and 1 isn't possible because 2 is discouraged"

>>57673580
now do it for a list of 4 elements :)
>>
>>57673715
>It shouldn't need to be allocated.
Of course you're right, I guess I'm tired.
>>
>3 fucking months unemployed

I don't know what to do anymore. If I don't get a job soon, I might have to start my own company despite a complete lack of charisma, business sense, and ideas for a marketable product
>>
>>57673764
No worries!
I think I'm gonna go with a chain of if-statements after all, in a separate function. Thanks!
>>
>>57673780
how many jobs have you applied for?
>>
>>57673680
>which will give us not O(n)
Exactly. It's O(n^2 / lg(n)) which, as I said, is not O(n). (I said that it would be quadratic, but that was a mistake. I forgot you can choose the base cleverly to improve the complexity).
>>
>>57673736
>when you put a restriction on randomization, the set of values you can output become smaller. that's like saying "generating a number between -1 and 1 isn't possible because 2 is discouraged"

Then the OP has to define what they mean by "random". ""generating a number between -1 and 1" is generally interpreted to mean that the number will assume all values between -1 and 1 with equal probability, which doesn't seem to hold.
>>
>>57673798
none bc i don't meet their requirements
>>
>>57673830
>>57673736
the numbers are random, you just allow the list to keep growing until the condition is met. in my initial reply, i thought the list was a static length
>>
>>57673798
hundreds. I keep getting rejected. At first I was just fucking up and had a bad cover letter. Now I'm getting rejected by jobs where I actually succeed at the interviews

I have one ongoing prospect left and i'm pretty sure they're going to reject me in the next few days. My speech impediment made me look like an idiot and my database skills aren't as good as they can get. They probably just told me they'd get back to me within a week so they could reject me AFTER thanksgiving
>>
>>57673639
You can try
if ((inst->type == CHLANG_ASSEMBLY_JMP && name = "JMP) || ...


Short circuiting will guarantee that the assignment will not be done unless the type check returns true. I'm 90% sure that string assignments always are evaluated as true (because the pointer is non-null).

If you are doing this sort of operation often you might want to consider creating a look-up table.
>>
>>57673850
I hate to say it but speech impediments are a huge hurdle. I had to spend a good half day convincing my boss to hire a pretty smart guy because he had a severe stutter.
>>
>>57673799
So the math looks ok then? I'm not very confident in it.
>>
>>57673875
I'm writing an int-to-string function that is straight up a list of IF statements. But what you're suggesting is a good idea, I should've thought of that. You're most likely right about string assignments.
>>
>>57673896
Looks fine to me.
>>
>>57673905
>int-to-string function that is straight up a list of IF statements
Why you can't just use the modulus and division operators in a loop?
>>
>>57673925
How could I do that?
I'm not seeing what you mean, sorry.
>>
>>57673885
I have the worst one for this sort of case too. I've got a fucking aphasia that makes me forget what I'm saying half way through a sentence either have go uhh for a good 15 seconds or just start over
>>
>>57673928
I don't know if this is what you are looking for, but here's my pseudocode interpretation:

string int-to-string(number) {
string s = ""
while(number > 0) {
s = (number % 10) + s
number /= 10
}
return s
}
>>
>>57673850
>>57673933
you're telling them at the start of the interview that you have a speech impediment right? so they don't think you're mentally retarded or high?
>>
>>57673933
>aphasia
Damn that blows, I feel for you.
>>
>>57673965
Oh, you misunderstood. Sorry, I wasn't clear enough I suppose.

I was writing a function that would convert an integer, an assembly instruction code, to its string representation. Not a regular atoi.

Sorry!
>>
>gtkmm doesn't even let you parse your own arguments
>have to derive from and boilerplate the entire init system just to accept a single first argument
fuck me
>>
>>57674000
GTK is mostly a C thing, and even pretty bad at that. Why not use Qt? Isn't that the standard GUI toolkit for C++?
>>
>>57674023
I don't know, I really don't know. I've never had a major problem until I am now simply trying to make my text editor accept an argument as a file. Now the "application" object which swallows my argv kills the entire application at runtime because "this program can't open files". You set a callback to "signal_open" which procs when a file is given as the first argument, binding the function pointer with the address of the "application" object as an extra argument and write two main() functions with that, or derive from the application object yourself and do boilerplate work. The first one I mentioned never even procs the signal handler in the first place for me. I'm gonna go and die in a corner, peacefully, now.
>>
>>57674053
> peacefully
Doesn't sound like GTK will let you go this easily.
>>
>>57673985
You should use a lookup table (likely enums) for that and use a switch case.
It's preferable to ifs because intent is far more clear.
>>
>>57674073
The bullet will probably bounce of my head and print to stdout "this program isn't able to accept files"

lmao god damn it man
>>
New thread? >>57674108
>>
How do i link opengl and sdl libraries to mother ufcking vim in ubuntu shit fuck damn
>>
>>57674053
Not him, but GTK isn't good software.

Qt is by far a superior solution.
It actually has reputable backers and industry use, unlike GTK that makes major breaking changes on minor releases and other foolery.

If you have an application written in C, your best bet is probably to make a "wrapper" application in C++ and Qt that would use your C program as a library, under the hood.
>>
>>57673970
No, I don't. Ir really should though. I apologized afterwards on that last interview, but I guess I kind of fucked myself by asking how I did (I figured I had already screwed up so I decided I might as well ask)
>>
>>57674116
>link to Vim
You link using your compiler. Do you mean how you get easy access to the files via the Vim file browser? I don't know.
>>
>>57674116
Agree with the other guy, no clue what you are trying to say.

Do you want syntax suggestions and autocomplete? If so, look at this one:

https://valloric.github.io/YouCompleteMe/
>>
>>57674131
No my application is a gtkmm program, entirely using the C++ wrapper for GTK. Maybe I will move to Qt. I always knew the C version of Gtk was atrocious due to its usage of GObject to basically create C object oriented code and callback/event mixups meaning every second line is a cast from *void, but I somehow did not believe gtkmm would be that bad. Perhaps it is time to move on.
>>
>>57674164
s-sorry...i usually use codeblocks and theres this magical tab called "linker" and stuff where you show codeblocks how to find the header files and shit so i dont realy know what im tryign to do
>>
>>57668001
Not him, but thanks for the suggestion; this is my new project.

Fuck gui though, I'm just gonna have it scrape the pdf adverts and email me a digest.
>>
>>57674187
ok i see

vim is a plain editor, so you don't get fancy build settings.

i'd recommend you take 10 minutes and learn a tiny bit about makefiles.

gcc accepts options for where include and library files are located, which you can tell your makefile about. (see this for details, you mainly want to see the '-I' and '-L' at the top of the page: https://gcc.gnu.org/onlinedocs/gcc-3.1/gcc/Directory-Options.html)

actually, if you are using linux and install sdl-dev and opengl-dev or the equivalent on your distro, they should already be in your system include and lib paths and you shouldn't have to do anything special.

this is why i'd discourage getting started programming with an ide, they make it too easy to ignore how all your tools interact and you miss out on a valuable learning experience.
>>
>>57674211
No problem anon. Happy to give you a good idea. Be sure to share it here if you so please. I could use that too.
>>
>>57674252
I sort of suspect the lion's share of the work will be fiddling with the pdf extraction and parsing for each individual retailer, and so it may not be that useful to those who live outside where I do, but we'll see.
>>
>>57674266
Well if you structure it well you will avoid most issues.
>>
>>57674187
Brief rundown to extend on what the other dude said.

Text editors enter text into a buffer and allow saving, sometimes syntax highlighting, plugins, special indentation, all sorts of things vim can do and more.

Compilers take the code you write, and make it into a long chain of unreadable calls to CPU instructions called an executable.

Linkers, between a compiler "reading" the code and actually "compiling" it, pull your libraries and dependencies into the code and sort it out. Most compilers have their own linkers and do that automatically for you to some extent.

so, vim file.cpp, gcc file.cpp -o myprogram, ./myprogram

Edit, compile/link, run.
Thread posts: 393
Thread images: 31


[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.