[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: 331
Thread images: 28

File: 1504338162071.gif (95KB, 500x384px) Image search: [Google]
1504338162071.gif
95KB, 500x384px
What are you working on, /g/?

Old thread: >>62374078
>>
>>62381043
When does the fun part start? I have been learning C++ because I want to create Qt Quick apps!
>>
>>62381052
>C++
>fun

Anon, I...
>>
File: lain_by_softcode-d5704ux.png (195KB, 653x1200px) Image search: [Google]
lain_by_softcode-d5704ux.png
195KB, 653x1200px
Came here to appreciate Lain.
>>
>>62381058
That's right, C++ is fun.
>>
>>62381052
The only part I find somewhat fun is debugging.
>>
>>62381068
I'm in chapter 9.12 of this tutorial
Will I ever make it? http://www.learncpp.com/
>>
>>62381079
Just wait until you meet templates, that's when the real fun begins.
>>
What's the best Scheme flavor?
>>
>>62381068
>C++ is fun
>en.wikipedia.org/wiki/Stockholm_syndrome
>>
>>62381099
>incomprehensible and kludgy C++ metaprogramming is "fun"
>>
>>62381136
>using templates for metaprogramming
>>
>>62381147
>not using templates for metaprogramming
>>
>>62381156
Template metaprogramming sucks, you said it yourself.
>>
>>62381147
>not using templates for metaprogramming
That only makes your statement weirder. They are about as "fun" as Java generics if used normally.
>>
File: campbell.jpg (91KB, 800x602px) Image search: [Google]
campbell.jpg
91KB, 800x602px
https://www.forbes.com/sites/rajatbhageria/2017/09/10/is-learning-how-to-code-still-worth-it/amp/
>>
File: rust_mandelbrot.png (52KB, 1123x905px) Image search: [Google]
rust_mandelbrot.png
52KB, 1123x905px
>his language's type system isn't turning-complete
>>
>>62381113
>best Scheme flavor
I'd say Racket is the most usable and practical option if you want to develop an entire application in it (rather than, say, use it as a scripting language for your app).
>>
>>62381256
>this is somehow actually useful
>>
>>62381270
at least Rust has compiletime computations now :)
>>
How would you parse a PDF invoice for the invoice number? (can be letter & numbers).

So far i load the document as 1 big string and then look for strings like "invoice no." Then I navigate right via 1 or 2 spaces and regex for potential hits.
Works ok~ish but hardly seems the best solution. Using the Itextsharp lib in .Net
>>
>>62381284
>compiletime computations
I'm waiting for the day mainstream language designers take a hint from lisps and start offering proper metaprogramming facilities instead of barely usable template and type system hacks.
>>
>>62381360
Without homoiconicity I don't see how you can get much further than constexpr.
>>
>>62381284
>>62381360
>They think type-level computation is the same as compile-time computation which is the same as macros
You really shouldn't post about things you don't understand. Besides, Rust already has compile-time computation as part of optimization and macros.
>>
File: 1485652958941.jpg (131KB, 591x800px) Image search: [Google]
1485652958941.jpg
131KB, 591x800px
Have you loved Lain today, /dpt/?
>>
>>62381402
>implying i ever said they are the same thing
You really shouldn't post at all because you're a sperg.
>>
>>62381389
>Without homoiconicity I don't see how you can get much further than constexpr
It can be done if you design your syntax so that it translates into s-expressions in a predictable manner.
>>
File: 1459714644932.png (39KB, 633x973px) Image search: [Google]
1459714644932.png
39KB, 633x973px
What is ( String [ ] args ) parameter means in main method?
>>
>>62381685
http://lmgtfy.com/?iie=1&q=What+is+string%5B%5D+args+in+main%3F
>>
>>62381685
>java -jar Foo.jar crap -x 100 -y 200 -z 300
>String[]{"crap", "-x", "100", "-y", "200", "-z", "300"}
>>
So guys, I am reading Kochan, and K&R at the same time. Which one is a better way to get input from the user?
int c;
while((c = getchar()) != EOF && c != \n)


||

scanf(%i, &i);
>>
File: bgc.png (645KB, 909x1077px) Image search: [Google]
bgc.png
645KB, 909x1077px
>he's a white boy who codes
psssh nothin personnel kid
>>
>>62381762
getchar
scanf is pretty unsafe.
>>
File: SlurpSlurp.gif (2MB, 356x200px) Image search: [Google]
SlurpSlurp.gif
2MB, 356x200px
Guys. Should I learn python as my first language or not? I want to get into programming. Been told python is a good start to learn the while C syntax and stuff. But what do you /g/entoolmen think?
>>
>>62381846
Yes, Python is a good choice for the first language.
>>
>>62381846
Python and JavaScript are ok for beginners, but be aware that in order to get into programming you have to understand how computers work and that implies also learning C/ASM.
>>
>>62381801
Thank you for your answer, but, could you elaborate on that? I was reading eskimo.com, or something, and he said the same thing. Never went into it, as far I remember, though.
>>
File: Ainstley.jpg (61KB, 600x900px) Image search: [Google]
Ainstley.jpg
61KB, 600x900px
>>62381865
Nice, thanks! Also just out of curiosity, what would be a next step from python?
>>
>>62381865
>in order to get into programming you have to understand how computers work and that implies also learning C/ASM

Plenty of people don't bother with such things and are able to create and contribute to software.
>>
>>62381874
getf might read more than fits to your variable.
There might be getnf or some other variation that lets you specify the byte count how much it can read max.
>>
>>62381874
C is a good idea. And then your third language should be something functional such as Ocaml or Haskell.

>>62381894
You can't design efficient software if you don't understand what's happening inside the machine.
>>
>>62381846
i fell for "python is super easy all beginners should start with python" meme, learn C or C++, for absolute beginner there is no difference, and python and C/C++ will be hard, so better start with less abstract language and if you need to learn other language in future then you can do it in a week or less without much effort.
>>
>>62381924
I think you replied to the wrong person, famalam.
>>
>>62381937
I did. I meant to respond to >>62381891 .
>>
>>62381924
Software should be easy to understand and maintain, and it should work. You can write very efficient code with only a cursory understanding of performance best-practices. Additional optimization comes later as necessary when the business needs are satisfied.
>>
>>62381916
I see, I will look into it, thanks anon.
>>
>>62381960
ok I said getf but meant scanf.
>>
yeah, Chapel really is the best language ever.
>>
>>62381951
You don't even really have to learn to program properly in order to shit out software. You can just get by by copy-pasting shit from tutorials and stackoverflow. It doesn't mean it's a good idea.
>>
>>62381846
No, Python is a perfectly fine language to learn if you want to write Python, but it's a terrible "stepping stone" language. C is really the baseline if you want to learn programming in general, it's a very simple language without a huge standard library to overwhelm you, or a ton of heavy abstractions that just confuse you and don't teach you anything. Don't fall for the C is hard for beginners meme, it's hard to write complex software in C as opposed to a higher level languages, but if you want to learn the basics of programming there's nothing better than C. Stuff you learn in C transfers very well over to other languages too, after spending a couple of years with C before going back to C# for my job I found that I could write far better code knowing better what was actually happening behind all of the abstractions.
>>
>>62381977
Oh, I see. So to avoid overflows, it's better to use getchar(), or other variations. I wonder why books use scanf(), though. Is it because it is easier to understand?
>>
>>62381433

Anime is not real, anon.
>>
>>62382049
Books try to teach concepts in easy way and on your small terminal application that only you will run it doesn't matter if you use scanf.
>>
>>62382016
Stop propping up an easily berated caricature of what you think people are doing if they don't go through the drudgery of learning the ins and outs of C/ASM.
>shit out software
Does it upset you that people are able to quickly produce software that meets the needs of the project without having to do the same tedious tasks that the software wizards of 20 years ago had to do?
>>
>>62382099

Not him , but "learning programming" is NOT "learning a language".

Software engineering is not tied to certain languages, it's a completely different best.


>Does it upset you that people are able to quickly produce software that meets the needs of the project..

Whoa, speaken like a true code monkey!

The problem is that "quick and dirty" works for short term, but will rape you anally in the long run. Just add some fundamental features to a projects you did one year ago, and you'll know what I'm talking. Either you wrote good code, with nice coupling and a decent structure, than you will get into the details pretty quick and hang in your code in the right hook. Or you created a monolithic bloated mess, where you need to refactor for days before you can even think about adding functionality.
>>
I'm trying to create a cli application in crystal that reads log data from a json file and assembles a valid LaTeX file with it. Afterwards it compiles the file and deleted the temporary outputs of LuaLaTeX. It works fine, however the crystal compiler --release flag, which should invoke the LLVM compiler toolchain, causes the compiler to crash. I tried it on Debian, arch, gentoo and even the Win 10 Ubuntu subsystem. Any ideas why it's crashing?
>>
>>62382021
While I agree with you about C being one of the most important languages to know I wouldn't say Python is a terrible stepping stone. Python will allow a beginner to learn how to build and decompose problems into a set of smaller problems without annoying them about stuff that only the machine cares about. Once you know how to build algorithm C becomes much easier to learn, you only have to deal with the syntax and memory management.

>>62382099
I wasn't saying that copy/pasting stackoverflow was what people who don't learn C do. I was saying that copy/pasting stackoverflow is a way to create apps without learning about what's really going on the algorithm side, much like using python/php/javascript without learning C is a way to create apps without learning about what's really going on the hardware side. Sure, it's possible but it's not something you should desire.
>Does it upset you that people are able to quickly produce software that meets the needs of the project
No. What upsets me is having so much computer power and so much ram and still having to deal with laggy software and web pages. It really makes me mad to see the size of websites explode while the same levels of functionality could already be reached ten years ago with a tenth of the resources we have now.
>>
>>62382090
Thank you, anon. I will use getchar(), because I think I have more control over the data that I am inputting.
>>
>>62382189
Try compiling the compiler in debug mode and running it through gdb.
>>
>>62381360
The syntax in other languages is unsuitable for real metaprogramming. You'd end up making your language lisp by doing so.

>>62381518
I wouldn't consider such a language distinct from a lisp. See https://srfi.schemers.org/srfi-119/srfi-119.html
>>
>>62382174
You now what's even worse? I've had a colleague who did a single task for about 15 years. He left the company a few months ago. Turned out he automated his work with visual basic scripts and wrote a new one for every additional feature pm wanted. It was a horrible, horribble mess, we had 3 people work out what was going on in about 150 vbs files and 10 temporary mdb databases
>>62382222
Will do, but how is this going to help with my problem?
>>
>>62382253
You'll see where it crashes and the input responsible for the crash. You'll probably be able to determine whether the problem is on your side or the compiler's side.
>>
>>62382275
Oh, ok. Will do.
>>
How do i check if a variable is defined in c#? And i don't mean null i mean defined
for example

defined("poop") // returns false


var poop = 1;
defined("poop") // returns true
>>
>>62382174
You keep making the assumption that quick is necessarily dirty. Something need not be tedious to be right.
>>
>>62382239
>The syntax in other languages is unsuitable for real metaprogramming
It wouldn't be ideal, but it can be done by generalizing the most useful common forms and defining s-exp transformations for them.

>I wouldn't consider such a language distinct from a lisp
Why does it matter whether or not you would consider it "distinct from a lisp"?
>>
>>62382311
What are you actually trying to accomplish here?

This smells of horrible design.
>>
>>62382311
C# is a compiled language. If a variable does not exist it won't compile.
>>
>>62382380
Doesn't matter, that is why quotes are used
>>
>>62382318
"I wouldn't consider ..." is weasel words for "it is not." See that SRFI I linked. What you described is literally that SRFI. Any such language isn't meaningfully distinct from a lisp since its only differences are visual sugar.

My point is there is no such thing as a good metaprogramming language that isn't a lisp and there never will be because it isn't possible to be good for metaprogramming and not be lisp.
>>
>>62382311
You could probably stitch something together using the information found on this page: https://docs.microsoft.com/en-us/dotnet/framework/reflection-and-codedom/reflection
>>
>>62382546
see
>>62382355

Explain what you're actually trying to do; this doesn't really make sense. Smells of an XY problem.

>>62382593
You cannot get local variables with reflection (at least, the implementation doesn't ensure that it is possible); only type members.
>>
>>62382589
>Any such language isn't meaningfully distinct from a lisp since its only differences are visual sugar.
I don't see how your subjective opinions about whether something is "meaningfully distinct" from lisp or not are relevant to the discussion. Your objection was that mainstream languages aren't suitable for lisp-like metaprogramming because they are not homoiconic. My response is that they can be made retroactively homoiconic by generalizing common syntactical structures and defining transformations into s-exps for them, and new languages can be designed to have a smaller number of more consistent syntactical structures and still look fairly "normal". If you want to label any such language "a lisp", be my guest. It makes no difference,
>>
File: 1421139415594.jpg (112KB, 1358x765px) Image search: [Google]
1421139415594.jpg
112KB, 1358x765px
Employed Haskell programmer here
>>
>>62382752
>(((academic))) work is actual work
>>
>>62382311
Aren't there implicit initialisations of variables in C#?
>>
>>62381237

>50% surplus supply of programmers
We're boned.
>>
>>62382847
what do you mean?
>>
>>62381237
That machine learning cirlejerk is getting annoying, I blame that musk retard
>>
what's the difference between a constexpr array and a static constexpr array?

why doesn't the compiler treat a constexpr array (in function scope) the same as a static constexpr array? are they not equivalent from an optimization point of view?
>>
>>62383594
static (in function scope) means that the value does not change between invocations. it's essentially a global that's only visible to the function it's declared in.
I don't see how you could have a nonstatic constexpr variable. Nonstatic means it belongs to a particular invocation of the function, and you can't make that constexpr.
>>
>>62383655
So you're saying you can't do partial specialization (or help the compiler with it, to be more accurate) using constexpr?
That sucks ass.
>>
>>62383655
>you can't make that constexpr.
yes you can

anyway i found this explanation

https://stackoverflow.com/questions/13865842/does-static-constexpr-variable-make-sense
>>
>>62383688
I'm just not clear about what you're asking. Partial specialization of what exactly?
>>
I know that is possible to speed up python program with C or C++, but it's possible to do the same things with Forth instead of C?
>>
>>62383757
I'd say only if you make your own hardware. Not even FPGA.
>>
File: Calm_down_baby.png (219KB, 500x500px) Image search: [Google]
Calm_down_baby.png
219KB, 500x500px
>>62382082
It is in my heart.
>>
>>62383757
Sure, you just need a way to interface the Python ABI with the Forth ABI.
>>
>>62383695
To clarify. I'm not the guy who asked first I'm just responding to your response.
Example:
 
void foo(int a, int b) { //b will be required to be a compile time known value for every callsite
return multiply(a, baz(b)); //Baz is a constexpr function

Would this compile assuming baz is just fine as a constexpr function? If it does constexpr can be used for partial specialization. If b is 2 or a multiple of 2 the compiler can figure out that a shift may be better than an IMUL on this platform.
If c++ doesn't have non-static constexpr using the function argument in baz would be incorrect unless the same argument is passed throughout the program or there's only one call (which has really cool uses come to think of it, but doesn't fit constexpr well).
>>
>>62383890
Should add that I misspoke. Like always with constexpr it's just a way to error when the compiler doesn't manage to resolve the constant expression. I doubt compilers 'try harder'. Wouldn't make sense.
>>
>>62381518
Why S-expressions? As long as you can produce an AST programmatically you've got the power.
>>
>>62384409
You have no idea what you are talking about.
You have clearly not achieved SATORI.
Fuck off. Read your SICP. Then you may come back.
>>
>>62384434
>SCIP
it's not scripture. It's a book.
I hate dogmatic programmers.
>>
>>62384409
>Why S-expressions?
Because they're a very convenient and uniform way to represent an AST.
>>
>>62384508
>I hate dogmatic programmers.
You're responding to a butthurt Java brainlet trying to be clever.
>>
>>62385312
You are Java brainlet trying to be clever.
>>
>>62382764
He said Haskell, not Lisp.

>inb4 joos
>>
File: lisp.png (46KB, 623x623px) Image search: [Google]
lisp.png
46KB, 623x623px
What Lisp do you prefer? Despite being bigger, and maybe slightly more bloated, I prefer Common Lisp to Scheme.
>>
File: 1504813224536.jpg (117KB, 800x591px) Image search: [Google]
1504813224536.jpg
117KB, 800x591px
>write a useful ~50kb (=51200 b) python script
>...and it requires 100 additional megs of python interpreter
Did I make a bloatware?
>>
>>62386020
No, you're an MIT nigger.
>>
>>62385775
Common Lisp
>standardized, many implementations
>reader macros
>useful stuff in standard library
>stable libraries that support all implementations for other major stuff like sockets, threads

scheme
>standard library doesn't cover shit
>few implementations bother implementing srfi, also most of srfi are just shit
>every implementation ends up implementing the stuff in Common Lisp in non portable way
>nothing is portable, every faggot has their own opinion what scheme should be

The only nice thing in scheme is that you can call function stored to variable without funcall.
Otherwise scheme when you want to implement YOUR OWN scripting language for your shitty C / C++ program.
Common Lisp when you want to a decent programming language.
>>
>>62385565
>He said Haskell, not Lisp.
You're hilariously deluded if you think more real world projects have been written in Haskell than in some variant of Lisp.
>>
Oi /dpt/. I'm a decent "coder", writing shit from scratch (and believe me, I've written a ton of it). I hate the word "coder" just as much as you, but I can't call myself a programmer yet as I'm having difficulties understanding how different technologies are connected together.

I have a great idea for a simple service. I need to implement front-end for both mobile and desktop use, as well as back-end for it later on. While I am confident all this is (or will be) within my abilities, I have no idea how to choose the technologies and where to start. If I start by designing the front-end, how do I avoid shooting myself in the foot and making it easy to implement a decent back-end for the service later on? Am I just blabbering nonsense? Do you have any decent reads to suggest regarding the connections between the front-end and the back-end?

I have a ton of programming experience with Linux (C++, Python, Java, Shell Scripting), but it's not helping me here.
>>
>>62385775
Common Lisp.

Although crazy enough Racket has been becoming enough of its own thing that I really enjoy it.
>>
>>62386161
>t. never heard of racket
I prefer CL myself, but you can't say that there is no Scheme implementation that covers all your CL pros.
>>
File: 1502212647811.jpg (152KB, 640x720px) Image search: [Google]
1502212647811.jpg
152KB, 640x720px
>>62386238
>I need to implement front-end for both mobile and desktop use, as well as back-end for it later on
You won't complete this task in decent time. Look for people and build a team. It's not possible to perform this alone.
>>
>>62386367
Racket is not scheme.
Racket is one implementation of their own language that is going on it's own way which is bad in many ways.
>>
File: 1505043276712.gif (3MB, 444x250px) Image search: [Google]
1505043276712.gif
3MB, 444x250px
Is this normal?

At my programming job we keep a tally of mistakes that every developer makes, and at the end of the week the dev with the most points has to give everyone snacks, with his own money.
>>
>>62386238
Its because of this that got buzzwords like MEAN stack, LAMP stack, etc exists. Some technologies go around with each other.

Just go to any online job website and look for a position that asks for a certain skill or technology, and look what other skills are also asked for in that position
>>
>>62386683
>Racket is not scheme.
Actually, you're probably right about that one.
>>
>>62386987
no, sounds weird.
>>
>>62386987
It depends how reasonable the mistake count is.
If they're style guide violations or ambiguous shit like "not pythonic" then yes it's bullshit.
>>
>>62387081
We have a lot of juniors, and I think it's better than firing them.
>>
>>62387143
We have a checklist that every developer has to go through before making a pull request / merge request.

If you forget an item, then that's one point.

And it's very light on style conventions.
>>
>>62386987
That's actually pretty normal, we used to do that all the time. But it got expensive later on and instead the dev with the most points per month would give out blowjobs instead, which you should consider
>>
>>62387321
>But it got expensive later on and instead the dev with the most points per month would give out blowjobs instead, which you should consider
Do you program in striped programming socks?
>>
>>62386161
I'm thinking about learning CL seriously, but I'm a die-hard Vim user. Is it ok to use it for CL development instead of Emacs?
>>
Does constant vs. non-constant pointer/data actually matter in C?
>>
>>62387623
no, just fucking ignore it unless you're writing c++
>>
>>62387599
There's slimv which is basically provides you embedded common lisp interpreter and also auto completion and all that. So yes vim is fine.
>>
>>62386614
>>62386991

Okay. Let's be honest here. It's not my idea. I'm a second year CS student who landed a decent internship and I am not excepted to know all of this. The project has not started yet and I was asked to "look into it". In reality, I will be given tasks according to my capabilities. If they tell me to design parts of the front-end, I will have instructions to follow and it will be an easy task.

However, I'd like to grasp the whole context. I vaguely know how front-end and back-end connect with each other, how databases work yadda yadda. I have a month until the start of the project and I'd like to read and prepare as much as I can to leave a good impression.

The technologies haven't been set in stone yet, so I can't read up on the exact technologies. However, I know all the programming languages I will need during the project.
>>
>>62387658
Why are sepples fags so obnoxious about const pointers?
>>
>>62387756
C++ is for patricians who don't have to use a dumbed down babby language
>>
>>62387756
Because it makes code much easier to understand and reason about, just like static typing.
>>
>>62387321
Silicon valley men have gotten so effeminate lately I can actually visualize this happening.
>>
>>62387892
>putting your data to function that you don't know what it does
sepplesfags are literally python-tier shitters
>>
>>62387957
The signature of a function should tell you everything that it does.
>>
>>62387991
I'm glad C++ has features like dependent types and a substructural type system to accomplish this.
>>
>>62388039
Just in time for C++26
>>
>>62387991
>The signature of a function should tell you everything that it does.
Does the type system let me distinguish between sin() and cos()?
>>
>>62388353
Nope, that's what the name is for. t
The type system should be strong enough to tell you whether it takes degrees/radians/something implementation defined.
>>
>>62383594
static is strictly a storage concept. it describes where the object is stored at execution time. this is almost totally distinct from constexpr, which describes whether the *value* is computable at *compile* time. they have some mild interactions when compiler optimizations get involved, but nothing deathly serious

note that constexpr is just a suggestion; the compiler is not required to do anything with it, like inline. conversely, static forces the compiler to allocate space in a specific way

a static constexpr in function scope will be stored in .DATA or .BSS, like all static objects. a non-static constexpr will be stored on the stack, assuming it has to be stored at all, like all non-static function scope objects
>>
>>62388653
is there any language with robust first-class strong unit types? i have never seen this

it's not enough to have degrees; you need support for e.g. degrees/second, degrees/second^2 ... this is very difficult to realize
>>
>>62383118
>the new iphone soc has a neural engine
reeeeeeeeeeee
>>
>>62381360
julia, my man
>>
>>62387835
>implying C++ is not a dumb-down babby language that grew too big
>>
>>62381177
>[Templates] are about as "fun" as Java generics if used normally.
<type_traits> has been kicking around in the std library for 6 years, enable_if is normal now. this stuff is internally hideous but externally, it's just verbose, there is nothing abstruse about it
>>
>templates instead of principled generics with traits (concepts)
>>
>>62389500
saying that technology uses a neural network is like saying that a computer uses linear algebra
>>
learning to make GUI programs in scala
>>
>>62390010
to be fair C++ has been trying to introduce concepts for years
>>
>>62390098
Haskell has had type classes (same thing) since its conception.
>>
>>62386987
a bit juvenile, but if the company spirit is in good shape, i prefer this to anal fisting which we had at Nestle
>>
>>62390098
you can already emulate concepts with crap like std::enable_if
>>
File: 1504191078366.jpg (47KB, 730x481px) Image search: [Google]
1504191078366.jpg
47KB, 730x481px
>>62381068
I love C++

pic related is me
>>
you can buy a cheap japanese used car for the price of 2 iphones
>>
>>62391281
yeah
and the car will last you 7-10 years
whereas the iphone will last you 3, tops
>>
GTK or Qt?

or raw Xlib?
>>
>>62391419
more like 30 years
I still see late 80s toyotas on the road
>>
>>62391461
>qt
sepples
>xlib
obsolete
>gtk
systemd botnet
>>
It took me 62 lines and 6 int variables to make hanged man game.
How bad is that?
>>
>>62391754
I probably would take 150 lines but only because I would compartmentalize everything.
>>
>>62391754
The question is, who cares?
>>
>>62391808
I ,as in myself, care.
>>
>>62391748
>Everything is shit, and only I am the one in the white coat!
>>
I'm working in C#
I have an abstract base class with a field that should never be updated, but I want each child class to define its own value for this field.
Is this the correct way to do this? This property shit feels so viscerally wrong to me.
public abstract class Spell {
public abstract uint baseCost { get; }
}

public class SpellFeather : Spell {

public override uint baseCost {
get { return 8; }
}

}
>>
>>62391754
>>62391841
Golfing your code does nothing but give you bad habits.

You can shorten your code for clarity, but when you shrink 3 meaningful instructions into one esoteric instruction, you're writing bad code.
>>
>>62391858
don't ask for advice if you can't handle it m9
>>
Question:
Anyone have any good resources for taking an existing webapp you've built (php/js/python) and "porting" it to a standalone desktop app?

I know what needs to be done, but I know fuck all about desktop development.
>>
>>62391950
Electron?
>>
>>62391859
I don't think you can force readonly behavior on implementations.

You could use an interface here; they allow you to enforce contracts on "types of types":

interface ISpells
{
int Damage { get; }
}

class Fireball : ISpells
{
public int Damage { get; } = 8;
}
>>
>>62391859
Yes.
>>
>>62391754
>62 lines
Absolutely subpar, even if you wrote it in x86 assembly. Find a McJob ASAP.
>>
>>62391859
Stop using properties, you're making this needlessly complicated.
Have one abstract method in your base class and override it in the subclasses.
>>
>>62392084
>Stop using properties
begone, plebeian
>>
Is it worth getting gud at emacs or vim?
>>
>>62391984
Totally forgot about Electron.

I think that'd be perfect. Thanks!
>>
>>62392201
It's like drugs. You don't appreciate it/need it until it's too late
>>
>>62392239
Yeah. I'm addicted to vim keybindings now. Whenever I dont have them typing feels empty, slow.
>>
Which compiler should I use on windows for best code optimization on its side?
>>
>>62392632
Fuck I forgot to mention it's for C++
>>
>>62392632
>using a compiler for "best code optimization"
>not writing optimized machine code manually
>>
>>62392632
MS Visual C++
>>
>>62392632
install WSL and use g++
>>
File: 1476818857607.png (138KB, 375x375px) Image search: [Google]
1476818857607.png
138KB, 375x375px
>>62392680
>Windows 10
>>
>pulse requires to be initialized with 65536 frames on app startup
>this is fucking 3 SECONDS of audio latency
What the fuck? Can I set this to something lower, like 1024 frames?
Using libsoundio btw.

static void audioCallback(struct SoundIoOutStream *outstream, int frameCountMin, int frameCountMax) {
/// frameCountMax is 65536 at first callback, making the audio latency 3 seconds @ 22050 Hz
int ready = MIN(frameCountMax, soundio_ring_buffer_fill_count(dg.audio.ring) / outstream->bytes_per_frame);
int silent = frameCountMax - ready;

struct SoundIoChannelArea *areas;

char *readPtr = soundio_ring_buffer_read_ptr(dg.audio.ring);
int readyCopy = ready; // we only advance readPtr after ready frames are exhausted
while (ready > 0) {
int written = ready;
soundio_outstream_begin_write(outstream, &areas, &written);
memcpy(areas->ptr, readPtr, written * outstream->bytes_per_frame);
soundio_outstream_end_write(outstream);
ready -= written;
readPtr += written * outstream->bytes_per_frame;
}
soundio_ring_buffer_advance_read_ptr(dg.audio.ring, readyCopy * outstream->bytes_per_frame);

while (silent > 0) {
int written = silent;
soundio_outstream_begin_write(outstream, &areas, &written);
memset(areas->ptr, 0, written * outstream->bytes_per_frame);
soundio_outstream_end_write(outstream);
silent -= written;
}
}
>>
>>62392713
>windows users being elitist towards other windows users
it's all the same botnet, gimping yourself because you dont want this flavor of MS botnet as opposed to the one you currently have is retarded
>>
>>62392725
oh nvm
http://libsound.io/doc-1.1.0/structSoundIoOutStream.html#a20aac1422d3cc64b679616bb8447f06d
>On systems that support clearing the buffer, this defaults to a large latency, potentially upwards of 2 seconds, with the understanding that you will call soundio_outstream_clear_buffer when you want to reduce the latency to 0. On systems that do not support clearing the buffer, this defaults to a reasonable lower latency value.
>>
>>62387892
It also helps the optimizer.
>>
it seems for java there is openJDK for linux. i have java assignments for uni, with tests that the teachers wrote. They said we needed the jdk. Will openJDK work?
>>
What programming books are you reading?
I tried to learn C++ but I kinda noped out of A Tour of C++ when I realized stuff like operator overloading and virtual functions are definitely not worth polluting your codebase with.
What a trainwreck.
>>
>>62391859
Ignore the other retarded replies. Have the base class take the parameter in its constructor. Subclasses can pass their own value up when calling the base constructor, without having to take it as a parameter to their own constructors.
>>
>>62393095
>I tried to learn C++
>I realized stuff like operator overloading and virtual functions are definitely not worth polluting your codebase with
They're not even trying to hide their lack of experience and understanding anymore...
>>
>>62393095
Ignore C++. Learn Rust instead. https://doc.rust-lang.org/book/
>>
>>62393095
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
>>
>>62393188
Ignore C++ and Rust. Learn C.
>>
>>62393095
>virtual functions are definitely not worth polluting your code with
you're on a path towards middle management
>>
>>62393217
>having to rely on a text substitution preprocessor for most abstraction and code reuse
>>
>>62393217
I did learn C.
I tried giving C++ a shot and it just seemed gross compared to the bare bones simplicity of C.
Rust is an uglier C that doesn't even let you write a doubly-linked list without going into an unsafe block.
You can't even write systems code without a 3rd party crate package that isn't part of the standard library, and they're STILL deleting keywords this far into it's lifespan.
>>
In C++, is a vector basically the same thing as an ArrayList in Java?
Are templates just C++'s way of implementing generics?
>>
is it okay to reinvent the wheel if you're doing it as a learning exercise
>>
>>62391859
>>62393165
Here you go:

public abstract class Spell {

private readonly uint baseCost;

public uint BaseCost => this.baseCost; // Should use PascalCase since it's a property.

protected Spell(uint baseCost) {
// TODO - Make sure baseCost is within whatever limits are appropriate for your system.
this.baseCost = baseCost;
}
}

public class SpellFeather : Spell {

public SpellFeather() : base(8) {}

}
>>
File: topmost-kek.jpg (45KB, 493x461px) Image search: [Google]
topmost-kek.jpg
45KB, 493x461px
>>62393246
>relying on Rust or C++ for abstraction and code reuse
>>
File: o2.webm (36KB, 800x624px) Image search: [Google]
o2.webm
36KB, 800x624px
>>62381043
Finished simple animation for solving hanoi towers.
Later I'll add solving problem from any position
>>
>>62393311
Rust is pretty good.
>>
>>62393281
If you're doing it purely to learn then go for it.
It isn't practical to do it in real situations though.
>>
File: C.jpg (53KB, 430x575px) Image search: [Google]
C.jpg
53KB, 430x575px
>>62393246
>>
>>62393270
>I did learn C.
Okay, so presumably you understand the basics of programming. What's your endgame? What kind of apps do you want to develop?
>>
>>62393338
It's really not. Haskell is probably the king. Lisp if you're talking about dynamic languages (although it's not impressive in a dynamic language).
>>
>>62393325
fuck off mozilla shill
>>
>>62393325
>Rust is pretty good.
You have a very low standard of "good".
>>
>>62393355
>>62393357
When it comes to abstraction and code reuse (but it could be better). I don't agree with the safety aspects.
>>
>>62392680
Gcc is pretty bad on windows, for when I want software on Linux I'm using gcc for sure !

It comes down from my research to intel and vc++
>>
>>62393351
We were talking about languges that actually matter like C and the c derivates that some hipsters think that matter.
>>
>>62393273
yes
yes
>>
>>62393351
>Haskell is probably the king.
The king of what? Immutability and laziness are not always particularly desirable.
>>
>>62392674
I would if I knew I was living 1000 years at minimum and I would've decided to program as a passion for all that existence.
>>
>>62393388
Most people are not autistic.

>>62393397
Abstraction and code reuse.
>>
File: rustcuck.jpg (96KB, 703x707px) Image search: [Google]
rustcuck.jpg
96KB, 703x707px
>>62393325
Fuck off Antifa.
>>
>>62393273
Yes and yes.
Although templates are quite different from generics in implementation, capabilities and behavior.
>>
>>62393397
state, st, io monad

laziness sure but with deepseq & whnf
>>
>>62392632
gcc
>>
>>62393407
>haskell
>king of abstraction and code reuse
Debatable. I guess it beats C++ and Rust, though, so I'll give you that.
>>
>>62393378
build it from source in cygwin
>>
>>62393445
What would you consider to be better?
>>
>>62393455
Agda
>>
>>62393469
Agda is the king of PROOF reuse.
>>
>>62393424
>state, st, io monad
Your point being what? That there are ways to handle side-effects? Doesn't make it any less inconvenient when you're (e.g.) making a game.
>>
>>62393485
broofs iz gode :DD
>>
>>62393408
>steve klabnik
literally who?
>>
>>62393455
>What would you consider to be better?
Any usable lisp variant.
>>
>>62393489
Haskell is one of the best imperative languages.

The only thing missing is something like Idris' ! notation
>>
>>62393499
Sure, but it's impractical to write useful programs in Agda.

>>62393525
>Lisp if you're talking about dynamic languages (although it's not impressive in a dynamic language).
>>
File: Hyperbolic tiling.png (730KB, 1278x930px) Image search: [Google]
Hyperbolic tiling.png
730KB, 1278x930px
Nothing has ever made me wish I knew math well more
http://h3.hypernom.com/
>>
fun
string_length
{n:nat} (
str: string (n)
) : size_t (n) = let
fun loop {i:nat | i <= n} .<n-i>.
(str: string n, i: size_t i): size_t (n) =
if string_isnot_atend (str, i) then loop (str, succ(i)) else i
// end of [loop]
in
loop (str, i2sz(0))
end // end of [string_length]
>>
I'm new to programming. What language should I learn?

I want to have more control over my computing, it being fast, and don't have to think too hard about solving problems therefore most of the work is done for me.
>>
>>62393562
Java, because there are millions of Java jobs that don't require you to think.
>>
File: rustcuck.png (21KB, 865x229px) Image search: [Google]
rustcuck.png
21KB, 865x229px
>>62393510
One of the eight people on the Rust Core Team.
>>
>>62393581
I want to do it for a hobby so I'm fine with using any language
>>
>>62393667
If you don't like problem solving, programming is not the hobby for you.
>>
>>62393532
Perhaps I misunderstood you. Do you think Haskell offers more in the way of abstraction and code reuse than lisp, or did you mean that Haskell is the king of abstractions when it comes to statically typed languages?
>>
>>62393704
The latter.
>>
>>62393627
Did his post was related to the topic and then some fgt mod removed it because of some tweet?
>>
>>62393530
>Haskell is one of the best imperative languages.
It really isn't. When it comes to games, at least, anything more complex than pacman becomes ugly and cumbersome in Haskell.
>>
>>62393720
Fair enough. It's true from my experience.
>>
Why would you embed a language in another project?
>>
>>62381052
Fuck me dude, I'm 13 chapters in C++ Primer.
My brain actually can't tolerate more monotone pages about iterators and pointers and memory management and containers and abstract class fuckery and OO
After this I'll have to learn OpenGL :(
I just want to make a game
>>
>>62393799
you only need to do this if the primary language sucks
>>
>>62393297
This is not idiomatic C#.
>>
>>62385775
I want to Lisp but CL is killing me.
How the fuck am I supposed to distribute my shit if not including the SBCL binary everytime.
>>
>>62393899
distribute source code
Otherwise use ccl or ecl for smaller binaries
>>
why do I need to include an entire library if I only use one function from it
that seems very wasteful
>>
>>62393942
Just statically link it.
Make sure the license terms allow static linking if you're working on a proprietary codebase.

If you're on linux, this doesn't matter, you can just tell users to install the required libraries and it doesn't bloat up their systems one bit.
>>
I had a kid in my introduction to programming class say this was really hard. LMAO. He'll be dropping out soon
This is Java btw.

Specify what the value of x is after the statements are executed.

1. int x = 5;
x++;
++x;


2. boolean y = true;
boolean z = false;
boolean x = true;

x = !y || z;
>>
>>62393995
7
false
>>
>>62393942
welcome to android development(they don't find it wasteful though)
>>
>>62393844
Right I'll just use that language that doesn't suck... oh wait.
>>
>>62393995
>He'll be dropping out soon
Nah he will probably learn and surpass you.
>>
>>62393942
Lispfags, is this what happens when I (require ...)
>>
File: 8RfVj0JO.png (29KB, 1190x138px) Image search: [Google]
8RfVj0JO.png
29KB, 1190x138px
Someone asked me to abuse typing a bit more, so I did.
>>
>>62393995
this guy is definitely going to graduate and be hired over you because his real life (aka bullshitting) skills are more adept than yours.
You wanna know how I know this?
He approached you about something you consider embarrassing, and he isn't fazed by it at all.
>>
>>62393942
what are you doing exactly? is it just a system header or?
>>
>>62394180
i dunno, I never write code like this.
>>
>>62394180
the answer is we can't tell because it's not stated whether "=" means "is equal to" or "is equivalent to/represents"
>>
is there a way to get vim to do code completion for java?
>>
Does anybody know how to get Eclipse to debug anything in C++? This is my error message, and I'm having a hard time finding anything about this at all.
>>
>>62394283
Have you tried not using eclipse?
>>
>>62394175
i wouldn't go that far but if he never programmed before and the teacher didn't say what those operations do maybe
>>
>>62393827

Use Godot C++ API and you're fine
>>
rate:
compilers
distributed/high performance systems
do not rate:
web development
app development (mobile or otherwise)
>>
>>62394380
explain
>>
>>62381043
I'm making a shell in PHP... Don't ask.

Is there any way to redirect stdin/out/err in PHP?
>>
>>62394283
http://wiki.c2.com/?ForgetTheDebugger
>>
i can't get this substitution to work
path=$1
sed -i '.bak' 's/(^|[^\n])\n{2}(?!\n)/$1\[\[slnc 600\]\]\n\n/g' "$path"

alternatively
perl -pei 's/(^|[^\n])\n{2}(?!\n)/$1\[\[slnc 600\]\]\n\n/g' "$path"
>>
>>62394406
when languages become intuitive enough that anyone can program, developers will be out of jobs, but the people working on the compilers will not
>>
>>62394143
>>62394175
The kid is actually me, I was just using this as way for you guys to answer it for me just so I can double check my results. I'm insecure in my programming abilities and used this as a ploy to get the correct results.
>>
>>62394470
You're gonna fail.
>>
>>62394470
clever girl
>>
>>62394467
puttering at your delusion
>>
>>62394483
>>62394490
I guess I'm just a brainlet not cut for this.
>>
>>62394493
explain
>>
>>62393995
calm down, gotta start somewhere.
>>
>>62394493
puttering at this
>>
File: 1483311864420.png (2MB, 1400x1096px) Image search: [Google]
1483311864420.png
2MB, 1400x1096px
>>62394493
>>>/cum/
>>
>>62394493
ALRI
>>
>>62393827
>I just want to make a game
If true, you wouldn't be planning to waste your time learning opengl
>>
>>62394470
>I'm insecure in my programming abilities and used this as a ploy to get the correct results.
Pointless. Do you really think people wouldn't answer this?
Even more silly is that you could just write a program that tests this for you. You should learn to do that instead.
Hypothetically we could be wrong about this. As you'll find people will be when you start having tougher questions.
But if you write a program you'll know what's going on.
>>
>>62394300
I wish. It's required for class and what we use at work.
>>62394427
>http://wiki.c2.com/?ForgetTheDebugger
I am still a baby so I need to step through this C++ code--it's not doing what I expect and I'm becoming blind by exposure to what could be the issue.
>>
>>62394551
Are you forced to submit eclipse project files?
What the fuck?
>>
>>62394551
try print debugging?
>>
>>62394493
FUCK OFFFFFF
>>
lot of truly terrible posts in this thread
>>
>>62394467
>when languages become intuitive enough that anyone can program
The fact that the majority of people can't program has little to do with the "intuitiveness" of languages and everything to do with the fact that computers don't understand all the (mostly invalid) logical leaps people make in their reasoning.
>>
>>62394467
>paying for a compiler
>>
>>62394606
explain
>>
>>62394467
Machine,

Pls make website,

all responsive like,
w/ BIG pictures oo,
use my fav fonts,
also fancy menus with whoosh on,
load fast pls

Thanks,
Human

PS no bugs :)
>>
>>62394620
you're right, instead of anyone i should've said physicists, biologists, etc. intelligent people, but people who don't have the time to devote to learning a language and spending all day coding. we get closer to it every day
>>
File: basically.png (434KB, 1280x720px) Image search: [Google]
basically.png
434KB, 1280x720px
>>62394467
>when languages become intuitive enough that anyone can program
Languages ARE intuitive enough that anyone can program. It's just not anyone wants to program.
>>
>>62394712
>>62394717
>>
>>62394717
sounds like a bad career choice to do something anyone can do
>>
>>62394717
>anyone
not ANYONE, but the majority of people imo are capable of it, some people will have an easier time though

and not being lazy is hard for people
i get that making people smarter with drugs is hard, but surely there has to be a straighforward way to create a motivation pill - it's 90% of the time equivalent
>>
>>62394717
>Languages ARE intuitive enough that anyone can program.
what is
>ocaml
>ats
>rust
>js
>sepples
>>
>>62394712
>physicists, biologists, etc. intelligent people
You didn't understand my post. Natural languages are as intuitive as they come. Do your best to formulate a precise solution to a problem in one and you'll find that it's extremely verbose and cumbersome, and even then I could point at a bunch of logical leaps and ambiguities.
>>
>>62393827
You won't retain all of it in one go anyway, just start writing code.
>>
>>62394769
Anyone can do anything
You're not special
>>
>>62394869
>Anyone can do anything
Keep telling that to yourself.
>>
>>62394869
>Anyone can do anything
no
most people can do most things

some people are just too retarded to do most things
and some people can actually do pretty much all things
>>
What's the difference between the OpenGL programming guide and superbible?
Is the latter a reference text?
>>
>>62394881
>silly American thinks he's actually special cuz his mommy told him so
>>
>>62394869
niggers can't do anything
>>
>>62394779
ATS just requires knowledge of applied type theory and linear types.
>>
>>62394915
>butthurt euroturk doesn't understand that his poor genetics preclude put a cap on his abilities
>>
Can someone PLEASE explain what the fuck is happening on line 8 that it keeps giving me traceback(most recent call last)? I've run it through three online interpreters, so I know it's not my compiler being stupid.

#Defines the main method

def main (

#Gathers the first and last name of the user

firstname = input("What is your first name? ")
lastname = input("And what is your last name? ")
fullname = firstname + lastname

#Says hello to the user using their first and last name
print('Hello ', fullname, '!')

)

#Calls the main method

main()
>>
>>62394779
Leave them for those who are professionally devoted to programming.
>>
>>62394977
What fucking stupid backwards language lets you add 2 strings together like that in a meaningful way?
>>
>>62394977
I don't know what's happening in line 8 but you'll need a space between first name and last name, senpai
>>
>>62394977
your bracket, the one that closes your argument list is in the wrong place
>>
>>62394977
Why is the body of main in parens?
>>
>>62394977
If that's supposed to be python it should look like this:
def main():
firstname = input("What is your first name? ")
lastname = input("And what is your last name? ")
fullname = firstname + lastname
print('Hello ', fullname, '!')

main()
>>
>>62394977
What the fuck are you doing with the default args my man?
>>
>>62395010
Even sepples let's you do that
Get with the time gramps
>>
>>62395025

And main wouldn't be a method, it'd be a function.
>>
Can you use expressions in cases for a switch statement in C++?
i.e.:
switch(a, b){
case a > b:
...
}

or does the expression have to be the switch statement?
>>
>>62395010
>def main():
> firstname = input("What is your first name? ")
> lastname = input("And what is your last name? ")
> fullname = firstname + lastname
> print('Hello ', fullname, '!')
>main()
>>62395012
>>62395014
>>62395025
>>62395037
>>62395053
Pls no bully, I literally started learning Python today and I haven't the faintest fucking clue what I'm doing
>>
>>62395042
In C++, you're overloading the + operator as a shorthand for strcat or whatever the C++ equivalent is.
+ shouldn't represent anything but addition
>>
>>62395063
No bullying, i just fixed your problem buddy
>>
New thread:

>>62395061
>>62395061
>>62395061
>>
File: pythonbook.png (80KB, 773x938px) Image search: [Google]
pythonbook.png
80KB, 773x938px
>>62395063

You'll probably also want a space between the first and last name.
>>
>>62395062
Nein, only integral types.
>>
>>62395063
Jesus Christ, I ran it like this >>62395025
and it worked

What fucking horrifying language actually cares about whitespace and indentions?
>>
>>62394971
>european american
>talks about poor european genetics
>>
>>62395105

A language where whitespaces and indentation has mean.
>>
>>62395105
Whitespace/indentation was not the problem you had though.
>>
>>62395145
My bad, I just realized what I did wrong.

Sorry for coming at you guys. I was just feeling stupid.
>>
>>62395025
Thx for solving my problem, btw
>>
>>62394977
why are you declaring main like a retard
>>
>>62395275

You mean he's calling it?
>>
>>62394896
>Is the latter a reference text?
no
>>
>>62395069
"str1" + "str2" = "str1str2" is pretty intuitive
>>
>>62395112
>assuming i'm american for no reason whatsoever
>failing to notice that i specifically said "euroturk"
>>
>>62393849
Sure it is. Although I would question whether inheritance is even needed at all there. It's generally better to favor composition over inheritance.
Thread posts: 331
Thread images: 28


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