[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: 324
Thread images: 38

Old thread: >>59407179

What are you programming in C, /g/?
>>
C is the most productive and practical programming language today.
>>
File: 1489530656576.jpg (49KB, 600x381px) Image search: [Google]
1489530656576.jpg
49KB, 600x381px
C is for brainlet toddlers. See pic, a toddler rhyme book on the left and a book for mature and adult person on the right
>>
C++ is the most productive and practical programming language today.
>>
I'm pretending to be retarded.
>>
File: cry_anime.jpg (79KB, 919x898px) Image search: [Google]
cry_anime.jpg
79KB, 919x898px
>>59409302
>no anime picture
Shit thread.
>>
File: js.jpg (792KB, 3264x1836px) Image search: [Google]
js.jpg
792KB, 3264x1836px
>>59409317
Your image is akin to this.
>>
Unity is not real programming.
>>
>>59409317
>he needs 650 kb of library code in his fizzbuzz apps
>>
Pointers are useless in real-world programming
>>
>>59409341
>he uses library to print hello world
>>
>>59409353
>he uses I/O in his program
>>
File: 1489461328707.png (740KB, 1834x1200px) Image search: [Google]
1489461328707.png
740KB, 1834x1200px
>>59409341
Why do c toddlers think it's all about library?
>>
>>59409333
lol
>>
File: gujira4gou_1.jpg (244KB, 1131x1600px) Image search: [Google]
gujira4gou_1.jpg
244KB, 1131x1600px
>>59409333
Trips of tres. Javascript is best programming language, but we didn't need trips of truth to know that.
>>
>>59409317
>>59409320
Bjarne, hvorfor skapte du et så forferdelig programmeringsspråk som C++?
>>
>>59409352
Unless you are using 'c'. The shitlang doesn't even have resizable arrays, so c tards are bound to use pointers
>>
>>59409377
Knep dig selv i roven, smatsæk! Flæk dig til helvede man.
>>
>>59409378
>resizable arrays
They're implemented in terms of fixed-size arrays, I hope you realize.
>>
I am a CSS programmer.
>>
>>59409398
So you are saying you have to implement them by yourself before doing anything useful. What a piece of fucking trash.
>>
>>59409394
Already did. And where did I claim to be "Australian"?
>>
>>59409409
>Already did. And where did I claim to be "E*ropean"?
>>
>>59409409
Learn English before posting here, you A***tralian nigger.
>>
>>59409362
But, as a C fag, I'm perfectly fine with all the extra features added by C++. They really don't have a downside for me, as a programmer, since I'm not forced to use them - they're there for me to use if I want to, but I don't have to. The problem is that the C++ standard library is openly advocated as the "right" way to do things, when it's often over-complicated for the use case.
>>
C was a mistake.
ML was robbed.
>>
>>59409378
>i have to rely on the data structures and routines provided by my language and its standard library instead of creating them myself
*clap clap clap*
Statist, stop giving language makers power, take power BACK and craft your world, take a language which gives YOU the power to develop first class syntax for it seamlessly. Lisp and Forth respect YOU and YOUR power. Honourable mention to Haskell too. FUCK GOLANG! AND FUCK _______________________
>>
STOP REPLYING TO RETARDS REEEEEEEEEE
>>
>>59409437
Idris > ML > C > C++
>>
File: laughing_lolis.png (55KB, 267x195px) Image search: [Google]
laughing_lolis.png
55KB, 267x195px
>his languages isn't memory safe
>>
File: 1488248151444.jpg (233KB, 503x662px) Image search: [Google]
1488248151444.jpg
233KB, 503x662px
>>59409437
Did you try Cyclone?
>>
>>59409455
>using a low IQ language
typical of a lolipedo
>>
>>59409451
True.
>>
Developing a multi threaded chess AI using higher kinded types in OCam. With no I/O.
>>
>>59409470
woah there hacker master I see you also like to live dangerously
>>
/dpt/ challenge #543: Write a program that prints the string "Hello World!" to the terminal, without using I/O.
>>
>>59409476
peabrained dinosaur tier intellect
>>
>>59409494
putStrLn "Hello World!"
>>
>>59409470
A memory safe language is an inherently better-documented and better-optimized language.
>>
>>59409500
>He actually replied
>>
>>59409512
>she actually replied
>>
>>59409525
>she
>>
>>59409503
you make me laugh, you must have the smallest brain on /g/
>>
>>59409530
>she doesn't know
>>
>>59409503
Please provide arguments, I'm intrigued.
>>
>>59409539
Whales have larger brains than a human, the only being more idiot than a whale is you
>>
>>59409512
You asked for a program that prints "Hello World!" to the terminal without using I/O, and I gave you one.
>>
>>59409568
>implying implications
>>
>>59409539
>>59409550
Assuming it's memory safe because it uses a stronger type system and not because it prevents you playing with memory outright.

How many C programmers use restrict? With linear types, the optimization can automatically be applied to every pointer. Types alert the programmer to errors, they guide implementation, they're documentation that is never out of date, and they're optimization flags that can never be wrong.
>>
school project involving a linked list inside a linked list.
>>
>>59409565
the typical low intelligence argument i'd expect from you
>>
>>59409568
>prints "Hello World!" to the terminal
>not I/O
>>
>>59409587
>I got owned: the post
lmao 50 bucks say you are a dumb c tard
>>
>>59409582
>a linked list.
Don't you have vectors?
>>
>>59409596
>this much damage control
>>
>>59409612
meant for >>59409587
>>
>>59409596
Your arguments are getting worse and worse my friend, your IQ is lower than even my lowest expectations!
>>
>>59409589
you didn't tell him to run it
>>
>>59409619
Oh? Are you actually suggesting IQ is proportional to brain size? hahaha
>>
>>59409618
Stop lying, r*ddit trash.
>>
59409658
Okay
>>
>>59409637
Between my human brain and your arguably human brain, yes it does, brainlet
>>
Posting in a bait thread.
>>
Programming really is a language if you think about it
>>
File: 1489536936847.png (731KB, 1834x1200px) Image search: [Google]
1489536936847.png
731KB, 1834x1200px
>>59409667
> my human brain
ape* brain
>>
>>59409686
Oh look you've reverted to the very argument you stated was flawed. Your brain is like a wet cashew nut, only less delicious!
>>
>>59409704
you seem very upset
>>
>>59409686
>no sizeof
>no offsetof
It's almost as if you don't actually know C.
>>
>>59409437
S/ML influenced Rust, OCaml, and even Swift, numerous other languages. ML has become Lisp, where all new imperative languages are just becoming closer to Lisp. All new functional languages are just becoming closer to SML.

Best part is it is dead easy to understand SML. Theorems are types (specifications), and proofs are the programs. Type theory has its origins in proof theory (the theory of human reasoning) and is closely related to category theory (the general theory of mathematical structures). If you learn type theory, proofs by induction, and category theory you essentially fully understand every single language that has yet to be invented. Also because SML has a formal definition you can write formal verifications for it without being a mathematician.

It's the main reason why How to Design Programs book (and edx course) is so successful at teaching people how to actually program because all they are doing is reasoning about types for the most part which in turn helps the student totally understand the specification of their program. When you grok the specification everything else is easy.
>>
>>59409710
Very low IQ
>>
>>59409714
Agreed
>>
>>59409713
offsetof isn't standard. And if it was, it would be offset_of, not offsetof.
>>
>>59409713
>offsetof
see >>59409723
>>
>>59409731
https://en.wikipedia.org/wiki/Offsetof

>C's offsetof() macro is an ANSI C library feature found in stddef.h.
>>
>>59409714
Except SML doesn't have dependent types so its ability to specify is pretty limited.
>>
File: akarin ambiguous.jpg (450KB, 1000x900px) Image search: [Google]
akarin ambiguous.jpg
450KB, 1000x900px
I made something simple and put it on github a while ago, basically a python script that acts as a password manager.

Do you guys think its a good idea to link my github here and let people comment on what I did?

After people make bigboy git projects are you supposed to shill it everywhere?
>>
Explain dependent types to someone who's briefly used and loved Haskell, and who doesn't afraid of maths.
>>
>>59409764
Go ahead and post'em
>>
>>59409783

f : Bool -> Type
f True = Int
f False = String

g : (b : Bool) -> f b
g True = 3
g False = "hello"
>>
>>59409783
Apparently they're types which require their values to satisfy certain constraints.

>t. 'c' fag
>>
File: angry mayushii.jpg (30KB, 172x195px) Image search: [Google]
angry mayushii.jpg
30KB, 172x195px
>>59409795
Promise you won't be mean?
>>
>>59409799
Hmm I sort of see, a little.

>>59409804
Thanks for an attempt
>>
C noob here. For char arrays, can I specify a subscript with an expression?

For example, is char[i -1] acceptable?
>>
>>59409837
I thought c tards are not lazy
>>
>>59409837
Yes.
>>
File: idris ex.png (5KB, 222x353px) Image search: [Google]
idris ex.png
5KB, 222x353px
>>59409827
h : Nat -> Type -> Type
h Z t = ()
h (S n) t = (t, h n t)
>>
File: 1485141778426.jpg (114KB, 350x420px) Image search: [Google]
1485141778426.jpg
114KB, 350x420px
>>59409302
>80% of the thread is language wars
>20% is random morons asking for help with their kiddie assignments
I know one of you must know a good place to discuss programming
>>
>>59409837
Yes (assuming you mean for array access and not declaration), the thing inside the brackets is an expression, so it doesn't have to be constant. The same is true in most programming languages.
>>
>>59409857
try reddit
>>
>>59409857
Freenode
>>
>>59409857
/prog/ was good until the admin fucked up the servers
>>
>>59409783
Dependent types are types that depend on a value. Some languages have something like this, but only for constant values that are known at compile time. Dependent types, on the other hand, can depend on variables or expressions containing variables. This allows you to interpret them as predicates, and you can construct types corresponding to "for all" or "there exists, s.t.".

For example, if you have two variables x and y of type A, you can have a dependent type family P : A -> Type. Then you can construct two types P x and P y. If you have a proof that x = y, you can then determine that P x = P y, and when types are equal, you can coerce values of one to the other. You can also do safe array indexing with no run time bounds checking required:
// natural numbers
data Nat : Type where
zero : Nat
succ : Nat -> Nat

_<_ : Nat -> Nat -> Type
_ < zero = Void // false as a type
zero < succ _ = Unit // true as a type
succ m < succ n = m < n

// is allowed because you can never have a value of Void
// lets you utilize the fact that predicates may prevent certain cases from being possible
absurd : Void -> A

Array : Type -> Nat -> Type
Array _ zero = Unit
Array A (succ n) = A * Array A n

index : (n : Nat) -> Array A n -> (i : Nat) -> (i < n) -> A
index zero _ _ p = absurd p // if n = zero, i < n can never be true, so we use absurdity to fill in this case
index (succ n) (a, _) zero _ = a
index (succ n) (_, as) (succ i) p = index n as i p // we use the recursive definition of _<_ to safely call index recursively

Regardless of how n is obtained, if you have an array of type Array A n and an index i with a proof that (i < n), you can index the array to safely get an element of type A.
>>
http://www.gnu-pascal.de/gpc/Succ.html
>>
>>59409861
good to know. thanks
>>
>>59409881
So it's basically the increment operator?
>>
>>59409783
https://www.youtube.com/watch?v=LXvP1A97oAM

Dependent Types are mainly used in shit like AST (Dependent ML), Twelf, Idris ect to prove language type safety and other verification.
>>
>>59409854
Thanks, I'll thinking about this over coffee.
>>
>>59409875
>>59409952
Thanks also this. Can't words today but thank @u.
>>
(SELECT name, grade, marks 
FROM students s, grades g
WHERE grade = (SELECT grade
FROM grades
WHERE marks BETWEEN min_mark AND max_mark
AND grade >= 8)
ORDER BY grade DESC)
UNION
(SELECT NULL, grade, marks
FROM students s, grades g
WHERE grade = (SELECT grade
FROM grades
WHERE marks BETWEEN min_mark AND max_mark
AND grade < 8)
ORDER BY grade);


what the fuck! I'm getting a 00907 error "missing right parentheses" on line 7:
ORDER BY grade DESC)
>>
>>59409904
Yeah it's a core component of Peano Arithmetic from which you can derive a lot of interesting things
>>
>>59409958
It's just a function from a value to a type to a type

Though if you actually start using this shit you'll have proofs flying everywhere and it'll be painful
>>
>>59409977
Dan Licata's page has a lot more including courses on this http://dlicata.web.wesleyan.edu/pubs.html

There's also Oregon PL summer school every year which focuses on verification/program theory so free Category Theory lectures https://www.cs.uoregon.edu/research/summerschool/summer16/curriculum.php
>>
>>59410003
Thanks. Someone showed me a pdf once that was about Category Theory, and it seemed very very good but I lost it. The title was something flowery, and possibly a reference to a Grothendieck quote. Something about ocean maybe.
>>
>>59410043
Actually I found it: http://math.stanford.edu/~vakil/216blog/FOAGdec3014public.pdf it's about algebraic geometry
>>
>>59409978
Try adding a right parentheses to line 7
>>
>>59410144
oh shit dude, why didn't I ever think of that!? /s
but seriously, I figured it out. It has to do with not being able to use ORDER BY on subselects in UNION statements. Why? I don't fucking know.
>>
>>59410206
>Why? I don't fucking know.
Welcome to programming
>>
just getting started with my first purescript project. i'm planning on just putting totgther a little twitter client on top of electron(thus PS over Haskell)

so far i'm really liking PS as a language; more than i thought i would. it's still pretty rough, but in general it feels like a more thought out Haskell.

anyone else have any experience with it yet?
>>
>>59410206
>>59410249
ORDER BY is applied the latest to the table.
>>
>>59410455
>in general it feels like a more thought out Haskell
you'd hope given that it began by building on 20 years of Haskell
>>
>>59409989
>Though if you actually start using this shit you'll have proofs flying everywhere and it'll be painful
Elaborate.
>>
>>59410482
I thought it would produce the first table, order that, then produce the second table, order that, and then union the two tables. I guess that's really not how it's done internally. :(
>>
>>59410507
well if you had a type safe lookup, you'd need a proof that what you're looking for is inside the list
>>
>>59410547
this is if you want

lookup :: Eq t => (x : t) -> (xs : [t]) -> Elem x xs -> t
and not

lookup :: Eq t => t -> [t] -> Maybe t
>>
>>59409302
working on my final assigment for my systems programming class.

Building a rudimentary webserver that supports get/head requests as well as cgi support. Nearly done, just need to make sure I handle any/all error cases and make sure I have a squeaky clean valgrind output for all possible cases
>>
How would you implement an image reversed search engine?

Google, iqdb, tineye, all are shit.

Set everything to grayscale. No need to match for rotated pics, maybe partial pics would be nice.
>>
>>59410662
Maybe read some papers
>>
C here

why don't you guys love me
>>
>>59410883
Because your memory leak stained my good clothes.
>>
>>59410894
programming languages have feelings too
>>
>>59410883
C was a mistake
ML was robbed
>>
>>59410883
High maintenance
>>
>>59410883
But I DO love you.
C and OCaml are the only two languages a man needs.
>>
>>59410971
program in me <3
>>
>>59410982
N-not in front of everyone.
>>
File: 1459224897392.jpg (356KB, 1280x720px) Image search: [Google]
1459224897392.jpg
356KB, 1280x720px
>>59410971
>OCaml
Garbage. It isn't worthy of the ML legacy.
>>
>>59411015
We value your input anon.
>>
>>59411015
+1
>>
Is there anyone here who's actually failed an interview? I'm super anxious about mass applying to places because of the feeling that the world will end if I fuck up
>>
>>59411130
Yup. I didn't interview live though. Basically they didn't take me because I didn't bother checking whether Skype worked beforehand thus we had to resort to a live call. Or so they say. I always got the position in every other case.
>>
>>59411155
Phone call*
>>
Which meme features should I try to implement in my shitposting language?
inb4 hkt
inb4 no I/O
>>
>>59411191
monads
>>
>>59411191
<= assign to left
=> assign to right
<=> equalize both left and right (average)
>>
>>59411191
Use mutable ASCIIZ strings as the only primitive data type. All arithmetic functions will be implemented using string handling as part of the standard library.
>>
Android development is such a pain in the ass.

Can't I just write shitty scripts and network applications all day?
>>
File: rust.jpg (242KB, 1231x930px) Image search: [Google]
rust.jpg
242KB, 1231x930px
>>
>>59411296
>rustics accusing others of being SJWs
>>
>>59411296
>rust dev complaining about sjws
?!
>>
File: 3ojz9o.jpg (23KB, 239x310px) Image search: [Google]
3ojz9o.jpg
23KB, 239x310px
upvote if you nest your pointers to arrays of functions 10 levels deep just to keep non-programmers away from you cool codebase
>>
>>59411321
I actually intentionally make my code as illegible as possible so that I have to explain to anyone reading it exactly how it works
>>
File: bs.png (51KB, 457x496px) Image search: [Google]
bs.png
51KB, 457x496px
>>> x = ((-(186444716)**2 - 1)/ -2)**0.5; x
131836323.0

This is wrong.
>>
  unsigned int a = 0;
unsigned int value = 7;
while (value)
{
if (value & 1)
a <<= 1;
else
a <<= 0;
value >>= 1;
}
printf("a: %d\n", a);


Why is a zero? Shouldn't it print 7? What I'm failing to understand here?
>>
>>59411491
i also subtly force self-developed convoluted frameworks on clients. gotta have that job security
>>
>>59411556
So then what is the answer?
>>
>>59411556
>What are significant figures
>>
File: costanza.jpg (7KB, 250x250px) Image search: [Google]
costanza.jpg
7KB, 250x250px
>>59411590
>a <<= 0;
>>
>>59411296
>(s)he was mad enough to make this
>>
>>59409362
C++ doesn't even have most of that..
>>
>>59411590
>a <<= 1;
>a <<= 0;
Bitshifting probably isn't doing what you think it's doing.
>>
>>59411556
is unary supposed to have higher precedence?

who would ever write something as ambiguous-looking as that though
>>
File: 1489298515949.jpg (17KB, 316x239px) Image search: [Google]
1489298515949.jpg
17KB, 316x239px
>>59409302
fuck off with this shitty garbage meme-book
>>
>>59411634
>he is mad enough to reply
>>
>>59411640
You wouldn't have this problem with prefix or postfix notation.
>>
>>59411321
I just write code normally and ignore every pull request I get. It's not like they ever do anything decent. Its very rare for someone to show the correct level of respect for the work that was already done. They either completely change things for no reason or make silly workarounds just so they don't have to introduce any real changes to existing code.
>>
>>59411590
Check the value of value after every line of code
>>
Spoonfeed me on Golang please.
What is it created for?
>>
>>59411703
It's crap. It's not really worth thinking about.
>>
>>59411707
What makes it to be crap then?
>>
>>59409387
>>59409409
Ew you post like some kid on a forum, "where did I claim to be "Australian"?" jesus try to be more interesting when you shitpost pls.
FYI the question mark goes inside the quotes, my little english major. Unless you live in the third world.
>>
>>59411703
> What is it created for?
It's created to be braindead enough for millions of low-quality graduates to learn it in a week. It's a good language if you need to get the most from a large amount of low-IQ programmers.
>>
File: 4iie2voZ1te0qnyo1_1280.jpg (64KB, 1011x755px) Image search: [Google]
4iie2voZ1te0qnyo1_1280.jpg
64KB, 1011x755px
I printed and started to read the book of C because a friend told me i should start with that.
I also have SICP from a garage sale a good while back.

Should I finish C before starting with SICP or do I just git gud and jump into the big book? Both at the same time?
>>
I am reading The C P.L. book right now and I can`t understand why everyone likes it. Exercises are boring and explanations aren't good enough for newbies.
>>
>>59411191
Declare as unknown.
Basically if you wrote (C- like syntax below).
 
int a=3;
int b=5;
unknown c;
a^2+b^2=c^2

It'd detect that you have one unknown in that equation and solve it for you (c=sqrt(a^2...)).
You could also do this with some sort of block structure for making systems with multiple unknowns possible.

It's not an extremely useful feature really but its what I feel most math-languages don't really do for you well. They never go all the way to make it convenient. A lot of the time you just have a bunch of relationships between variables and want to retrieve a couple of them. This syntax would allow you to just write the relationships and do a multiple return on the variables you wanted.
>>
>>59409409
>lern muh engriesh
enelsh is liek cursing 2 me anywai fanalam
i will execute every one of you native english speakers when western civ falls
>>
>>59411750
This really makes the language sound interesting. I've heard people who like python have said they like this language because it's 'more safe' in the sense of being more strict and giving you errors at compile time.
>>
>>59411617
The answer is a float, something near 131836322.999999998. I know because it doesn't satisfy an equation, but if it were an integer, it would. Currently looking into the decimal module to learn and fix these floating point errors.
>>
>>59411556
The single slash is going to auto convert to floating point if you're using Python 3; not sure you're aware of that. Using // will force integer division if that's what you want.
>>
>>59411760
A book teaching you C doesn't prepare you for SCIP in any way.
Either order is fine.
>>
>>59411772
It's not for newbies.
>>
>>59411902
It is. If you're not a retard.
>>
>>59411902
K&R was the first book I ever read on programming and within a month I had written my own compiler for C and 2 months later I had written my own operating system. I think the book is thorough in its explanations unless you are retarded.
>>
>>59412033
>within a month I had written my own compiler for C and 2 months later I had written my own operating system.
um
>>
File: brainy_pepe.jpg (7KB, 250x246px) Image search: [Google]
brainy_pepe.jpg
7KB, 250x246px
>>59412040
Is there a problem?
>>
>>59410482
Of course not why the fuck would you order two sub selections of data if you're going to have to order it again as a whole? What you can do, however is make a column for weights and order based on those weights determined in your sub select
>>
>>59410503
Sorry meant to reply to the guy asking the question but I'm a fucking retard. I don't know why I'm so offensive right now either sorry im just an asshole
>>
>>59410662
A more complicated form of image to bytes matching patterns of bytes or some shit
>>
>>59411772
>The C P.L. book
It's called K&R
>>
>>59412107
Comma-less sentences make me sick.
>>
>>59412164
ok
>>
Looks like Scala has just uncucked itself: https://www.scala-lang.org/blog/2017/03/14/scala-native-0.1-is-here.html
>Unlike the reference implementation of Scala which generates bytecode that runs on top of the Java Virtual Machine, Scala Native toolchain produces stand-alone native executables. This opens the door for Scala to be used in environments where full-blown virtual machine is usually an overkill: command-line tools, resource-constrained hardware applications, video games etc.
>>
>>59412084
that is not normal
>>
>>59412265
>cuck/uncuck
I've seen this word for a while, but I still don't know its proper definition.
>>
File: 1470441217279.jpg (79KB, 494x698px) Image search: [Google]
1470441217279.jpg
79KB, 494x698px
What should I read on writing languages in Haskell?
>>
>>59412033
Link?
>>
File: 2tq6lvvxlbly.jpg (54KB, 640x647px) Image search: [Google]
2tq6lvvxlbly.jpg
54KB, 640x647px
>>59412291
No one does, but that shouldn't prevent you from using it tho.
>>
>>59412334
>No one does
Only people who have access to a dictionary website.
>>
>>59412345
The word had outgrown its dictionary definition ages ago.
>>
>>59412289
>All his software wasn't made by him in under a week
Brainlet
>>
>>59412356
That's not relevant if that usage was literally what its defined to be in most dictionaries.
>>
bash is an irredeemable piece of shit
>>
>have std string
>want to split using delimiter
>somehow theres no proper way to easily do this using std libraries

Jesus christ I fucking hate this language.
>>
>>59412404
Are you talking about C++ ?
>>
>>59412430
Ye.

What fucking language does not fucking include a native split method on strings? Like holy fuck what the fuck is wrong with it?
>>
File: lua.gif (5KB, 256x255px) Image search: [Google]
lua.gif
5KB, 256x255px
>one of the best languages around was made by Brazilians
How is this possible?
>>
HTML5/CSS3 rendering engine. I hate <pre> tag now.
>>
>>59412444
What is Lua good for outside of indie gaming?
>>
>>59412442
C++ is popular why?
procedure Find_Token (Source : in String;
Set : in Maps.Character_Set;
From : in Positive;
Test : in Membership;
First : out Positive;
Last : out Natural);

procedure Find_Token (Source : in String;
Set : in Maps.Character_Set;
Test : in Membership;
First : out Positive;
Last : out Natural);
>>
File: threading.png (74KB, 747x693px) Image search: [Google]
threading.png
74KB, 747x693px
I'm trying to learn more about threading in Java.

When I create a class that extends Thread, all the code that I put in the run() method executes on its own thread.

But what about other methods inside of this class? If I instantiate an object of this class, and then call the run() method, then another method (in this picture, the senFile() method), does that code get executed on its own thread as well? Or on the same thread as the code in the run() method? Or on the same thread as the class that ran instantiated the object?
>>
>>59412467
Ye mang, it is used as a plugin language because it is so light weight and fast, I believe mpv uses Lua for plugins and firefox did as well. It is also one of the fastest scripting languages there is; I think there was a benchmark where LuaJIT was almost at the same speed as C. It's a pretty comfy language though.
>>
>>59409317
I have a copy of the C++ reference which I use to raise my monitor slightly off my desk.
>>
>>59412514
I do the same but with C++ Primer 5e.
>>
>>59412442
There are ways to do it though, that are not *hard*, and that use the standard library.
>>
>>59412500
Jesus start with the basics my dude.
run() will run once the thread has been started. The other function will run wherever the fuck its called.
>>
>>59412553
Theres also ways to do it in fucking asm but that doesnt mean it isnt fucking stupid not to include such basic functionality in the standard library.
>>
>>59412489
Based Ada, at it again
>>
>>59412500
Better implement runnable.
Thread begin special class, thread.start create thread and call run, just call run execute on mono thread.
>>
>>59411779
Just use Prolog
>>
File: 0011.jpg (30KB, 309x400px) Image search: [Google]
0011.jpg
30KB, 309x400px
"Let's pretend you were swimming in the deep ocean and you really don't know what's underneath you. You have no idea what's underneath you...

Well, that's kind of the situation of a modern programmer; they're in the deep ocean they're doing a web application and it's so far down to the bottom hardware. The hardware is at the bottom of the ocean. And when you are in the middle of the ocean, boy you are a long way from anything called hardware.

In the old days, it was kind of a shallow lake and you walked on the bottom and you waded out in the little pond and that's how you lived. You walked on the bottom of a muddy pond and you had your feet on the hardware and you knew what was underneath you — you know, it's completely different feeling. It's a different feeling when you are in a pond and you have your feet on the bottom. It's qualitatively different than being in the middle of the ocean where you have absolutely no idea what is underneath you. Modern programmers have no idea."
>>
>>59409764
>I made something simple and put it on github a while ago, basically a python script that acts as a password manager.

You fucked up the crypto, the clipboard handling or some other part. Do not write password managers unless you're a cryptographer. You are not a cryptographer. Nobody reading this is a cryptographer.
>>
Are there any general IT certs I can get without ever leaving my bedroom, if so which and how do I go about getting it all sorted?
>>
Why is writing c wrapper to sepples classes so fucking obnoxious? It's like they want people to write in C.
>>
File: 1484014710837.jpg (214KB, 600x620px) Image search: [Google]
1484014710837.jpg
214KB, 600x620px
>>59412467
>implying AAA companies don't use Lua
>>
>>59412942
There are. You even have MOOC to teach yourself some interesting things. But for all these things to be valuable on the job market, you have to be known and make yourself known.
>>
>>59412992
ok so online courses are the way to go, how do I prove i've worked through them do I make a github repo containing all code from the course or do I just put it on my resume or what? sorry, never had a job before
>>
#include <stdio.h>
int main(void)
{
int x = 5;
printf("%d\n", 1 ? 2 : ({
int x = ({ 3; });
x;
}));
printf("x %d\n", x);
return 0;
}

Gnu statement expressions are fucking great.
Why doesn't C standard support return value {} block? Would make writing macros way easier.
>>
Rate my Rust:

http://pastebin.com/f5PLJLff
>>
>>59412991
Varies from dev to dev, it's so easily pluggable that it does not even look like a dependency inside projects. I mean, except in vidya shops, I don't see why big IT companies would enforce the use of Lua inside projects.
>>
File: 43143149031.gif (62KB, 260x200px) Image search: [Google]
43143149031.gif
62KB, 260x200px
Im writing a program in C.
Im using relative paths to load files ("./data/foo.bar" , etc..)
I want to use the executable directory as the base for all the relative paths.
Im thinking about setting (and later restoring) the working directory using getcwd , readlink("proc/self/exe") , chdir.
But I want my program to work on POSIX and Windows systems not only on Linux.
How can I use the executable path to resolve relative paths in a way that works on all systems?
There isn't any ANSI C way to do this?
>>
>>59413003
GNU devs everyone:
>yo dawg, i heard u like functions, so we put functions in your functions so you can have undefined behavior in your undefined behavior

Just write first-order functions, you don't need more than that in C. Lambdas may look elegant, but they're just syntactic sugar, their implementation is nearer from that of a first-order function than it looks like. At least, that's how they're implemented in C++. Let that shit to C++ when possible.
>>
>>59413007
Quite good, but danger_at should return something like
enum DangerLevel {
Mine,
MinesNearby(usize),
}

and not u8 with magic value 9.
>>
>>59413042
Look at any bigger project they usually have their own implementation of cross platform paths.
glib, apr or the likes.
>>
>>59413042
>I want to use the executable directory as the base for all the relative paths.
You might think you want this, but you probably actually don't.
>>
>>59413003
The next C standard has a proposal for closures, which sort of could be used for that.
You would just create a closure and immediately use it. It might make some macros cleaner, as you can have 'return' which won't fuck with the flow control of the enclosed function.
>>
>>59413138
>c20
You really think we are going to alive then? Fucking 3 for the new standard and 5 years more for compiler support. Also the standard committee will find a way to fuck it up anyways.
>>
>>59413188
>C20
It's more likely to be C21 or C22, but it currently referred to as C2X. But yes, it will be a fucking long time away. The standardisation process isn't quick.
Regarding the closures though, they're based on a features already present in clang ("Blocks"), which Apple uses for their API.
>5 years more for compiler support
I think it might be a bit quicker than that.
It didn't take that long for most of the (non-optional) C11 stuff to be in a useful state in GCC and Clang.
>>
>>59413188
> 5 years more for compiler support
Both gcc and clang support C++17 and it isn't even technically out yet.
>>
>>59413076
I think that maybe I will end doing this.
So there is no cross-platform standard way?
>>59413090
Explain this please.
Is better to let things the way they are?
Even if that means that the program will not work if the working directory is diferent than the executable directory?
do other programs do this?
>>
>>59413317
> So there is no cross-platform standard way?
There is one, but you might have to switch to a superior language: http://en.cppreference.com/w/cpp/filesystem .
>>
>>59413349
Not a viable option at this stage of development
>>
>>59413014
I think that's because it lets to use C modules out of the box.
>>
>>59413138
Nobody cares about the new standard. Most people writting C still do it c89 for compatibility and portability.

And compatibility and portability are pretty much the only reasons to write C in the first place.
>>
>>59412305
The code of people who have written languages in Haskell
>>
>>59413408
> Most people writting C still do it c89 for compatibility and portability.
[citation needed]
>>
>>59413408
Both GCC and Clang default to C11 (GNU11 technically, but whatever). That alone means that there are people actually using it.
Even then, I know of several important projects that are written in at least C99. Even MS, which is known for it's hostility to C, had to implement some of C99 so that popular libraries could work with their terrible, terrible compiler.
>>
Why do I need lambdas?
>>
>>59413461
Callbacks.
>>
>>59413447
I don't care what it defaults to. I always add -std=c90

Honestly if you use C for applications you're doing it wrong. C is for writing high performance, highly portable libraries. Pretty much every language has a C ffi (if it doesn't it's a non language).

You write your actual application in a different language uses these C libraries.
>>
has /dpt/ ever done a group project?

/dpt/ let's make a game, ok first we decide on a language that should be easy enough
>>
>>59413491
Rust, obviously.
>>
>>59413491
MUMPS
>>
>>59413491
Fuck you I have my own project to spend time on. It's currently closed source because it's incomplete, I'll open the source when it's usable
>>
>>59413511
Don't bloat the open source space with more shit please
>>
>>59413484
Can't I use pointers to functions instead then?
>>
>>59413522
You can.
>>
So I have thought about Prolog. It's clear there are usability issues in the language. Many have a poor experience with Prolog because of this. They are already pretty established and Prolog books/papers will point them out. As Kowalski famously said, "What went wrong?"
With our current knowledge of programming languages, we could pretty much fix all the flaws. If we did this and re-worked Prolog from the ground up, could logic programming have a revival?

My skills with implementing languages in C aren't great, so I'm just shilling the ideas.

- Syntax

It's not that hard to get used to Prolog's syntax but it's odd by today's standard.
For one, the meaning of a name changes depending on whether is capitalized or not.
The operators are also unconventional, e.g. '\='.

- Abusing NOT/CUT/SOFT-CUT/etc.

Prolog programmers will often abandon the logic aspect of the language and use CUT, an impure operator.
A book that explains the distinction between pure and impure in logic programming is The Reasoned Schemer.
A good logic language should discourage "impure" behavior but still provide it as an option. Then you can actually use its benefit of reasoning in logic.

- Closure and other FP features

- CLP and immutable structures

Two high-level features that have the intent of increasing purity.
Immutable data structures are very well represented in Clojure. We could have something like JavaScript/Lua going where they use hash tables for objects, json, etc. except without side effects.
CLP extends LP into working for numbers and other datatypes. It could be turned off.
A downside is these would increase the size of an otherwise compact language.
>>
File: 1487974409142.jpg (79KB, 640x640px) Image search: [Google]
1487974409142.jpg
79KB, 640x640px
>>59413519
How does one "bloat the open source"?
>>
>>59413527
Well, there is a reason why lambdas are used instead of function pointers, isn't it?
>>
>>59413522
Function pointers can't capture values.
>>
- NOT
You use "not", then learn that it's deprecated and the correct is "\x", then learn that it doesn't work logically. It is an impure operator, like CUT.
Prolog also has a feature analogous to IF that is also impure; the SOFT-CUT.
There have been different proposals for alternate NOTs in Prolog. For example, I know of a book called "Techniques of PROLOG Programming with Implementation of Logical Negation" which as the title says presents one.
I came up with this for a pure NOT (along with a pure IF):

if(not p())
z()
else
q()


NOT can only be used inside IFs. If it were to be used outside, as in

not p()


Then it would have similar problems to Prolog's NOT.

Here, NOT is syntax sugar for pure logic programming. The code would translate to:

if(p())
q()
else
z()


IFs, in turn, are also syntax sugar. The above code would correspond to

(p() and q()) or z()


AND/OR implements the mechanics that Prolog is known for.

- Modes
The Mercury language already has this. A simplified version might have the following modes: rel (default, allows anything), bool (true/false, no outputs), void (used for side-effects) and fun (last parameter is Out and others are In, checks that it's used as a regular function). Then you can use Out/In for the parameters in certain relations.
>>
>>59413486
>I don't care what it defaults to. I always add -std=c90
And you are indicative of every developer? You sure are projecting pretty hard.
But really, this is so fucking stupid. What are you targeting? What do you tangibly gain by limiting yourself like that?
It's not like it's a massive fucking pile of bloated shit puked onto the language (i.e. C++). The later C standards add several useful features, including some which increase the opportunities for optimisation, and still keep the spirit of C intact.
Technology changes, and the new standards are made to reflect that.

>>59413491
>has /dpt/ ever done a group project?
/dpt/ (and /g/) is utterly unsuited to work together on anything.
There are so many conflicting opinions, idiots, and trolls, that nothing will ever be agreed on and nothing will ever get done.
It will immediately devolve into bike shedding. It's happens so consistently, it has turned into a joke.

The only way it will ever work is a "design by dictator" approach, but at that point, is it really a /dpt/ project?
>>
>>59413072
Thanks for the feedback!

I refactored my code a bit. Here's the new version: http://pastebin.com/A0j77Nue
>>
>>59413531
>Abusing NOT/CUT/SOFT-CUT/etc.
Cuts restrict solution search space, where it is known that those solutions won't provide a correct answer.
Did you read about CLP in SWI-Prolog?

What Prolog lacks, it's mechanisms of working with different complex datatypes other than lists.
>>
Any GUI dev here?
Is QML the only thing I need? If I don't use the entirety of Qt what will I miss?
Color picker?
Slider?
Dropdown menus?
>>
>>59413535
Could you elaborate on that?
Why do you need to capture values?
>>
>been learning programming on and off for over 1.5 years
>still never done actual programming outside of text book and tutorial examples

...How?! Will I have to use libraries? Is that acceptable or is it a sign of stupidity?

I don't even know how to make stuff. Every tutorial is about messing with maths examples but I don't know, for example, how to begin making browser games or a website that would, for example allow people to trade bitcoin
>>
>>59413644
>Is that acceptable or is it a sign of stupidity?
It's the reality.
>>
>>59413644
>Will I have to use libraries?
What do you mean? You don't use libraries?
>>
>>59413644
> Is that acceptable or is it a sign of stupidity?
It's a sing of you lacking any interest.
>>
>>59413598
function pointers don't scale because once you need to implement a function/callback whose behavior depends on any input other than the ones described in the function pointer signature, you're fucked into having to make use of global state. closures solve this problem
>>
>>59413644
Using libraries is part of programming. Don't worry about it.
>>
>>59413719
Oh boy here we go again
>23 rolls
>0 solutions
>>
>>59413644
>Will I have to use libraries?
Yes.
>Is that acceptable or is it a sign of stupidity?
Literally everyone uses libraries.

A library just means that someone else has already done the heavy lifting for you, and you can move on with applying that particular set of work to a greater concept in order to create useful programs.
>>
what are some really new langs, like bleeding edge,
I know of Crystal which is pretty new, any others ??

also, Crystal seems pretty good, is this wrong to think this way ?
>>
>>59413776
Rust.
>>
>>59413776
Rust.
>>
>>59413776
Prolog.
>>
>>59413776
Rust.
>>
>>59413644
>Is that acceptable or is it a sign of stupidity?
It's both, sort of.
Libraries are an essential part of actually getting shit done. A lot of things that you typically need to do is very complex.
I you want to draw a simple window, you don't want to have to implement the whole damn X11 protocol to get it, and then do it again for Windows, MacOS and any other shit you might be targeting.
But then again, you shouldn't be over-reliant on libraries for some things. Libraries are dependencies, and dependencies make your program more complicated, harder to build, and harder to ship. You don't want to pull a dependency in for some simple shit you could pretty easily do yourself, or pull in a massive library for only a small use of its functionality (JSfags and the whole left-pad shit, C++fags pulling in Boost).
>>
>>59413588
Correct. The idea is to find ways for discouraging CUT, if possible, (for example, by having pure operators like in the NOT example be the default style) or at least having it be other options like SOFT-CUT.
CLP and immutable structures isn't really a flaw in Prolog (there is a record library), I suppose.
>>
>>59413729
>>59413719
>factorial
import std.stdio, std.string;

int factorial(uint x){
uint result = 1;
for(int i = x; i>1; i--){
result*=i;
}
return result;
}

void main(){
write("Enter your number: ");
int n;
readf(" %s", &n);
writeln(factorial(n));

}
>>
>>59413776
Rust
>>
>>59413719
30 get pls
>>
how does bitcoin work?
any links with the specification etc?
>>
>>59413871
> how does bitcoin work?
Badly.
>>
>>59409317
I have both these books, haven't used them in 10 years or so, but still think it's funny to see them here.
>>
File: factorial.png (12KB, 436x501px) Image search: [Google]
factorial.png
12KB, 436x501px
>>59413851
>int factorial(uint x)
>int
>uint
This is why you use real programming languages with real type system.
>>
>>59413944
Oh that was a typo
>>
>>59413944
>real programming languages
A real programming language is good for writing real code, not just for shilling. Stop being such a mindless drone and get something done if you want your opinion to be respected.
>>
>>59413974
I'm okay with Rust 2bh
>>
>>59414068
Might as well have said you're okay with not writing any code. In which case, what are you doing here?
>>
>>59414086
>Might as well have said you're okay with not writing any code
?
>>
Can someone tell me what's the difference between
CALL rel16

and
CALL r/m16

with code example in nasm?
>>
>>59413862
If you want to do that you could always just do it instead of rolling for it you know.

>>59413719
Rolling
>>
>>59414099
I guess 'rel16' mean immediate 16bit value with relative offset to call, and 'r/m16' means register or address in memory with 16bit relative offset to call.
>>
>>59414114
>If you want to do that you could always just do it instead of rolling for it you know.
good idea, thanks
>>
>>59413944
The only reason I picked D over Rust is because Rust doesn't have an introductory book.

With D I got this:
http://ddili.org/ders/d.en/
It's thorough, introduces you to every concepts from ground up and It's a standalone reference book.

Rust is yet to have something like this
>>
>>59413719
roll
>>
>>59414152
How https://doc.rust-lang.org/book/ is different?
>>
>>59414195
Doesn't have exercises, it's just an information dump
>>
>>59414195
Out of date, most of the examples are from before 1.0 when the syntax was different. Documentation just isn't a priority in Rust.
>>
>>59414190
>>59413719
>Flappy bird
Did you expect someone to actually write this in a thread, moron?
>>
what alternatives to JSON exists that has widespread support but smaller overhead?
>>
>>59414234
CSV
>>
File: a68.png (514KB, 520x678px) Image search: [Google]
a68.png
514KB, 520x678px
>>59414253
what the fuck
>>
>>59414218
You have no idea what you're talking about: https://github.com/rust-lang/rust/commits/master/src/doc/book/src .
>>
>>59414234
custom binary
>>
>>59414278
It was one of ESR's complaints when he tried to use it to write a program.
>>
>>59414218
Heres the wip second edition. Its much better https://rust-lang.github.io/book/second-edition/index.html
>>
>>59413783
Rust is 7 years old...
practically an artifact.
>>
File: 1478609742190.jpg (80KB, 478x644px) Image search: [Google]
1478609742190.jpg
80KB, 478x644px
>>59414299
>widespread support
>>
>>59414318
I will look at it when it's no longer WIP/"in beta" like the rest of the ecosystem.
>>
>>59414316
> one of ESR's complaints
Well he isn't the brightest man out there, is he?
>>
>>59414324
binary has widespread support. just document how it's interpreted.

What are you even looking for here? JSON and XML are going to be your path of least resistance. If you need lower overhead than JSON, you're going to have to use something much less convenient geared towards your specific optimization needs.
>>
>>59414218
>Out of date,
Show me where
>>
>>59413408
I use C99 for compound literals and integers within for loops. It also helps when embedding shader code, because C89 only guarantees that string of maximum length of 509 characters will be supported, while C99 allows ensures 4095 characters. Also, from x86 perspective, variable length arrays seem like a decent idea, though I don't know how are they implemented on other architectures.
>>
>>59414234
maybe try BSON or protobuf
>>
>>59414320
2 years old since release 1.
>>
>>59414234
X M L
M
L
>>
>>59413596
bump
>>
>>59414552
>smaller overhead
>>
New thread:

>>59414582
>>59414582
>>59414582
>>
>>59413944
Also, a fold is so much cleaner than a for loop in this case.
fn factorial(n : i64) -> i64 {
(2..(n+1)).fold(1,std::ops::Mul::mul)
}
>>
>>59409352
Knowing that they are there below the hood is important though. Otherwise you will never understand why the performance of your java code is so terrible.
>>
Why people like K&R so much? It's terribly outdated.

No reason to read it besides historical value.
>>
>>59414732
Shhh, it's an inside joke. Same with SICP.
>>
>>59414783
Except SICP is actually good.
>>
>>59414794
Haha, yes, it is very important for all new people here to read SICP!
>>
>>59414732
It's not a matter of date, but a matter of method and techniques. K&R presents the C language from a concise way, bringing clear and relevant examples as to how to implement useful data structures and solutions to practical problems.

Still a reference in technical writing.
>>
>>59414804
Programming and practice using C++ by Stroustrup is better imho, both for new and for experienced programmers.
>>
>>59414804
>>59415093
Modern C, by Jens Gustedt.
>>
File: 0a1.jpg (78KB, 643x820px) Image search: [Google]
0a1.jpg
78KB, 643x820px
>>59415093
>Programming and practice using C++
>1300 pages
Aaaaaaa...

>>59415113
I started to read it, but I don't think I'll get anything new compared to what I learned with K&R and years of experience.
>>
>>59415311
The last "levels" are pretty interesting, even for an experienced programmer.
>>
>>59412614
Yeah sure, use a language that doesn't fit my use case at all because it has this niche feature.
Thread posts: 324
Thread images: 38


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